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"
9 #include <linux/etherdevice.h>
13 extern struct timer_list hDuringIpTimer;
15 extern u8 g_wilc_initialized;
17 /* Message types of the Host IF Message Queue*/
18 #define HOST_IF_MSG_SCAN 0
19 #define HOST_IF_MSG_CONNECT 1
20 #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
21 #define HOST_IF_MSG_KEY 3
22 #define HOST_IF_MSG_RCVD_NTWRK_INFO 4
23 #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
24 #define HOST_IF_MSG_CFG_PARAMS 6
25 #define HOST_IF_MSG_SET_CHANNEL 7
26 #define HOST_IF_MSG_DISCONNECT 8
27 #define HOST_IF_MSG_GET_RSSI 9
28 #define HOST_IF_MSG_GET_CHNL 10
29 #define HOST_IF_MSG_ADD_BEACON 11
30 #define HOST_IF_MSG_DEL_BEACON 12
31 #define HOST_IF_MSG_ADD_STATION 13
32 #define HOST_IF_MSG_DEL_STATION 14
33 #define HOST_IF_MSG_EDIT_STATION 15
34 #define HOST_IF_MSG_SCAN_TIMER_FIRED 16
35 #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
36 #define HOST_IF_MSG_POWER_MGMT 18
37 #define HOST_IF_MSG_GET_INACTIVETIME 19
38 #define HOST_IF_MSG_REMAIN_ON_CHAN 20
39 #define HOST_IF_MSG_REGISTER_FRAME 21
40 #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
41 #define HOST_IF_MSG_GET_LINKSPEED 23
42 #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
43 #define HOST_IF_MSG_SET_MAC_ADDRESS 25
44 #define HOST_IF_MSG_GET_MAC_ADDRESS 26
45 #define HOST_IF_MSG_SET_OPERATION_MODE 27
46 #define HOST_IF_MSG_SET_IPADDRESS 28
47 #define HOST_IF_MSG_GET_IPADDRESS 29
48 #define HOST_IF_MSG_FLUSH_CONNECT 30
49 #define HOST_IF_MSG_GET_STATISTICS 31
50 #define HOST_IF_MSG_SET_MULTICAST_FILTER 32
51 #define HOST_IF_MSG_ADD_BA_SESSION 33
52 #define HOST_IF_MSG_DEL_BA_SESSION 34
53 #define HOST_IF_MSG_Q_IDLE 35
54 #define HOST_IF_MSG_DEL_ALL_STA 36
55 #define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
56 #define HOST_IF_MSG_EXIT 100
58 #define HOST_IF_SCAN_TIMEOUT 4000
59 #define HOST_IF_CONNECT_TIMEOUT 9500
61 #define BA_SESSION_DEFAULT_BUFFER_SIZE 16
62 #define BA_SESSION_DEFAULT_TIMEOUT 1000
63 #define BLOCK_ACK_REQ_SIZE 0x14
66 * @struct cfg_param_attr
67 * @brief Structure to hold Host IF CFG Params Attributes
71 * @author Mai Daftedar
75 struct cfg_param_attr {
76 struct cfg_param_val pstrCfgParamVal;
80 * @struct host_if_wpa_attr
81 * @brief Structure to hold Host IF Scan Attributes
85 * @author Mai Daftedar
89 struct host_if_wpa_attr {
101 * @struct host_if_wep_attr
102 * @brief Structure to hold Host IF Scan Attributes
106 * @author Mai Daftedar
107 * @date 25 March 2012
110 struct host_if_wep_attr {
115 enum AUTHTYPE tenuAuth_type;
119 * @struct host_if_key_attr
120 * @brief Structure to hold Host IF Scan Attributes
124 * @author Mai Daftedar
125 * @date 25 March 2012
128 union host_if_key_attr {
129 struct host_if_wep_attr strHostIFwepAttr;
130 struct host_if_wpa_attr strHostIFwpaAttr;
131 struct host_if_pmkid_attr strHostIFpmkidAttr;
136 * @brief Structure to hold Host IF Scan Attributes
140 * @author Mai Daftedar
141 * @date 25 March 2012
145 enum KEY_TYPE enuKeyType;
147 union host_if_key_attr uniHostIFkeyAttr;
155 * @brief Structure to hold Host IF Scan Attributes
159 * @author Mostafa Abu Bakr
160 * @date 25 March 2012
170 wilc_scan_result pfScanResult;
172 struct hidden_network strHiddenNetwork;
176 * @struct connect_attr
177 * @brief Structure to hold Host IF Connect Attributes
181 * @author Mostafa Abu Bakr
182 * @date 25 March 2012
185 struct connect_attr {
192 wilc_connect_result pfConnectResult;
194 enum AUTHTYPE tenuAuth_type;
200 * @struct rcvd_async_info
201 * @brief Structure to hold Received General Asynchronous info
205 * @author Mostafa Abu Bakr
206 * @date 25 March 2012
209 struct rcvd_async_info {
215 * @struct channel_attr
216 * @brief Set Channel message body
220 * @author Mai Daftedar
221 * @date 25 March 2012
224 struct channel_attr {
229 * @struct tstrScanComplete
230 * @brief hold received Async. Scan Complete message body
235 * @date 25 March 2012
238 /*typedef struct _tstrScanComplete
242 * } tstrScanComplete;*/
245 * @struct beacon_attr
246 * @brief Set Beacon message body
250 * @author Adham Abozaeid
255 u32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */
256 u32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames
257 * (including the current frame) appear before the next DTIM */
258 u32 u32HeadLen; /*!< Length of the head buffer in bytes */
259 u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
260 * from the beacon's start till the TIM element, NOT including the TIM */
261 u32 u32TailLen; /*!< Length of the tail buffer in bytes */
262 u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
263 * after the TIM inormation element */
267 * @struct set_multicast
268 * @brief set Multicast filter Address
272 * @author Abdelrahman Sobhy
273 * @date 30 August 2013
274 * @version 1.0 Description
277 struct set_multicast {
283 * @struct del_all_sta
284 * @brief Deauth station message body
288 * @author Mai Daftedar
289 * @date 09 April 2014
290 * @version 1.0 Description
293 u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN];
299 * @brief Delete station message body
303 * @author Adham Abozaeid
305 * @version 1.0 Description
308 u8 au8MacAddr[ETH_ALEN];
312 * @struct power_mgmt_param
313 * @brief Power management message body
317 * @author Adham Abozaeid
318 * @date 24 November 2012
321 struct power_mgmt_param {
328 * @struct set_ip_addr
329 * @brief set IP Address message body
333 * @author Abdelrahman Sobhy
334 * @date 30 August 2013
335 * @version 1.0 Description
343 * @struct sta_inactive_t
344 * @brief Get station message body
348 * @author Mai Daftedar
349 * @date 16 April 2013
352 struct sta_inactive_t {
357 * @union message_body
358 * @brief Message body for the Host Interface message_q
362 * @author Mostafa Abu Bakr
363 * @date 25 March 2012
367 struct scan_attr scan_info;
368 struct connect_attr con_info;
369 struct rcvd_net_info net_info;
370 struct rcvd_async_info async_info;
371 struct key_attr key_info;
372 struct cfg_param_attr cfg_info;
373 struct channel_attr channel_info;
374 struct beacon_attr beacon_info;
375 struct add_sta_param add_sta_info;
376 struct del_sta del_sta_info;
377 struct add_sta_param edit_sta_info;
378 struct power_mgmt_param pwr_mgmt_info;
379 struct sta_inactive_t mac_info;
380 struct set_ip_addr ip_info;
381 struct drv_handler drv;
382 struct set_multicast multicast_info;
384 struct set_mac_addr set_mac_info;
385 struct get_mac_addr get_mac_info;
386 struct ba_session_info session_info;
387 struct remain_ch remain_on_ch;
388 struct reg_frame reg_frame;
390 struct del_all_sta del_all_sta_info;
394 * @struct struct host_if_msg
395 * @brief Host Interface message
399 * @author Mostafa Abu Bakr
400 * @date 25 March 2012
404 u16 id; /*!< Message ID */
405 union message_body body; /*!< Message body */
406 struct host_if_drv *drv;
409 /*Struct containg joinParam of each AP*/
410 struct join_bss_param {
416 char ssid[MAX_SSID_LEN];
418 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
425 u8 rsn_pcip_policy[3];
426 u8 rsn_auth_policy[3];
442 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
445 /*****************************************************************************/
447 /* Global Variabls */
449 /*****************************************************************************/
450 /* Zero is not used, because a zero ID means termination */
451 static struct host_if_drv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
452 struct host_if_drv *terminated_handle;
453 struct host_if_drv *gWFiDrvHandle;
454 bool g_obtainingIP = false;
456 static struct task_struct *HostIFthreadHandler;
457 static WILC_MsgQueueHandle gMsgQHostIF;
458 static struct semaphore hSemHostIFthrdEnd;
460 struct semaphore hSemDeinitDrvHandle;
461 static struct semaphore hWaitResponse;
462 struct semaphore hSemHostIntDeinit;
463 struct timer_list g_hPeriodicRSSI;
467 u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
469 static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
471 bool gbScanWhileConnected = false;
476 static u8 gs8SetIP[2][4];
477 static u8 gs8GetIP[2][4];
478 static u32 gu32InactiveTime;
480 static u32 gu32WidConnRstHack;
482 u8 *gu8FlushedJoinReq;
483 u8 *gu8FlushedInfoElemAsoc;
484 u8 gu8Flushed11iMode;
485 u8 gu8FlushedAuthType;
486 u32 gu32FlushedJoinReqSize;
487 u32 gu32FlushedInfoElemAsocSize;
488 struct host_if_drv *gu8FlushedJoinReqDrvHandler;
489 #define REAL_JOIN_REQ 0
490 #define FLUSHED_JOIN_REQ 1
491 #define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
493 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
495 extern void chip_sleep_manually(u32 u32SleepTime);
496 extern int linux_wlan_get_num_conn_ifcs(void);
498 static int add_handler_in_list(struct host_if_drv *handler)
502 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
503 if (!wfidrv_list[i]) {
504 wfidrv_list[i] = handler;
512 static int remove_handler_in_list(struct host_if_drv *handler)
516 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
517 if (wfidrv_list[i] == handler) {
518 wfidrv_list[i] = NULL;
526 static int get_id_from_handler(struct host_if_drv *handler)
533 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
534 if (wfidrv_list[i] == handler)
541 static struct host_if_drv *get_handler_from_id(int id)
543 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
545 return wfidrv_list[id];
549 * @brief Handle_SetChannel
550 * @details Sending config packet to firmware to set channel
551 * @param[in] struct channel_attr *pstrHostIFSetChan
552 * @return Error code.
557 static s32 Handle_SetChannel(struct host_if_drv *drvHandler,
558 struct channel_attr *pstrHostIFSetChan)
563 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
565 /*prepare configuration packet*/
566 strWID.id = (u16)WID_CURRENT_CHANNEL;
567 strWID.type = WID_CHAR;
568 strWID.val = (char *)&(pstrHostIFSetChan->u8SetChan);
569 strWID.size = sizeof(char);
571 PRINT_D(HOSTINF_DBG, "Setting channel\n");
573 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
574 get_id_from_handler(pstrWFIDrv));
576 PRINT_ER("Failed to set channel\n");
583 * @brief Handle_SetWfiDrvHandler
584 * @details Sending config packet to firmware to set driver handler
585 * @param[in] void * drvHandler,
586 * struct drv_handler *pstrHostIfSetDrvHandler
587 * @return Error code.
592 static s32 Handle_SetWfiDrvHandler(struct host_if_drv *drvHandler,
593 struct drv_handler *pstrHostIfSetDrvHandler)
598 struct host_if_drv *pstrWFIDrv = drvHandler;
601 /*prepare configuration packet*/
602 strWID.id = (u16)WID_SET_DRV_HANDLER;
603 strWID.type = WID_INT;
604 strWID.val = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
605 strWID.size = sizeof(u32);
609 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
610 pstrHostIfSetDrvHandler->u32Address);
612 if (pstrWFIDrv == NULL)
613 up(&hSemDeinitDrvHandle);
617 PRINT_ER("Failed to set driver handler\n");
625 * @brief Handle_SetWfiAPDrvHandler
626 * @details Sending config packet to firmware to set driver handler
627 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
628 * @return Error code.
633 static s32 Handle_SetOperationMode(struct host_if_drv *drvHandler,
634 struct op_mode *pstrHostIfSetOperationMode)
639 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
642 /*prepare configuration packet*/
643 strWID.id = (u16)WID_SET_OPERATION_MODE;
644 strWID.type = WID_INT;
645 strWID.val = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
646 strWID.size = sizeof(u32);
649 PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p\n", pstrWFIDrv);
651 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
652 get_id_from_handler(pstrWFIDrv));
655 if ((pstrHostIfSetOperationMode->u32Mode) == IDLE_MODE)
656 up(&hSemDeinitDrvHandle);
660 PRINT_ER("Failed to set driver handler\n");
668 * @brief host_int_set_IPAddress
669 * @details Setting IP address params in message queue
670 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
671 * @return Error code.
676 s32 Handle_set_IPAddress(struct host_if_drv *drvHandler, u8 *pu8IPAddr, u8 idx)
681 char firmwareIPAddress[4] = {0};
682 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
684 if (pu8IPAddr[0] < 192)
687 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
689 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
691 /*prepare configuration packet*/
692 strWID.id = (u16)WID_IP_ADDRESS;
693 strWID.type = WID_STR;
694 strWID.val = (u8 *)pu8IPAddr;
695 strWID.size = IP_ALEN;
697 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
698 get_id_from_handler(pstrWFIDrv));
701 host_int_get_ipaddress(drvHandler, firmwareIPAddress, idx);
704 PRINT_ER("Failed to set IP address\n");
708 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
715 * @brief Handle_get_IPAddress
716 * @details Setting IP address params in message queue
717 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
718 * @return Error code.
723 s32 Handle_get_IPAddress(struct host_if_drv *drvHandler, u8 *pu8IPAddr, u8 idx)
728 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
730 /*prepare configuration packet*/
731 strWID.id = (u16)WID_IP_ADDRESS;
732 strWID.type = WID_STR;
733 strWID.val = kmalloc(IP_ALEN, GFP_KERNEL);
734 strWID.size = IP_ALEN;
736 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
737 get_id_from_handler(pstrWFIDrv));
739 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.val);
741 memcpy(gs8GetIP[idx], strWID.val, IP_ALEN);
743 /*get the value by searching the local copy*/
746 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
747 host_int_setup_ipaddress(pstrWFIDrv, gs8SetIP[idx], idx);
750 PRINT_ER("Failed to get IP address\n");
754 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
755 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
756 PRINT_INFO(HOSTINF_DBG, "\n");
763 * @brief Handle_SetMacAddress
764 * @details Setting mac address
765 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
766 * @return Error code.
767 * @author Amr Abdel-Moghny
768 * @date November 2013
771 static s32 Handle_SetMacAddress(struct host_if_drv *drvHandler,
772 struct set_mac_addr *pstrHostIfSetMacAddress)
777 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
778 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
780 if (mac_buf == NULL) {
781 PRINT_ER("No buffer to send mac address\n");
784 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
786 /*prepare configuration packet*/
787 strWID.id = (u16)WID_MAC_ADDR;
788 strWID.type = WID_STR;
789 strWID.val = mac_buf;
790 strWID.size = ETH_ALEN;
791 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.val);
793 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
794 get_id_from_handler(pstrWFIDrv));
796 PRINT_ER("Failed to set mac address\n");
806 * @brief Handle_GetMacAddress
807 * @details Getting mac address
808 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
809 * @return Error code.
810 * @author Amr Abdel-Moghny
814 static s32 Handle_GetMacAddress(struct host_if_drv *drvHandler,
815 struct get_mac_addr *pstrHostIfGetMacAddress)
821 /*prepare configuration packet*/
822 strWID.id = (u16)WID_MAC_ADDR;
823 strWID.type = WID_STR;
824 strWID.val = pstrHostIfGetMacAddress->u8MacAddress;
825 strWID.size = ETH_ALEN;
828 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
829 get_id_from_handler(drvHandler));
831 PRINT_ER("Failed to get mac address\n");
841 * @brief Handle_CfgParam
842 * @details Sending config packet to firmware to set CFG params
843 * @param[in] struct cfg_param_attr *strHostIFCfgParamAttr
844 * @return Error code.
849 static s32 Handle_CfgParam(struct host_if_drv *drvHandler,
850 struct cfg_param_attr *strHostIFCfgParamAttr)
853 struct wid strWIDList[32];
855 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
858 down(&(pstrWFIDrv->gtOsCfgValuesSem));
861 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
863 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) {
864 /*----------------------------------------------------------*/
865 /*Input Value: INFRASTRUCTURE = 1, */
866 /* INDEPENDENT= 2, */
868 /*----------------------------------------------------------*/
869 /* validate input then copy>> need to check value 4 and 5 */
870 if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) {
871 strWIDList[u8WidCnt].id = WID_BSS_TYPE;
872 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
873 strWIDList[u8WidCnt].type = WID_CHAR;
874 strWIDList[u8WidCnt].size = sizeof(char);
875 pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
877 PRINT_ER("check value 6 over\n");
883 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) {
884 /*------------------------------------------------------*/
885 /*Input Values: OPEN_SYSTEM = 0, */
886 /* SHARED_KEY = 1, */
888 /*------------------------------------------------------*/
889 /*validate Possible values*/
890 if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) {
891 strWIDList[u8WidCnt].id = WID_AUTH_TYPE;
892 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
893 strWIDList[u8WidCnt].type = WID_CHAR;
894 strWIDList[u8WidCnt].size = sizeof(char);
895 pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
897 PRINT_ER("Impossible value \n");
903 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) {
904 /* range is 1 to 65535. */
905 if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) {
906 strWIDList[u8WidCnt].id = WID_AUTH_TIMEOUT;
907 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
908 strWIDList[u8WidCnt].type = WID_SHORT;
909 strWIDList[u8WidCnt].size = sizeof(u16);
910 pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
912 PRINT_ER("Range(1 ~ 65535) over\n");
918 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) {
919 /*-----------------------------------------------------------*/
920 /*Input Values: NO_POWERSAVE = 0, */
921 /* MIN_FAST_PS = 1, */
922 /* MAX_FAST_PS = 2, */
923 /* MIN_PSPOLL_PS = 3, */
924 /* MAX_PSPOLL_PS = 4 */
925 /*----------------------------------------------------------*/
926 if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) {
927 strWIDList[u8WidCnt].id = WID_POWER_MANAGEMENT;
928 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
929 strWIDList[u8WidCnt].type = WID_CHAR;
930 strWIDList[u8WidCnt].size = sizeof(char);
931 pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
933 PRINT_ER("Invalide power mode\n");
939 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) {
940 /* range from 1 to 256 */
941 if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) {
942 strWIDList[u8WidCnt].id = WID_SHORT_RETRY_LIMIT;
943 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
944 strWIDList[u8WidCnt].type = WID_SHORT;
945 strWIDList[u8WidCnt].size = sizeof(u16);
946 pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
948 PRINT_ER("Range(1~256) over\n");
954 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) {
955 /* range from 1 to 256 */
956 if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) {
957 strWIDList[u8WidCnt].id = WID_LONG_RETRY_LIMIT;
958 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
960 strWIDList[u8WidCnt].type = WID_SHORT;
961 strWIDList[u8WidCnt].size = sizeof(u16);
962 pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
964 PRINT_ER("Range(1~256) over\n");
970 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) {
972 if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) {
973 strWIDList[u8WidCnt].id = WID_FRAG_THRESHOLD;
974 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
975 strWIDList[u8WidCnt].type = WID_SHORT;
976 strWIDList[u8WidCnt].size = sizeof(u16);
977 pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
979 PRINT_ER("Threshold Range fail\n");
985 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) {
986 /* range 256 to 65535 */
987 if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) {
988 strWIDList[u8WidCnt].id = WID_RTS_THRESHOLD;
989 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
990 strWIDList[u8WidCnt].type = WID_SHORT;
991 strWIDList[u8WidCnt].size = sizeof(u16);
992 pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
994 PRINT_ER("Threshold Range fail\n");
1000 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) {
1001 /*-----------------------------------------------------*/
1002 /*Input Values: Short= 0, */
1005 /*------------------------------------------------------*/
1006 if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) {
1007 strWIDList[u8WidCnt].id = WID_PREAMBLE;
1008 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1009 strWIDList[u8WidCnt].type = WID_CHAR;
1010 strWIDList[u8WidCnt].size = sizeof(char);
1011 pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1013 PRINT_ER("Preamle Range(0~2) over\n");
1019 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) {
1020 if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) {
1021 strWIDList[u8WidCnt].id = WID_SHORT_SLOT_ALLOWED;
1022 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
1023 strWIDList[u8WidCnt].type = WID_CHAR;
1024 strWIDList[u8WidCnt].size = sizeof(char);
1025 pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
1027 PRINT_ER("Short slot(2) over\n");
1033 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) {
1034 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1035 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1036 /* this information is useful for external supplicant */
1037 /*Input Values: 1 for enable and 0 for disable. */
1038 if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) {
1039 strWIDList[u8WidCnt].id = WID_11N_TXOP_PROT_DISABLE;
1040 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
1041 strWIDList[u8WidCnt].type = WID_CHAR;
1042 strWIDList[u8WidCnt].size = sizeof(char);
1043 pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
1045 PRINT_ER("TXOP prot disable\n");
1051 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) {
1052 /* range is 1 to 65535. */
1053 if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) {
1054 strWIDList[u8WidCnt].id = WID_BEACON_INTERVAL;
1055 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1056 strWIDList[u8WidCnt].type = WID_SHORT;
1057 strWIDList[u8WidCnt].size = sizeof(u16);
1058 pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1060 PRINT_ER("Beacon interval(1~65535) fail\n");
1066 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) {
1067 /* range is 1 to 255. */
1068 if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) {
1069 strWIDList[u8WidCnt].id = WID_DTIM_PERIOD;
1070 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1071 strWIDList[u8WidCnt].type = WID_CHAR;
1072 strWIDList[u8WidCnt].size = sizeof(char);
1073 pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1075 PRINT_ER("DTIM range(1~255) fail\n");
1081 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) {
1082 /*----------------------------------------------------------------------*/
1083 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1084 /* SITE_SURVEY_ALL_CH = 1, */
1085 /* SITE_SURVEY_OFF = 2 */
1086 /*----------------------------------------------------------------------*/
1087 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) {
1088 strWIDList[u8WidCnt].id = WID_SITE_SURVEY;
1089 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
1090 strWIDList[u8WidCnt].type = WID_CHAR;
1091 strWIDList[u8WidCnt].size = sizeof(char);
1092 pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
1094 PRINT_ER("Site survey disable\n");
1100 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) {
1101 /* range is 1 to 65535. */
1102 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) {
1103 strWIDList[u8WidCnt].id = WID_SITE_SURVEY_SCAN_TIME;
1104 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1105 strWIDList[u8WidCnt].type = WID_SHORT;
1106 strWIDList[u8WidCnt].size = sizeof(u16);
1107 pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1109 PRINT_ER("Site survey scan time(1~65535) over\n");
1115 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) {
1116 /* range is 1 to 65535. */
1117 if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) {
1118 strWIDList[u8WidCnt].id = WID_ACTIVE_SCAN_TIME;
1119 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1120 strWIDList[u8WidCnt].type = WID_SHORT;
1121 strWIDList[u8WidCnt].size = sizeof(u16);
1122 pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1124 PRINT_ER("Active scan time(1~65535) over\n");
1130 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) {
1131 /* range is 1 to 65535. */
1132 if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) {
1133 strWIDList[u8WidCnt].id = WID_PASSIVE_SCAN_TIME;
1134 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1135 strWIDList[u8WidCnt].type = WID_SHORT;
1136 strWIDList[u8WidCnt].size = sizeof(u16);
1137 pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1139 PRINT_ER("Passive scan time(1~65535) over\n");
1145 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) {
1146 enum CURRENT_TXRATE curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate;
1147 /*----------------------------------------------------------------------*/
1148 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1149 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1150 /*----------------------------------------------------------------------*/
1152 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
1153 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
1154 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
1155 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
1156 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
1157 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
1158 strWIDList[u8WidCnt].id = WID_CURRENT_TX_RATE;
1159 strWIDList[u8WidCnt].val = (s8 *)&curr_tx_rate;
1160 strWIDList[u8WidCnt].type = WID_SHORT;
1161 strWIDList[u8WidCnt].size = sizeof(u16);
1162 pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
1164 PRINT_ER("out of TX rate\n");
1170 s32Error = send_config_pkt(SET_CFG, strWIDList, u8WidCnt,
1171 get_id_from_handler(pstrWFIDrv));
1174 PRINT_ER("Error in setting CFG params\n");
1177 up(&(pstrWFIDrv->gtOsCfgValuesSem));
1183 * @brief Handle_wait_msg_q_empty
1184 * @details this should be the last msg and then the msg Q becomes idle
1185 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1186 * @return Error code.
1191 static s32 Handle_wait_msg_q_empty(void)
1193 g_wilc_initialized = 0;
1199 * @brief Handle_Scan
1200 * @details Sending config packet to firmware to set the scan params
1201 * @param[in] struct scan_attr *pstrHostIFscanAttr
1202 * @return Error code.
1207 static s32 Handle_Scan(struct host_if_drv *drvHandler,
1208 struct scan_attr *pstrHostIFscanAttr)
1211 struct wid strWIDList[5];
1212 u32 u32WidsCount = 0;
1216 u8 *pu8HdnNtwrksWidVal = NULL;
1217 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *) drvHandler;
1219 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1220 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", pstrWFIDrv->enuHostIFstate);
1222 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
1223 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
1225 if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) {
1226 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1227 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate);
1228 PRINT_ER("Already scan\n");
1233 if (g_obtainingIP || connecting) {
1234 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
1235 PRINT_ER("Don't do obss scan\n");
1240 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1243 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0;
1245 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
1246 strWIDList[u32WidsCount].type = WID_STR;
1248 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++)
1249 valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
1250 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
1251 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
1252 if (strWIDList[u32WidsCount].val != NULL) {
1253 pu8Buffer = strWIDList[u32WidsCount].val;
1255 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
1257 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
1259 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1260 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1261 memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
1262 pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1267 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
1271 /*filling cfg param array*/
1273 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1275 /* IEs to be inserted in Probe Request */
1276 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
1277 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1278 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->pu8IEs;
1279 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->IEsLen;
1284 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
1285 strWIDList[u32WidsCount].type = WID_CHAR;
1286 strWIDList[u32WidsCount].size = sizeof(char);
1287 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->u8ScanType));
1290 /*list of channels to be scanned*/
1291 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
1292 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1294 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
1297 for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
1298 if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0)
1299 pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
1303 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->pu8ChnlFreqList;
1304 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->u8ChnlListLen;
1308 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
1309 strWIDList[u32WidsCount].type = WID_CHAR;
1310 strWIDList[u32WidsCount].size = sizeof(char);
1311 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource));
1314 /*keep the state as is , no need to change it*/
1315 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1317 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
1318 gbScanWhileConnected = true;
1319 else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE)
1320 gbScanWhileConnected = false;
1322 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1323 get_id_from_handler(pstrWFIDrv));
1326 PRINT_ER("Failed to send scan paramters config packet\n");
1328 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
1332 del_timer(&pstrWFIDrv->hScanTimer);
1333 /*if there is an ongoing scan request*/
1334 Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED);
1337 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1338 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
1339 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
1340 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1343 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1344 if (pstrHostIFscanAttr->pu8IEs != NULL) {
1345 kfree(pstrHostIFscanAttr->pu8IEs);
1346 pstrHostIFscanAttr->pu8IEs = NULL;
1348 if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
1349 kfree(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
1350 pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
1353 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1354 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
1355 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
1356 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1359 if (pu8HdnNtwrksWidVal != NULL)
1360 kfree(pu8HdnNtwrksWidVal);
1366 * @brief Handle_ScanDone
1367 * @details Call scan notification callback function
1369 * @return Error code.
1374 static s32 Handle_ScanDone(struct host_if_drv *drvHandler, tenuScanEvent enuEvent)
1378 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
1381 u8 u8abort_running_scan;
1385 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
1387 /*Ask FW to abort the running scan, if any*/
1388 if (enuEvent == SCAN_EVENT_ABORTED) {
1389 PRINT_D(GENERIC_DBG, "Abort running scan\n");
1390 u8abort_running_scan = 1;
1391 strWID.id = (u16)WID_ABORT_RUNNING_SCAN;
1392 strWID.type = WID_CHAR;
1393 strWID.val = (s8 *)&u8abort_running_scan;
1394 strWID.size = sizeof(char);
1397 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1398 get_id_from_handler(pstrWFIDrv));
1400 PRINT_ER("Failed to set abort running scan\n");
1405 if (pstrWFIDrv == NULL) {
1406 PRINT_ER("Driver handler is NULL\n");
1410 /*if there is an ongoing scan request*/
1411 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
1412 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
1413 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1414 /*delete current scan request*/
1415 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1422 * @brief Handle_Connect
1423 * @details Sending config packet to firmware to starting connection
1424 * @param[in] struct connect_attr *pstrHostIFconnectAttr
1425 * @return Error code.
1430 u8 u8ConnectedSSID[6] = {0};
1431 static s32 Handle_Connect(struct host_if_drv *drvHandler,
1432 struct connect_attr *pstrHostIFconnectAttr)
1434 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *) drvHandler;
1436 struct wid strWIDList[8];
1437 u32 u32WidsCount = 0, dummyval = 0;
1438 /* char passphrase[] = "12345678"; */
1439 u8 *pu8CurrByte = NULL;
1440 struct join_bss_param *ptstrJoinBssParam;
1442 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1444 /* if we try to connect to an already connected AP then discard the request */
1446 if (memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
1449 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1453 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1455 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->pJoinParams;
1456 if (ptstrJoinBssParam == NULL) {
1457 PRINT_ER("Required BSSID not found\n");
1462 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1463 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
1464 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1467 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1468 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1469 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssidLen + 1, GFP_KERNEL);
1470 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
1471 pstrHostIFconnectAttr->ssidLen);
1472 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1475 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1476 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1477 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
1478 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
1479 pstrHostIFconnectAttr->IEsLen);
1482 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1483 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1484 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1485 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1487 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
1488 strWIDList[u32WidsCount].type = WID_INT;
1489 strWIDList[u32WidsCount].size = sizeof(u32);
1490 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1493 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
1494 strWIDList[u32WidsCount].type = WID_INT;
1495 strWIDList[u32WidsCount].size = sizeof(u32);
1496 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1499 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
1500 strWIDList[u32WidsCount].type = WID_INT;
1501 strWIDList[u32WidsCount].size = sizeof(u32);
1502 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
1505 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1506 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1508 /* IEs to be inserted in Association Request */
1509 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1510 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1511 strWIDList[u32WidsCount].val = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1512 strWIDList[u32WidsCount].size = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1515 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1517 gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1518 gu8FlushedInfoElemAsoc = kmalloc(gu32FlushedInfoElemAsocSize, GFP_KERNEL);
1519 memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1520 gu32FlushedInfoElemAsocSize);
1523 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1524 strWIDList[u32WidsCount].type = WID_CHAR;
1525 strWIDList[u32WidsCount].size = sizeof(char);
1526 strWIDList[u32WidsCount].val = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
1529 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
1530 gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security;
1532 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1535 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1536 strWIDList[u32WidsCount].type = WID_CHAR;
1537 strWIDList[u32WidsCount].size = sizeof(char);
1538 strWIDList[u32WidsCount].val = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1541 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
1542 gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type;
1544 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1546 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
1547 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1548 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
1549 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
1553 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1554 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
1556 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1557 strWIDList[u32WidsCount].type = WID_STR;
1559 /*Sending NoA attributes during connection*/
1560 strWIDList[u32WidsCount].size = 112; /* 79; */
1561 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
1563 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1564 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].size;
1565 gu8FlushedJoinReq = kmalloc(gu32FlushedJoinReqSize, GFP_KERNEL);
1567 if (strWIDList[u32WidsCount].val == NULL) {
1572 pu8CurrByte = strWIDList[u32WidsCount].val;
1575 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1576 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
1577 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1579 pu8CurrByte += MAX_SSID_LEN;
1582 *(pu8CurrByte++) = INFRASTRUCTURE;
1584 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1585 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1587 PRINT_ER("Channel out of range\n");
1588 *(pu8CurrByte++) = 0xFF;
1591 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1592 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1593 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1596 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1597 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1601 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1602 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
1606 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1607 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1608 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1610 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1611 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1612 /* Supported rates*/
1613 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
1614 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1617 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1618 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1620 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1623 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1624 /* copy this information to the user request */
1625 pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1628 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1629 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1630 /* rsn group policy*/
1631 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1632 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1634 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1635 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1636 /* rsn pcip policy*/
1637 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
1638 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1640 /* rsn auth policy*/
1641 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
1642 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1644 /* rsn auth policy*/
1645 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
1646 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1648 *(pu8CurrByte++) = REAL_JOIN_REQ;
1650 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1651 if (ptstrJoinBssParam->u8NoaEnbaled) {
1652 PRINT_D(HOSTINF_DBG, "NOA present\n");
1654 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1655 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1656 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1657 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1659 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1661 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1663 if (ptstrJoinBssParam->u8OppEnable)
1664 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1666 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1668 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
1670 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1672 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
1674 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1676 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
1678 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1681 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1683 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1684 pu8CurrByte = strWIDList[u32WidsCount].val;
1687 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1688 * firmware at chip reset when processing the WIDs of the Connect Request.
1689 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1690 /* ////////////////////// */
1691 gu32WidConnRstHack = 0;
1692 /* ////////////////////// */
1694 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
1695 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
1696 gu8FlushedJoinReqDrvHandler = pstrWFIDrv;
1699 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1701 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1702 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
1704 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->pu8bssid);
1705 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
1708 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1709 get_id_from_handler(pstrWFIDrv));
1711 PRINT_ER("failed to send config packet\n");
1715 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1716 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1721 tstrConnectInfo strConnectInfo;
1723 del_timer(&pstrWFIDrv->hConnectTimer);
1725 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1727 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1729 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
1730 if (pstrHostIFconnectAttr->pu8bssid != NULL)
1731 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
1733 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1734 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1735 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
1736 memcpy(strConnectInfo.pu8ReqIEs,
1737 pstrHostIFconnectAttr->pu8IEs,
1738 pstrHostIFconnectAttr->IEsLen);
1741 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1745 pstrHostIFconnectAttr->pvUserArg);
1746 /*Change state to idle*/
1747 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
1749 if (strConnectInfo.pu8ReqIEs != NULL) {
1750 kfree(strConnectInfo.pu8ReqIEs);
1751 strConnectInfo.pu8ReqIEs = NULL;
1755 PRINT_ER("Connect callback function pointer is NULL\n");
1759 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
1760 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
1761 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
1762 kfree(pstrHostIFconnectAttr->pu8bssid);
1763 pstrHostIFconnectAttr->pu8bssid = NULL;
1766 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
1767 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
1768 kfree(pstrHostIFconnectAttr->pu8ssid);
1769 pstrHostIFconnectAttr->pu8ssid = NULL;
1772 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
1773 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1774 kfree(pstrHostIFconnectAttr->pu8IEs);
1775 pstrHostIFconnectAttr->pu8IEs = NULL;
1778 if (pu8CurrByte != NULL)
1784 * @brief Handle_FlushConnect
1785 * @details Sending config packet to firmware to flush an old connection
1786 * after switching FW from station one to hybrid one
1787 * @param[in] void * drvHandler
1788 * @return Error code.
1789 * @author Amr Abdel-Moghny
1794 static s32 Handle_FlushConnect(struct host_if_drv *drvHandler)
1797 struct wid strWIDList[5];
1798 u32 u32WidsCount = 0;
1799 u8 *pu8CurrByte = NULL;
1802 /* IEs to be inserted in Association Request */
1803 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
1804 strWIDList[u32WidsCount].type = WID_BIN_DATA;
1805 strWIDList[u32WidsCount].val = gu8FlushedInfoElemAsoc;
1806 strWIDList[u32WidsCount].size = gu32FlushedInfoElemAsocSize;
1809 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
1810 strWIDList[u32WidsCount].type = WID_CHAR;
1811 strWIDList[u32WidsCount].size = sizeof(char);
1812 strWIDList[u32WidsCount].val = (s8 *)(&(gu8Flushed11iMode));
1817 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
1818 strWIDList[u32WidsCount].type = WID_CHAR;
1819 strWIDList[u32WidsCount].size = sizeof(char);
1820 strWIDList[u32WidsCount].val = (s8 *)(&gu8FlushedAuthType);
1823 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
1824 strWIDList[u32WidsCount].type = WID_STR;
1825 strWIDList[u32WidsCount].size = gu32FlushedJoinReqSize;
1826 strWIDList[u32WidsCount].val = (s8 *)gu8FlushedJoinReq;
1827 pu8CurrByte = strWIDList[u32WidsCount].val;
1829 pu8CurrByte += FLUSHED_BYTE_POS;
1830 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1834 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
1835 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
1837 PRINT_ER("failed to send config packet\n");
1845 * @brief Handle_ConnectTimeout
1846 * @details Call connect notification callback function indicating connection failure
1848 * @return Error code.
1853 static s32 Handle_ConnectTimeout(struct host_if_drv *drvHandler)
1856 tstrConnectInfo strConnectInfo;
1858 u16 u16DummyReasonCode = 0;
1859 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *) drvHandler;
1861 if (pstrWFIDrv == NULL) {
1862 PRINT_ER("Driver handler is NULL\n");
1866 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
1868 gbScanWhileConnected = false;
1871 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
1874 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
1875 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
1876 * WID_DISCONNECT} */
1877 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1878 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
1879 memcpy(strConnectInfo.au8bssid,
1880 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
1883 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1884 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1885 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
1886 memcpy(strConnectInfo.pu8ReqIEs,
1887 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1888 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
1891 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1895 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
1897 /* Deallocation of strConnectInfo.pu8ReqIEs */
1898 if (strConnectInfo.pu8ReqIEs != NULL) {
1899 kfree(strConnectInfo.pu8ReqIEs);
1900 strConnectInfo.pu8ReqIEs = NULL;
1903 PRINT_ER("Connect callback function pointer is NULL\n");
1906 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
1907 * WID_DISCONNECT} */
1908 strWID.id = (u16)WID_DISCONNECT;
1909 strWID.type = WID_CHAR;
1910 strWID.val = (s8 *)&u16DummyReasonCode;
1911 strWID.size = sizeof(char);
1913 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1915 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
1916 get_id_from_handler(pstrWFIDrv));
1918 PRINT_ER("Failed to send dissconect config packet\n");
1920 /* Deallocation of the Saved Connect Request in the global Handle */
1921 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
1922 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
1923 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
1924 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
1927 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
1928 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
1929 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
1932 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1933 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1934 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
1935 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
1938 eth_zero_addr(u8ConnectedSSID);
1939 /*Freeing flushed join request params on connect timeout*/
1940 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
1941 kfree(gu8FlushedJoinReq);
1942 gu8FlushedJoinReq = NULL;
1944 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
1945 kfree(gu8FlushedInfoElemAsoc);
1946 gu8FlushedInfoElemAsoc = NULL;
1953 * @brief Handle_RcvdNtwrkInfo
1954 * @details Handling received network information
1955 * @param[in] struct rcvd_net_info *pstrRcvdNetworkInfo
1956 * @return Error code.
1961 static s32 Handle_RcvdNtwrkInfo(struct host_if_drv *drvHandler,
1962 struct rcvd_net_info *pstrRcvdNetworkInfo)
1965 bool bNewNtwrkFound;
1970 tstrNetworkInfo *pstrNetworkInfo = NULL;
1971 void *pJoinParams = NULL;
1973 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
1977 bNewNtwrkFound = true;
1978 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1980 /*if there is a an ongoing scan request*/
1981 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
1982 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
1983 parse_network_info(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
1984 if ((pstrNetworkInfo == NULL)
1985 || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
1986 PRINT_ER("driver is null\n");
1991 /* check whether this network is discovered before */
1992 for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
1994 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
1995 (pstrNetworkInfo->au8bssid != NULL)) {
1996 if (memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
1997 pstrNetworkInfo->au8bssid, 6) == 0) {
1998 if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
1999 /*we have already found this network with better rssi, so keep the old cached one and don't
2000 * send anything to the upper layer */
2001 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
2004 /* here the same already found network is found again but with a better rssi, so just update
2005 * the rssi for this cached network and send this updated network to the upper layer but
2006 * don't add a new record for it */
2007 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
2008 bNewNtwrkFound = false;
2015 if (bNewNtwrkFound == true) {
2016 /* here it is confirmed that it is a new discovered network,
2017 * so add its record then call the User CallBack function */
2019 PRINT_D(HOSTINF_DBG, "New network found\n");
2021 if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
2022 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
2024 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
2025 && (pstrNetworkInfo->au8bssid != NULL)) {
2026 memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
2027 pstrNetworkInfo->au8bssid, 6);
2029 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++;
2031 pstrNetworkInfo->bNewNetwork = true;
2032 /* add new BSS to JoinBssTable */
2033 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
2035 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2036 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid,
2042 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
2045 pstrNetworkInfo->bNewNetwork = false;
2046 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2047 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2048 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2053 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2054 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
2055 kfree(pstrRcvdNetworkInfo->pu8Buffer);
2056 pstrRcvdNetworkInfo->pu8Buffer = NULL;
2059 /*free structure allocated*/
2060 if (pstrNetworkInfo != NULL) {
2061 DeallocateNetworkInfo(pstrNetworkInfo);
2062 pstrNetworkInfo = NULL;
2069 * @brief Handle_RcvdGnrlAsyncInfo
2070 * @details Handling received asynchrous general network information
2071 * @param[in] struct rcvd_async_info *pstrRcvdGnrlAsyncInfo
2072 * @return Error code.
2077 static s32 Handle_RcvdGnrlAsyncInfo(struct host_if_drv *drvHandler,
2078 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
2080 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2081 /* which carries only 1 WID which have WID ID = WID_STATUS */
2086 u16 u16WidID = (u16)WID_NIL;
2089 u8 u8MacStatusReasonCode;
2090 u8 u8MacStatusAdditionalInfo;
2091 tstrConnectInfo strConnectInfo;
2092 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2094 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *) drvHandler;
2097 PRINT_ER("Driver handler is NULL\n");
2100 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
2101 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
2103 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
2104 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) ||
2105 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2106 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
2107 (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
2108 PRINT_ER("driver is null\n");
2112 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
2114 /* Check whether the received message type is 'I' */
2115 if ('I' != u8MsgType) {
2116 PRINT_ER("Received Message format incorrect.\n");
2120 /* Extract message ID */
2121 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
2123 /* Extract message Length */
2124 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
2126 /* Extract WID ID [expected to be = WID_STATUS] */
2127 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
2129 /* Extract WID Length [expected to be = 1] */
2130 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
2132 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2133 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
2134 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
2135 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
2136 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2137 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2138 /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */
2139 u32 u32RcvdAssocRespInfoLen;
2140 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
2142 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2144 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
2146 if (u8MacStatus == MAC_CONNECTED) {
2147 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
2149 host_int_get_assoc_res_info(pstrWFIDrv,
2151 MAX_ASSOC_RESP_FRAME_SIZE,
2152 &u32RcvdAssocRespInfoLen);
2154 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
2156 if (u32RcvdAssocRespInfoLen != 0) {
2158 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
2159 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
2160 &pstrConnectRespInfo);
2162 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
2164 /* use the necessary parsed Info from the Received Association Response */
2165 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
2167 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
2168 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
2169 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
2170 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
2173 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
2174 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
2175 pstrConnectRespInfo->u16RespIEsLen);
2179 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2180 if (pstrConnectRespInfo != NULL) {
2181 DeallocateAssocRespInfo(pstrConnectRespInfo);
2182 pstrConnectRespInfo = NULL;
2188 /* The station has just received mac status and it also received assoc. response which
2189 * it was waiting for.
2190 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2191 if ((u8MacStatus == MAC_CONNECTED) &&
2192 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
2193 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
2194 eth_zero_addr(u8ConnectedSSID);
2196 } else if (u8MacStatus == MAC_DISCONNECTED) {
2197 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
2198 eth_zero_addr(u8ConnectedSSID);
2201 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2202 /* through a structure of type tstrConnectRespInfo */
2203 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2204 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
2205 memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2207 if ((u8MacStatus == MAC_CONNECTED) &&
2208 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2209 memcpy(pstrWFIDrv->au8AssociatedBSSID,
2210 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
2215 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2216 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
2217 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
2218 memcpy(strConnectInfo.pu8ReqIEs,
2219 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2220 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2224 del_timer(&pstrWFIDrv->hConnectTimer);
2225 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2229 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2232 /* if received mac status is MAC_CONNECTED and
2233 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2234 * else change state to IDLE */
2235 if ((u8MacStatus == MAC_CONNECTED) &&
2236 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2237 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
2239 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
2240 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED;
2242 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
2243 g_obtainingIP = true;
2244 mod_timer(&hDuringIpTimer,
2245 jiffies + msecs_to_jiffies(10000));
2247 /* open a BA session if possible */
2248 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
2249 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2251 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
2252 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2253 gbScanWhileConnected = false;
2257 if (strConnectInfo.pu8RespIEs != NULL) {
2258 kfree(strConnectInfo.pu8RespIEs);
2259 strConnectInfo.pu8RespIEs = NULL;
2262 if (strConnectInfo.pu8ReqIEs != NULL) {
2263 kfree(strConnectInfo.pu8ReqIEs);
2264 strConnectInfo.pu8ReqIEs = NULL;
2268 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2269 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2270 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2271 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2274 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2275 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2276 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2279 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2280 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2281 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2282 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2285 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2286 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) {
2287 /* Disassociation or Deauthentication frame has been received */
2288 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
2290 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2292 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2293 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
2294 del_timer(&pstrWFIDrv->hScanTimer);
2295 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2298 strDisconnectNotifInfo.u16reason = 0;
2299 strDisconnectNotifInfo.ie = NULL;
2300 strDisconnectNotifInfo.ie_len = 0;
2302 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2303 g_obtainingIP = false;
2304 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
2306 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2309 &strDisconnectNotifInfo,
2310 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2313 PRINT_ER("Connect result callback function is NULL\n");
2316 eth_zero_addr(pstrWFIDrv->au8AssociatedBSSID);
2321 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2322 * should be deallocated here */
2324 * if(strDisconnectNotifInfo.ie != NULL)
2326 * kfree(strDisconnectNotifInfo.ie);
2327 * strDisconnectNotifInfo.ie = NULL;
2331 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2332 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2333 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2334 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2337 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2338 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2339 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2342 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2343 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2344 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2345 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2348 /*Freeing flushed join request params on receiving*/
2349 /*MAC_DISCONNECTED while connected*/
2350 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
2351 kfree(gu8FlushedJoinReq);
2352 gu8FlushedJoinReq = NULL;
2354 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
2355 kfree(gu8FlushedInfoElemAsoc);
2356 gu8FlushedInfoElemAsoc = NULL;
2359 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2360 gbScanWhileConnected = false;
2362 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2363 (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
2364 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
2365 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
2366 /*Abort the running scan*/
2367 del_timer(&pstrWFIDrv->hScanTimer);
2368 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult)
2369 Handle_ScanDone(pstrWFIDrv, SCAN_EVENT_ABORTED);
2375 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2376 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
2377 kfree(pstrRcvdGnrlAsyncInfo->pu8Buffer);
2378 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
2386 * @details Sending config packet to firmware to set key
2387 * @param[in] struct key_attr *pstrHostIFkeyAttr
2388 * @return Error code.
2393 static int Handle_Key(struct host_if_drv *drvHandler,
2394 struct key_attr *pstrHostIFkeyAttr)
2398 struct wid strWIDList[5];
2403 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
2406 switch (pstrHostIFkeyAttr->enuKeyType) {
2411 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2413 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2414 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2415 strWIDList[0].id = (u16)WID_11I_MODE;
2416 strWIDList[0].type = WID_CHAR;
2417 strWIDList[0].size = sizeof(char);
2418 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode));
2420 strWIDList[1].id = WID_AUTH_TYPE;
2421 strWIDList[1].type = WID_CHAR;
2422 strWIDList[1].size = sizeof(char);
2423 strWIDList[1].val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type));
2425 strWIDList[2].id = (u16)WID_KEY_ID;
2426 strWIDList[2].type = WID_CHAR;
2428 strWIDList[2].val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2429 strWIDList[2].size = sizeof(char);
2432 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, GFP_KERNEL);
2435 if (pu8keybuf == NULL) {
2436 PRINT_ER("No buffer to send Key\n");
2440 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
2441 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2444 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
2446 strWIDList[3].id = (u16)WID_WEP_KEY_VALUE;
2447 strWIDList[3].type = WID_STR;
2448 strWIDList[3].size = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
2449 strWIDList[3].val = (s8 *)pu8keybuf;
2452 s32Error = send_config_pkt(SET_CFG, strWIDList, 4,
2453 get_id_from_handler(pstrWFIDrv));
2459 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2460 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2461 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2, GFP_KERNEL);
2462 if (pu8keybuf == NULL) {
2463 PRINT_ER("No buffer to send Key\n");
2466 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2468 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
2470 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
2471 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2473 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
2475 strWID.id = (u16)WID_ADD_WEP_KEY;
2476 strWID.type = WID_STR;
2477 strWID.val = (s8 *)pu8keybuf;
2478 strWID.size = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2;
2480 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2481 get_id_from_handler(pstrWFIDrv));
2483 } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) {
2485 PRINT_D(HOSTINF_DBG, "Removing key\n");
2486 strWID.id = (u16)WID_REMOVE_WEP_KEY;
2487 strWID.type = WID_STR;
2489 s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2490 strWID.val = s8idxarray;
2493 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2494 get_id_from_handler(pstrWFIDrv));
2496 strWID.id = (u16)WID_KEY_ID;
2497 strWID.type = WID_CHAR;
2498 strWID.val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
2499 strWID.size = sizeof(char);
2501 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
2503 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2504 get_id_from_handler(pstrWFIDrv));
2506 up(&(pstrWFIDrv->hSemTestKeyBlock));
2510 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2511 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
2512 if (pu8keybuf == NULL) {
2513 PRINT_ER("No buffer to send RxGTK Key\n");
2515 goto _WPARxGtk_end_case_;
2518 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
2521 /*|----------------------------------------------------------------------------|
2522 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2523 * |------------|---------|-------|------------|---------------|----------------|
2524 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2528 if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
2529 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
2532 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2534 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2536 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2537 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2538 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
2539 strWIDList[0].id = (u16)WID_11I_MODE;
2540 strWIDList[0].type = WID_CHAR;
2541 strWIDList[0].size = sizeof(char);
2542 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
2544 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
2545 strWIDList[1].type = WID_STR;
2546 strWIDList[1].val = (s8 *)pu8keybuf;
2547 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
2549 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
2550 get_id_from_handler(pstrWFIDrv));
2554 /* ////////////////////////// */
2555 up(&(pstrWFIDrv->hSemTestKeyBlock));
2556 /* ///////////////////////// */
2559 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2560 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
2562 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
2563 if (pu8keybuf == NULL) {
2564 PRINT_ER("No buffer to send RxGTK Key\n");
2566 goto _WPARxGtk_end_case_;
2569 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
2572 /*|----------------------------------------------------------------------------|
2573 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2574 * |------------|---------|-------|------------|---------------|----------------|
2575 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2577 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
2578 memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
2580 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
2582 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
2584 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2586 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2587 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2588 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2590 strWID.id = (u16)WID_ADD_RX_GTK;
2591 strWID.type = WID_STR;
2592 strWID.val = (s8 *)pu8keybuf;
2593 strWID.size = RX_MIC_KEY_MSG_LEN;
2595 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2596 get_id_from_handler(pstrWFIDrv));
2600 /* ////////////////////////// */
2601 up(&(pstrWFIDrv->hSemTestKeyBlock));
2602 /* ///////////////////////// */
2604 _WPARxGtk_end_case_:
2605 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2606 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq);
2613 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2616 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
2620 if (pu8keybuf == NULL) {
2621 PRINT_ER("No buffer to send PTK Key\n");
2623 goto _WPAPtk_end_case_;
2627 /*|-----------------------------------------------------------------------------|
2628 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2629 * |----------------|------------ |--------------|----------------|---------------|
2630 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2631 |-----------------------------------------------------------------------------|*/
2633 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
2635 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2636 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2638 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2639 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2642 strWIDList[0].id = (u16)WID_11I_MODE;
2643 strWIDList[0].type = WID_CHAR;
2644 strWIDList[0].size = sizeof(char);
2645 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
2647 strWIDList[1].id = (u16)WID_ADD_PTK;
2648 strWIDList[1].type = WID_STR;
2649 strWIDList[1].val = (s8 *)pu8keybuf;
2650 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
2652 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
2653 get_id_from_handler(pstrWFIDrv));
2656 /* ////////////////////////// */
2657 up(&(pstrWFIDrv->hSemTestKeyBlock));
2658 /* ///////////////////////// */
2660 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2663 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
2667 if (pu8keybuf == NULL) {
2668 PRINT_ER("No buffer to send PTK Key\n");
2670 goto _WPAPtk_end_case_;
2674 /*|-----------------------------------------------------------------------------|
2675 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
2676 * |----------------|------------|--------------|----------------|---------------|
2677 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
2678 |-----------------------------------------------------------------------------|*/
2680 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
2682 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2684 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
2685 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2688 strWID.id = (u16)WID_ADD_PTK;
2689 strWID.type = WID_STR;
2690 strWID.val = (s8 *)pu8keybuf;
2691 strWID.size = PTK_KEY_MSG_LEN;
2693 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2694 get_id_from_handler(pstrWFIDrv));
2697 /* ////////////////////////// */
2698 up(&(pstrWFIDrv->hSemTestKeyBlock));
2699 /* ///////////////////////// */
2703 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2712 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
2714 pu8keybuf = kmalloc((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
2715 if (pu8keybuf == NULL) {
2716 PRINT_ER("No buffer to send PMKSA Key\n");
2720 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
2722 for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
2724 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
2725 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN);
2728 strWID.id = (u16)WID_PMKID_INFO;
2729 strWID.type = WID_STR;
2730 strWID.val = (s8 *)pu8keybuf;
2731 strWID.size = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1;
2733 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2734 get_id_from_handler(pstrWFIDrv));
2741 PRINT_ER("Failed to send key config packet\n");
2749 * @brief Handle_Disconnect
2750 * @details Sending config packet to firmware to disconnect
2757 static void Handle_Disconnect(struct host_if_drv *drvHandler)
2762 u16 u16DummyReasonCode = 0;
2763 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
2766 strWID.id = (u16)WID_DISCONNECT;
2767 strWID.type = WID_CHAR;
2768 strWID.val = (s8 *)&u16DummyReasonCode;
2769 strWID.size = sizeof(char);
2773 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2775 g_obtainingIP = false;
2776 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
2778 eth_zero_addr(u8ConnectedSSID);
2780 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
2781 get_id_from_handler(pstrWFIDrv));
2784 PRINT_ER("Failed to send dissconect config packet\n");
2786 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2788 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
2790 strDisconnectNotifInfo.u16reason = 0;
2791 strDisconnectNotifInfo.ie = NULL;
2792 strDisconnectNotifInfo.ie_len = 0;
2794 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2795 del_timer(&pstrWFIDrv->hScanTimer);
2796 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
2797 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2799 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
2802 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2804 /*Stop connect timer, if connection in progress*/
2805 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2806 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
2807 del_timer(&pstrWFIDrv->hConnectTimer);
2810 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
2811 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2813 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
2816 gbScanWhileConnected = false;
2818 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2820 eth_zero_addr(pstrWFIDrv->au8AssociatedBSSID);
2824 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2825 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
2826 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
2827 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2830 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2831 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
2832 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2835 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2836 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2837 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
2838 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2842 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
2843 kfree(gu8FlushedJoinReq);
2844 gu8FlushedJoinReq = NULL;
2846 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
2847 kfree(gu8FlushedInfoElemAsoc);
2848 gu8FlushedInfoElemAsoc = NULL;
2853 /* ////////////////////////// */
2854 up(&(pstrWFIDrv->hSemTestDisconnectBlock));
2855 /* ///////////////////////// */
2860 void resolve_disconnect_aberration(struct host_if_drv *drvHandler)
2862 struct host_if_drv *pstrWFIDrv;
2864 pstrWFIDrv = (struct host_if_drv *)drvHandler;
2865 if (pstrWFIDrv == NULL)
2867 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
2868 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
2869 host_int_disconnect(pstrWFIDrv, 1);
2874 * @brief Handle_GetChnl
2875 * @details Sending config packet to get channel
2883 static s32 Handle_GetChnl(struct host_if_drv *drvHandler)
2888 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
2890 strWID.id = (u16)WID_CURRENT_CHANNEL;
2891 strWID.type = WID_CHAR;
2892 strWID.val = (s8 *)&gu8Chnl;
2893 strWID.size = sizeof(char);
2895 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2897 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2898 get_id_from_handler(pstrWFIDrv));
2899 /*get the value by searching the local copy*/
2901 PRINT_ER("Failed to get channel number\n");
2905 up(&(pstrWFIDrv->hSemGetCHNL));
2915 * @brief Handle_GetRssi
2916 * @details Sending config packet to get RSSI
2923 static void Handle_GetRssi(struct host_if_drv *drvHandler)
2927 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
2929 strWID.id = (u16)WID_RSSI;
2930 strWID.type = WID_CHAR;
2931 strWID.val = &gs8Rssi;
2932 strWID.size = sizeof(char);
2935 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2937 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2938 get_id_from_handler(pstrWFIDrv));
2940 PRINT_ER("Failed to get RSSI value\n");
2944 up(&(pstrWFIDrv->hSemGetRSSI));
2950 static void Handle_GetLinkspeed(struct host_if_drv *drvHandler)
2954 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
2958 strWID.id = (u16)WID_LINKSPEED;
2959 strWID.type = WID_CHAR;
2960 strWID.val = &gs8lnkspd;
2961 strWID.size = sizeof(char);
2963 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2965 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
2966 get_id_from_handler(pstrWFIDrv));
2968 PRINT_ER("Failed to get LINKSPEED value\n");
2972 up(&(pstrWFIDrv->hSemGetLINKSPEED));
2977 s32 Handle_GetStatistics(struct host_if_drv *drvHandler, tstrStatistics *pstrStatistics)
2979 struct wid strWIDList[5];
2980 u32 u32WidsCount = 0, s32Error = 0;
2982 strWIDList[u32WidsCount].id = WID_LINKSPEED;
2983 strWIDList[u32WidsCount].type = WID_CHAR;
2984 strWIDList[u32WidsCount].size = sizeof(char);
2985 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u8LinkSpeed));
2988 strWIDList[u32WidsCount].id = WID_RSSI;
2989 strWIDList[u32WidsCount].type = WID_CHAR;
2990 strWIDList[u32WidsCount].size = sizeof(char);
2991 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->s8RSSI));
2994 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
2995 strWIDList[u32WidsCount].type = WID_INT;
2996 strWIDList[u32WidsCount].size = sizeof(u32);
2997 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxCount));
3000 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
3001 strWIDList[u32WidsCount].type = WID_INT;
3002 strWIDList[u32WidsCount].size = sizeof(u32);
3003 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32RxCount));
3006 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
3007 strWIDList[u32WidsCount].type = WID_INT;
3008 strWIDList[u32WidsCount].size = sizeof(u32);
3009 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxFailureCount));
3012 s32Error = send_config_pkt(GET_CFG, strWIDList, u32WidsCount,
3013 get_id_from_handler(drvHandler));
3016 PRINT_ER("Failed to send scan paramters config packet\n");
3024 * @brief Handle_Get_InActiveTime
3025 * @details Sending config packet to set mac adddress for station and
3034 static s32 Handle_Get_InActiveTime(struct host_if_drv *drvHandler,
3035 struct sta_inactive_t *strHostIfStaInactiveT)
3041 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3044 strWID.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
3045 strWID.type = WID_STR;
3046 strWID.size = ETH_ALEN;
3047 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
3050 stamac = strWID.val;
3051 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
3054 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
3057 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
3058 get_id_from_handler(pstrWFIDrv));
3059 /*get the value by searching the local copy*/
3061 PRINT_ER("Failed to SET incative time\n");
3066 strWID.id = (u16)WID_GET_INACTIVE_TIME;
3067 strWID.type = WID_INT;
3068 strWID.val = (s8 *)&gu32InactiveTime;
3069 strWID.size = sizeof(u32);
3072 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
3073 get_id_from_handler(pstrWFIDrv));
3074 /*get the value by searching the local copy*/
3076 PRINT_ER("Failed to get incative time\n");
3081 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
3083 up(&(pstrWFIDrv->hSemInactiveTime));
3093 * @brief Handle_AddBeacon
3094 * @details Sending config packet to add beacon
3095 * @param[in] struct beacon_attr *pstrSetBeaconParam
3101 static void Handle_AddBeacon(struct host_if_drv *drvHandler,
3102 struct beacon_attr *pstrSetBeaconParam)
3107 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3109 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
3111 strWID.id = (u16)WID_ADD_BEACON;
3112 strWID.type = WID_BIN;
3113 strWID.size = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
3114 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
3115 if (strWID.val == NULL)
3118 pu8CurrByte = strWID.val;
3119 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
3120 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
3121 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
3122 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
3124 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
3125 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
3126 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
3127 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
3129 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
3130 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
3131 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
3132 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
3134 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
3135 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
3137 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
3138 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
3139 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
3140 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
3142 if (pstrSetBeaconParam->pu8Tail > 0)
3143 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
3144 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
3149 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
3150 get_id_from_handler(pstrWFIDrv));
3152 PRINT_ER("Failed to send add beacon config packet\n");
3156 kfree(pstrSetBeaconParam->pu8Head);
3157 kfree(pstrSetBeaconParam->pu8Tail);
3162 * @brief Handle_AddBeacon
3163 * @details Sending config packet to delete beacon
3164 * @param[in] struct host_if_drv *drvHandler
3170 static void Handle_DelBeacon(struct host_if_drv *drvHandler)
3175 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3177 strWID.id = (u16)WID_DEL_BEACON;
3178 strWID.type = WID_CHAR;
3179 strWID.size = sizeof(char);
3180 strWID.val = &gu8DelBcn;
3182 if (strWID.val == NULL)
3185 pu8CurrByte = strWID.val;
3187 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
3188 /* TODO: build del beacon message*/
3191 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
3192 get_id_from_handler(pstrWFIDrv));
3194 PRINT_ER("Failed to send delete beacon config packet\n");
3199 * @brief WILC_HostIf_PackStaParam
3200 * @details Handling packing of the station params in a buffer
3201 * @param[in] u8* pu8Buffer, struct add_sta_param *pstrStationParam
3207 static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
3208 struct add_sta_param *pstrStationParam)
3212 pu8CurrByte = pu8Buffer;
3214 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
3215 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
3216 pu8CurrByte += ETH_ALEN;
3218 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
3219 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
3221 *pu8CurrByte++ = pstrStationParam->u8NumRates;
3222 if (pstrStationParam->u8NumRates > 0)
3223 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
3224 pu8CurrByte += pstrStationParam->u8NumRates;
3226 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
3227 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
3228 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
3230 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
3231 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
3232 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
3234 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
3235 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
3237 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
3238 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
3239 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
3240 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
3242 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
3244 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
3245 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
3247 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
3248 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
3250 return pu8CurrByte - pu8Buffer;
3254 * @brief Handle_AddStation
3255 * @details Sending config packet to add station
3256 * @param[in] struct add_sta_param *pstrStationParam
3262 static void Handle_AddStation(struct host_if_drv *drvHandler,
3263 struct add_sta_param *pstrStationParam)
3268 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3270 PRINT_D(HOSTINF_DBG, "Handling add station\n");
3271 strWID.id = (u16)WID_ADD_STA;
3272 strWID.type = WID_BIN;
3273 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3275 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
3276 if (strWID.val == NULL)
3279 pu8CurrByte = strWID.val;
3280 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3283 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
3284 get_id_from_handler(pstrWFIDrv));
3286 PRINT_ER("Failed to send add station config packet\n");
3289 kfree(pstrStationParam->pu8Rates);
3294 * @brief Handle_DelAllSta
3295 * @details Sending config packet to delete station
3296 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3302 static void Handle_DelAllSta(struct host_if_drv *drvHandler,
3303 struct del_all_sta *pstrDelAllStaParam)
3309 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3311 u8 au8Zero_Buff[6] = {0};
3313 strWID.id = (u16)WID_DEL_ALL_STA;
3314 strWID.type = WID_STR;
3315 strWID.size = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
3317 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
3319 strWID.val = kmalloc((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1, GFP_KERNEL);
3320 if (strWID.val == NULL)
3323 pu8CurrByte = strWID.val;
3325 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
3327 for (i = 0; i < MAX_NUM_STA; i++) {
3328 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
3329 memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
3333 pu8CurrByte += ETH_ALEN;
3337 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
3338 get_id_from_handler(pstrWFIDrv));
3340 PRINT_ER("Failed to send add station config packet\n");
3350 * @brief Handle_DelStation
3351 * @details Sending config packet to delete station
3352 * @param[in] struct del_sta *pstrDelStaParam
3358 static void Handle_DelStation(struct host_if_drv *drvHandler,
3359 struct del_sta *pstrDelStaParam)
3364 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3366 strWID.id = (u16)WID_REMOVE_STA;
3367 strWID.type = WID_BIN;
3368 strWID.size = ETH_ALEN;
3370 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
3372 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
3373 if (strWID.val == NULL)
3376 pu8CurrByte = strWID.val;
3378 memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
3381 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
3382 get_id_from_handler(pstrWFIDrv));
3384 PRINT_ER("Failed to send add station config packet\n");
3392 * @brief Handle_EditStation
3393 * @details Sending config packet to edit station
3394 * @param[in] struct add_sta_param *pstrStationParam
3400 static void Handle_EditStation(struct host_if_drv *drvHandler,
3401 struct add_sta_param *pstrStationParam)
3406 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3408 strWID.id = (u16)WID_EDIT_STA;
3409 strWID.type = WID_BIN;
3410 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3412 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
3413 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
3414 if (strWID.val == NULL)
3417 pu8CurrByte = strWID.val;
3418 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3421 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
3422 get_id_from_handler(pstrWFIDrv));
3424 PRINT_ER("Failed to send edit station config packet\n");
3427 kfree(pstrStationParam->pu8Rates);
3432 * @brief Handle_RemainOnChan
3433 * @details Sending config packet to edit station
3434 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3440 static int Handle_RemainOnChan(struct host_if_drv *drvHandler,
3441 struct remain_ch *pstrHostIfRemainOnChan)
3444 u8 u8remain_on_chan_flag;
3446 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *) drvHandler;
3448 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3449 if (!pstrWFIDrv->u8RemainOnChan_pendingreq) {
3450 pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
3451 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
3452 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
3453 pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
3454 pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
3456 /*Set the channel to use it as a wid val*/
3457 pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel;
3460 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3461 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
3462 pstrWFIDrv->u8RemainOnChan_pendingreq = 1;
3466 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3467 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
3472 if (g_obtainingIP || connecting) {
3473 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
3478 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
3480 u8remain_on_chan_flag = true;
3481 strWID.id = (u16)WID_REMAIN_ON_CHAN;
3482 strWID.type = WID_STR;
3484 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
3486 if (strWID.val == NULL) {
3491 strWID.val[0] = u8remain_on_chan_flag;
3492 strWID.val[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
3495 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
3496 get_id_from_handler(pstrWFIDrv));
3498 PRINT_ER("Failed to set remain on channel\n");
3502 P2P_LISTEN_STATE = 1;
3503 pstrWFIDrv->hRemainOnChannel.data = (unsigned long)pstrWFIDrv;
3504 mod_timer(&pstrWFIDrv->hRemainOnChannel,
3506 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
3508 /*Calling CFG ready_on_channel*/
3509 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady)
3510 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
3512 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3513 pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
3519 * @brief Handle_RegisterFrame
3527 static int Handle_RegisterFrame(struct host_if_drv *drvHandler,
3528 struct reg_frame *pstrHostIfRegisterFrame)
3533 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3535 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
3537 /*prepare configuration packet*/
3538 strWID.id = (u16)WID_REGISTER_FRAME;
3539 strWID.type = WID_STR;
3540 strWID.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
3541 if (strWID.val == NULL)
3544 pu8CurrByte = strWID.val;
3546 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
3547 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
3548 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
3551 strWID.size = sizeof(u16) + 2;
3555 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
3556 get_id_from_handler(pstrWFIDrv));
3558 PRINT_ER("Failed to frame register config packet\n");
3567 * @brief Handle_ListenStateExpired
3568 * @details Handle of listen state expiration
3570 * @return Error code.
3575 #define FALSE_FRMWR_CHANNEL 100
3576 static u32 Handle_ListenStateExpired(struct host_if_drv *drvHandler,
3577 struct remain_ch *pstrHostIfRemainOnChan)
3579 u8 u8remain_on_chan_flag;
3582 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *) drvHandler;
3584 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
3586 /*Make sure we are already in listen state*/
3587 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
3588 if (P2P_LISTEN_STATE) {
3589 u8remain_on_chan_flag = false;
3590 strWID.id = (u16)WID_REMAIN_ON_CHAN;
3591 strWID.type = WID_STR;
3593 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
3595 if (strWID.val == NULL)
3596 PRINT_ER("Failed to allocate memory\n");
3598 strWID.val[0] = u8remain_on_chan_flag;
3599 strWID.val[1] = FALSE_FRMWR_CHANNEL;
3602 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
3603 get_id_from_handler(pstrWFIDrv));
3604 if (s32Error != 0) {
3605 PRINT_ER("Failed to set remain on channel\n");
3609 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) {
3610 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid
3611 , pstrHostIfRemainOnChan->u32ListenSessionID);
3613 P2P_LISTEN_STATE = 0;
3615 PRINT_D(GENERIC_DBG, "Not in listen state\n");
3625 * @brief ListenTimerCB
3626 * @details Callback function of remain-on-channel timer
3628 * @return Error code.
3633 static void ListenTimerCB(unsigned long arg)
3636 struct host_if_msg msg;
3637 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)arg;
3638 /*Stopping remain-on-channel timer*/
3639 del_timer(&pstrWFIDrv->hRemainOnChannel);
3641 /* prepare the Timer Callback message */
3642 memset(&msg, 0, sizeof(struct host_if_msg));
3643 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
3644 msg.drv = pstrWFIDrv;
3645 msg.body.remain_on_ch.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID;
3647 /* send the message */
3648 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3650 PRINT_ER("wilc_mq_send fail\n");
3654 * @brief Handle_EditStation
3655 * @details Sending config packet to edit station
3656 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3662 static void Handle_PowerManagement(struct host_if_drv *drvHandler,
3663 struct power_mgmt_param *strPowerMgmtParam)
3668 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3670 strWID.id = (u16)WID_POWER_MANAGEMENT;
3672 if (strPowerMgmtParam->bIsEnabled == true)
3673 s8PowerMode = MIN_FAST_PS;
3675 s8PowerMode = NO_POWERSAVE;
3676 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
3677 strWID.val = &s8PowerMode;
3678 strWID.size = sizeof(char);
3680 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
3683 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
3684 get_id_from_handler(pstrWFIDrv));
3686 PRINT_ER("Failed to send power management config packet\n");
3690 * @brief Handle_SetMulticastFilter
3691 * @details Set Multicast filter in firmware
3692 * @param[in] struct set_multicast *strHostIfSetMulti
3698 static void Handle_SetMulticastFilter(struct host_if_drv *drvHandler,
3699 struct set_multicast *strHostIfSetMulti)
3705 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
3707 strWID.id = (u16)WID_SETUP_MULTICAST_FILTER;
3708 strWID.type = WID_BIN;
3709 strWID.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
3710 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
3711 if (strWID.val == NULL)
3714 pu8CurrByte = strWID.val;
3715 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
3716 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
3717 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
3718 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
3720 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
3721 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
3722 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
3723 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
3725 if ((strHostIfSetMulti->u32count) > 0)
3726 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
3729 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
3730 get_id_from_handler(drvHandler));
3732 PRINT_ER("Failed to send setup multicast config packet\n");
3741 * @brief Handle_AddBASession
3742 * @details Add block ack session
3743 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
3745 * @author Amr Abdel-Moghny
3749 static s32 Handle_AddBASession(struct host_if_drv *drvHandler,
3750 struct ba_session_info *strHostIfBASessionInfo)
3754 int AddbaTimeout = 100;
3756 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3758 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
3759 strHostIfBASessionInfo->au8Bssid[0],
3760 strHostIfBASessionInfo->au8Bssid[1],
3761 strHostIfBASessionInfo->au8Bssid[2],
3762 strHostIfBASessionInfo->u16BufferSize,
3763 strHostIfBASessionInfo->u16SessionTimeout,
3764 strHostIfBASessionInfo->u8Ted);
3766 strWID.id = (u16)WID_11E_P_ACTION_REQ;
3767 strWID.type = WID_STR;
3768 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
3769 strWID.size = BLOCK_ACK_REQ_SIZE;
3771 /* *ptr++ = 0x14; */
3775 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
3777 *ptr++ = strHostIfBASessionInfo->u8Ted;
3781 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
3782 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
3784 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
3785 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
3787 *ptr++ = (AddbaTimeout & 0xFF);
3788 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
3789 /* Group Buffer Max Frames*/
3791 /* Group Buffer Timeout */
3794 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
3795 get_id_from_handler(pstrWFIDrv));
3797 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
3800 strWID.id = (u16)WID_11E_P_ACTION_REQ;
3801 strWID.type = WID_STR;
3804 /* *ptr++ = 0x14; */
3808 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
3811 *ptr++ = strHostIfBASessionInfo->u8Ted;
3815 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
3816 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
3819 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
3820 get_id_from_handler(pstrWFIDrv));
3822 if (strWID.val != NULL)
3830 * @brief Handle_DelAllRxBASessions
3831 * @details Delete all Rx BA sessions
3832 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
3834 * @author Abdelrahman Sobhy
3838 static s32 Handle_DelAllRxBASessions(struct host_if_drv *drvHandler,
3839 struct ba_session_info *strHostIfBASessionInfo)
3844 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)drvHandler;
3846 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
3847 strHostIfBASessionInfo->au8Bssid[0],
3848 strHostIfBASessionInfo->au8Bssid[1],
3849 strHostIfBASessionInfo->au8Bssid[2],
3850 strHostIfBASessionInfo->u8Ted);
3852 strWID.id = (u16)WID_DEL_ALL_RX_BA;
3853 strWID.type = WID_STR;
3854 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
3855 strWID.size = BLOCK_ACK_REQ_SIZE;
3860 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
3862 *ptr++ = strHostIfBASessionInfo->u8Ted;
3863 /* BA direction = recipent*/
3866 *ptr++ = 32; /* Unspecific QOS reason */
3868 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
3869 get_id_from_handler(pstrWFIDrv));
3871 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
3874 if (strWID.val != NULL)
3884 * @brief hostIFthread
3885 * @details Main thread to handle message queue requests
3886 * @param[in] void* pvArg
3892 static int hostIFthread(void *pvArg)
3895 struct host_if_msg msg;
3896 struct host_if_drv *pstrWFIDrv;
3898 memset(&msg, 0, sizeof(struct host_if_msg));
3901 wilc_mq_recv(&gMsgQHostIF, &msg, sizeof(struct host_if_msg), &u32Ret);
3902 pstrWFIDrv = (struct host_if_drv *)msg.drv;
3903 if (msg.id == HOST_IF_MSG_EXIT) {
3904 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
3909 /*Re-Queue HIF message*/
3910 if ((!g_wilc_initialized)) {
3911 PRINT_D(GENERIC_DBG, "--WAIT--");
3912 usleep_range(200 * 1000, 200 * 1000);
3913 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3917 if (msg.id == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3918 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
3919 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3920 usleep_range(2 * 1000, 2 * 1000);
3925 case HOST_IF_MSG_Q_IDLE:
3926 Handle_wait_msg_q_empty();
3929 case HOST_IF_MSG_SCAN:
3930 Handle_Scan(msg.drv, &msg.body.scan_info);
3933 case HOST_IF_MSG_CONNECT:
3934 Handle_Connect(msg.drv, &msg.body.con_info);
3937 case HOST_IF_MSG_FLUSH_CONNECT:
3938 Handle_FlushConnect(msg.drv);
3941 case HOST_IF_MSG_RCVD_NTWRK_INFO:
3942 Handle_RcvdNtwrkInfo(msg.drv, &msg.body.net_info);
3945 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
3946 Handle_RcvdGnrlAsyncInfo(msg.drv, &msg.body.async_info);
3949 case HOST_IF_MSG_KEY:
3950 Handle_Key(msg.drv, &msg.body.key_info);
3953 case HOST_IF_MSG_CFG_PARAMS:
3955 Handle_CfgParam(msg.drv, &msg.body.cfg_info);
3958 case HOST_IF_MSG_SET_CHANNEL:
3959 Handle_SetChannel(msg.drv, &msg.body.channel_info);
3962 case HOST_IF_MSG_DISCONNECT:
3963 Handle_Disconnect(msg.drv);
3966 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
3967 del_timer(&pstrWFIDrv->hScanTimer);
3968 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
3970 /*Allow chip sleep, only if both interfaces are not connected*/
3971 if (!linux_wlan_get_num_conn_ifcs())
3972 chip_sleep_manually(INFINITE_SLEEP_TIME);
3974 Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
3976 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3977 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
3981 case HOST_IF_MSG_GET_RSSI:
3982 Handle_GetRssi(msg.drv);
3985 case HOST_IF_MSG_GET_LINKSPEED:
3986 Handle_GetLinkspeed(msg.drv);
3989 case HOST_IF_MSG_GET_STATISTICS:
3990 Handle_GetStatistics(msg.drv, (tstrStatistics *)msg.body.data);
3993 case HOST_IF_MSG_GET_CHNL:
3994 Handle_GetChnl(msg.drv);
3997 case HOST_IF_MSG_ADD_BEACON:
3998 Handle_AddBeacon(msg.drv, &msg.body.beacon_info);
4001 case HOST_IF_MSG_DEL_BEACON:
4002 Handle_DelBeacon(msg.drv);
4005 case HOST_IF_MSG_ADD_STATION:
4006 Handle_AddStation(msg.drv, &msg.body.add_sta_info);
4009 case HOST_IF_MSG_DEL_STATION:
4010 Handle_DelStation(msg.drv, &msg.body.del_sta_info);
4013 case HOST_IF_MSG_EDIT_STATION:
4014 Handle_EditStation(msg.drv, &msg.body.edit_sta_info);
4017 case HOST_IF_MSG_GET_INACTIVETIME:
4018 Handle_Get_InActiveTime(msg.drv, &msg.body.mac_info);
4021 case HOST_IF_MSG_SCAN_TIMER_FIRED:
4022 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
4024 Handle_ScanDone(msg.drv, SCAN_EVENT_ABORTED);
4027 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
4028 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
4029 Handle_ConnectTimeout(msg.drv);
4032 case HOST_IF_MSG_POWER_MGMT:
4033 Handle_PowerManagement(msg.drv, &msg.body.pwr_mgmt_info);
4036 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
4037 Handle_SetWfiDrvHandler(msg.drv,
4041 case HOST_IF_MSG_SET_OPERATION_MODE:
4042 Handle_SetOperationMode(msg.drv, &msg.body.mode);
4045 case HOST_IF_MSG_SET_IPADDRESS:
4046 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4047 Handle_set_IPAddress(msg.drv, msg.body.ip_info.au8IPAddr, msg.body.ip_info.idx);
4050 case HOST_IF_MSG_GET_IPADDRESS:
4051 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4052 Handle_get_IPAddress(msg.drv, msg.body.ip_info.au8IPAddr, msg.body.ip_info.idx);
4055 case HOST_IF_MSG_SET_MAC_ADDRESS:
4056 Handle_SetMacAddress(msg.drv, &msg.body.set_mac_info);
4059 case HOST_IF_MSG_GET_MAC_ADDRESS:
4060 Handle_GetMacAddress(msg.drv, &msg.body.get_mac_info);
4063 case HOST_IF_MSG_REMAIN_ON_CHAN:
4064 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
4065 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
4068 case HOST_IF_MSG_REGISTER_FRAME:
4069 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
4070 Handle_RegisterFrame(msg.drv, &msg.body.reg_frame);
4073 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
4074 Handle_ListenStateExpired(msg.drv, &msg.body.remain_on_ch);
4077 case HOST_IF_MSG_SET_MULTICAST_FILTER:
4078 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
4079 Handle_SetMulticastFilter(msg.drv, &msg.body.multicast_info);
4082 case HOST_IF_MSG_ADD_BA_SESSION:
4083 Handle_AddBASession(msg.drv, &msg.body.session_info);
4086 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
4087 Handle_DelAllRxBASessions(msg.drv, &msg.body.session_info);
4090 case HOST_IF_MSG_DEL_ALL_STA:
4091 Handle_DelAllSta(msg.drv, &msg.body.del_all_sta_info);
4095 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
4100 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
4101 up(&hSemHostIFthrdEnd);
4105 static void TimerCB_Scan(unsigned long arg)
4107 void *pvArg = (void *)arg;
4108 struct host_if_msg msg;
4110 /* prepare the Timer Callback message */
4111 memset(&msg, 0, sizeof(struct host_if_msg));
4113 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
4115 /* send the message */
4116 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4119 static void TimerCB_Connect(unsigned long arg)
4121 void *pvArg = (void *)arg;
4122 struct host_if_msg msg;
4124 /* prepare the Timer Callback message */
4125 memset(&msg, 0, sizeof(struct host_if_msg));
4127 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
4129 /* send the message */
4130 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4135 * @brief removes wpa/wpa2 keys
4136 * @details only in BSS STA mode if External Supplicant support is enabled.
4137 * removes all WPA/WPA2 station key entries from MAC hardware.
4138 * @param[in,out] handle to the wifi driver
4139 * @param[in] 6 bytes of Station Adress in the station entry table
4140 * @return Error code indicating success/failure
4143 * @date 8 March 2012
4146 /* Check implementation in core adding 9 bytes to the input! */
4147 s32 host_int_remove_key(struct host_if_drv *hWFIDrv, const u8 *pu8StaAddress)
4151 strWID.id = (u16)WID_REMOVE_KEY;
4152 strWID.type = WID_STR;
4153 strWID.val = (s8 *)pu8StaAddress;
4160 * @brief removes WEP key
4161 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4162 * remove a WEP key entry from MAC HW.
4163 * The BSS Station automatically finds the index of the entry using its
4164 * BSS ID and removes that entry from the MAC hardware.
4165 * @param[in,out] handle to the wifi driver
4166 * @param[in] 6 bytes of Station Adress in the station entry table
4167 * @return Error code indicating success/failure
4168 * @note NO need for the STA add since it is not used for processing
4170 * @date 8 March 2012
4173 int host_int_remove_wep_key(struct host_if_drv *wfi_drv, u8 index)
4176 struct host_if_msg msg;
4180 PRINT_ER("Failed to send setup multicast config packet\n");
4184 /* prepare the Remove Wep Key Message */
4185 memset(&msg, 0, sizeof(struct host_if_msg));
4187 msg.id = HOST_IF_MSG_KEY;
4188 msg.body.key_info.enuKeyType = WEP;
4189 msg.body.key_info.u8KeyAction = REMOVEKEY;
4193 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = index;
4195 /* send the message */
4196 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4198 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
4199 down(&wfi_drv->hSemTestKeyBlock);
4205 * @brief sets WEP default key
4206 * @details Sets the index of the WEP encryption key in use,
4208 * @param[in,out] handle to the wifi driver
4209 * @param[in] key index ( 0, 1, 2, 3)
4210 * @return Error code indicating success/failure
4213 * @date 8 March 2012
4216 s32 host_int_set_WEPDefaultKeyID(struct host_if_drv *hWFIDrv, u8 u8Index)
4219 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
4220 struct host_if_msg msg;
4223 if (pstrWFIDrv == NULL) {
4225 PRINT_ER("driver is null\n");
4229 /* prepare the Key Message */
4230 memset(&msg, 0, sizeof(struct host_if_msg));
4233 msg.id = HOST_IF_MSG_KEY;
4234 msg.body.key_info.enuKeyType = WEP;
4235 msg.body.key_info.u8KeyAction = DEFAULTKEY;
4240 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
4242 /* send the message */
4243 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4245 PRINT_ER("Error in sending message queue : Default key index\n");
4246 down(&(pstrWFIDrv->hSemTestKeyBlock));
4252 * @brief sets WEP deafault key
4253 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4254 * sets WEP key entry into MAC hardware when it receives the
4255 * corresponding request from NDIS.
4256 * @param[in,out] handle to the wifi driver
4257 * @param[in] message containing WEP Key in the following format
4258 *|---------------------------------------|
4259 *|Key ID Value | Key Length | Key |
4260 *|-------------|------------|------------|
4261 | 1byte | 1byte | Key Length |
4262 ||---------------------------------------|
4264 * @return Error code indicating success/failure
4267 * @date 8 March 2012
4270 s32 host_int_add_wep_key_bss_sta(struct host_if_drv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx)
4274 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
4275 struct host_if_msg msg;
4277 if (pstrWFIDrv == NULL) {
4279 PRINT_ER("driver is null\n");
4283 /* prepare the Key Message */
4284 memset(&msg, 0, sizeof(struct host_if_msg));
4287 msg.id = HOST_IF_MSG_KEY;
4288 msg.body.key_info.enuKeyType = WEP;
4289 msg.body.key_info.u8KeyAction = ADDKEY;
4294 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
4296 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
4297 pu8WepKey, u8WepKeylen);
4301 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4304 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4306 /* send the message */
4307 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4309 PRINT_ER("Error in sending message queue :WEP Key\n");
4310 down(&(pstrWFIDrv->hSemTestKeyBlock));
4318 * @brief host_int_add_wep_key_bss_ap
4319 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4320 * sets WEP key entry into MAC hardware when it receives the
4322 * corresponding request from NDIS.
4323 * @param[in,out] handle to the wifi driver
4326 * @return Error code indicating success/failure
4332 s32 host_int_add_wep_key_bss_ap(struct host_if_drv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, enum AUTHTYPE tenuAuth_type)
4336 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
4337 struct host_if_msg msg;
4340 if (pstrWFIDrv == NULL) {
4342 PRINT_ER("driver is null\n");
4346 /* prepare the Key Message */
4347 memset(&msg, 0, sizeof(struct host_if_msg));
4350 for (i = 0; i < u8WepKeylen; i++)
4351 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4353 msg.id = HOST_IF_MSG_KEY;
4354 msg.body.key_info.enuKeyType = WEP;
4355 msg.body.key_info.u8KeyAction = ADDKEY_AP;
4360 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
4363 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
4364 pu8WepKey, (u8WepKeylen));
4368 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4371 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4374 uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
4377 uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
4378 /* send the message */
4379 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4382 PRINT_ER("Error in sending message queue :WEP Key\n");
4383 down(&(pstrWFIDrv->hSemTestKeyBlock));
4390 * @brief adds ptk Key
4392 * @param[in,out] handle to the wifi driver
4393 * @param[in] message containing PTK Key in the following format
4394 *|-----------------------------------------------------------------------------|
4395 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4396 *|----------------|------------|--------------|----------------|---------------|
4397 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4398 ||-----------------------------------------------------------------------------|
4399 * @return Error code indicating success/failure
4402 * @date 8 March 2012
4405 s32 host_int_add_ptk(struct host_if_drv *hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
4406 const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx)
4409 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
4410 struct host_if_msg msg;
4411 u8 u8KeyLen = u8PtkKeylen;
4414 if (pstrWFIDrv == NULL) {
4416 PRINT_ER("driver is null\n");
4419 if (pu8RxMic != NULL)
4420 u8KeyLen += RX_MIC_KEY_LEN;
4421 if (pu8TxMic != NULL)
4422 u8KeyLen += TX_MIC_KEY_LEN;
4424 /* prepare the Key Message */
4425 memset(&msg, 0, sizeof(struct host_if_msg));
4428 msg.id = HOST_IF_MSG_KEY;
4429 msg.body.key_info.enuKeyType = WPAPtk;
4430 if (mode == AP_MODE) {
4431 msg.body.key_info.u8KeyAction = ADDKEY_AP;
4433 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
4435 if (mode == STATION_MODE)
4436 msg.body.key_info.u8KeyAction = ADDKEY;
4440 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8PtkKeylen, GFP_KERNEL);
4443 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
4444 pu8Ptk, u8PtkKeylen);
4446 if (pu8RxMic != NULL) {
4448 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
4449 pu8RxMic, RX_MIC_KEY_LEN);
4451 for (i = 0; i < RX_MIC_KEY_LEN; i++)
4452 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
4455 if (pu8TxMic != NULL) {
4457 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
4458 pu8TxMic, TX_MIC_KEY_LEN);
4460 for (i = 0; i < TX_MIC_KEY_LEN; i++)
4461 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
4466 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4469 uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
4471 uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
4474 /* send the message */
4475 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4478 PRINT_ER("Error in sending message queue: PTK Key\n");
4480 /* ////////////// */
4481 down(&(pstrWFIDrv->hSemTestKeyBlock));
4488 * @brief adds Rx GTk Key
4490 * @param[in,out] handle to the wifi driver
4491 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
4492 * u8GtkKeylen :The total key length
4494 * @return Error code indicating success/failure
4497 * @date 8 March 2012
4500 s32 host_int_add_rx_gtk(struct host_if_drv *hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
4501 u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC,
4502 const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode)
4505 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
4506 struct host_if_msg msg;
4507 u8 u8KeyLen = u8GtkKeylen;
4509 if (pstrWFIDrv == NULL) {
4511 PRINT_ER("driver is null\n");
4514 /* prepare the Key Message */
4515 memset(&msg, 0, sizeof(struct host_if_msg));
4518 if (pu8RxMic != NULL)
4519 u8KeyLen += RX_MIC_KEY_LEN;
4520 if (pu8TxMic != NULL)
4521 u8KeyLen += TX_MIC_KEY_LEN;
4522 if (KeyRSC != NULL) {
4524 uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
4526 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
4527 KeyRSC, u32KeyRSClen);
4531 msg.id = HOST_IF_MSG_KEY;
4532 msg.body.key_info.enuKeyType = WPARxGtk;
4535 if (mode == AP_MODE) {
4536 msg.body.key_info.u8KeyAction = ADDKEY_AP;
4537 msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
4539 if (mode == STATION_MODE)
4540 msg.body.key_info.u8KeyAction = ADDKEY;
4544 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8KeyLen, GFP_KERNEL);
4546 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
4547 pu8RxGtk, u8GtkKeylen);
4549 if (pu8RxMic != NULL) {
4551 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
4552 pu8RxMic, RX_MIC_KEY_LEN);
4555 if (pu8TxMic != NULL) {
4557 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
4558 pu8TxMic, TX_MIC_KEY_LEN);
4563 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
4565 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4568 uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
4572 /* send the message */
4573 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4575 PRINT_ER("Error in sending message queue: RX GTK\n");
4576 /* ////////////// */
4577 down(&(pstrWFIDrv->hSemTestKeyBlock));
4584 * @brief host_int_set_pmkid_info
4585 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
4586 * support is enabled. This Function sets the PMKID in firmware
4587 * when host drivr receives the corresponding request from NDIS.
4588 * The firmware then includes theset PMKID in the appropriate
4590 * @param[in,out] handle to the wifi driver
4591 * @param[in] message containing PMKID Info in the following format
4592 *|-----------------------------------------------------------------|
4593 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
4594 *|-----------|------------|----------|-------|----------|----------|
4595 | 1 | 6 | 16 | ... | 6 | 16 |
4596 ||-----------------------------------------------------------------|
4597 * @return Error code indicating success/failure
4600 * @date 8 March 2012
4603 s32 host_int_set_pmkid_info(struct host_if_drv *hWFIDrv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
4606 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
4607 struct host_if_msg msg;
4611 if (pstrWFIDrv == NULL) {
4613 PRINT_ER("driver is null\n");
4617 /* prepare the Key Message */
4618 memset(&msg, 0, sizeof(struct host_if_msg));
4620 msg.id = HOST_IF_MSG_KEY;
4621 msg.body.key_info.enuKeyType = PMKSA;
4622 msg.body.key_info.u8KeyAction = ADDKEY;
4625 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
4627 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
4630 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
4634 /* send the message */
4635 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4637 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
4643 * @brief gets the cached the pmkid info
4644 * @details valid only in BSS STA mode if External Supplicant
4645 * support is enabled. This Function sets the PMKID in firmware
4646 * when host drivr receives the corresponding request from NDIS.
4647 * The firmware then includes theset PMKID in the appropriate
4649 * @param[in,out] handle to the wifi driver,
4650 * message containing PMKID Info in the following format
4651 *|-----------------------------------------------------------------|
4652 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
4653 *|-----------|------------|----------|-------|----------|----------|
4654 | 1 | 6 | 16 | ... | 6 | 16 |
4655 ||-----------------------------------------------------------------|
4657 * @return Error code indicating success/failure
4660 * @date 8 March 2012
4663 s32 host_int_get_pmkid_info(struct host_if_drv *hWFIDrv, u8 *pu8PmkidInfoArray,
4664 u32 u32PmkidInfoLen)
4668 strWID.id = (u16)WID_PMKID_INFO;
4669 strWID.type = WID_STR;
4670 strWID.size = u32PmkidInfoLen;
4671 strWID.val = pu8PmkidInfoArray;
4677 * @brief sets the pass phrase
4678 * @details AP/STA mode. This function gives the pass phrase used to
4679 * generate the Pre-Shared Key when WPA/WPA2 is enabled
4680 * The length of the field can vary from 8 to 64 bytes,
4681 * the lower layer should get the
4682 * @param[in,out] handle to the wifi driver,
4683 * @param[in] String containing PSK
4684 * @return Error code indicating success/failure
4687 * @date 8 March 2012
4690 s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hWFIDrv, u8 *pu8PassPhrase,
4695 /*validating psk length*/
4696 if ((u8Psklength > 7) && (u8Psklength < 65)) {
4697 strWID.id = (u16)WID_11I_PSK;
4698 strWID.type = WID_STR;
4699 strWID.val = pu8PassPhrase;
4700 strWID.size = u8Psklength;
4706 * @brief host_int_get_MacAddress
4707 * @details gets mac address
4708 * @param[in,out] handle to the wifi driver,
4710 * @return Error code indicating success/failure
4713 * @date 19 April 2012
4716 s32 host_int_get_MacAddress(struct host_if_drv *hWFIDrv, u8 *pu8MacAddress)
4719 struct host_if_msg msg;
4722 /* prepare the Message */
4723 memset(&msg, 0, sizeof(struct host_if_msg));
4725 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
4726 msg.body.get_mac_info.u8MacAddress = pu8MacAddress;
4728 /* send the message */
4729 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4731 PRINT_ER("Failed to send get mac address\n");
4735 down(&hWaitResponse);
4740 * @brief host_int_set_MacAddress
4741 * @details sets mac address
4742 * @param[in,out] handle to the wifi driver,
4744 * @return Error code indicating success/failure
4747 * @date 16 July 2012
4750 s32 host_int_set_MacAddress(struct host_if_drv *hWFIDrv, u8 *pu8MacAddress)
4753 struct host_if_msg msg;
4755 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
4757 /* prepare setting mac address message */
4758 memset(&msg, 0, sizeof(struct host_if_msg));
4759 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
4760 memcpy(msg.body.set_mac_info.u8MacAddress, pu8MacAddress, ETH_ALEN);
4763 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4765 PRINT_ER("Failed to send message queue: Set mac address\n");
4772 * @brief host_int_get_RSNAConfigPSKPassPhrase
4773 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
4774 * generate the Pre-Shared Key when WPA/WPA2 is enabled
4775 * The length of the field can vary from 8 to 64 bytes,
4776 * the lower layer should get the
4777 * @param[in,out] handle to the wifi driver,
4778 * String containing PSK
4779 * @return Error code indicating success/failure
4782 * @date 8 March 2012
4785 s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hWFIDrv,
4786 u8 *pu8PassPhrase, u8 u8Psklength)
4790 strWID.id = (u16)WID_11I_PSK;
4791 strWID.type = WID_STR;
4792 strWID.size = u8Psklength;
4793 strWID.val = pu8PassPhrase;
4799 * @brief sets a start scan request
4801 * @param[in,out] handle to the wifi driver,
4802 * @param[in] Scan Source one of the following values
4805 * OBSS_PERIODIC_SCAN BIT1
4806 * OBSS_ONETIME_SCAN BIT2
4807 * @return Error code indicating success/failure
4810 * @date 8 March 2012
4813 s32 host_int_set_start_scan_req(struct host_if_drv *hWFIDrv, u8 scanSource)
4817 strWID.id = (u16)WID_START_SCAN_REQ;
4818 strWID.type = WID_CHAR;
4819 strWID.val = (s8 *)&scanSource;
4820 strWID.size = sizeof(char);
4826 * @brief host_int_get_start_scan_req
4827 * @details gets 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
4841 s32 host_int_get_start_scan_req(struct host_if_drv *hWFIDrv, u8 *pu8ScanSource)
4845 strWID.id = (u16)WID_START_SCAN_REQ;
4846 strWID.type = WID_CHAR;
4847 strWID.val = (s8 *)pu8ScanSource;
4848 strWID.size = sizeof(char);
4854 * @brief host_int_set_join_req
4855 * @details sets a join request
4856 * @param[in,out] handle to the wifi driver,
4857 * @param[in] Index of the bss descriptor
4858 * @return Error code indicating success/failure
4861 * @date 8 March 2012
4864 s32 host_int_set_join_req(struct host_if_drv *hWFIDrv, u8 *pu8bssid,
4865 const u8 *pu8ssid, size_t ssidLen,
4866 const u8 *pu8IEs, size_t IEsLen,
4867 wilc_connect_result pfConnectResult, void *pvUserArg,
4868 u8 u8security, enum AUTHTYPE tenuAuth_type,
4873 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
4874 struct host_if_msg msg;
4875 tenuScanConnTimer enuScanConnTimer;
4877 if (pstrWFIDrv == NULL || pfConnectResult == NULL) {
4879 PRINT_ER("Driver is null\n");
4883 if (hWFIDrv == NULL) {
4884 PRINT_ER("Driver is null\n");
4888 if (pJoinParams == NULL) {
4889 PRINT_ER("Unable to Join - JoinParams is NULL\n");
4893 /* prepare the Connect Message */
4894 memset(&msg, 0, sizeof(struct host_if_msg));
4896 msg.id = HOST_IF_MSG_CONNECT;
4898 msg.body.con_info.u8security = u8security;
4899 msg.body.con_info.tenuAuth_type = tenuAuth_type;
4900 msg.body.con_info.u8channel = u8channel;
4901 msg.body.con_info.pfConnectResult = pfConnectResult;
4902 msg.body.con_info.pvUserArg = pvUserArg;
4903 msg.body.con_info.pJoinParams = pJoinParams;
4906 if (pu8bssid != NULL) {
4907 msg.body.con_info.pu8bssid = kmalloc(6, GFP_KERNEL); /* will be deallocated by the receiving thread */
4908 memcpy(msg.body.con_info.pu8bssid,
4912 if (pu8ssid != NULL) {
4913 msg.body.con_info.ssidLen = ssidLen;
4914 msg.body.con_info.pu8ssid = kmalloc(ssidLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
4915 memcpy(msg.body.con_info.pu8ssid,
4920 if (pu8IEs != NULL) {
4921 msg.body.con_info.IEsLen = IEsLen;
4922 msg.body.con_info.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
4923 memcpy(msg.body.con_info.pu8IEs,
4926 if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING)
4927 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING;
4929 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate);
4931 /* send the message */
4932 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4934 PRINT_ER("Failed to send message queue: Set join request\n");
4938 enuScanConnTimer = CONNECT_TIMER;
4939 pstrWFIDrv->hConnectTimer.data = (unsigned long)hWFIDrv;
4940 mod_timer(&pstrWFIDrv->hConnectTimer,
4941 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
4947 * @brief Flush a join request parameters to FW, but actual connection
4948 * @details The function is called in situation where WILC is connected to AP and
4949 * required to switch to hybrid FW for P2P connection
4950 * @param[in] handle to the wifi driver,
4951 * @return Error code indicating success/failure
4953 * @author Amr Abdel-Moghny
4958 s32 host_int_flush_join_req(struct host_if_drv *hWFIDrv)
4961 struct host_if_msg msg;
4963 if (!gu8FlushedJoinReq) {
4969 if (hWFIDrv == NULL) {
4971 PRINT_ER("Driver is null\n");
4975 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
4978 /* send the message */
4979 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4981 PRINT_ER("Failed to send message queue: Flush join request\n");
4989 * @brief host_int_disconnect
4990 * @details disconnects from the currently associated network
4991 * @param[in,out] handle to the wifi driver,
4992 * @param[in] Reason Code of the Disconnection
4993 * @return Error code indicating success/failure
4996 * @date 8 March 2012
4999 s32 host_int_disconnect(struct host_if_drv *hWFIDrv, u16 u16ReasonCode)
5002 struct host_if_msg msg;
5003 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5005 if (pstrWFIDrv == NULL) {
5006 PRINT_ER("Driver is null\n");
5010 /* prepare the Disconnect Message */
5011 memset(&msg, 0, sizeof(struct host_if_msg));
5013 msg.id = HOST_IF_MSG_DISCONNECT;
5016 /* send the message */
5017 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5019 PRINT_ER("Failed to send message queue: disconnect\n");
5020 /* ////////////// */
5021 down(&(pstrWFIDrv->hSemTestDisconnectBlock));
5028 * @brief host_int_disconnect_station
5029 * @details disconnects a sta
5030 * @param[in,out] handle to the wifi driver,
5031 * @param[in] Association Id of the station to be disconnected
5032 * @return Error code indicating success/failure
5035 * @date 8 March 2012
5038 s32 host_int_disconnect_station(struct host_if_drv *hWFIDrv, u8 assoc_id)
5042 strWID.id = (u16)WID_DISCONNECT;
5043 strWID.type = WID_CHAR;
5044 strWID.val = (s8 *)&assoc_id;
5045 strWID.size = sizeof(char);
5051 * @brief host_int_get_assoc_req_info
5052 * @details gets a Association request info
5053 * @param[in,out] handle to the wifi driver,
5054 * Message containg assoc. req info in the following format
5055 * ------------------------------------------------------------------------
5056 | Management Frame Format |
5057 ||-------------------------------------------------------------------|
5058 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5059 ||-------------|--------|--|--|-----|----------------|----------|----|
5060 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5061 ||-------------------------------------------------------------------|
5063 | Association Request Frame - Frame Body |
5064 ||-------------------------------------------------------------------|
5065 | Capability Information | Listen Interval | SSID | Supported Rates |
5066 ||------------------------|-----------------|------|-----------------|
5067 | 2 | 2 | 2-34 | 3-10 |
5068 | ---------------------------------------------------------------------
5069 * @return Error code indicating success/failure
5072 * @date 8 March 2012
5076 s32 host_int_get_assoc_req_info(struct host_if_drv *hWFIDrv, u8 *pu8AssocReqInfo,
5077 u32 u32AssocReqInfoLen)
5081 strWID.id = (u16)WID_ASSOC_REQ_INFO;
5082 strWID.type = WID_STR;
5083 strWID.val = pu8AssocReqInfo;
5084 strWID.size = u32AssocReqInfoLen;
5090 * @brief gets a Association Response info
5092 * @param[in,out] handle to the wifi driver,
5093 * Message containg assoc. resp info
5094 * @return Error code indicating success/failure
5097 * @date 8 March 2012
5100 s32 host_int_get_assoc_res_info(struct host_if_drv *hWFIDrv, u8 *pu8AssocRespInfo,
5101 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
5105 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5107 if (pstrWFIDrv == NULL) {
5108 PRINT_ER("Driver is null\n");
5112 strWID.id = (u16)WID_ASSOC_RES_INFO;
5113 strWID.type = WID_STR;
5114 strWID.val = pu8AssocRespInfo;
5115 strWID.size = u32MaxAssocRespInfoLen;
5118 /* Sending Configuration packet */
5119 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
5120 get_id_from_handler(pstrWFIDrv));
5122 *pu32RcvdAssocRespInfoLen = 0;
5123 PRINT_ER("Failed to send association response config packet\n");
5126 *pu32RcvdAssocRespInfoLen = strWID.size;
5133 * @brief gets a Association Response info
5134 * @details Valid only in STA mode. This function gives the RSSI
5135 * values observed in all the channels at the time of scanning.
5136 * The length of the field is 1 greater that the total number of
5137 * channels supported. Byte 0 contains the number of channels while
5138 * each of Byte N contains the observed RSSI value for the channel index N.
5139 * @param[in,out] handle to the wifi driver,
5140 * array of scanned channels' RSSI
5141 * @return Error code indicating success/failure
5144 * @date 8 March 2012
5147 s32 host_int_get_rx_power_level(struct host_if_drv *hWFIDrv, u8 *pu8RxPowerLevel,
5148 u32 u32RxPowerLevelLen)
5152 strWID.id = (u16)WID_RX_POWER_LEVEL;
5153 strWID.type = WID_STR;
5154 strWID.val = pu8RxPowerLevel;
5155 strWID.size = u32RxPowerLevelLen;
5161 * @brief sets a channel
5163 * @param[in,out] handle to the wifi driver,
5164 * @param[in] Index of the channel to be set
5165 *|-------------------------------------------------------------------|
5166 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5168 ||-------------------------------------------------------------------|
5169 * @return Error code indicating success/failure
5172 * @date 8 March 2012
5175 int host_int_set_mac_chnl_num(struct host_if_drv *wfi_drv, u8 channel)
5178 struct host_if_msg msg;
5181 PRINT_ER("driver is null\n");
5185 /* prepare the set channel message */
5186 memset(&msg, 0, sizeof(struct host_if_msg));
5187 msg.id = HOST_IF_MSG_SET_CHANNEL;
5188 msg.body.channel_info.u8SetChan = channel;
5191 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5193 PRINT_ER("wilc mq send fail\n");
5200 int host_int_wait_msg_queue_idle(void)
5204 struct host_if_msg msg;
5206 /* prepare the set driver handler message */
5208 memset(&msg, 0, sizeof(struct host_if_msg));
5209 msg.id = HOST_IF_MSG_Q_IDLE;
5210 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5212 PRINT_ER("wilc mq send fail\n");
5216 /* wait untill MSG Q is empty */
5217 down(&hWaitResponse);
5222 int host_int_set_wfi_drv_handler(struct host_if_drv *address)
5226 struct host_if_msg msg;
5228 /* prepare the set driver handler message */
5230 memset(&msg, 0, sizeof(struct host_if_msg));
5231 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
5232 msg.body.drv.u32Address = get_id_from_handler(address);
5235 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5237 PRINT_ER("wilc mq send fail\n");
5244 int host_int_set_operation_mode(struct host_if_drv *wfi_drv, u32 mode)
5248 struct host_if_msg msg;
5250 /* prepare the set driver handler message */
5252 memset(&msg, 0, sizeof(struct host_if_msg));
5253 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
5254 msg.body.mode.u32Mode = mode;
5257 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5259 PRINT_ER("wilc mq send fail\n");
5267 * @brief gets the current channel index
5269 * @param[in,out] handle to the wifi driver,
5270 * current channel index
5271 *|-----------------------------------------------------------------------|
5272 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5274 ||-----------------------------------------------------------------------|
5275 * @return Error code indicating success/failure
5278 * @date 8 March 2012
5281 s32 host_int_get_host_chnl_num(struct host_if_drv *hWFIDrv, u8 *pu8ChNo)
5284 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5285 struct host_if_msg msg;
5287 if (pstrWFIDrv == NULL) {
5288 PRINT_ER("driver is null\n");
5292 /* prepare the Get Channel Message */
5293 memset(&msg, 0, sizeof(struct host_if_msg));
5295 msg.id = HOST_IF_MSG_GET_CHNL;
5298 /* send the message */
5299 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5301 PRINT_ER("wilc mq send fail\n");
5302 down(&(pstrWFIDrv->hSemGetCHNL));
5313 * @brief host_int_get_inactive_time
5315 * @param[in,out] handle to the wifi driver,
5316 * current sta macaddress, inactive_time
5323 s32 host_int_get_inactive_time(struct host_if_drv *hWFIDrv, const u8 *mac, u32 *pu32InactiveTime)
5326 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5327 struct host_if_msg msg;
5329 if (pstrWFIDrv == NULL) {
5330 PRINT_ER("driver is null\n");
5334 memset(&msg, 0, sizeof(struct host_if_msg));
5337 memcpy(msg.body.mac_info.mac,
5340 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
5343 /* send the message */
5344 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5346 PRINT_ER("Failed to send get host channel param's message queue ");
5348 down(&(pstrWFIDrv->hSemInactiveTime));
5350 *pu32InactiveTime = gu32InactiveTime;
5356 * @brief host_int_test_get_int_wid
5357 * @details Test function for getting wids
5358 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
5359 * @return Error code indicating success/failure
5362 * @date 8 March 2012
5365 s32 host_int_test_get_int_wid(struct host_if_drv *hWFIDrv, u32 *pu32TestMemAddr)
5370 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5373 if (pstrWFIDrv == NULL) {
5374 PRINT_ER("driver is null\n");
5378 strWID.id = (u16)WID_MEMORY_ADDRESS;
5379 strWID.type = WID_INT;
5380 strWID.val = (s8 *)pu32TestMemAddr;
5381 strWID.size = sizeof(u32);
5383 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
5384 get_id_from_handler(pstrWFIDrv));
5385 /*get the value by searching the local copy*/
5387 PRINT_ER("Failed to get wid value\n");
5390 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
5399 * @brief host_int_get_rssi
5400 * @details gets the currently maintained RSSI value for the station.
5401 * The received signal strength value in dB.
5402 * The range of valid values is -128 to 0.
5403 * @param[in,out] handle to the wifi driver,
5405 * @return Error code indicating success/failure
5408 * @date 8 March 2012
5411 s32 host_int_get_rssi(struct host_if_drv *hWFIDrv, s8 *ps8Rssi)
5414 struct host_if_msg msg;
5415 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5418 /* prepare the Get RSSI Message */
5419 memset(&msg, 0, sizeof(struct host_if_msg));
5421 msg.id = HOST_IF_MSG_GET_RSSI;
5424 /* send the message */
5425 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5427 PRINT_ER("Failed to send get host channel param's message queue ");
5431 down(&(pstrWFIDrv->hSemGetRSSI));
5434 if (ps8Rssi == NULL) {
5435 PRINT_ER("RSS pointer value is null");
5446 s32 host_int_get_link_speed(struct host_if_drv *hWFIDrv, s8 *ps8lnkspd)
5448 struct host_if_msg msg;
5451 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5455 /* prepare the Get LINKSPEED Message */
5456 memset(&msg, 0, sizeof(struct host_if_msg));
5458 msg.id = HOST_IF_MSG_GET_LINKSPEED;
5461 /* send the message */
5462 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5464 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
5468 down(&(pstrWFIDrv->hSemGetLINKSPEED));
5471 if (ps8lnkspd == NULL) {
5472 PRINT_ER("LINKSPEED pointer value is null");
5477 *ps8lnkspd = gs8lnkspd;
5483 s32 host_int_get_statistics(struct host_if_drv *hWFIDrv, tstrStatistics *pstrStatistics)
5486 struct host_if_msg msg;
5489 /* prepare the Get RSSI Message */
5490 memset(&msg, 0, sizeof(struct host_if_msg));
5492 msg.id = HOST_IF_MSG_GET_STATISTICS;
5493 msg.body.data = (char *)pstrStatistics;
5495 /* send the message */
5496 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5498 PRINT_ER("Failed to send get host channel param's message queue ");
5502 down(&hWaitResponse);
5508 * @brief host_int_scan
5509 * @details scans a set of channels
5510 * @param[in,out] handle to the wifi driver,
5511 * @param[in] Scan source
5512 * Scan Type PASSIVE_SCAN = 0,
5515 * Channels Array length
5516 * Scan Callback function
5517 * @return Error code indicating success/failure
5520 * @date 8 March 2012
5523 s32 host_int_scan(struct host_if_drv *hWFIDrv, u8 u8ScanSource,
5524 u8 u8ScanType, u8 *pu8ChnlFreqList,
5525 u8 u8ChnlListLen, const u8 *pu8IEs,
5526 size_t IEsLen, wilc_scan_result ScanResult,
5528 struct hidden_network *pstrHiddenNetwork)
5531 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5532 struct host_if_msg msg;
5533 tenuScanConnTimer enuScanConnTimer;
5535 if (pstrWFIDrv == NULL || ScanResult == NULL) {
5536 PRINT_ER("pstrWFIDrv or ScanResult = NULL\n");
5540 /* prepare the Scan Message */
5541 memset(&msg, 0, sizeof(struct host_if_msg));
5543 msg.id = HOST_IF_MSG_SCAN;
5545 if (pstrHiddenNetwork != NULL) {
5546 msg.body.scan_info.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
5547 msg.body.scan_info.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
5550 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
5553 msg.body.scan_info.u8ScanSource = u8ScanSource;
5554 msg.body.scan_info.u8ScanType = u8ScanType;
5555 msg.body.scan_info.pfScanResult = ScanResult;
5556 msg.body.scan_info.pvUserArg = pvUserArg;
5558 msg.body.scan_info.u8ChnlListLen = u8ChnlListLen;
5559 msg.body.scan_info.pu8ChnlFreqList = kmalloc(u8ChnlListLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5560 memcpy(msg.body.scan_info.pu8ChnlFreqList,
5561 pu8ChnlFreqList, u8ChnlListLen);
5563 msg.body.scan_info.IEsLen = IEsLen;
5564 msg.body.scan_info.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5565 memcpy(msg.body.scan_info.pu8IEs,
5568 /* send the message */
5569 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5571 PRINT_ER("Error in sending message queue\n");
5575 enuScanConnTimer = SCAN_TIMER;
5576 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
5577 pstrWFIDrv->hScanTimer.data = (unsigned long)hWFIDrv;
5578 mod_timer(&pstrWFIDrv->hScanTimer,
5579 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
5585 * @brief hif_set_cfg
5586 * @details sets configuration wids values
5587 * @param[in,out] handle to the wifi driver,
5588 * @param[in] WID, WID value
5589 * @return Error code indicating success/failure
5592 * @date 8 March 2012
5595 s32 hif_set_cfg(struct host_if_drv *hWFIDrv, struct cfg_param_val *pstrCfgParamVal)
5599 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5601 struct host_if_msg msg;
5604 if (pstrWFIDrv == NULL) {
5605 PRINT_ER("pstrWFIDrv NULL\n");
5608 /* prepare the WiphyParams Message */
5609 memset(&msg, 0, sizeof(struct host_if_msg));
5610 msg.id = HOST_IF_MSG_CFG_PARAMS;
5611 msg.body.cfg_info.pstrCfgParamVal = *pstrCfgParamVal;
5614 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5622 * @brief hif_get_cfg
5623 * @details gets configuration wids values
5624 * @param[in,out] handle to the wifi driver,
5627 * @return Error code indicating success/failure
5631 * @date 8 March 2012
5634 s32 hif_get_cfg(struct host_if_drv *hWFIDrv, u16 u16WID, u16 *pu16WID_Value)
5637 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5639 down(&(pstrWFIDrv->gtOsCfgValuesSem));
5641 if (pstrWFIDrv == NULL) {
5642 PRINT_ER("pstrWFIDrv NULL\n");
5645 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
5649 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type;
5653 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type;
5656 case WID_AUTH_TIMEOUT:
5657 *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout;
5660 case WID_POWER_MANAGEMENT:
5661 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode;
5664 case WID_SHORT_RETRY_LIMIT:
5665 *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit;
5668 case WID_LONG_RETRY_LIMIT:
5669 *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit;
5672 case WID_FRAG_THRESHOLD:
5673 *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold;
5676 case WID_RTS_THRESHOLD:
5677 *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold;
5681 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type;
5684 case WID_SHORT_SLOT_ALLOWED:
5685 *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed;
5688 case WID_11N_TXOP_PROT_DISABLE:
5689 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled;
5692 case WID_BEACON_INTERVAL:
5693 *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval;
5696 case WID_DTIM_PERIOD:
5697 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period;
5700 case WID_SITE_SURVEY:
5701 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled;
5704 case WID_SITE_SURVEY_SCAN_TIME:
5705 *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time;
5708 case WID_ACTIVE_SCAN_TIME:
5709 *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time;
5712 case WID_PASSIVE_SCAN_TIME:
5713 *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time;
5716 case WID_CURRENT_TX_RATE:
5717 *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate;
5724 up(&(pstrWFIDrv->gtOsCfgValuesSem));
5730 /*****************************************************************************/
5731 /* Notification Functions */
5732 /*****************************************************************************/
5734 * @brief notifies host with join and leave requests
5735 * @details This function prepares an Information frame having the
5736 * information about a joining/leaving station.
5737 * @param[in,out] handle to the wifi driver,
5738 * @param[in] 6 byte Sta Adress
5739 * Join or leave flag:
5742 * @return Error code indicating success/failure
5745 * @date 8 March 2012
5748 void host_int_send_join_leave_info_to_host
5749 (u16 assocId, u8 *stationAddr, bool joining)
5753 * @brief notifies host with stations found in scan
5754 * @details sends the beacon/probe response from scan
5755 * @param[in,out] handle to the wifi driver,
5756 * @param[in] Sta Address,
5758 * Rssi of the Station found
5759 * @return Error code indicating success/failure
5762 * @date 8 March 2012
5766 static void GetPeriodicRSSI(unsigned long arg)
5768 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)arg;
5770 if (pstrWFIDrv == NULL) {
5771 PRINT_ER("Driver handler is NULL\n");
5775 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
5777 struct host_if_msg msg;
5779 /* prepare the Get RSSI Message */
5780 memset(&msg, 0, sizeof(struct host_if_msg));
5782 msg.id = HOST_IF_MSG_GET_RSSI;
5783 msg.drv = pstrWFIDrv;
5785 /* send the message */
5786 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5788 PRINT_ER("Failed to send get host channel param's message queue ");
5792 g_hPeriodicRSSI.data = (unsigned long)pstrWFIDrv;
5793 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
5797 void host_int_send_network_info_to_host
5798 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
5802 * @brief host_int_init
5803 * @details host interface initialization function
5804 * @param[in,out] handle to the wifi driver,
5807 * @date 8 March 2012
5810 static u32 clients_count;
5812 s32 host_int_init(struct host_if_drv **phWFIDrv)
5815 struct host_if_drv *pstrWFIDrv;
5818 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
5820 gbScanWhileConnected = false;
5822 sema_init(&hWaitResponse, 0);
5824 /*Allocate host interface private structure*/
5825 pstrWFIDrv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
5830 *phWFIDrv = pstrWFIDrv;
5831 err = add_handler_in_list(pstrWFIDrv);
5837 g_obtainingIP = false;
5839 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv);
5840 if (clients_count == 0) {
5841 sema_init(&hSemHostIFthrdEnd, 0);
5842 sema_init(&hSemDeinitDrvHandle, 0);
5843 sema_init(&hSemHostIntDeinit, 1);
5846 sema_init(&pstrWFIDrv->hSemTestKeyBlock, 0);
5847 sema_init(&pstrWFIDrv->hSemTestDisconnectBlock, 0);
5848 sema_init(&pstrWFIDrv->hSemGetRSSI, 0);
5849 sema_init(&pstrWFIDrv->hSemGetLINKSPEED, 0);
5850 sema_init(&pstrWFIDrv->hSemGetCHNL, 0);
5851 sema_init(&pstrWFIDrv->hSemInactiveTime, 0);
5853 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
5855 if (clients_count == 0) {
5856 result = wilc_mq_create(&gMsgQHostIF);
5859 PRINT_ER("Failed to creat MQ\n");
5862 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
5863 if (IS_ERR(HostIFthreadHandler)) {
5864 PRINT_ER("Failed to creat Thread\n");
5868 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
5869 (unsigned long)pstrWFIDrv);
5870 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
5873 setup_timer(&pstrWFIDrv->hScanTimer, TimerCB_Scan, 0);
5875 setup_timer(&pstrWFIDrv->hConnectTimer, TimerCB_Connect, 0);
5877 /*Remain on channel timer*/
5878 setup_timer(&pstrWFIDrv->hRemainOnChannel, ListenTimerCB, 0);
5880 sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1);
5881 down(&pstrWFIDrv->gtOsCfgValuesSem);
5883 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
5885 /*Initialize CFG WIDS Defualt Values*/
5887 pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
5888 pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN;
5889 pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
5890 pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
5891 pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE;
5893 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
5895 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",
5897 pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source,
5898 pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time,
5899 pstrWFIDrv->strCfgValues.curr_tx_rate);
5901 up(&pstrWFIDrv->gtOsCfgValuesSem);
5903 clients_count++; /* increase number of created entities */
5908 up(&pstrWFIDrv->gtOsCfgValuesSem);
5909 del_timer_sync(&pstrWFIDrv->hConnectTimer);
5910 del_timer_sync(&pstrWFIDrv->hScanTimer);
5911 kthread_stop(HostIFthreadHandler);
5913 wilc_mq_destroy(&gMsgQHostIF);
5918 * @brief host_int_deinit
5919 * @details host interface initialization function
5920 * @param[in,out] handle to the wifi driver,
5923 * @date 8 March 2012
5927 s32 host_int_deinit(struct host_if_drv *hWFIDrv)
5930 struct host_if_msg msg;
5933 /*obtain driver handle*/
5934 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
5936 if (pstrWFIDrv == NULL) {
5937 PRINT_ER("pstrWFIDrv = NULL\n");
5941 down(&hSemHostIntDeinit);
5943 terminated_handle = pstrWFIDrv;
5944 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
5946 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
5947 /*to guarantee handling all messages befor proceeding*/
5948 if (del_timer_sync(&pstrWFIDrv->hScanTimer)) {
5949 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
5950 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
5953 if (del_timer_sync(&pstrWFIDrv->hConnectTimer)) {
5954 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
5955 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
5959 if (del_timer_sync(&g_hPeriodicRSSI)) {
5960 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
5961 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
5964 /*Destroy Remain-onchannel Timer*/
5965 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
5967 host_int_set_wfi_drv_handler(NULL);
5968 down(&hSemDeinitDrvHandle);
5971 /*Calling the CFG80211 scan done function with the abort flag set to true*/
5972 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
5973 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
5974 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
5976 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
5979 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
5981 gbScanWhileConnected = false;
5983 memset(&msg, 0, sizeof(struct host_if_msg));
5985 if (clients_count == 1) {
5986 if (del_timer_sync(&g_hPeriodicRSSI)) {
5987 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
5988 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
5990 msg.id = HOST_IF_MSG_EXIT;
5994 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5996 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
5998 down(&hSemHostIFthrdEnd);
6000 wilc_mq_destroy(&gMsgQHostIF);
6003 down(&(pstrWFIDrv->gtOsCfgValuesSem));
6005 /*Setting the gloabl driver handler with NULL*/
6006 /* gWFiDrvHandle = NULL; */
6007 ret = remove_handler_in_list(pstrWFIDrv);
6011 if (pstrWFIDrv != NULL) {
6013 /* pstrWFIDrv=NULL; */
6017 clients_count--; /* Decrease number of created entities */
6018 terminated_handle = NULL;
6019 up(&hSemHostIntDeinit);
6025 * @brief NetworkInfoReceived
6026 * @details function to to be called when network info packet is received
6027 * @param[in] pu8Buffer the received packet
6028 * @param[in] u32Length length of the received packet
6035 void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
6038 struct host_if_msg msg;
6040 struct host_if_drv *pstrWFIDrv = NULL;
6042 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6043 pstrWFIDrv = get_handler_from_id(id);
6048 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6049 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv);
6053 /* prepare the Asynchronous Network Info message */
6054 memset(&msg, 0, sizeof(struct host_if_msg));
6056 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
6057 msg.drv = pstrWFIDrv;
6059 msg.body.net_info.u32Length = u32Length;
6060 msg.body.net_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
6061 memcpy(msg.body.net_info.pu8Buffer,
6062 pu8Buffer, u32Length);
6064 /* send the message */
6065 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6067 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
6071 * @brief GnrlAsyncInfoReceived
6072 * @details function to be called when general Asynchronous info packet is received
6073 * @param[in] pu8Buffer the received packet
6074 * @param[in] u32Length length of the received packet
6081 void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
6084 struct host_if_msg msg;
6086 struct host_if_drv *pstrWFIDrv = NULL;
6088 down(&hSemHostIntDeinit);
6090 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6091 pstrWFIDrv = get_handler_from_id(id);
6092 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
6095 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6096 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
6097 up(&hSemHostIntDeinit);
6101 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) {
6102 /* received mac status is not needed when there is no current Connect Request */
6103 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
6104 up(&hSemHostIntDeinit);
6108 /* prepare the General Asynchronous Info message */
6109 memset(&msg, 0, sizeof(struct host_if_msg));
6112 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
6113 msg.drv = pstrWFIDrv;
6116 msg.body.async_info.u32Length = u32Length;
6117 msg.body.async_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
6118 memcpy(msg.body.async_info.pu8Buffer,
6119 pu8Buffer, u32Length);
6121 /* send the message */
6122 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6124 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
6126 up(&hSemHostIntDeinit);
6130 * @brief host_int_ScanCompleteReceived
6131 * @details Setting scan complete received notifcation in message queue
6132 * @param[in] u8* pu8Buffer, u32 u32Length
6133 * @return Error code.
6138 void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
6141 struct host_if_msg msg;
6143 struct host_if_drv *pstrWFIDrv = NULL;
6145 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6146 pstrWFIDrv = get_handler_from_id(id);
6149 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv);
6151 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle)
6154 /*if there is an ongoing scan request*/
6155 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6156 /* prepare theScan Done message */
6157 memset(&msg, 0, sizeof(struct host_if_msg));
6159 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
6160 msg.drv = pstrWFIDrv;
6163 /* will be deallocated by the receiving thread */
6164 /*no need to send message body*/
6166 /*msg.body.strScanComplete.u32Length = u32Length;
6167 * msg.body.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
6168 * memcpy(msg.body.strScanComplete.pu8Buffer,
6169 * pu8Buffer, u32Length); */
6171 /* send the message */
6172 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6174 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
6183 * @brief host_int_remain_on_channel
6185 * @param[in] Handle to wifi driver
6186 * Duration to remain on channel
6187 * Channel to remain on
6188 * Pointer to fn to be called on receive frames in listen state
6189 * Pointer to remain-on-channel expired fn
6191 * @return Error code.
6196 s32 host_int_remain_on_channel(struct host_if_drv *hWFIDrv, u32 u32SessionID, u32 u32duration, u16 chan, wilc_remain_on_chan_expired RemainOnChanExpired, wilc_remain_on_chan_ready RemainOnChanReady, void *pvUserArg)
6199 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6200 struct host_if_msg msg;
6202 if (pstrWFIDrv == NULL) {
6203 PRINT_ER("driver is null\n");
6207 /* prepare the remainonchan Message */
6208 memset(&msg, 0, sizeof(struct host_if_msg));
6210 /* prepare the WiphyParams Message */
6211 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
6212 msg.body.remain_on_ch.u16Channel = chan;
6213 msg.body.remain_on_ch.pRemainOnChanExpired = RemainOnChanExpired;
6214 msg.body.remain_on_ch.pRemainOnChanReady = RemainOnChanReady;
6215 msg.body.remain_on_ch.pVoid = pvUserArg;
6216 msg.body.remain_on_ch.u32duration = u32duration;
6217 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
6220 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6222 PRINT_ER("wilc mq send fail\n");
6228 * @brief host_int_ListenStateExpired
6230 * @param[in] Handle to wifi driver
6231 * Duration to remain on channel
6232 * Channel to remain on
6233 * Pointer to fn to be called on receive frames in listen state
6234 * Pointer to remain-on-channel expired fn
6236 * @return Error code.
6241 s32 host_int_ListenStateExpired(struct host_if_drv *hWFIDrv, u32 u32SessionID)
6244 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6245 struct host_if_msg msg;
6247 if (pstrWFIDrv == NULL) {
6248 PRINT_ER("driver is null\n");
6252 /*Stopping remain-on-channel timer*/
6253 del_timer(&pstrWFIDrv->hRemainOnChannel);
6255 /* prepare the timer fire Message */
6256 memset(&msg, 0, sizeof(struct host_if_msg));
6257 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
6259 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
6261 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6263 PRINT_ER("wilc mq send fail\n");
6269 * @brief host_int_frame_register
6271 * @param[in] Handle to wifi driver
6272 * @return Error code.
6276 s32 host_int_frame_register(struct host_if_drv *hWFIDrv, u16 u16FrameType, bool bReg)
6279 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6280 struct host_if_msg msg;
6282 if (pstrWFIDrv == NULL) {
6283 PRINT_ER("driver is null\n");
6287 memset(&msg, 0, sizeof(struct host_if_msg));
6289 /* prepare the WiphyParams Message */
6290 msg.id = HOST_IF_MSG_REGISTER_FRAME;
6291 switch (u16FrameType) {
6293 PRINT_D(HOSTINF_DBG, "ACTION\n");
6294 msg.body.reg_frame.u8Regid = ACTION_FRM_IDX;
6298 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
6299 msg.body.reg_frame.u8Regid = PROBE_REQ_IDX;
6303 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
6306 msg.body.reg_frame.u16FrameType = u16FrameType;
6307 msg.body.reg_frame.bReg = bReg;
6310 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6312 PRINT_ER("wilc mq send fail\n");
6320 * @brief host_int_add_beacon
6321 * @details Setting add beacon params in message queue
6322 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
6323 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
6324 * u32 u32TailLen, u8* pu8Tail
6325 * @return Error code.
6330 s32 host_int_add_beacon(struct host_if_drv *hWFIDrv, u32 u32Interval,
6332 u32 u32HeadLen, u8 *pu8Head,
6333 u32 u32TailLen, u8 *pu8Tail)
6336 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6337 struct host_if_msg msg;
6338 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
6340 if (pstrWFIDrv == NULL) {
6341 PRINT_ER("driver is null\n");
6345 memset(&msg, 0, sizeof(struct host_if_msg));
6347 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
6350 /* prepare the WiphyParams Message */
6351 msg.id = HOST_IF_MSG_ADD_BEACON;
6353 pstrSetBeaconParam->u32Interval = u32Interval;
6354 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
6355 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
6356 pstrSetBeaconParam->pu8Head = kmalloc(u32HeadLen, GFP_KERNEL);
6357 if (pstrSetBeaconParam->pu8Head == NULL) {
6361 memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
6362 pstrSetBeaconParam->u32TailLen = u32TailLen;
6364 if (u32TailLen > 0) {
6365 pstrSetBeaconParam->pu8Tail = kmalloc(u32TailLen, GFP_KERNEL);
6366 if (pstrSetBeaconParam->pu8Tail == NULL) {
6370 memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
6372 pstrSetBeaconParam->pu8Tail = NULL;
6375 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6377 PRINT_ER("wilc mq send fail\n");
6381 if (pstrSetBeaconParam->pu8Head != NULL)
6382 kfree(pstrSetBeaconParam->pu8Head);
6384 if (pstrSetBeaconParam->pu8Tail != NULL)
6385 kfree(pstrSetBeaconParam->pu8Tail);
6394 * @brief host_int_del_beacon
6395 * @details Setting add beacon params in message queue
6396 * @param[in] WILC_WFIDrvHandle hWFIDrv
6397 * @return Error code.
6402 s32 host_int_del_beacon(struct host_if_drv *hWFIDrv)
6405 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6406 struct host_if_msg msg;
6408 if (pstrWFIDrv == NULL) {
6409 PRINT_ER("driver is null\n");
6413 /* prepare the WiphyParams Message */
6414 msg.id = HOST_IF_MSG_DEL_BEACON;
6416 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
6418 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6420 PRINT_ER("wilc_mq_send fail\n");
6427 * @brief host_int_add_station
6428 * @details Setting add station params in message queue
6429 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
6430 * @return Error code.
6435 s32 host_int_add_station(struct host_if_drv *hWFIDrv,
6436 struct add_sta_param *pstrStaParams)
6439 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6440 struct host_if_msg msg;
6441 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
6444 if (pstrWFIDrv == NULL) {
6445 PRINT_ER("driver is null\n");
6449 memset(&msg, 0, sizeof(struct host_if_msg));
6451 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
6454 /* prepare the WiphyParams Message */
6455 msg.id = HOST_IF_MSG_ADD_STATION;
6458 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
6459 if (pstrAddStationMsg->u8NumRates > 0) {
6460 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
6465 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
6466 pstrAddStationMsg->pu8Rates = rates;
6470 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6472 PRINT_ER("wilc_mq_send fail\n");
6477 * @brief host_int_del_station
6478 * @details Setting delete station params in message queue
6479 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
6480 * @return Error code.
6485 s32 host_int_del_station(struct host_if_drv *hWFIDrv, const u8 *pu8MacAddr)
6488 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6489 struct host_if_msg msg;
6490 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
6492 if (pstrWFIDrv == NULL) {
6493 PRINT_ER("driver is null\n");
6497 memset(&msg, 0, sizeof(struct host_if_msg));
6499 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
6503 /* prepare the WiphyParams Message */
6504 msg.id = HOST_IF_MSG_DEL_STATION;
6507 if (pu8MacAddr == NULL)
6508 memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
6510 memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
6512 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6514 PRINT_ER("wilc_mq_send fail\n");
6518 * @brief host_int_del_allstation
6519 * @details Setting del station params in message queue
6520 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
6521 * @return Error code.
6526 s32 host_int_del_allstation(struct host_if_drv *hWFIDrv,
6527 u8 pu8MacAddr[][ETH_ALEN])
6530 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6531 struct host_if_msg msg;
6532 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
6533 u8 au8Zero_Buff[ETH_ALEN] = {0};
6538 if (pstrWFIDrv == NULL) {
6539 PRINT_ER("driver is null\n");
6543 memset(&msg, 0, sizeof(struct host_if_msg));
6545 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
6547 /* prepare the WiphyParams Message */
6548 msg.id = HOST_IF_MSG_DEL_ALL_STA;
6551 /* Handling situation of deauthenticing all associated stations*/
6552 for (i = 0; i < MAX_NUM_STA; i++) {
6553 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
6554 memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
6555 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],
6556 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
6561 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
6565 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
6566 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6570 PRINT_ER("wilc_mq_send fail\n");
6572 down(&hWaitResponse);
6579 * @brief host_int_edit_station
6580 * @details Setting edit station params in message queue
6581 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
6582 * @return Error code.
6587 s32 host_int_edit_station(struct host_if_drv *hWFIDrv,
6588 struct add_sta_param *pstrStaParams)
6591 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6592 struct host_if_msg msg;
6593 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
6595 if (pstrWFIDrv == NULL) {
6596 PRINT_ER("driver is null\n");
6600 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
6602 memset(&msg, 0, sizeof(struct host_if_msg));
6605 /* prepare the WiphyParams Message */
6606 msg.id = HOST_IF_MSG_EDIT_STATION;
6609 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
6610 if (pstrAddStationMsg->u8NumRates > 0) {
6611 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
6616 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
6617 pstrAddStationMsg->pu8Rates = rates;
6620 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6622 PRINT_ER("wilc_mq_send fail\n");
6627 s32 host_int_set_power_mgmt(struct host_if_drv *hWFIDrv, bool bIsEnabled, u32 u32Timeout)
6630 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6631 struct host_if_msg msg;
6632 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
6634 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
6636 if (pstrWFIDrv == NULL) {
6637 PRINT_ER("driver is null\n");
6641 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
6643 memset(&msg, 0, sizeof(struct host_if_msg));
6646 /* prepare the WiphyParams Message */
6647 msg.id = HOST_IF_MSG_POWER_MGMT;
6650 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
6651 pstrPowerMgmtParam->u32Timeout = u32Timeout;
6654 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6656 PRINT_ER("wilc_mq_send fail\n");
6660 s32 host_int_setup_multicast_filter(struct host_if_drv *hWFIDrv, bool bIsEnabled, u32 u32count)
6664 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6665 struct host_if_msg msg;
6666 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
6669 if (pstrWFIDrv == NULL) {
6670 PRINT_ER("driver is null\n");
6674 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
6676 memset(&msg, 0, sizeof(struct host_if_msg));
6679 /* prepare the WiphyParams Message */
6680 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
6683 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
6684 pstrMulticastFilterParam->u32count = u32count;
6686 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6688 PRINT_ER("wilc_mq_send fail\n");
6693 * @brief host_int_ParseJoinBssParam
6694 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
6695 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
6700 static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
6702 struct join_bss_param *pNewJoinBssParam = NULL;
6711 u8 pcipherTotalCount = 0;
6712 u8 authTotalCount = 0;
6715 pu8IEs = ptstrNetworkInfo->pu8IEs;
6716 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
6718 pNewJoinBssParam = kmalloc(sizeof(struct join_bss_param), GFP_KERNEL);
6719 if (pNewJoinBssParam != NULL) {
6720 memset(pNewJoinBssParam, 0, sizeof(struct join_bss_param));
6721 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
6722 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
6723 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
6724 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
6726 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
6727 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
6728 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
6729 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
6730 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
6731 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
6732 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
6734 /* parse supported rates: */
6735 while (index < u16IEsLen) {
6736 /* supportedRates IE */
6737 if (pu8IEs[index] == SUPP_RATES_IE) {
6738 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
6739 suppRatesNo = pu8IEs[index + 1];
6740 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
6741 index += 2; /* skipping ID and length bytes; */
6743 for (i = 0; i < suppRatesNo; i++) {
6744 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
6745 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
6747 index += suppRatesNo;
6750 /* Ext SupportedRates IE */
6751 else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
6752 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
6753 /* checking if no of ext. supp and supp rates < max limit */
6754 extSuppRatesNo = pu8IEs[index + 1];
6755 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
6756 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
6758 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
6760 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
6761 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
6762 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
6763 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
6765 index += extSuppRatesNo;
6769 else if (pu8IEs[index] == HT_CAPABILITY_IE) {
6770 /* if IE found set the flag */
6771 pNewJoinBssParam->ht_capable = true;
6772 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6773 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
6775 } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
6776 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
6777 (pu8IEs[index + 4] == 0xF2) && /* OUI */
6778 (pu8IEs[index + 5] == 0x02) && /* OUI Type */
6779 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
6780 (pu8IEs[index + 7] == 0x01)) {
6781 /* Presence of WMM Info/Param element indicates WMM capability */
6782 pNewJoinBssParam->wmm_cap = true;
6784 /* Check if Bit 7 is set indicating U-APSD capability */
6785 if (pu8IEs[index + 8] & BIT(7))
6786 pNewJoinBssParam->uapsd_cap = true;
6787 index += pu8IEs[index + 1] + 2;
6790 else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
6791 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
6792 (pu8IEs[index + 4] == 0x9a) && /* OUI */
6793 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
6796 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
6797 pNewJoinBssParam->u8NoaEnbaled = 1;
6798 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
6800 /* Check if Bit 7 is set indicating Opss capability */
6801 if (pu8IEs[index + 10] & BIT(7)) {
6802 pNewJoinBssParam->u8OppEnable = 1;
6803 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
6805 pNewJoinBssParam->u8OppEnable = 0;
6807 PRINT_D(GENERIC_DBG, "P2P Dump\n");
6808 for (i = 0; i < pu8IEs[index + 7]; i++)
6809 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
6811 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
6812 u16P2P_count = index + 12;
6814 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
6817 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
6820 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
6822 index += pu8IEs[index + 1] + 2;
6826 else if ((pu8IEs[index] == RSN_IE) ||
6827 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
6828 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
6829 (pu8IEs[index + 5] == 0x01))) {
6830 u16 rsnIndex = index;
6831 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
6832 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
6834 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
6836 if (pu8IEs[rsnIndex] == RSN_IE) {
6837 pNewJoinBssParam->mode_802_11i = 2;
6838 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
6839 } else { /* check if rsn was previously parsed */
6840 if (pNewJoinBssParam->mode_802_11i == 0)
6841 pNewJoinBssParam->mode_802_11i = 1;
6842 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
6845 rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
6846 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
6848 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
6849 /* initialize policies with invalid values */
6851 jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
6853 /*parsing pairwise cipher*/
6855 /* saving 3 pcipher max. */
6856 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
6857 rsnIndex += 2; /* jump 2 bytes of pcipher count */
6859 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
6860 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
6861 /* each count corresponds to 4 bytes, only last byte is saved */
6862 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
6863 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
6865 pcipherTotalCount += pcipherCount;
6866 rsnIndex += jumpOffset;
6868 jumpOffset = pu8IEs[rsnIndex] * 4;
6870 /*parsing AKM suite (auth_policy)*/
6871 /* saving 3 auth policies max. */
6872 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
6873 rsnIndex += 2; /* jump 2 bytes of pcipher count */
6875 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
6876 /* each count corresponds to 4 bytes, only last byte is saved */
6877 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
6879 authTotalCount += authCount;
6880 rsnIndex += jumpOffset;
6881 /*pasring rsn cap. only if rsn IE*/
6882 if (pu8IEs[index] == RSN_IE) {
6883 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
6884 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
6887 pNewJoinBssParam->rsn_found = true;
6888 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6891 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6898 return (void *)pNewJoinBssParam;
6902 void host_int_freeJoinParams(void *pJoinParams)
6904 if ((struct bss_param *)pJoinParams != NULL)
6905 kfree((struct bss_param *)pJoinParams);
6907 PRINT_ER("Unable to FREE null pointer\n");
6910 s32 host_int_delBASession(struct host_if_drv *hWFIDrv, char *pBSSID, char TID)
6913 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6914 struct host_if_msg msg;
6915 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
6917 if (pstrWFIDrv == NULL) {
6918 PRINT_ER("driver is null\n");
6922 memset(&msg, 0, sizeof(struct host_if_msg));
6924 /* prepare the WiphyParams Message */
6925 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
6927 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
6928 pBASessionInfo->u8Ted = TID;
6931 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6933 PRINT_ER("wilc_mq_send fail\n");
6935 down(&hWaitResponse);
6940 s32 host_int_del_All_Rx_BASession(struct host_if_drv *hWFIDrv, char *pBSSID, char TID)
6943 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6944 struct host_if_msg msg;
6945 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
6947 if (pstrWFIDrv == NULL) {
6948 PRINT_ER("driver is null\n");
6952 memset(&msg, 0, sizeof(struct host_if_msg));
6954 /* prepare the WiphyParams Message */
6955 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
6957 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
6958 pBASessionInfo->u8Ted = TID;
6961 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
6963 PRINT_ER("wilc_mq_send fail\n");
6965 down(&hWaitResponse);
6971 * @brief host_int_setup_ipaddress
6972 * @details setup IP in firmware
6973 * @param[in] Handle to wifi driver
6974 * @return Error code.
6975 * @author Abdelrahman Sobhy
6978 s32 host_int_setup_ipaddress(struct host_if_drv *hWFIDrv, u8 *u16ipadd, u8 idx)
6981 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
6982 struct host_if_msg msg;
6984 /* TODO: Enable This feature on softap firmware */
6987 if (pstrWFIDrv == NULL) {
6988 PRINT_ER("driver is null\n");
6992 memset(&msg, 0, sizeof(struct host_if_msg));
6994 /* prepare the WiphyParams Message */
6995 msg.id = HOST_IF_MSG_SET_IPADDRESS;
6997 msg.body.ip_info.au8IPAddr = u16ipadd;
6999 msg.body.ip_info.idx = idx;
7001 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
7003 PRINT_ER("wilc_mq_send fail\n");
7011 * @brief host_int_get_ipaddress
7012 * @details Get IP from firmware
7013 * @param[in] Handle to wifi driver
7014 * @return Error code.
7015 * @author Abdelrahman Sobhy
7018 s32 host_int_get_ipaddress(struct host_if_drv *hWFIDrv, u8 *u16ipadd, u8 idx)
7021 struct host_if_drv *pstrWFIDrv = (struct host_if_drv *)hWFIDrv;
7022 struct host_if_msg msg;
7024 if (pstrWFIDrv == NULL) {
7025 PRINT_ER("driver is null\n");
7029 memset(&msg, 0, sizeof(struct host_if_msg));
7031 /* prepare the WiphyParams Message */
7032 msg.id = HOST_IF_MSG_GET_IPADDRESS;
7034 msg.body.ip_info.au8IPAddr = u16ipadd;
7036 msg.body.ip_info.idx = idx;
7038 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
7040 PRINT_ER("wilc_mq_send fail\n");