]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - drivers/staging/wilc1000/host_interface.c
Merge branches 'pm-cpu', 'pm-cpuidle' and 'pm-domains'
[mirror_ubuntu-zesty-kernel.git] / drivers / staging / wilc1000 / host_interface.c
CommitLineData
c5c77ba1 1#include "host_interface.h"
c5c77ba1
JK
2#include "coreconfigurator.h"
3
fb4ec9ca
CL
4extern s32 TransportInit(void);
5extern s32 TransportDeInit(void);
63d03e47 6extern u8 connecting;
c5c77ba1
JK
7
8#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
da711eb6 9extern struct timer_list hDuringIpTimer;
c5c77ba1
JK
10#endif
11
c5c77ba1 12/*BugID_5137*/
63d03e47 13extern u8 g_wilc_initialized;
c5c77ba1
JK
14/*****************************************************************************/
15/* Macros */
16/*****************************************************************************/
17
18/* Message types of the Host IF Message Queue*/
9eac3a15
CL
19#define HOST_IF_MSG_SCAN 0
20#define HOST_IF_MSG_CONNECT 1
21#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
22#define HOST_IF_MSG_KEY 3
23#define HOST_IF_MSG_RCVD_NTWRK_INFO 4
24#define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
25#define HOST_IF_MSG_CFG_PARAMS 6
26#define HOST_IF_MSG_SET_CHANNEL 7
27#define HOST_IF_MSG_DISCONNECT 8
28#define HOST_IF_MSG_GET_RSSI 9
29#define HOST_IF_MSG_GET_CHNL 10
30#define HOST_IF_MSG_ADD_BEACON 11
31#define HOST_IF_MSG_DEL_BEACON 12
32#define HOST_IF_MSG_ADD_STATION 13
33#define HOST_IF_MSG_DEL_STATION 14
34#define HOST_IF_MSG_EDIT_STATION 15
35#define HOST_IF_MSG_SCAN_TIMER_FIRED 16
36#define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
37#define HOST_IF_MSG_POWER_MGMT 18
38#define HOST_IF_MSG_GET_INACTIVETIME 19
39#define HOST_IF_MSG_REMAIN_ON_CHAN 20
40#define HOST_IF_MSG_REGISTER_FRAME 21
41#define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
42#define HOST_IF_MSG_GET_LINKSPEED 23
43#define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
44#define HOST_IF_MSG_SET_MAC_ADDRESS 25
45#define HOST_IF_MSG_GET_MAC_ADDRESS 26
46#define HOST_IF_MSG_SET_OPERATION_MODE 27
47#define HOST_IF_MSG_SET_IPADDRESS 28
48#define HOST_IF_MSG_GET_IPADDRESS 29
49#define HOST_IF_MSG_FLUSH_CONNECT 30
50#define HOST_IF_MSG_GET_STATISTICS 31
51#define HOST_IF_MSG_SET_MULTICAST_FILTER 32
52#define HOST_IF_MSG_ADD_BA_SESSION 33
53#define HOST_IF_MSG_DEL_BA_SESSION 34
54#define HOST_IF_MSG_Q_IDLE 35
55#define HOST_IF_MSG_DEL_ALL_STA 36
56#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
57#define HOST_IF_MSG_EXIT 100
d85f5326 58
e54d5b75
CL
59#define HOST_IF_SCAN_TIMEOUT 4000
60#define HOST_IF_CONNECT_TIMEOUT 9500
c5c77ba1 61
e54d5b75
CL
62#define BA_SESSION_DEFAULT_BUFFER_SIZE 16
63#define BA_SESSION_DEFAULT_TIMEOUT 1000
64#define BLOCK_ACK_REQ_SIZE 0x14
c5c77ba1
JK
65/*****************************************************************************/
66/* Type Definitions */
67/*****************************************************************************/
68
69/*!
70 * @struct tstrHostIFCfgParamAttr
71 * @brief Structure to hold Host IF CFG Params Attributes
72 * @details
73 * @todo
74 * @sa
75 * @author Mai Daftedar
76 * @date 02 April 2012
77 * @version 1.0
78 */
79typedef struct _tstrHostIFCfgParamAttr {
80 tstrCfgParamVal pstrCfgParamVal;
81
82} tstrHostIFCfgParamAttr;
83
84/*!
85 * @struct tstrHostIFwpaAttr
86 * @brief Structure to hold Host IF Scan Attributes
87 * @details
88 * @todo
89 * @sa
90 * @author Mai Daftedar
91 * @date 25 March 2012
92 * @version 1.0
93 */
94typedef struct _tstrHostIFwpaAttr {
63d03e47
GKH
95 u8 *pu8key;
96 const u8 *pu8macaddr;
97 u8 *pu8seq;
98 u8 u8seqlen;
99 u8 u8keyidx;
100 u8 u8Keylen;
101 u8 u8Ciphermode;
c5c77ba1
JK
102} tstrHostIFwpaAttr;
103
104
105/*!
106 * @struct tstrHostIFwepAttr
107 * @brief Structure to hold Host IF Scan Attributes
108 * @details
109 * @todo
110 * @sa
111 * @author Mai Daftedar
112 * @date 25 March 2012
113 * @version 1.0
114 */
115typedef struct _tstrHostIFwepAttr {
63d03e47
GKH
116 u8 *pu8WepKey;
117 u8 u8WepKeylen;
118 u8 u8Wepidx;
119 u8 u8mode;
c5c77ba1
JK
120 AUTHTYPE_T tenuAuth_type;
121
122} tstrHostIFwepAttr;
123
124/*!
125 * @struct tuniHostIFkeyAttr
126 * @brief Structure to hold Host IF Scan Attributes
127 * @details
128 * @todo
129 * @sa
130 * @author Mai Daftedar
131 * @date 25 March 2012
132 * @version 1.0
133 */
134typedef union _tuniHostIFkeyAttr {
135 tstrHostIFwepAttr strHostIFwepAttr;
136 tstrHostIFwpaAttr strHostIFwpaAttr;
137 tstrHostIFpmkidAttr strHostIFpmkidAttr;
138} tuniHostIFkeyAttr;
139
140/*!
141 * @struct tstrHostIFkeyAttr
142 * @brief Structure to hold Host IF Scan Attributes
143 * @details
144 * @todo
145 * @sa
146 * @author Mai Daftedar
147 * @date 25 March 2012
148 * @version 1.0
149 */
150typedef struct _tstrHostIFkeyAttr {
151 tenuKeyType enuKeyType;
63d03e47 152 u8 u8KeyAction;
c5c77ba1
JK
153 tuniHostIFkeyAttr uniHostIFkeyAttr;
154} tstrHostIFkeyAttr;
155
156
157
158
159/*!
160 * @struct tstrHostIFscanAttr
161 * @brief Structure to hold Host IF Scan Attributes
162 * @details
163 * @todo
164 * @sa
165 * @author Mostafa Abu Bakr
166 * @date 25 March 2012
167 * @version 1.0
168 */
169typedef struct _tstrHostIFscanAttr {
63d03e47
GKH
170 u8 u8ScanSource;
171 u8 u8ScanType;
172 u8 *pu8ChnlFreqList;
173 u8 u8ChnlListLen;
174 u8 *pu8IEs;
c5c77ba1
JK
175 size_t IEsLen;
176 tWILCpfScanResult pfScanResult;
177 void *pvUserArg;
178 /*BugID_4189*/
179 tstrHiddenNetwork strHiddenNetwork;
180
181} tstrHostIFscanAttr;
182
183/*!
184 * @struct tstrHostIFconnectAttr
185 * @brief Structure to hold Host IF Connect Attributes
186 * @details
187 * @todo
188 * @sa
189 * @author Mostafa Abu Bakr
190 * @date 25 March 2012
191 * @version 1.0
192 */
193typedef struct _tstrHostIFconnectAttr {
63d03e47
GKH
194 u8 *pu8bssid;
195 u8 *pu8ssid;
c5c77ba1 196 size_t ssidLen;
63d03e47 197 u8 *pu8IEs;
c5c77ba1 198 size_t IEsLen;
63d03e47 199 u8 u8security;
c5c77ba1
JK
200 tWILCpfConnectResult pfConnectResult;
201 void *pvUserArg;
202 AUTHTYPE_T tenuAuth_type;
63d03e47 203 u8 u8channel;
c5c77ba1
JK
204 void *pJoinParams;
205} tstrHostIFconnectAttr;
206
207/*!
208 * @struct tstrRcvdGnrlAsyncInfo
209 * @brief Structure to hold Received General Asynchronous info
210 * @details
211 * @todo
212 * @sa
213 * @author Mostafa Abu Bakr
214 * @date 25 March 2012
215 * @version 1.0
216 */
217typedef struct _tstrRcvdGnrlAsyncInfo {
63d03e47 218 u8 *pu8Buffer;
4e4467fd 219 u32 u32Length;
c5c77ba1
JK
220} tstrRcvdGnrlAsyncInfo;
221
222/*!
223 * @struct tstrHostIFSetChan
224 * @brief Set Channel message body
225 * @details
226 * @todo
227 * @sa
228 * @author Mai Daftedar
229 * @date 25 March 2012
230 * @version 1.0
231 */
232typedef struct _tstrHostIFSetChan {
63d03e47 233 u8 u8SetChan;
c5c77ba1
JK
234} tstrHostIFSetChan;
235
236/*!
237 * @struct tstrHostIFSetChan
238 * @brief Get Channel message body
239 * @details
240 * @todo
241 * @sa
242 * @author Mai Daftedar
243 * @date 01 Jule 2012
244 * @version 1.0
245 */
246typedef struct _tstrHostIFGetChan {
63d03e47 247 u8 u8GetChan;
c5c77ba1
JK
248} tstrHostIFGetChan;
249
250/*bug3819: Add Scan acomplete notification to host*/
251/*!
252 * @struct tstrScanComplete
253 * @brief hold received Async. Scan Complete message body
254 * @details
255 * @todo
256 * @sa
257 * @author zsalah
258 * @date 25 March 2012
259 * @version 1.0
260 */
261/*typedef struct _tstrScanComplete
262 * {
63d03e47 263 * u8* pu8Buffer;
4e4467fd 264 * u32 u32Length;
c5c77ba1
JK
265 * } tstrScanComplete;*/
266
267/*!
268 * @struct tstrHostIFSetBeacon
269 * @brief Set Beacon message body
270 * @details
271 * @todo
272 * @sa
273 * @author Adham Abozaeid
274 * @date 10 July 2012
275 * @version 1.0
276 */
277typedef struct _tstrHostIFSetBeacon {
4e4467fd
CL
278 u32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */
279 u32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames
c5c77ba1 280 * (including the current frame) appear before the next DTIM */
4e4467fd 281 u32 u32HeadLen; /*!< Length of the head buffer in bytes */
63d03e47 282 u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
c5c77ba1 283 * from the beacon's start till the TIM element, NOT including the TIM */
4e4467fd 284 u32 u32TailLen; /*!< Length of the tail buffer in bytes */
63d03e47 285 u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
c5c77ba1
JK
286 * after the TIM inormation element */
287} tstrHostIFSetBeacon;
288
289
290
291/*!
292 * @struct tstrHostIFDelBeacon
293 * @brief Del Beacon message body
294 * @details
295 * @todo
296 * @sa
297 * @author Adham Abozaeid
298 * @date 15 July 2012
299 * @version 1.0
300 */
301typedef struct _tstrHostIFDelBeacon {
63d03e47 302 u8 u8dummy;
c5c77ba1
JK
303} tstrHostIFDelBeacon;
304
305/*!
306 * @struct tstrHostIFSetMulti
307 * @brief set Multicast filter Address
308 * @details
309 * @todo
310 * @sa
311 * @author Abdelrahman Sobhy
312 * @date 30 August 2013
313 * @version 1.0 Description
314 */
315
316typedef struct {
72ed4dc7 317 bool bIsEnabled;
4e4467fd 318 u32 u32count;
c5c77ba1
JK
319} tstrHostIFSetMulti;
320
321/*!
322 * @struct tstrHostIFDelAllSta
323 * @brief Deauth station message body
324 * @details
325 * @todo
326 * @sa
327 * @author Mai Daftedar
328 * @date 09 April 2014
329 * @version 1.0 Description
330 */
331
332typedef struct {
63d03e47
GKH
333 u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN];
334 u8 u8Num_AssocSta;
c5c77ba1
JK
335} tstrHostIFDelAllSta;
336
337/*!
338 * @struct tstrHostIFDelSta
339 * @brief Delete station message body
340 * @details
341 * @todo
342 * @sa
343 * @author Adham Abozaeid
344 * @date 15 July 2012
345 * @version 1.0 Description
346 */
347
348typedef struct {
63d03e47 349 u8 au8MacAddr[ETH_ALEN];
c5c77ba1
JK
350} tstrHostIFDelSta;
351
352/*!
353 * @struct tstrTimerCb
354 * @brief Timer callback message body
355 * @details
356 * @todo
357 * @sa
358 * @author Mostafa Abu Bakr
359 * @date 25 March 2012
360 * @version 1.0
361 */
362typedef struct _tstrTimerCb {
363 void *pvUsrArg; /*!< Private data passed at timer start */
364} tstrTimerCb;
365
366/*!
367 * @struct tstrHostIfPowerMgmtParam
368 * @brief Power management message body
369 * @details
370 * @todo
371 * @sa
372 * @author Adham Abozaeid
373 * @date 24 November 2012
374 * @version 1.0
375 */
376typedef struct {
377
72ed4dc7 378 bool bIsEnabled;
4e4467fd 379 u32 u32Timeout;
c5c77ba1
JK
380} tstrHostIfPowerMgmtParam;
381
382/*!
383 * @struct tstrHostIFSetIPAddr
384 * @brief set IP Address message body
385 * @details
386 * @todo
387 * @sa
388 * @author Abdelrahman Sobhy
389 * @date 30 August 2013
390 * @version 1.0 Description
391 */
392
393typedef struct {
63d03e47
GKH
394 u8 *au8IPAddr;
395 u8 idx;
c5c77ba1
JK
396} tstrHostIFSetIPAddr;
397
398/*!
399 * @struct tstrHostIfStaInactiveT
400 * @brief Get station message body
401 * @details
402 * @todo
403 * @sa
404 * @author Mai Daftedar
405 * @date 16 April 2013
406 * @version 1.0
407 */
408typedef struct {
63d03e47 409 u8 mac[6];
c5c77ba1
JK
410
411} tstrHostIfStaInactiveT;
412/**/
413/*!
414 * @union tuniHostIFmsgBody
415 * @brief Message body for the Host Interface message_q
416 * @details
417 * @todo
418 * @sa
419 * @author Mostafa Abu Bakr
420 * @date 25 March 2012
421 * @version 1.0
422 */
423typedef union _tuniHostIFmsgBody {
424 tstrHostIFscanAttr strHostIFscanAttr; /*!< Host IF Scan Request Attributes message body */
425 tstrHostIFconnectAttr strHostIFconnectAttr; /*!< Host IF Connect Request Attributes message body */
426 tstrRcvdNetworkInfo strRcvdNetworkInfo; /*!< Received Asynchronous Network Info message body */
427 tstrRcvdGnrlAsyncInfo strRcvdGnrlAsyncInfo; /*!< Received General Asynchronous Info message body */
428 tstrHostIFkeyAttr strHostIFkeyAttr; /*!<>*/
429 tstrHostIFCfgParamAttr strHostIFCfgParamAttr; /*! <CFG Parameter message Body> */
430 tstrHostIFSetChan strHostIFSetChan;
431 tstrHostIFGetChan strHostIFGetChan;
432 tstrHostIFSetBeacon strHostIFSetBeacon; /*!< Set beacon message body */
433 tstrHostIFDelBeacon strHostIFDelBeacon; /*!< Del beacon message body */
434 tstrWILC_AddStaParam strAddStaParam; /*!< Add station message body */
435 tstrHostIFDelSta strDelStaParam; /*!< Del Station message body */
436 tstrWILC_AddStaParam strEditStaParam; /*!< Edit station message body */
437 /* tstrScanComplete strScanComplete; / *Received Async. Scan Complete message body* / */
438 tstrTimerCb strTimerCb; /*!< Timer callback message body */
439 tstrHostIfPowerMgmtParam strPowerMgmtparam; /*!< Power Management message body */
440 tstrHostIfStaInactiveT strHostIfStaInactiveT;
441 tstrHostIFSetIPAddr strHostIfSetIP;
442 tstrHostIfSetDrvHandler strHostIfSetDrvHandler;
443 tstrHostIFSetMulti strHostIfSetMulti;
444 tstrHostIfSetOperationMode strHostIfSetOperationMode;
445 tstrHostIfSetMacAddress strHostIfSetMacAddress;
446 tstrHostIfGetMacAddress strHostIfGetMacAddress;
447 tstrHostIfBASessionInfo strHostIfBASessionInfo;
448 #ifdef WILC_P2P
449 tstrHostIfRemainOnChan strHostIfRemainOnChan;
450 tstrHostIfRegisterFrame strHostIfRegisterFrame;
451 #endif
576917ad 452 char *pUserData;
c5c77ba1
JK
453 tstrHostIFDelAllSta strHostIFDelAllSta;
454} tuniHostIFmsgBody;
455
456/*!
457 * @struct tstrHostIFmsg
458 * @brief Host Interface message
459 * @details
460 * @todo
461 * @sa
462 * @author Mostafa Abu Bakr
463 * @date 25 March 2012
464 * @version 1.0
465 */
466typedef struct _tstrHostIFmsg {
d85f5326 467 u16 u16MsgId; /*!< Message ID */
c5c77ba1 468 tuniHostIFmsgBody uniHostIFmsgBody; /*!< Message body */
11f58c88 469 tstrWILC_WFIDrv *drvHandler;
c5c77ba1
JK
470} tstrHostIFmsg;
471
472#ifdef CONNECT_DIRECT
473typedef struct _tstrWidJoinReqExt {
576917ad 474 char SSID[MAX_SSID_LEN];
63d03e47
GKH
475 u8 u8channel;
476 u8 BSSID[6];
c5c77ba1
JK
477} tstrWidJoinReqExt;
478#endif
479
480/*Bug4218: Parsing Join Param*/
481#ifdef WILC_PARSE_SCAN_IN_HOST
482/*Struct containg joinParam of each AP*/
483typedef struct _tstrJoinBssParam {
484 BSSTYPE_T bss_type;
63d03e47 485 u8 dtim_period;
d85f5326
CL
486 u16 beacon_period;
487 u16 cap_info;
63d03e47 488 u8 au8bssid[6];
576917ad 489 char ssid[MAX_SSID_LEN];
63d03e47
GKH
490 u8 ssidLen;
491 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
492 u8 ht_capable;
493 u8 wmm_cap;
494 u8 uapsd_cap;
72ed4dc7 495 bool rsn_found;
63d03e47
GKH
496 u8 rsn_grp_policy;
497 u8 mode_802_11i;
498 u8 rsn_pcip_policy[3];
499 u8 rsn_auth_policy[3];
500 u8 rsn_cap[2];
c5c77ba1
JK
501 struct _tstrJoinParam *nextJoinBss;
502 #ifdef WILC_P2P
4e4467fd 503 u32 tsf;
63d03e47
GKH
504 u8 u8NoaEnbaled;
505 u8 u8OppEnable;
506 u8 u8CtWindow;
507 u8 u8Count;
508 u8 u8Index;
509 u8 au8Duration[4];
510 u8 au8Interval[4];
511 u8 au8StartTime[4];
c5c77ba1
JK
512 #endif
513} tstrJoinBssParam;
514/*Bug4218: Parsing Join Param*/
515/*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
516typedef struct _tstrBssTable {
63d03e47 517 u8 u8noBssEntries;
c5c77ba1
JK
518 tstrJoinBssParam *head;
519 tstrJoinBssParam *tail;
520} tstrBssTable;
521#endif /*WILC_PARSE_SCAN_IN_HOST*/
522
523typedef enum {
524 SCAN_TIMER = 0,
525 CONNECT_TIMER = 1,
526 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
527} tenuScanConnTimer;
528
529/*****************************************************************************/
530/* */
531/* Global Variabls */
532/* */
533/*****************************************************************************/
534
535
6fdb302c
DM
536tstrWILC_WFIDrv *terminated_handle;
537tstrWILC_WFIDrv *gWFiDrvHandle;
c5c77ba1 538#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
72ed4dc7 539bool g_obtainingIP = false;
c5c77ba1 540#endif
63d03e47 541u8 P2P_LISTEN_STATE;
1999bd52 542static struct task_struct *HostIFthreadHandler;
c5c77ba1 543static WILC_MsgQueueHandle gMsgQHostIF;
83383ea3 544static struct semaphore hSemHostIFthrdEnd;
c5c77ba1 545
83383ea3
AB
546struct semaphore hSemDeinitDrvHandle;
547static struct semaphore hWaitResponse;
548struct semaphore hSemHostIntDeinit;
da711eb6 549struct timer_list g_hPeriodicRSSI;
c5c77ba1
JK
550
551
552
63d03e47 553u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
c5c77ba1
JK
554
555#ifndef CONNECT_DIRECT
63d03e47 556static u8 gapu8RcvdSurveyResults[2][MAX_SURVEY_RESULT_FRAG_SIZE];
c5c77ba1
JK
557#endif
558
63d03e47 559static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
c5c77ba1 560
72ed4dc7 561bool gbScanWhileConnected = false;
c5c77ba1 562
ca356ada
CL
563static s8 gs8Rssi;
564static s8 gs8lnkspd;
63d03e47
GKH
565static u8 gu8Chnl;
566static u8 gs8SetIP[2][4];
567static u8 gs8GetIP[2][4];
c5c77ba1 568#ifdef WILC_AP_EXTERNAL_MLME
4e4467fd 569static u32 gu32InactiveTime;
63d03e47 570static u8 gu8DelBcn;
c5c77ba1 571#endif
4e4467fd 572static u32 gu32WidConnRstHack;
c5c77ba1
JK
573
574/*BugID_5137*/
63d03e47
GKH
575u8 *gu8FlushedJoinReq;
576u8 *gu8FlushedInfoElemAsoc;
577u8 gu8Flushed11iMode;
578u8 gu8FlushedAuthType;
4e4467fd
CL
579u32 gu32FlushedJoinReqSize;
580u32 gu32FlushedInfoElemAsocSize;
581u32 gu8FlushedJoinReqDrvHandler;
c5c77ba1
JK
582#define REAL_JOIN_REQ 0
583#define FLUSHED_JOIN_REQ 1
584#define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
585
586/*Bug4218: Parsing Join Param*/
587#ifdef WILC_PARSE_SCAN_IN_HOST
588/*Bug4218: Parsing Join Param*/
589static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
590#endif /*WILC_PARSE_SCAN_IN_HOST*/
591
4e4467fd 592extern void chip_sleep_manually(u32 u32SleepTime);
c5c77ba1
JK
593extern int linux_wlan_get_num_conn_ifcs(void);
594
595/**
596 * @brief Handle_SetChannel
597 * @details Sending config packet to firmware to set channel
598 * @param[in] tstrHostIFSetChan* pstrHostIFSetChan
599 * @return Error code.
600 * @author
601 * @date
602 * @version 1.0
603 */
2b05df55 604static s32 Handle_SetChannel(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetChan *pstrHostIFSetChan)
c5c77ba1
JK
605{
606
fb4ec9ca 607 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
608 tstrWID strWID;
609 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
610
611 /*prepare configuration packet*/
d85f5326 612 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
c5c77ba1 613 strWID.enuWIDtype = WID_CHAR;
576917ad
DL
614 strWID.ps8WidVal = (char *)&(pstrHostIFSetChan->u8SetChan);
615 strWID.s32ValueSize = sizeof(char);
c5c77ba1
JK
616
617 PRINT_D(HOSTINF_DBG, "Setting channel\n");
618 /*Sending Cfg*/
72ed4dc7 619 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
620 if (s32Error) {
621 PRINT_ER("Failed to set channel\n");
622 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
623 }
624 WILC_CATCH(s32Error)
625 {
626
627 }
628
629 return s32Error;
630}
631/**
632 * @brief Handle_SetWfiDrvHandler
633 * @details Sending config packet to firmware to set driver handler
634 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
635 * @return Error code.
636 * @author
637 * @date
638 * @version 1.0
639 */
fb4ec9ca 640static s32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler *pstrHostIfSetDrvHandler)
c5c77ba1
JK
641{
642
fb4ec9ca 643 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
644 tstrWID strWID;
645 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)((pstrHostIfSetDrvHandler->u32Address));
646
647
648 /*prepare configuration packet*/
d85f5326 649 strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER;
c5c77ba1 650 strWID.enuWIDtype = WID_INT;
ca356ada 651 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
4e4467fd 652 strWID.s32ValueSize = sizeof(u32);
c5c77ba1
JK
653
654 /*Sending Cfg*/
655
72ed4dc7 656 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
657
658
2b9d5b48 659 if ((pstrHostIfSetDrvHandler->u32Address) == (u32)NULL)
83383ea3 660 up(&hSemDeinitDrvHandle);
c5c77ba1
JK
661
662
663 if (s32Error) {
664 PRINT_ER("Failed to set driver handler\n");
665 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
666 }
667 WILC_CATCH(s32Error)
668 {
669
670 }
671
672 return s32Error;
673}
674
675/**
676 * @brief Handle_SetWfiAPDrvHandler
677 * @details Sending config packet to firmware to set driver handler
678 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
679 * @return Error code.
680 * @author
681 * @date
682 * @version 1.0
683 */
2b05df55 684static s32 Handle_SetOperationMode(tstrWILC_WFIDrv *drvHandler, tstrHostIfSetOperationMode *pstrHostIfSetOperationMode)
c5c77ba1
JK
685{
686
fb4ec9ca 687 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
688 tstrWID strWID;
689 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
690
691
692 /*prepare configuration packet*/
d85f5326 693 strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE;
c5c77ba1 694 strWID.enuWIDtype = WID_INT;
ca356ada 695 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
4e4467fd 696 strWID.s32ValueSize = sizeof(u32);
c5c77ba1
JK
697
698 /*Sending Cfg*/
03b2d5e7 699 PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p\n", pstrWFIDrv);
c5c77ba1 700
72ed4dc7 701 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
702
703
2b9d5b48 704 if ((pstrHostIfSetOperationMode->u32Mode) == (u32)NULL)
83383ea3 705 up(&hSemDeinitDrvHandle);
c5c77ba1
JK
706
707
708 if (s32Error) {
709 PRINT_ER("Failed to set driver handler\n");
710 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
711 }
712 WILC_CATCH(s32Error)
713 {
714
715 }
716
717 return s32Error;
718}
719
720/**
721 * @brief host_int_set_IPAddress
722 * @details Setting IP address params in message queue
63d03e47 723 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
c5c77ba1
JK
724 * @return Error code.
725 * @author
726 * @date
727 * @version 1.0
728 */
2b05df55 729s32 Handle_set_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
c5c77ba1
JK
730{
731
fb4ec9ca 732 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
733 tstrWID strWID;
734 char firmwareIPAddress[4] = {0};
735 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
736
737 if (pu8IPAddr[0] < 192)
738 pu8IPAddr[0] = 0;
739
b3a02832 740 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
c5c77ba1 741
d00d2ba3 742 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
c5c77ba1
JK
743
744 /*prepare configuration packet*/
d85f5326 745 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
c5c77ba1 746 strWID.enuWIDtype = WID_STR;
63d03e47 747 strWID.ps8WidVal = (u8 *)pu8IPAddr;
c5c77ba1
JK
748 strWID.s32ValueSize = IP_ALEN;
749
72ed4dc7 750 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
751
752
753
218dc407 754 host_int_get_ipaddress(drvHandler, firmwareIPAddress, idx);
c5c77ba1
JK
755
756 if (s32Error) {
757 PRINT_D(HOSTINF_DBG, "Failed to set IP address\n");
758 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
759 } else {
760 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
761 }
762
763 WILC_CATCH(s32Error)
764 {
765
766 }
767
768 return s32Error;
769}
770
771
772/**
773 * @brief Handle_get_IPAddress
774 * @details Setting IP address params in message queue
63d03e47 775 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
c5c77ba1
JK
776 * @return Error code.
777 * @author
778 * @date
779 * @version 1.0
780 */
2b05df55 781s32 Handle_get_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
c5c77ba1
JK
782{
783
fb4ec9ca 784 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
785 tstrWID strWID;
786 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
787
788 /*prepare configuration packet*/
d85f5326 789 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
c5c77ba1 790 strWID.enuWIDtype = WID_STR;
dc0ad74b 791 strWID.ps8WidVal = WILC_MALLOC(IP_ALEN);
c5c77ba1
JK
792 strWID.s32ValueSize = IP_ALEN;
793
72ed4dc7 794 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1 795
b3a02832 796 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.ps8WidVal);
c5c77ba1 797
d00d2ba3 798 memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN);
c5c77ba1
JK
799
800 /*get the value by searching the local copy*/
49188af2 801 kfree(strWID.ps8WidVal);
c5c77ba1 802
1a646e7e 803 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
218dc407 804 host_int_setup_ipaddress(pstrWFIDrv, gs8SetIP[idx], idx);
c5c77ba1
JK
805
806 if (s32Error != WILC_SUCCESS) {
807 PRINT_ER("Failed to get IP address\n");
808 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
809 } else {
03b2d5e7 810 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
b3a02832 811 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
c5c77ba1
JK
812 PRINT_INFO(HOSTINF_DBG, "\n");
813 }
814
815 WILC_CATCH(s32Error)
816 {
817
818 }
819
820 return s32Error;
821}
822
823
824/*BugId_5077*/
825/**
826 * @brief Handle_SetMacAddress
827 * @details Setting mac address
828 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
829 * @return Error code.
830 * @author Amr Abdel-Moghny
831 * @date November 2013
832 * @version 7.0
833 */
2b05df55 834static s32 Handle_SetMacAddress(tstrWILC_WFIDrv *drvHandler, tstrHostIfSetMacAddress *pstrHostIfSetMacAddress)
c5c77ba1
JK
835{
836
fb4ec9ca 837 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
838 tstrWID strWID;
839 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
dc0ad74b 840 u8 *mac_buf = WILC_MALLOC(ETH_ALEN);
78c87591 841
c5c77ba1
JK
842 if (mac_buf == NULL) {
843 PRINT_ER("No buffer to send mac address\n");
844 return WILC_FAIL;
845 }
d00d2ba3 846 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
c5c77ba1
JK
847
848 /*prepare configuration packet*/
d85f5326 849 strWID.u16WIDid = (u16)WID_MAC_ADDR;
c5c77ba1
JK
850 strWID.enuWIDtype = WID_STR;
851 strWID.ps8WidVal = mac_buf;
852 strWID.s32ValueSize = ETH_ALEN;
853 PRINT_D(GENERIC_DBG, "mac addr = :%x:%x:%x:%x:%x:%x\n", strWID.ps8WidVal[0], strWID.ps8WidVal[1], strWID.ps8WidVal[2], strWID.ps8WidVal[3], strWID.ps8WidVal[4], strWID.ps8WidVal[5]);
854 /*Sending Cfg*/
72ed4dc7 855 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
856 if (s32Error) {
857 PRINT_ER("Failed to set mac address\n");
858 WILC_ERRORREPORT(s32Error, WILC_FAIL);
859 }
860
861 WILC_CATCH(s32Error)
862 {
863
864 }
49188af2 865 kfree(mac_buf);
c5c77ba1
JK
866 return s32Error;
867}
868
869
870/*BugID_5213*/
871/**
872 * @brief Handle_GetMacAddress
873 * @details Getting mac address
874 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
875 * @return Error code.
876 * @author Amr Abdel-Moghny
877 * @date JAN 2013
878 * @version 8.0
879 */
2b05df55 880static s32 Handle_GetMacAddress(tstrWILC_WFIDrv *drvHandler, tstrHostIfGetMacAddress *pstrHostIfGetMacAddress)
c5c77ba1
JK
881{
882
fb4ec9ca 883 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
884 tstrWID strWID;
885
886 /*prepare configuration packet*/
d85f5326 887 strWID.u16WIDid = (u16)WID_MAC_ADDR;
c5c77ba1
JK
888 strWID.enuWIDtype = WID_STR;
889 strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress;
890 strWID.s32ValueSize = ETH_ALEN;
891
892 /*Sending Cfg*/
72ed4dc7 893 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, false, (u32)drvHandler);
c5c77ba1
JK
894 if (s32Error) {
895 PRINT_ER("Failed to get mac address\n");
896 WILC_ERRORREPORT(s32Error, WILC_FAIL);
897 }
898 WILC_CATCH(s32Error)
899 {
900
901 }
83383ea3 902 up(&hWaitResponse);
c5c77ba1
JK
903
904 return s32Error;
905}
906
907
908/**
909 * @brief Handle_CfgParam
910 * @details Sending config packet to firmware to set CFG params
911 * @param[in] tstrHostIFCfgParamAttr* strHostIFCfgParamAttr
912 * @return Error code.
913 * @author
914 * @date
915 * @version 1.0
916 */
2b05df55 917static s32 Handle_CfgParam(tstrWILC_WFIDrv *drvHandler, tstrHostIFCfgParamAttr *strHostIFCfgParamAttr)
c5c77ba1 918{
fb4ec9ca 919 s32 s32Error = WILC_SUCCESS;
c5c77ba1 920 tstrWID strWIDList[32];
63d03e47 921 u8 u8WidCnt = 0;
c5c77ba1
JK
922 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
923
924
83383ea3 925 down(&(pstrWFIDrv->gtOsCfgValuesSem));
c5c77ba1
JK
926
927
928 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
929
930 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) {
931 /*----------------------------------------------------------*/
932 /*Input Value: INFRASTRUCTURE = 1, */
933 /* INDEPENDENT= 2, */
934 /* ANY_BSS= 3 */
935 /*----------------------------------------------------------*/
936 /* validate input then copy>> need to check value 4 and 5 */
937 if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) {
938 strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE;
ca356ada 939 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
c5c77ba1 940 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
576917ad 941 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
63d03e47 942 pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
c5c77ba1
JK
943 } else {
944 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
945 }
946 u8WidCnt++;
947 }
948 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) {
949 /*------------------------------------------------------*/
950 /*Input Values: OPEN_SYSTEM = 0, */
951 /* SHARED_KEY = 1, */
952 /* ANY = 2 */
953 /*------------------------------------------------------*/
954 /*validate Possible values*/
955 if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) {
956 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE;
ca356ada 957 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
c5c77ba1 958 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
576917ad 959 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
63d03e47 960 pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
c5c77ba1
JK
961 } else {
962 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
963 }
964 u8WidCnt++;
965 }
966 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) {
967 /* range is 1 to 65535. */
968 if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) {
969 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT;
ca356ada 970 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
c5c77ba1 971 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
d85f5326 972 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
c5c77ba1
JK
973 pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
974 } else {
975 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
976 }
977 u8WidCnt++;
978 }
979 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) {
980 /*-----------------------------------------------------------*/
981 /*Input Values: NO_POWERSAVE = 0, */
982 /* MIN_FAST_PS = 1, */
983 /* MAX_FAST_PS = 2, */
984 /* MIN_PSPOLL_PS = 3, */
985 /* MAX_PSPOLL_PS = 4 */
986 /*----------------------------------------------------------*/
987 if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) {
988 strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT;
ca356ada 989 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
c5c77ba1 990 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
576917ad 991 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
63d03e47 992 pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
c5c77ba1
JK
993 } else {
994 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
995 }
996 u8WidCnt++;
997 }
998 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) {
999 /* range from 1 to 256 */
1000 if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) {
1001 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT;
ca356ada 1002 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
c5c77ba1 1003 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
d85f5326 1004 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
c5c77ba1
JK
1005 pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
1006 } else {
1007 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1008 }
1009 u8WidCnt++;
1010 }
1011 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) {
1012 /* range from 1 to 256 */
1013 if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) {
1014 strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT;
ca356ada 1015 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
c5c77ba1
JK
1016
1017 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
d85f5326 1018 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
c5c77ba1
JK
1019 pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
1020 } else {
1021 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1022 }
1023 u8WidCnt++;
1024 }
1025 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) {
1026
1027 if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) {
1028 strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD;
ca356ada 1029 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
c5c77ba1 1030 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
d85f5326 1031 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
c5c77ba1
JK
1032 pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
1033 } else {
1034 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1035 }
1036 u8WidCnt++;
1037 }
1038 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) {
1039 /* range 256 to 65535 */
1040 if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) {
1041 strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD;
ca356ada 1042 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
c5c77ba1 1043 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
d85f5326 1044 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
c5c77ba1
JK
1045 pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1046 } else {
1047 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1048 }
1049 u8WidCnt++;
1050 }
1051 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) {
1052 /*-----------------------------------------------------*/
1053 /*Input Values: Short= 0, */
1054 /* Long= 1, */
1055 /* Auto= 2 */
1056 /*------------------------------------------------------*/
1057 if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) {
1058 strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE;
ca356ada 1059 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
c5c77ba1 1060 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
576917ad 1061 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
c5c77ba1
JK
1062 pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1063 } else {
1064 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1065 }
1066 u8WidCnt++;
1067 }
1068 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) {
1069 if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) {
1070 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED;
ca356ada 1071 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
c5c77ba1 1072 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
576917ad 1073 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
63d03e47 1074 pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
c5c77ba1
JK
1075 } else {
1076 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1077 }
1078 u8WidCnt++;
1079 }
1080 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) {
1081 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1082 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1083 /* this information is useful for external supplicant */
1084 /*Input Values: 1 for enable and 0 for disable. */
1085 if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) {
1086 strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE;
ca356ada 1087 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
c5c77ba1 1088 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
576917ad 1089 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
63d03e47 1090 pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
c5c77ba1
JK
1091 } else {
1092 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1093 }
1094 u8WidCnt++;
1095 }
1096 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) {
1097 /* range is 1 to 65535. */
1098 if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) {
1099 strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL;
ca356ada 1100 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
c5c77ba1 1101 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
d85f5326 1102 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
c5c77ba1
JK
1103 pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1104 } else {
1105 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1106 }
1107 u8WidCnt++;
1108 }
1109 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) {
1110 /* range is 1 to 255. */
1111 if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) {
1112 strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD;
ca356ada 1113 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
c5c77ba1 1114 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
576917ad 1115 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
c5c77ba1
JK
1116 pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1117 } else {
1118 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1119 }
1120 u8WidCnt++;
1121 }
1122 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) {
1123 /*----------------------------------------------------------------------*/
1124 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1125 /* SITE_SURVEY_ALL_CH = 1, */
1126 /* SITE_SURVEY_OFF = 2 */
1127 /*----------------------------------------------------------------------*/
1128 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) {
1129 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY;
ca356ada 1130 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
c5c77ba1 1131 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
576917ad 1132 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
63d03e47 1133 pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
c5c77ba1
JK
1134 } else {
1135 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1136 }
1137 u8WidCnt++;
1138 }
1139 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) {
1140 /* range is 1 to 65535. */
1141 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) {
1142 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME;
ca356ada 1143 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
c5c77ba1 1144 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
d85f5326 1145 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
c5c77ba1
JK
1146 pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1147 } else {
1148 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1149 }
1150 u8WidCnt++;
1151 }
1152 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) {
1153 /* range is 1 to 65535. */
1154 if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) {
1155 strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME;
ca356ada 1156 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
c5c77ba1 1157 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
d85f5326 1158 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
c5c77ba1
JK
1159 pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1160 } else {
1161 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1162 }
1163 u8WidCnt++;
1164 }
1165 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) {
1166 /* range is 1 to 65535. */
1167 if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) {
1168 strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME;
ca356ada 1169 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
c5c77ba1 1170 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
d85f5326 1171 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
c5c77ba1
JK
1172 pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1173 } else {
1174 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1175 }
1176 u8WidCnt++;
1177 }
1178 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) {
1179 CURRENT_TX_RATE_T curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate;
1180 /*----------------------------------------------------------------------*/
1181 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1182 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1183 /*----------------------------------------------------------------------*/
1184 /* validate rate */
1185 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
1186 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
1187 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
1188 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
1189 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
1190 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
1191 strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE;
ca356ada 1192 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&curr_tx_rate;
c5c77ba1 1193 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
d85f5326 1194 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
63d03e47 1195 pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
c5c77ba1
JK
1196 } else {
1197 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1198 }
1199 u8WidCnt++;
1200 }
72ed4dc7 1201 s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, false, (u32)pstrWFIDrv);
c5c77ba1 1202
2b9d5b48 1203 if (s32Error)
c5c77ba1
JK
1204 PRINT_ER("Error in setting CFG params\n");
1205
c5c77ba1
JK
1206 WILC_CATCH(s32Error)
1207 {
1208 }
83383ea3 1209 up(&(pstrWFIDrv->gtOsCfgValuesSem));
c5c77ba1
JK
1210 return s32Error;
1211}
1212
1213
1214/**
1215 * @brief Handle_wait_msg_q_empty
1216 * @details this should be the last msg and then the msg Q becomes idle
1217 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1218 * @return Error code.
1219 * @author
1220 * @date
1221 * @version 1.0
1222 */
fb4ec9ca 1223static s32 Handle_wait_msg_q_empty(void)
c5c77ba1 1224{
fb4ec9ca 1225 s32 s32Error = WILC_SUCCESS;
78c87591 1226
c5c77ba1 1227 g_wilc_initialized = 0;
83383ea3 1228 up(&hWaitResponse);
c5c77ba1
JK
1229 return s32Error;
1230}
1231
1232/**
1233 * @brief Handle_Scan
1234 * @details Sending config packet to firmware to set the scan params
1235 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1236 * @return Error code.
1237 * @author
1238 * @date
1239 * @version 1.0
1240 */
2b05df55 1241static s32 Handle_Scan(tstrWILC_WFIDrv *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr)
c5c77ba1 1242{
fb4ec9ca 1243 s32 s32Error = WILC_SUCCESS;
c5c77ba1 1244 tstrWID strWIDList[5];
4e4467fd
CL
1245 u32 u32WidsCount = 0;
1246 u32 i;
63d03e47
GKH
1247 u8 *pu8Buffer;
1248 u8 valuesize = 0;
1249 u8 *pu8HdnNtwrksWidVal = NULL;
c5c77ba1
JK
1250 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1251
1252 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
03b2d5e7 1253 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", pstrWFIDrv->enuHostIFstate);
c5c77ba1
JK
1254
1255 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
1256 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
1257
1258 #ifdef WILC_P2P
c5c77ba1
JK
1259 #endif
1260
1261 if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) {
1262 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1263 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate);
1264 WILC_ERRORREPORT(s32Error, WILC_BUSY);
1265 }
1266
1267 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
1268 if (g_obtainingIP || connecting) {
1269 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
1270 WILC_ERRORREPORT(s32Error, WILC_BUSY);
1271 }
1272 #endif
1273
1274 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1275
1276
1277 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0;
1278
1279 /*BugID_4189*/
d85f5326 1280 strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ;
c5c77ba1
JK
1281 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1282
2b9d5b48 1283 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++)
c5c77ba1 1284 valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
c5c77ba1
JK
1285 pu8HdnNtwrksWidVal = WILC_MALLOC(valuesize + 1);
1286 strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal;
b1413b60 1287 if (strWIDList[u32WidsCount].ps8WidVal != NULL) {
c5c77ba1
JK
1288 pu8Buffer = strWIDList[u32WidsCount].ps8WidVal;
1289
1290 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
1291
1292 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
1293
1294 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1295 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
d00d2ba3 1296 memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
c5c77ba1
JK
1297 pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1298 }
1299
1300
1301
fb4ec9ca 1302 strWIDList[u32WidsCount].s32ValueSize = (s32)(valuesize + 1);
c5c77ba1
JK
1303 u32WidsCount++;
1304 }
1305
1306 /*filling cfg param array*/
1307
1308 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1309 {
1310 /* IEs to be inserted in Probe Request */
1311 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE;
1312 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1313 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs;
1314 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen;
1315 u32WidsCount++;
1316 }
1317
1318 /*Scan Type*/
1319 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE;
1320 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
576917ad 1321 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
ca356ada 1322 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType));
c5c77ba1
JK
1323 u32WidsCount++;
1324
1325 /*list of channels to be scanned*/
1326 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST;
1327 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1328
1329 /* Bug 4648: Convert channel numbers to start from 0 not 1. */
1330 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
1331 int i;
1332
1333 for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
2b9d5b48 1334 if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0)
c5c77ba1 1335 pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
c5c77ba1
JK
1336 }
1337 }
1338
1339 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList;
1340 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen;
1341 u32WidsCount++;
1342
1343 /*Scan Request*/
1344 strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ;
1345 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
576917ad 1346 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
ca356ada 1347 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource));
c5c77ba1
JK
1348 u32WidsCount++;
1349
1350 /*keep the state as is , no need to change it*/
1351 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1352
78174ada 1353 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
72ed4dc7 1354 gbScanWhileConnected = true;
78174ada 1355 else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE)
72ed4dc7 1356 gbScanWhileConnected = false;
c5c77ba1 1357
72ed4dc7 1358 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
c5c77ba1
JK
1359
1360 if (s32Error) {
1361 PRINT_ER("Failed to send scan paramters config packet\n");
1362 WILC_ERRORREPORT(s32Error, s32Error);
1363 } else {
1364 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
1365 }
1366
1367 WILC_CATCH(s32Error)
1368 {
8972d0fe 1369 del_timer(&pstrWFIDrv->hScanTimer);
c5c77ba1
JK
1370 /*if there is an ongoing scan request*/
1371 Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED);
1372 }
1373
1374 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1375 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
49188af2 1376 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
c5c77ba1
JK
1377 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1378 }
1379
1380 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1381 if (pstrHostIFscanAttr->pu8IEs != NULL) {
49188af2 1382 kfree(pstrHostIFscanAttr->pu8IEs);
c5c77ba1
JK
1383 pstrHostIFscanAttr->pu8IEs = NULL;
1384 }
1385 if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
49188af2 1386 kfree(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
c5c77ba1
JK
1387 pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
1388 }
1389
1390 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1391 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
49188af2 1392 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
c5c77ba1
JK
1393 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1394 }
1395
2b9d5b48 1396 if (pu8HdnNtwrksWidVal != NULL)
49188af2 1397 kfree(pu8HdnNtwrksWidVal);
c5c77ba1
JK
1398
1399 return s32Error;
1400}
1401
1402/**
1403 * @brief Handle_ScanDone
1404 * @details Call scan notification callback function
1405 * @param[in] NONE
1406 * @return Error code.
1407 * @author
1408 * @date
1409 * @version 1.0
1410 */
2b05df55 1411static s32 Handle_ScanDone(tstrWILC_WFIDrv *drvHandler, tenuScanEvent enuEvent)
c5c77ba1 1412{
fb4ec9ca 1413 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
1414
1415 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
1416
1417
63d03e47 1418 u8 u8abort_running_scan;
c5c77ba1
JK
1419 tstrWID strWID;
1420
1421
1422 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
1423
1424 /*BugID_4978*/
1425 /*Ask FW to abort the running scan, if any*/
1426 if (enuEvent == SCAN_EVENT_ABORTED) {
1427 PRINT_D(GENERIC_DBG, "Abort running scan\n");
1428 u8abort_running_scan = 1;
d85f5326 1429 strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN;
c5c77ba1 1430 strWID.enuWIDtype = WID_CHAR;
ca356ada 1431 strWID.ps8WidVal = (s8 *)&u8abort_running_scan;
576917ad 1432 strWID.s32ValueSize = sizeof(char);
c5c77ba1
JK
1433
1434 /*Sending Cfg*/
72ed4dc7 1435 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
1436 if (s32Error != WILC_SUCCESS) {
1437 PRINT_ER("Failed to set abort running scan\n");
1438 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1439 }
1440 WILC_CATCH(s32Error)
1441 {
1442 }
1443 }
1444
1445 if (pstrWFIDrv == NULL) {
1446 PRINT_ER("Driver handler is NULL\n");
1447 return s32Error;
1448 }
1449
1450 /*if there is an ongoing scan request*/
1451 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
b1413b60 1452 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
c5c77ba1
JK
1453 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1454 /*delete current scan request*/
1455 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1456 }
1457
1458 return s32Error;
1459}
1460
1461/**
1462 * @brief Handle_Connect
1463 * @details Sending config packet to firmware to starting connection
1464 * @param[in] tstrHostIFconnectAttr* pstrHostIFconnectAttr
1465 * @return Error code.
1466 * @author
1467 * @date
1468 * @version 1.0
1469 */
63d03e47 1470u8 u8ConnectedSSID[6] = {0};
2b05df55 1471static s32 Handle_Connect(tstrWILC_WFIDrv *drvHandler, tstrHostIFconnectAttr *pstrHostIFconnectAttr)
c5c77ba1
JK
1472{
1473 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
fb4ec9ca 1474 s32 s32Error = WILC_SUCCESS;
c5c77ba1 1475 tstrWID strWIDList[8];
4e4467fd 1476 u32 u32WidsCount = 0, dummyval = 0;
c5c77ba1
JK
1477 /* char passphrase[] = "12345678"; */
1478 #ifndef CONNECT_DIRECT
fb4ec9ca 1479 s32 s32Err = WILC_SUCCESS;
4e4467fd 1480 u32 i;
63d03e47 1481 u8 u8bssDscListIndex;
b1413b60 1482 wid_site_survey_reslts_s *pstrSurveyResults = NULL;
c5c77ba1 1483 #else
63d03e47 1484 u8 *pu8CurrByte = NULL;
c5c77ba1
JK
1485 /*Bug4218: Parsing Join Param*/
1486 #ifdef WILC_PARSE_SCAN_IN_HOST
1487 tstrJoinBssParam *ptstrJoinBssParam;
1488 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1489
1490 #endif
1491
1492 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1493
1494 #ifndef CONNECT_DIRECT
2cc46837
CL
1495 memset(gapu8RcvdSurveyResults[0], 0, MAX_SURVEY_RESULT_FRAG_SIZE);
1496 memset(gapu8RcvdSurveyResults[1], 0, MAX_SURVEY_RESULT_FRAG_SIZE);
c5c77ba1
JK
1497
1498
1499 PRINT_D(HOSTINF_DBG, "Getting site survey results\n");
218dc407 1500 s32Err = host_int_get_site_survey_results(pstrWFIDrv,
c5c77ba1
JK
1501 gapu8RcvdSurveyResults,
1502 MAX_SURVEY_RESULT_FRAG_SIZE);
1503 if (s32Err) {
1504 PRINT_ER("Failed to get site survey results\n");
1505 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1506
1507 }
1508 s32Err = ParseSurveyResults(gapu8RcvdSurveyResults, &pstrSurveyResults,
1509 &pstrWFIDrv->u32SurveyResultsCount);
1510
1511
1512 if (s32Err == WILC_SUCCESS) {
1513 /* use the parsed info in pstrSurveyResults, then deallocate it */
1514 PRINT_D(HOSTINF_DBG, "Copying site survey results in global structure, then deallocate\n");
1515 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
d00d2ba3 1516 memcpy(&pstrWFIDrv->astrSurveyResults[i], &pstrSurveyResults[i],
c5c77ba1
JK
1517 sizeof(wid_site_survey_reslts_s));
1518 }
1519
1520 DeallocateSurveyResults(pstrSurveyResults);
1521 } else {
1522 WILC_ERRORREPORT(s32Error, WILC_FAIL);
03b2d5e7 1523 PRINT_ER("ParseSurveyResults() Error(%d)\n", s32Err);
c5c77ba1
JK
1524 }
1525
1526
1527 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
1a646e7e 1528 if (memcmp(pstrWFIDrv->astrSurveyResults[i].SSID,
c5c77ba1
JK
1529 pstrHostIFconnectAttr->pu8ssid,
1530 pstrHostIFconnectAttr->ssidLen) == 0) {
1531 PRINT_INFO(HOSTINF_DBG, "Network with required SSID is found %s\n", pstrHostIFconnectAttr->pu8ssid);
1532 if (pstrHostIFconnectAttr->pu8bssid == NULL) {
1533 /* BSSID is not passed from the user, so decision of matching
1534 * is done by SSID only */
1535 PRINT_INFO(HOSTINF_DBG, "BSSID is not passed from the user\n");
1536 break;
1537 } else {
1538 /* BSSID is also passed from the user, so decision of matching
1539 * should consider also this passed BSSID */
1540
1a646e7e 1541 if (memcmp(pstrWFIDrv->astrSurveyResults[i].BSSID,
c5c77ba1
JK
1542 pstrHostIFconnectAttr->pu8bssid,
1543 6) == 0) {
1544 PRINT_INFO(HOSTINF_DBG, "BSSID is passed from the user and matched\n");
1545 break;
1546 }
1547 }
1548 }
1549 }
1550
1551 if (i < pstrWFIDrv->u32SurveyResultsCount) {
1552 u8bssDscListIndex = i;
1553
03b2d5e7 1554 PRINT_INFO(HOSTINF_DBG, "Connecting to network of Bss Idx%d and SSID %s and channel%d\n",
c5c77ba1
JK
1555 u8bssDscListIndex, pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].SSID,
1556 pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].Channel);
1557
1558 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1559
1560 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
dc0ad74b 1561 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = WILC_MALLOC(6);
d00d2ba3 1562 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
c5c77ba1
JK
1563 }
1564
1565 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1566 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
dc0ad74b 1567 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1);
d00d2ba3 1568 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
c5c77ba1
JK
1569 pstrHostIFconnectAttr->ssidLen);
1570 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1571 }
1572
1573 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1574 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
dc0ad74b 1575 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
d00d2ba3 1576 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
c5c77ba1
JK
1577 pstrHostIFconnectAttr->IEsLen);
1578 }
1579
1580 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1581 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1582 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1583 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1584
1585
1586 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1587 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1588 {
1589 /* IEs to be inserted in Association Request */
1590 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1591 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1592 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1593 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1594 u32WidsCount++;
1595 }
d85f5326 1596 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
c5c77ba1 1597 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
576917ad 1598 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
ca356ada 1599 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
c5c77ba1
JK
1600 u32WidsCount++;
1601
1602 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1603
d85f5326 1604 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
c5c77ba1 1605 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
576917ad 1606 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
ca356ada 1607 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
c5c77ba1
JK
1608 u32WidsCount++;
1609
1610 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1611 /*
d85f5326 1612 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
c5c77ba1
JK
1613 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1614 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
ca356ada 1615 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
c5c77ba1
JK
1616 * u32WidsCount++;
1617 */
1618
d85f5326 1619 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ;
c5c77ba1 1620 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
576917ad 1621 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
ca356ada 1622 strWIDList[u32WidsCount].ps8WidVal = (s8 *)&u8bssDscListIndex;
c5c77ba1
JK
1623 u32WidsCount++;
1624
c5c77ba1
JK
1625 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1626 * firmware at chip reset when processing the WIDs of the Connect Request.
1627 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1628 /* ////////////////////// */
1629 gu32WidConnRstHack = 0;
1630 /* ////////////////////// */
c5c77ba1 1631
72ed4dc7 1632 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
c5c77ba1
JK
1633 if (s32Error) {
1634 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1635 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
1636 } else {
1637 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1638 }
1639
1640 } else {
1641 PRINT_ER("Required BSSID not found\n");
1642 WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
1643 }
1644
1645 #else
1646
1647 /* if we try to connect to an already connected AP then discard the request */
1648
1a646e7e 1649 if (memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
c5c77ba1
JK
1650
1651 s32Error = WILC_SUCCESS;
1652 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1653 return s32Error;
1654 }
1655
1656 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1657
1658 /*Bug4218: Parsing Join Param*/
1659 #ifdef WILC_PARSE_SCAN_IN_HOST
1660 ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams;
1661 if (ptstrJoinBssParam == NULL) {
1662 PRINT_ER("Required BSSID not found\n");
1663 WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
1664 }
1665 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1666
c5c77ba1 1667 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
dc0ad74b 1668 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = WILC_MALLOC(6);
d00d2ba3 1669 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
c5c77ba1
JK
1670 }
1671
1672 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1673 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
dc0ad74b 1674 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1);
d00d2ba3 1675 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
c5c77ba1
JK
1676 pstrHostIFconnectAttr->ssidLen);
1677 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1678 }
1679
1680 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1681 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
dc0ad74b 1682 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
d00d2ba3 1683 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
c5c77ba1
JK
1684 pstrHostIFconnectAttr->IEsLen);
1685 }
1686
1687 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1688 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1689 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1690 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1691
1692 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
1693 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
4e4467fd 1694 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
ca356ada 1695 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
c5c77ba1
JK
1696 u32WidsCount++;
1697
1698 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
1699 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
4e4467fd 1700 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
ca356ada 1701 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
c5c77ba1
JK
1702 u32WidsCount++;
1703
1704 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
1705 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
4e4467fd 1706 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
ca356ada 1707 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
c5c77ba1
JK
1708 u32WidsCount++;
1709
1710 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1711 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1712 {
1713 /* IEs to be inserted in Association Request */
1714 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1715 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1716 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1717 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1718 u32WidsCount++;
1719
1720 /*BugID_5137*/
1a646e7e 1721 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
c5c77ba1
JK
1722
1723 gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1724 gu8FlushedInfoElemAsoc = WILC_MALLOC(gu32FlushedInfoElemAsocSize);
1725 memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1726 gu32FlushedInfoElemAsocSize);
1727 }
1728 }
d85f5326 1729 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
c5c77ba1 1730 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
576917ad 1731 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
ca356ada 1732 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
c5c77ba1
JK
1733 u32WidsCount++;
1734
1735 /*BugID_5137*/
1a646e7e 1736 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
c5c77ba1
JK
1737 gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security;
1738
1739 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1740
1741
d85f5326 1742 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
c5c77ba1 1743 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
576917ad 1744 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
ca356ada 1745 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
c5c77ba1
JK
1746 u32WidsCount++;
1747
1748 /*BugID_5137*/
1a646e7e 1749 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
63d03e47 1750 gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type;
c5c77ba1
JK
1751
1752 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1753 /*
d85f5326 1754 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
c5c77ba1
JK
1755 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1756 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
ca356ada 1757 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
c5c77ba1
JK
1758 * u32WidsCount++;
1759 */
1760
1761 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1762 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
1763
1764
1765#ifndef WILC_PARSE_SCAN_IN_HOST
d85f5326 1766 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
c5c77ba1
JK
1767 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1768 strWIDList[u32WidsCount].s32ValueSize = MAX_SSID_LEN + 7;
1769 strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize);
1770
2b9d5b48 1771 if (strWIDList[u32WidsCount].ps8WidVal == NULL)
c5c77ba1 1772 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
c5c77ba1
JK
1773
1774 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1775
1776 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
d00d2ba3 1777 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
c5c77ba1
JK
1778 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1779 }
1780 pu8CurrByte += MAX_SSID_LEN;
1781 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1782 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1783 } else {
1784 PRINT_ER("Channel out of range\n");
1785 *(pu8CurrByte++) = 0xFF;
1786 }
2b9d5b48 1787 if (pstrHostIFconnectAttr->pu8bssid != NULL)
d00d2ba3 1788 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
c5c77ba1
JK
1789 pu8CurrByte += 6;
1790
1791 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1792 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1793
1794 #else
1795
d85f5326 1796 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
c5c77ba1
JK
1797 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1798
1799 /*Sending NoA attributes during connection*/
1800 strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */
1801 strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize);
1802
1803 /*BugID_5137*/
1a646e7e 1804 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
c5c77ba1
JK
1805 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize;
1806 gu8FlushedJoinReq = WILC_MALLOC(gu32FlushedJoinReqSize);
1807 }
2b9d5b48 1808 if (strWIDList[u32WidsCount].ps8WidVal == NULL)
c5c77ba1 1809 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
c5c77ba1
JK
1810
1811 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1812
1813
1814 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
d00d2ba3 1815 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
c5c77ba1
JK
1816 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1817 }
1818 pu8CurrByte += MAX_SSID_LEN;
1819
1820 /* BSS type*/
1821 *(pu8CurrByte++) = INFRASTRUCTURE;
1822 /* Channel*/
1823 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1824 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1825 } else {
1826 PRINT_ER("Channel out of range\n");
1827 *(pu8CurrByte++) = 0xFF;
1828 }
1829 /* Cap Info*/
1830 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1831 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1832 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1833
1834 /* sa*/
2b9d5b48 1835 if (pstrHostIFconnectAttr->pu8bssid != NULL)
d00d2ba3 1836 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
c5c77ba1
JK
1837 pu8CurrByte += 6;
1838
1839 /* bssid*/
2b9d5b48 1840 if (pstrHostIFconnectAttr->pu8bssid != NULL)
d00d2ba3 1841 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
c5c77ba1
JK
1842 pu8CurrByte += 6;
1843
1844 /* Beacon Period*/
1845 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1846 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1847 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1848 /* DTIM Period*/
1849 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1850 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1851 /* Supported rates*/
d00d2ba3 1852 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
c5c77ba1
JK
1853 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1854
1855 /* wmm cap*/
1856 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1857 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1858 /* uapsd cap*/
1859 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1860
1861 /* ht cap*/
1862 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1863 /* copy this information to the user request */
1864 pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1865
1866 /* rsn found*/
1867 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1868 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1869 /* rsn group policy*/
1870 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1871 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1872 /* mode_802_11i*/
1873 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1874 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1875 /* rsn pcip policy*/
d00d2ba3 1876 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
c5c77ba1
JK
1877 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1878
1879 /* rsn auth policy*/
d00d2ba3 1880 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
c5c77ba1
JK
1881 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1882
1883 /* rsn auth policy*/
d00d2ba3 1884 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
c5c77ba1
JK
1885 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1886
1887 /*BugID_5137*/
1888 *(pu8CurrByte++) = REAL_JOIN_REQ;
1889
1890 #ifdef WILC_P2P
1891 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1892 if (ptstrJoinBssParam->u8NoaEnbaled) {
1893 PRINT_D(HOSTINF_DBG, "NOA present\n");
1894
1895 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1896 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1897 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1898 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1899
1900 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1901
1902 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1903
1904 if (ptstrJoinBssParam->u8OppEnable)
1905 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1906
1907 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1908
d00d2ba3 1909 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
c5c77ba1
JK
1910
1911 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1912
d00d2ba3 1913 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
c5c77ba1
JK
1914
1915 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1916
d00d2ba3 1917 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
c5c77ba1
JK
1918
1919 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1920
1921 } else
1922 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1923 #endif
1924
1925
1926 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1927 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1928
1929
1930 #endif /* #ifdef WILC_PARSE_SCAN_IN_HOST*/
1931 u32WidsCount++;
1932
c5c77ba1
JK
1933 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1934 * firmware at chip reset when processing the WIDs of the Connect Request.
1935 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1936 /* ////////////////////// */
1937 gu32WidConnRstHack = 0;
1938 /* ////////////////////// */
c5c77ba1
JK
1939
1940 /*BugID_5137*/
1a646e7e 1941 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
c5c77ba1 1942 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
4e4467fd 1943 gu8FlushedJoinReqDrvHandler = (u32)pstrWFIDrv;
c5c77ba1
JK
1944 }
1945
1946 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1947
1948 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
d00d2ba3 1949 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
c5c77ba1
JK
1950
1951 PRINT_D(GENERIC_DBG, "save Bssid = %x:%x:%x:%x:%x:%x\n", (pstrHostIFconnectAttr->pu8bssid[0]), (pstrHostIFconnectAttr->pu8bssid[1]), (pstrHostIFconnectAttr->pu8bssid[2]), (pstrHostIFconnectAttr->pu8bssid[3]), (pstrHostIFconnectAttr->pu8bssid[4]), (pstrHostIFconnectAttr->pu8bssid[5]));
1952 PRINT_D(GENERIC_DBG, "save bssid = %x:%x:%x:%x:%x:%x\n", (u8ConnectedSSID[0]), (u8ConnectedSSID[1]), (u8ConnectedSSID[2]), (u8ConnectedSSID[3]), (u8ConnectedSSID[4]), (u8ConnectedSSID[5]));
1953 }
1954
72ed4dc7 1955 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, (u32)pstrWFIDrv);
c5c77ba1
JK
1956 if (s32Error) {
1957 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1958 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
1959 } else {
1960 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1961 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1962 }
1963 #endif
1964
1965 WILC_CATCH(s32Error)
1966 {
1967 tstrConnectInfo strConnectInfo;
1968
8972d0fe 1969 del_timer(&pstrWFIDrv->hConnectTimer);
c5c77ba1
JK
1970
1971 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1972
2cc46837 1973 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
c5c77ba1
JK
1974
1975 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
2b9d5b48 1976 if (pstrHostIFconnectAttr->pu8bssid != NULL)
d00d2ba3 1977 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
c5c77ba1
JK
1978
1979 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1980 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
dc0ad74b 1981 strConnectInfo.pu8ReqIEs = WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
d00d2ba3 1982 memcpy(strConnectInfo.pu8ReqIEs,
c5c77ba1
JK
1983 pstrHostIFconnectAttr->pu8IEs,
1984 pstrHostIFconnectAttr->IEsLen);
1985 }
1986
1987 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1988 &strConnectInfo,
1989 MAC_DISCONNECTED,
1990 NULL,
1991 pstrHostIFconnectAttr->pvUserArg);
1992 /*Change state to idle*/
1993 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
1994 /* Deallocation */
1995 if (strConnectInfo.pu8ReqIEs != NULL) {
49188af2 1996 kfree(strConnectInfo.pu8ReqIEs);
c5c77ba1
JK
1997 strConnectInfo.pu8ReqIEs = NULL;
1998 }
1999
2000 } else {
03b2d5e7 2001 PRINT_ER("Connect callback function pointer is NULL\n");
c5c77ba1
JK
2002 }
2003 }
2004
2005 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
2006 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
2007 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
49188af2 2008 kfree(pstrHostIFconnectAttr->pu8bssid);
c5c77ba1
JK
2009 pstrHostIFconnectAttr->pu8bssid = NULL;
2010 }
2011
2012 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
2013 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
49188af2 2014 kfree(pstrHostIFconnectAttr->pu8ssid);
c5c77ba1
JK
2015 pstrHostIFconnectAttr->pu8ssid = NULL;
2016 }
2017
2018 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
2019 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
49188af2 2020 kfree(pstrHostIFconnectAttr->pu8IEs);
c5c77ba1
JK
2021 pstrHostIFconnectAttr->pu8IEs = NULL;
2022 }
2023
2b9d5b48 2024 if (pu8CurrByte != NULL)
49188af2 2025 kfree(pu8CurrByte);
c5c77ba1
JK
2026 return s32Error;
2027}
2028
2029/**
2030 * @brief Handle_FlushConnect
2031 * @details Sending config packet to firmware to flush an old connection
2032 * after switching FW from station one to hybrid one
2033 * @param[in] void * drvHandler
2034 * @return Error code.
2035 * @author Amr Abdel-Moghny
2036 * @date 19 DEC 2013
2037 * @version 8.0
2038 */
2039
2b05df55 2040static s32 Handle_FlushConnect(tstrWILC_WFIDrv *drvHandler)
c5c77ba1 2041{
fb4ec9ca 2042 s32 s32Error = WILC_SUCCESS;
c5c77ba1 2043 tstrWID strWIDList[5];
4e4467fd 2044 u32 u32WidsCount = 0;
63d03e47 2045 u8 *pu8CurrByte = NULL;
c5c77ba1
JK
2046
2047
2048 /* IEs to be inserted in Association Request */
2049 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
2050 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
2051 strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc;
2052 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize;
2053 u32WidsCount++;
2054
d85f5326 2055 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
c5c77ba1 2056 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
576917ad 2057 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
ca356ada 2058 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode));
c5c77ba1
JK
2059 u32WidsCount++;
2060
2061
2062
d85f5326 2063 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
c5c77ba1 2064 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
576917ad 2065 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
ca356ada 2066 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType);
c5c77ba1
JK
2067 u32WidsCount++;
2068
2069
2070 #ifdef WILC_PARSE_SCAN_IN_HOST
d85f5326 2071 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
c5c77ba1
JK
2072 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
2073 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize;
ca356ada 2074 strWIDList[u32WidsCount].ps8WidVal = (s8 *)gu8FlushedJoinReq;
c5c77ba1
JK
2075 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
2076
2077 pu8CurrByte += FLUSHED_BYTE_POS;
2078 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
2079
2080 u32WidsCount++;
2081
2082 #endif
2083
72ed4dc7 2084 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false, gu8FlushedJoinReqDrvHandler);
c5c77ba1
JK
2085 if (s32Error) {
2086 PRINT_ER("Handle_Flush_Connect()] failed to send config packet\n");
2087 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
2088 }
2089
2090 WILC_CATCH(s32Error)
2091 {
2092
2093 }
2094
2095 return s32Error;
2096}
2097
2098/**
2099 * @brief Handle_ConnectTimeout
2100 * @details Call connect notification callback function indicating connection failure
2101 * @param[in] NONE
2102 * @return Error code.
2103 * @author
2104 * @date
2105 * @version 1.0
2106 */
2b05df55 2107static s32 Handle_ConnectTimeout(tstrWILC_WFIDrv *drvHandler)
c5c77ba1 2108{
fb4ec9ca 2109 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
2110 tstrConnectInfo strConnectInfo;
2111 tstrWID strWID;
d85f5326 2112 u16 u16DummyReasonCode = 0;
c5c77ba1
JK
2113 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
2114
2115 if (pstrWFIDrv == NULL) {
2116 PRINT_ER("Driver handler is NULL\n");
2117 return s32Error;
2118 }
2119
2120 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2121
72ed4dc7 2122 gbScanWhileConnected = false;
c5c77ba1
JK
2123
2124
2cc46837 2125 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
c5c77ba1
JK
2126
2127
2128 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
2129 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2130 * WID_DISCONNECT} */
2131 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2132 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
d00d2ba3 2133 memcpy(strConnectInfo.au8bssid,
c5c77ba1
JK
2134 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2135 }
2136
2137 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2138 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
dc0ad74b 2139 strConnectInfo.pu8ReqIEs = WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
d00d2ba3 2140 memcpy(strConnectInfo.pu8ReqIEs,
c5c77ba1
JK
2141 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2142 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2143 }
2144
2145 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2146 &strConnectInfo,
2147 MAC_DISCONNECTED,
2148 NULL,
2149 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2150
2151 /* Deallocation of strConnectInfo.pu8ReqIEs */
2152 if (strConnectInfo.pu8ReqIEs != NULL) {
49188af2 2153 kfree(strConnectInfo.pu8ReqIEs);
c5c77ba1
JK
2154 strConnectInfo.pu8ReqIEs = NULL;
2155 }
2156 } else {
03b2d5e7 2157 PRINT_ER("Connect callback function pointer is NULL\n");
c5c77ba1
JK
2158 }
2159
2160 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2161 * WID_DISCONNECT} */
d85f5326 2162 strWID.u16WIDid = (u16)WID_DISCONNECT;
c5c77ba1 2163 strWID.enuWIDtype = WID_CHAR;
ca356ada 2164 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
576917ad 2165 strWID.s32ValueSize = sizeof(char);
c5c77ba1
JK
2166
2167 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2168
72ed4dc7 2169 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
2b9d5b48 2170 if (s32Error)
c5c77ba1 2171 PRINT_ER("Failed to send dissconect config packet\n");
c5c77ba1
JK
2172
2173 /* Deallocation of the Saved Connect Request in the global Handle */
2174 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2175 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
49188af2 2176 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
c5c77ba1
JK
2177 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2178 }
2179
2180 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
49188af2 2181 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
c5c77ba1
JK
2182 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2183 }
2184
2185 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2186 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
49188af2 2187 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
c5c77ba1
JK
2188 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2189 }
2190
2cc46837 2191 memset(u8ConnectedSSID, 0, ETH_ALEN);
c5c77ba1
JK
2192 /*BugID_5213*/
2193 /*Freeing flushed join request params on connect timeout*/
4e4467fd 2194 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
49188af2 2195 kfree(gu8FlushedJoinReq);
c5c77ba1
JK
2196 gu8FlushedJoinReq = NULL;
2197 }
4e4467fd 2198 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
49188af2 2199 kfree(gu8FlushedInfoElemAsoc);
c5c77ba1
JK
2200 gu8FlushedInfoElemAsoc = NULL;
2201 }
2202
2203 return s32Error;
2204}
2205
2206/**
2207 * @brief Handle_RcvdNtwrkInfo
2208 * @details Handling received network information
2209 * @param[in] tstrRcvdNetworkInfo* pstrRcvdNetworkInfo
2210 * @return Error code.
2211 * @author
2212 * @date
2213 * @version 1.0
2214 */
2b05df55 2215static s32 Handle_RcvdNtwrkInfo(tstrWILC_WFIDrv *drvHandler, tstrRcvdNetworkInfo *pstrRcvdNetworkInfo)
c5c77ba1 2216{
4e4467fd 2217 u32 i;
72ed4dc7 2218 bool bNewNtwrkFound;
c5c77ba1
JK
2219
2220
2221
fb4ec9ca 2222 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
2223 tstrNetworkInfo *pstrNetworkInfo = NULL;
2224 void *pJoinParams = NULL;
2225
2226 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2227
2228
2229
72ed4dc7 2230 bNewNtwrkFound = true;
c5c77ba1
JK
2231 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
2232
2233 /*if there is a an ongoing scan request*/
2234 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2235 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
2236 ParseNetworkInfo(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
2237 if ((pstrNetworkInfo == NULL)
b1413b60 2238 || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
c5c77ba1
JK
2239 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
2240 }
2241
2242 /* check whether this network is discovered before */
2243 for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
2244
2245 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
2246 (pstrNetworkInfo->au8bssid != NULL)) {
1a646e7e 2247 if (memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
c5c77ba1
JK
2248 pstrNetworkInfo->au8bssid, 6) == 0) {
2249 if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
2250 /*we have already found this network with better rssi, so keep the old cached one and don't
2251 * send anything to the upper layer */
2252 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
2253 goto done;
2254 } else {
2255 /* here the same already found network is found again but with a better rssi, so just update
2256 * the rssi for this cached network and send this updated network to the upper layer but
2257 * don't add a new record for it */
2258 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
72ed4dc7 2259 bNewNtwrkFound = false;
c5c77ba1
JK
2260 break;
2261 }
2262 }
2263 }
2264 }
2265
72ed4dc7 2266 if (bNewNtwrkFound == true) {
c5c77ba1
JK
2267 /* here it is confirmed that it is a new discovered network,
2268 * so add its record then call the User CallBack function */
2269
2270 PRINT_D(HOSTINF_DBG, "New network found\n");
2271
2272 if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
2273 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
2274
2275 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
2276 && (pstrNetworkInfo->au8bssid != NULL)) {
d00d2ba3 2277 memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
c5c77ba1
JK
2278 pstrNetworkInfo->au8bssid, 6);
2279
2280 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++;
2281
72ed4dc7 2282 pstrNetworkInfo->bNewNetwork = true;
c5c77ba1
JK
2283 /*Bug4218: Parsing Join Param*/
2284 /* add new BSS to JoinBssTable */
2285 #ifdef WILC_PARSE_SCAN_IN_HOST
2286 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
2287 #endif /*WILC_PARSE_SCAN_IN_HOST*/
2288
2289 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2290 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid,
2291 pJoinParams);
2292
2293
2294 }
2295 } else {
03b2d5e7 2296 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
c5c77ba1
JK
2297 }
2298 } else {
72ed4dc7 2299 pstrNetworkInfo->bNewNetwork = false;
c5c77ba1
JK
2300 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2301 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2302 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2303 }
2304 }
2305
2306
2307 WILC_CATCH(s32Error)
2308 {
2309
2310 }
2311
2312done:
2313 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2314 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
49188af2 2315 kfree(pstrRcvdNetworkInfo->pu8Buffer);
c5c77ba1
JK
2316 pstrRcvdNetworkInfo->pu8Buffer = NULL;
2317 }
2318
2319 /*free structure allocated*/
b1413b60 2320 if (pstrNetworkInfo != NULL) {
c5c77ba1 2321 DeallocateNetworkInfo(pstrNetworkInfo);
b1413b60 2322 pstrNetworkInfo = NULL;
c5c77ba1
JK
2323 }
2324
2325 return s32Error;
2326}
2327
2328/**
2329 * @brief Handle_RcvdGnrlAsyncInfo
2330 * @details Handling received asynchrous general network information
2331 * @param[in] tstrRcvdGnrlAsyncInfo* pstrRcvdGnrlAsyncInfo
2332 * @return Error code.
2333 * @author
2334 * @date
2335 * @version 1.0
2336 */
2b05df55 2337static s32 Handle_RcvdGnrlAsyncInfo(tstrWILC_WFIDrv *drvHandler, tstrRcvdGnrlAsyncInfo *pstrRcvdGnrlAsyncInfo)
c5c77ba1
JK
2338{
2339 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2340 /* which carries only 1 WID which have WID ID = WID_STATUS */
fb4ec9ca 2341 s32 s32Error = WILC_SUCCESS;
63d03e47
GKH
2342 u8 u8MsgType = 0;
2343 u8 u8MsgID = 0;
d85f5326
CL
2344 u16 u16MsgLen = 0;
2345 u16 u16WidID = (u16)WID_NIL;
63d03e47
GKH
2346 u8 u8WidLen = 0;
2347 u8 u8MacStatus;
2348 u8 u8MacStatusReasonCode;
2349 u8 u8MacStatusAdditionalInfo;
c5c77ba1
JK
2350 tstrConnectInfo strConnectInfo;
2351 tstrDisconnectNotifInfo strDisconnectNotifInfo;
fb4ec9ca 2352 s32 s32Err = WILC_SUCCESS;
c5c77ba1 2353 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
78c87591 2354
2b9d5b48 2355 if (pstrWFIDrv == NULL)
c5c77ba1 2356 PRINT_ER("Driver handler is NULL\n");
c5c77ba1
JK
2357 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
2358 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
2359
2360 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
2361 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) ||
2362 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2363 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
b1413b60 2364 (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
c5c77ba1
JK
2365 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
2366 }
2367
2368 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
2369
2370 /* Check whether the received message type is 'I' */
2371 if ('I' != u8MsgType) {
2372 PRINT_ER("Received Message format incorrect.\n");
2373 WILC_ERRORREPORT(s32Error, WILC_FAIL);
2374 }
2375
2376 /* Extract message ID */
2377 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
2378
2379 /* Extract message Length */
2380 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
2381
2382 /* Extract WID ID [expected to be = WID_STATUS] */
2383 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
2384
2385 /* Extract WID Length [expected to be = 1] */
2386 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
2387
2388 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2389 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
2390 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
2391 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
2392 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2393 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2394 /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */
4e4467fd 2395 u32 u32RcvdAssocRespInfoLen;
c5c77ba1
JK
2396 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
2397
2398 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2399
2cc46837 2400 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
c5c77ba1
JK
2401
2402 if (u8MacStatus == MAC_CONNECTED) {
2cc46837 2403 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
c5c77ba1 2404
218dc407 2405 host_int_get_assoc_res_info(pstrWFIDrv,
c5c77ba1
JK
2406 gapu8RcvdAssocResp,
2407 MAX_ASSOC_RESP_FRAME_SIZE,
2408 &u32RcvdAssocRespInfoLen);
2409
2410 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
2411
2412 if (u32RcvdAssocRespInfoLen != 0) {
2413
2414 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
2415 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
2416 &pstrConnectRespInfo);
2417 if (s32Err) {
03b2d5e7 2418 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
c5c77ba1
JK
2419 } else {
2420 /* use the necessary parsed Info from the Received Association Response */
2421 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
2422
2423 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
2424 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
2425 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
2426 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
2427
2428
dc0ad74b 2429 strConnectInfo.pu8RespIEs = WILC_MALLOC(pstrConnectRespInfo->u16RespIEsLen);
d00d2ba3 2430 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
c5c77ba1
JK
2431 pstrConnectRespInfo->u16RespIEsLen);
2432 }
2433 }
2434
2435 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2436 if (pstrConnectRespInfo != NULL) {
2437 DeallocateAssocRespInfo(pstrConnectRespInfo);
2438 pstrConnectRespInfo = NULL;
2439 }
2440 }
2441 }
2442 }
2443
2444 /* The station has just received mac status and it also received assoc. response which
2445 * it was waiting for.
2446 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2447 if ((u8MacStatus == MAC_CONNECTED) &&
2448 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
03b2d5e7 2449 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
2cc46837 2450 memset(u8ConnectedSSID, 0, ETH_ALEN);
c5c77ba1
JK
2451
2452 } else if (u8MacStatus == MAC_DISCONNECTED) {
2453 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
2cc46837 2454 memset(u8ConnectedSSID, 0, ETH_ALEN);
c5c77ba1
JK
2455 }
2456
2457 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2458 /* through a structure of type tstrConnectRespInfo */
2459 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2460 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
d00d2ba3 2461 memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
c5c77ba1
JK
2462
2463 if ((u8MacStatus == MAC_CONNECTED) &&
2464 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
d00d2ba3 2465 memcpy(pstrWFIDrv->au8AssociatedBSSID,
c5c77ba1
JK
2466 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
2467 }
2468 }
2469
2470
2471 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2472 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
dc0ad74b 2473 strConnectInfo.pu8ReqIEs = WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
d00d2ba3 2474 memcpy(strConnectInfo.pu8ReqIEs,
c5c77ba1
JK
2475 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2476 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2477 }
2478
2479
8972d0fe 2480 del_timer(&pstrWFIDrv->hConnectTimer);
c5c77ba1
JK
2481 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2482 &strConnectInfo,
2483 u8MacStatus,
2484 NULL,
2485 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2486
2487
2488 /* if received mac status is MAC_CONNECTED and
2489 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2490 * else change state to IDLE */
2491 if ((u8MacStatus == MAC_CONNECTED) &&
2492 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2493 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2494
218dc407 2495 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
c5c77ba1
JK
2496 #endif
2497
2498 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
2499 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED;
2500
2501 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2502 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
72ed4dc7 2503 g_obtainingIP = true;
9eb06643
GKH
2504 mod_timer(&hDuringIpTimer,
2505 jiffies + msecs_to_jiffies(10000));
c5c77ba1
JK
2506 #endif
2507
2508 #ifdef WILC_PARSE_SCAN_IN_HOST
2509 /* open a BA session if possible */
2510 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
2511
2512 #endif
2513
2514 /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
2515 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2516 } else {
2517 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
2518 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
72ed4dc7 2519 gbScanWhileConnected = false;
c5c77ba1
JK
2520 }
2521
2522 /* Deallocation */
2523 if (strConnectInfo.pu8RespIEs != NULL) {
49188af2 2524 kfree(strConnectInfo.pu8RespIEs);
c5c77ba1
JK
2525 strConnectInfo.pu8RespIEs = NULL;
2526 }
2527
2528 if (strConnectInfo.pu8ReqIEs != NULL) {
49188af2 2529 kfree(strConnectInfo.pu8ReqIEs);
c5c77ba1
JK
2530 strConnectInfo.pu8ReqIEs = NULL;
2531 }
2532
2533
2534 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2535 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
49188af2 2536 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
c5c77ba1
JK
2537 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2538 }
2539
2540 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
49188af2 2541 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
c5c77ba1
JK
2542 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2543 }
2544
2545 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2546 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
49188af2 2547 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
c5c77ba1
JK
2548 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2549 }
2550
2551 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2552 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) {
2553 /* Disassociation or Deauthentication frame has been received */
2554 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
2555
2cc46837 2556 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
c5c77ba1
JK
2557
2558 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
03b2d5e7 2559 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
8972d0fe 2560 del_timer(&pstrWFIDrv->hScanTimer);
c5c77ba1
JK
2561 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2562 }
2563
2564 strDisconnectNotifInfo.u16reason = 0;
2565 strDisconnectNotifInfo.ie = NULL;
2566 strDisconnectNotifInfo.ie_len = 0;
2567
2568 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2569 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2570
72ed4dc7 2571 g_obtainingIP = false;
218dc407 2572 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
c5c77ba1
JK
2573 #endif
2574
2575 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2576 NULL,
2577 0,
2578 &strDisconnectNotifInfo,
2579 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2580
2581 } else {
03b2d5e7 2582 PRINT_ER("Connect result callback function is NULL\n");
c5c77ba1
JK
2583 }
2584
2cc46837 2585 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
c5c77ba1
JK
2586
2587
2588 /* Deallocation */
2589
2590 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2591 * should be deallocated here */
2592 /*
2593 * if(strDisconnectNotifInfo.ie != NULL)
2594 * {
49188af2 2595 * kfree(strDisconnectNotifInfo.ie);
c5c77ba1
JK
2596 * strDisconnectNotifInfo.ie = NULL;
2597 * }
2598 */
2599
2600 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2601 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
49188af2 2602 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
c5c77ba1
JK
2603 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2604 }
2605
2606 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
49188af2 2607 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
c5c77ba1
JK
2608 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2609 }
2610
2611 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2612 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
49188af2 2613 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
c5c77ba1
JK
2614 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2615 }
2616
2617 /*BugID_5213*/
2618 /*Freeing flushed join request params on receiving*/
2619 /*MAC_DISCONNECTED while connected*/
4e4467fd 2620 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
49188af2 2621 kfree(gu8FlushedJoinReq);
c5c77ba1
JK
2622 gu8FlushedJoinReq = NULL;
2623 }
4e4467fd 2624 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
49188af2 2625 kfree(gu8FlushedInfoElemAsoc);
c5c77ba1
JK
2626 gu8FlushedInfoElemAsoc = NULL;
2627 }
2628
2629 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
72ed4dc7 2630 gbScanWhileConnected = false;
c5c77ba1
JK
2631
2632 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2633 (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
2634 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
03b2d5e7 2635 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
c5c77ba1 2636 /*Abort the running scan*/
8972d0fe 2637 del_timer(&pstrWFIDrv->hScanTimer);
2b9d5b48 2638 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult)
2b05df55 2639 Handle_ScanDone(pstrWFIDrv, SCAN_EVENT_ABORTED);
c5c77ba1 2640
c5c77ba1
JK
2641 }
2642
2643 }
2644
2645 WILC_CATCH(s32Error)
2646 {
2647
2648 }
2649
2650 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2651 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
49188af2 2652 kfree(pstrRcvdGnrlAsyncInfo->pu8Buffer);
c5c77ba1
JK
2653 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
2654 }
2655
2656 return s32Error;
2657}
2658
2659/**
2660 * @brief Handle_Key
2661 * @details Sending config packet to firmware to set key
2662 * @param[in] tstrHostIFkeyAttr* pstrHostIFkeyAttr
2663 * @return Error code.
2664 * @author
2665 * @date
2666 * @version 1.0
2667 */
2b05df55 2668static int Handle_Key(tstrWILC_WFIDrv *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr)
c5c77ba1 2669{
fb4ec9ca 2670 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
2671 tstrWID strWID;
2672 #ifdef WILC_AP_EXTERNAL_MLME
2673 tstrWID strWIDList[5];
2674 #endif
63d03e47
GKH
2675 u8 i;
2676 u8 *pu8keybuf;
ca356ada
CL
2677 s8 s8idxarray[1];
2678 s8 ret = 0;
c5c77ba1
JK
2679 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2680
2681
2682 switch (pstrHostIFkeyAttr->enuKeyType) {
2683
2684
2685 case WEP:
2686
2687#ifdef WILC_AP_EXTERNAL_MLME
2688 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2689
2690 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2691 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
d85f5326 2692 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
c5c77ba1 2693 strWIDList[0].enuWIDtype = WID_CHAR;
576917ad 2694 strWIDList[0].s32ValueSize = sizeof(char);
ca356ada 2695 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode));
c5c77ba1
JK
2696
2697 strWIDList[1].u16WIDid = WID_AUTH_TYPE;
2698 strWIDList[1].enuWIDtype = WID_CHAR;
576917ad 2699 strWIDList[1].s32ValueSize = sizeof(char);
ca356ada 2700 strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type));
c5c77ba1 2701
d85f5326 2702 strWIDList[2].u16WIDid = (u16)WID_KEY_ID;
c5c77ba1
JK
2703 strWIDList[2].enuWIDtype = WID_CHAR;
2704
ca356ada 2705 strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
576917ad 2706 strWIDList[2].s32ValueSize = sizeof(char);
c5c77ba1
JK
2707
2708
dc0ad74b 2709 pu8keybuf = WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
c5c77ba1
JK
2710
2711
2712 if (pu8keybuf == NULL) {
2713 PRINT_ER("No buffer to send Key\n");
2714 return -1;
2715 }
2716
d00d2ba3 2717 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
c5c77ba1
JK
2718 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2719
2720
49188af2 2721 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
c5c77ba1 2722
d85f5326 2723 strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE;
c5c77ba1
JK
2724 strWIDList[3].enuWIDtype = WID_STR;
2725 strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
ca356ada 2726 strWIDList[3].ps8WidVal = (s8 *)pu8keybuf;
c5c77ba1
JK
2727
2728
72ed4dc7 2729 s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, true, (u32)pstrWFIDrv);
49188af2 2730 kfree(pu8keybuf);
c5c77ba1
JK
2731
2732
2733 }
2734#endif
2735
2736 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2737 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
dc0ad74b 2738 pu8keybuf = WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2);
c5c77ba1
JK
2739 if (pu8keybuf == NULL) {
2740 PRINT_ER("No buffer to send Key\n");
2741 return -1;
2742 }
2743 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2744
d00d2ba3 2745 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
c5c77ba1 2746
d00d2ba3 2747 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
c5c77ba1
JK
2748 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2749
49188af2 2750 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
c5c77ba1 2751
d85f5326 2752 strWID.u16WIDid = (u16)WID_ADD_WEP_KEY;
c5c77ba1 2753 strWID.enuWIDtype = WID_STR;
ca356ada 2754 strWID.ps8WidVal = (s8 *)pu8keybuf;
c5c77ba1
JK
2755 strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2;
2756
72ed4dc7 2757 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
49188af2 2758 kfree(pu8keybuf);
c5c77ba1
JK
2759 } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) {
2760
2761 PRINT_D(HOSTINF_DBG, "Removing key\n");
d85f5326 2762 strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY;
c5c77ba1
JK
2763 strWID.enuWIDtype = WID_STR;
2764
ca356ada 2765 s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
c5c77ba1
JK
2766 strWID.ps8WidVal = s8idxarray;
2767 strWID.s32ValueSize = 1;
2768
72ed4dc7 2769 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1 2770 } else {
d85f5326 2771 strWID.u16WIDid = (u16)WID_KEY_ID;
c5c77ba1 2772 strWID.enuWIDtype = WID_CHAR;
ca356ada 2773 strWID.ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
576917ad 2774 strWID.s32ValueSize = sizeof(char);
c5c77ba1
JK
2775
2776 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
2777
72ed4dc7 2778 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1 2779 }
83383ea3 2780 up(&(pstrWFIDrv->hSemTestKeyBlock));
c5c77ba1
JK
2781 break;
2782
2783 case WPARxGtk:
2784 #ifdef WILC_AP_EXTERNAL_MLME
2785 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
dc0ad74b 2786 pu8keybuf = WILC_MALLOC(RX_MIC_KEY_MSG_LEN);
c5c77ba1
JK
2787 if (pu8keybuf == NULL) {
2788 PRINT_ER("No buffer to send RxGTK Key\n");
2789 ret = -1;
2790 goto _WPARxGtk_end_case_;
2791 }
2792
2cc46837 2793 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
c5c77ba1
JK
2794
2795
2796 /*|----------------------------------------------------------------------------|
2797 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2798 * |------------|---------|-------|------------|---------------|----------------|
2799 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2800
2801
2802
2803 if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
d00d2ba3 2804 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
c5c77ba1
JK
2805
2806
d00d2ba3 2807 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
c5c77ba1 2808
d00d2ba3 2809 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
c5c77ba1 2810
d00d2ba3 2811 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
c5c77ba1
JK
2812 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2813 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
d85f5326 2814 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
c5c77ba1 2815 strWIDList[0].enuWIDtype = WID_CHAR;
576917ad 2816 strWIDList[0].s32ValueSize = sizeof(char);
ca356ada 2817 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
c5c77ba1 2818
d85f5326 2819 strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK;
c5c77ba1 2820 strWIDList[1].enuWIDtype = WID_STR;
ca356ada 2821 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
c5c77ba1
JK
2822 strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN;
2823
72ed4dc7 2824 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true, (u32)pstrWFIDrv);
c5c77ba1 2825
49188af2 2826 kfree(pu8keybuf);
c5c77ba1
JK
2827
2828 /* ////////////////////////// */
83383ea3 2829 up(&(pstrWFIDrv->hSemTestKeyBlock));
c5c77ba1
JK
2830 /* ///////////////////////// */
2831 }
2832
2833 #endif
2834 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2835 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
2836
dc0ad74b 2837 pu8keybuf = WILC_MALLOC(RX_MIC_KEY_MSG_LEN);
c5c77ba1
JK
2838 if (pu8keybuf == NULL) {
2839 PRINT_ER("No buffer to send RxGTK Key\n");
2840 ret = -1;
2841 goto _WPARxGtk_end_case_;
2842 }
2843
2cc46837 2844 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
c5c77ba1
JK
2845
2846
2847 /*|----------------------------------------------------------------------------|
2848 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2849 * |------------|---------|-------|------------|---------------|----------------|
2850 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2851
78174ada 2852 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
d00d2ba3 2853 memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
78174ada 2854 else
03b2d5e7 2855 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
c5c77ba1 2856
d00d2ba3 2857 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
c5c77ba1 2858
d00d2ba3 2859 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
c5c77ba1 2860
d00d2ba3
CL
2861 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2862 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
c5c77ba1
JK
2863 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2864
d85f5326 2865 strWID.u16WIDid = (u16)WID_ADD_RX_GTK;
c5c77ba1 2866 strWID.enuWIDtype = WID_STR;
ca356ada 2867 strWID.ps8WidVal = (s8 *)pu8keybuf;
c5c77ba1
JK
2868 strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN;
2869
72ed4dc7 2870 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1 2871
49188af2 2872 kfree(pu8keybuf);
c5c77ba1
JK
2873
2874 /* ////////////////////////// */
83383ea3 2875 up(&(pstrWFIDrv->hSemTestKeyBlock));
c5c77ba1
JK
2876 /* ///////////////////////// */
2877 }
2878_WPARxGtk_end_case_:
49188af2
CL
2879 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2880 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq);
c5c77ba1
JK
2881 if (ret == -1)
2882 return ret;
2883
2884 break;
2885
2886 case WPAPtk:
2887 #ifdef WILC_AP_EXTERNAL_MLME
2888 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2889
2890
dc0ad74b 2891 pu8keybuf = WILC_MALLOC(PTK_KEY_MSG_LEN + 1);
c5c77ba1
JK
2892
2893
2894
2895 if (pu8keybuf == NULL) {
2896 PRINT_ER("No buffer to send PTK Key\n");
2897 ret = -1;
2898 goto _WPAPtk_end_case_;
2899
2900 }
2901
2902 /*|-----------------------------------------------------------------------------|
2903 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2904 * |----------------|------------ |--------------|----------------|---------------|
2905 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2906 |-----------------------------------------------------------------------------|*/
2907
d00d2ba3 2908 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
c5c77ba1 2909
d00d2ba3
CL
2910 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2911 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
c5c77ba1 2912 /*16 byte TK*/
d00d2ba3 2913 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
c5c77ba1
JK
2914 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2915
2916
d85f5326 2917 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
c5c77ba1 2918 strWIDList[0].enuWIDtype = WID_CHAR;
576917ad 2919 strWIDList[0].s32ValueSize = sizeof(char);
ca356ada 2920 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
c5c77ba1 2921
d85f5326 2922 strWIDList[1].u16WIDid = (u16)WID_ADD_PTK;
c5c77ba1 2923 strWIDList[1].enuWIDtype = WID_STR;
ca356ada 2924 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
c5c77ba1
JK
2925 strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1;
2926
72ed4dc7 2927 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true, (u32)pstrWFIDrv);
49188af2 2928 kfree(pu8keybuf);
c5c77ba1
JK
2929
2930 /* ////////////////////////// */
83383ea3 2931 up(&(pstrWFIDrv->hSemTestKeyBlock));
c5c77ba1
JK
2932 /* ///////////////////////// */
2933 }
2934 #endif
2935 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2936
2937
dc0ad74b 2938 pu8keybuf = WILC_MALLOC(PTK_KEY_MSG_LEN);
c5c77ba1
JK
2939
2940
2941
2942 if (pu8keybuf == NULL) {
2943 PRINT_ER("No buffer to send PTK Key\n");
2944 ret = -1;
2945 goto _WPAPtk_end_case_;
2946
2947 }
2948
2949 /*|-----------------------------------------------------------------------------|
2950 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
2951 * |----------------|------------|--------------|----------------|---------------|
2952 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
2953 |-----------------------------------------------------------------------------|*/
2954
d00d2ba3 2955 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
c5c77ba1 2956
d00d2ba3 2957 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
c5c77ba1 2958 /*16 byte TK*/
d00d2ba3 2959 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
c5c77ba1
JK
2960 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2961
2962
d85f5326 2963 strWID.u16WIDid = (u16)WID_ADD_PTK;
c5c77ba1 2964 strWID.enuWIDtype = WID_STR;
ca356ada 2965 strWID.ps8WidVal = (s8 *)pu8keybuf;
c5c77ba1
JK
2966 strWID.s32ValueSize = PTK_KEY_MSG_LEN;
2967
72ed4dc7 2968 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
49188af2 2969 kfree(pu8keybuf);
c5c77ba1
JK
2970
2971 /* ////////////////////////// */
83383ea3 2972 up(&(pstrWFIDrv->hSemTestKeyBlock));
c5c77ba1
JK
2973 /* ///////////////////////// */
2974 }
2975
2976_WPAPtk_end_case_:
49188af2 2977 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
c5c77ba1
JK
2978 if (ret == -1)
2979 return ret;
2980
2981 break;
2982
2983
2984 case PMKSA:
2985
2986 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
2987
dc0ad74b 2988 pu8keybuf = WILC_MALLOC((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1);
c5c77ba1
JK
2989 if (pu8keybuf == NULL) {
2990 PRINT_ER("No buffer to send PMKSA Key\n");
2991 return -1;
2992 }
2993
2994 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
2995
2996 for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
2997
d00d2ba3
CL
2998 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
2999 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN);
c5c77ba1
JK
3000 }
3001
d85f5326 3002 strWID.u16WIDid = (u16)WID_PMKID_INFO;
c5c77ba1 3003 strWID.enuWIDtype = WID_STR;
ca356ada 3004 strWID.ps8WidVal = (s8 *)pu8keybuf;
c5c77ba1
JK
3005 strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1;
3006
72ed4dc7 3007 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1 3008
49188af2 3009 kfree(pu8keybuf);
c5c77ba1
JK
3010 break;
3011 }
3012
3013 if (s32Error)
3014 PRINT_ER("Failed to send key config packet\n");
3015
3016
3017 return s32Error;
3018}
3019
3020
3021/**
3022 * @brief Handle_Disconnect
3023 * @details Sending config packet to firmware to disconnect
3024 * @param[in] NONE
3025 * @return NONE
3026 * @author
3027 * @date
3028 * @version 1.0
3029 */
2b05df55 3030static void Handle_Disconnect(tstrWILC_WFIDrv *drvHandler)
c5c77ba1
JK
3031{
3032 tstrWID strWID;
3033
fb4ec9ca 3034 s32 s32Error = WILC_SUCCESS;
d85f5326 3035 u16 u16DummyReasonCode = 0;
c5c77ba1
JK
3036 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3037
3038
d85f5326 3039 strWID.u16WIDid = (u16)WID_DISCONNECT;
c5c77ba1 3040 strWID.enuWIDtype = WID_CHAR;
ca356ada 3041 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
576917ad 3042 strWID.s32ValueSize = sizeof(char);
c5c77ba1
JK
3043
3044
3045
3046 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
3047
3048 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3049
72ed4dc7 3050 g_obtainingIP = false;
218dc407 3051 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
c5c77ba1
JK
3052 #endif
3053
2cc46837 3054 memset(u8ConnectedSSID, 0, ETH_ALEN);
c5c77ba1 3055
72ed4dc7 3056 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
c5c77ba1
JK
3057
3058 if (s32Error) {
3059 PRINT_ER("Failed to send dissconect config packet\n");
3060 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3061 } else {
3062 tstrDisconnectNotifInfo strDisconnectNotifInfo;
3063
2cc46837 3064 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
c5c77ba1
JK
3065
3066 strDisconnectNotifInfo.u16reason = 0;
3067 strDisconnectNotifInfo.ie = NULL;
3068 strDisconnectNotifInfo.ie_len = 0;
3069
3070 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
8972d0fe 3071 del_timer(&pstrWFIDrv->hScanTimer);
b1413b60 3072 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
c5c77ba1
JK
3073 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
3074
b1413b60 3075 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
c5c77ba1
JK
3076 }
3077
3078 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
3079
3080 /*BugID_5193*/
3081 /*Stop connect timer, if connection in progress*/
3082 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3083 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
8972d0fe 3084 del_timer(&pstrWFIDrv->hConnectTimer);
c5c77ba1
JK
3085 }
3086
3087 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
3088 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
3089 } else {
03b2d5e7 3090 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
c5c77ba1
JK
3091 }
3092
72ed4dc7 3093 gbScanWhileConnected = false;
c5c77ba1
JK
3094
3095 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
3096
2cc46837 3097 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
c5c77ba1
JK
3098
3099
3100 /* Deallocation */
3101 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
3102 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
49188af2 3103 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
c5c77ba1
JK
3104 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
3105 }
3106
3107 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
49188af2 3108 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
c5c77ba1
JK
3109 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
3110 }
3111
3112 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
3113 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
49188af2 3114 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
c5c77ba1
JK
3115 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
3116 }
3117
3118
3119 /*BugID_5137*/
4e4467fd 3120 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
49188af2 3121 kfree(gu8FlushedJoinReq);
c5c77ba1
JK
3122 gu8FlushedJoinReq = NULL;
3123 }
4e4467fd 3124 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (u32)drvHandler) {
49188af2 3125 kfree(gu8FlushedInfoElemAsoc);
c5c77ba1
JK
3126 gu8FlushedInfoElemAsoc = NULL;
3127 }
3128
3129 }
3130
3131 WILC_CATCH(s32Error)
3132 {
3133
3134 }
3135
3136 /* ////////////////////////// */
83383ea3 3137 up(&(pstrWFIDrv->hSemTestDisconnectBlock));
c5c77ba1
JK
3138 /* ///////////////////////// */
3139
3140}
3141
3142
2b05df55 3143void resolve_disconnect_aberration(tstrWILC_WFIDrv *drvHandler)
c5c77ba1
JK
3144{
3145 tstrWILC_WFIDrv *pstrWFIDrv;
3146
3147 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
b1413b60 3148 if (pstrWFIDrv == NULL)
c5c77ba1
JK
3149 return;
3150 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
3151 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
218dc407 3152 host_int_disconnect(pstrWFIDrv, 1);
c5c77ba1
JK
3153 }
3154}
2b05df55 3155static s32 Switch_Log_Terminal(tstrWILC_WFIDrv *drvHandler)
c5c77ba1
JK
3156{
3157
3158
fb4ec9ca 3159 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
3160 tstrWID strWID;
3161 static char dummy = 9;
3162 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3163
d85f5326 3164 strWID.u16WIDid = (u16)WID_LOGTerminal_Switch;
c5c77ba1
JK
3165 strWID.enuWIDtype = WID_CHAR;
3166 strWID.ps8WidVal = &dummy;
576917ad 3167 strWID.s32ValueSize = sizeof(char);
c5c77ba1 3168
72ed4dc7 3169 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
3170
3171
3172 if (s32Error) {
3173 PRINT_D(HOSTINF_DBG, "Failed to switch log terminal\n");
3174 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
3175 } else {
03b2d5e7 3176 PRINT_INFO(HOSTINF_DBG, "MAC address set ::\n");
c5c77ba1
JK
3177
3178
3179 }
3180
3181 WILC_CATCH(s32Error)
3182 {
3183
3184 }
3185
3186 return s32Error;
3187}
3188
3189/**
3190 * @brief Handle_GetChnl
3191 * @details Sending config packet to get channel
3192 * @param[in] NONE
3193 * @return NONE
3194 *
3195 * @author
3196 * @date
3197 * @version 1.0
3198 */
2b05df55 3199static s32 Handle_GetChnl(tstrWILC_WFIDrv *drvHandler)
c5c77ba1
JK
3200{
3201
fb4ec9ca 3202 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
3203 tstrWID strWID;
3204 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
3205 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
78c87591 3206
d85f5326 3207 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
c5c77ba1 3208 strWID.enuWIDtype = WID_CHAR;
ca356ada 3209 strWID.ps8WidVal = (s8 *)&gu8Chnl;
576917ad 3210 strWID.s32ValueSize = sizeof(char);
c5c77ba1
JK
3211
3212 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
3213
72ed4dc7 3214 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
3215 /*get the value by searching the local copy*/
3216 if (s32Error) {
3217 PRINT_ER("Failed to get channel number\n");
3218 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3219 }
3220
3221
3222 WILC_CATCH(s32Error)
3223 {
3224
3225 }
83383ea3 3226 up(&(pstrWFIDrv->hSemGetCHNL));
c5c77ba1
JK
3227
3228 return s32Error;
3229
3230
3231
3232}
3233
3234
3235/**
3236 * @brief Handle_GetRssi
3237 * @details Sending config packet to get RSSI
3238 * @param[in] NONE
3239 * @return NONE
3240 * @author
3241 * @date
3242 * @version 1.0
3243 */
2b05df55 3244static void Handle_GetRssi(tstrWILC_WFIDrv *drvHandler)
c5c77ba1 3245{
fb4ec9ca 3246 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
3247 tstrWID strWID;
3248 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3249
d85f5326 3250 strWID.u16WIDid = (u16)WID_RSSI;
c5c77ba1
JK
3251 strWID.enuWIDtype = WID_CHAR;
3252 strWID.ps8WidVal = &gs8Rssi;
576917ad 3253 strWID.s32ValueSize = sizeof(char);
c5c77ba1
JK
3254
3255 /*Sending Cfg*/
3256 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
3257
72ed4dc7 3258 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
3259 if (s32Error) {
3260 PRINT_ER("Failed to get RSSI value\n");
3261 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3262 }
3263
3264 WILC_CATCH(s32Error)
3265 {
3266
3267 }
83383ea3 3268 up(&(pstrWFIDrv->hSemGetRSSI));
c5c77ba1
JK
3269
3270
3271}
3272
3273
2b05df55 3274static void Handle_GetLinkspeed(tstrWILC_WFIDrv *drvHandler)
c5c77ba1 3275{
fb4ec9ca 3276 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
3277 tstrWID strWID;
3278 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3279
3280 gs8lnkspd = 0;
3281
d85f5326 3282 strWID.u16WIDid = (u16)WID_LINKSPEED;
c5c77ba1
JK
3283 strWID.enuWIDtype = WID_CHAR;
3284 strWID.ps8WidVal = &gs8lnkspd;
576917ad 3285 strWID.s32ValueSize = sizeof(char);
c5c77ba1
JK
3286 /*Sending Cfg*/
3287 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
3288
72ed4dc7 3289 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
3290 if (s32Error) {
3291 PRINT_ER("Failed to get LINKSPEED value\n");
3292 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3293 }
3294
3295 WILC_CATCH(s32Error)
3296 {
3297
3298 }
83383ea3 3299 up(&(pstrWFIDrv->hSemGetLINKSPEED));
c5c77ba1
JK
3300
3301
3302}
3303
2b05df55 3304s32 Handle_GetStatistics(tstrWILC_WFIDrv *drvHandler, tstrStatistics *pstrStatistics)
c5c77ba1
JK
3305{
3306 tstrWID strWIDList[5];
3307 uint32_t u32WidsCount = 0, s32Error = 0;
3308
3309 strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED;
3310 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
576917ad 3311 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
ca356ada 3312 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed));
c5c77ba1
JK
3313 u32WidsCount++;
3314
3315 strWIDList[u32WidsCount].u16WIDid = WID_RSSI;
3316 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
576917ad 3317 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
ca356ada 3318 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->s8RSSI));
c5c77ba1
JK
3319 u32WidsCount++;
3320
3321 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
3322 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
4e4467fd 3323 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
ca356ada 3324 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxCount));
c5c77ba1
JK
3325 u32WidsCount++;
3326
3327 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
3328 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
4e4467fd 3329 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
ca356ada 3330 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32RxCount));
c5c77ba1
JK
3331 u32WidsCount++;
3332
3333 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
3334 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
4e4467fd 3335 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
ca356ada 3336 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxFailureCount));
c5c77ba1
JK
3337 u32WidsCount++;
3338
72ed4dc7 3339 s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, false, (u32)drvHandler);
c5c77ba1
JK
3340
3341 if (s32Error) {
3342 PRINT_ER("Failed to send scan paramters config packet\n");
3343 /* WILC_ERRORREPORT(s32Error, s32Error); */
3344 }
83383ea3 3345 up(&hWaitResponse);
c5c77ba1
JK
3346 return 0;
3347
3348}
3349
3350
3351#ifdef WILC_AP_EXTERNAL_MLME
3352
3353
3354/**
3355 * @brief Handle_Get_InActiveTime
3356 * @details Sending config packet to set mac adddress for station and
3357 * get inactive time
3358 * @param[in] NONE
3359 * @return NONE
3360 *
3361 * @author
3362 * @date
3363 * @version 1.0
3364 */
2b05df55 3365static s32 Handle_Get_InActiveTime(tstrWILC_WFIDrv *drvHandler, tstrHostIfStaInactiveT *strHostIfStaInactiveT)
c5c77ba1
JK
3366{
3367
fb4ec9ca 3368 s32 s32Error = WILC_SUCCESS;
63d03e47 3369 u8 *stamac;
c5c77ba1
JK
3370 tstrWID strWID;
3371 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3372
3373
d85f5326 3374 strWID.u16WIDid = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
c5c77ba1
JK
3375 strWID.enuWIDtype = WID_STR;
3376 strWID.s32ValueSize = ETH_ALEN;
dc0ad74b 3377 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
c5c77ba1
JK
3378
3379
3380 stamac = strWID.ps8WidVal;
d00d2ba3 3381 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
c5c77ba1
JK
3382
3383
3384 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
3385
3386
72ed4dc7 3387 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
3388 /*get the value by searching the local copy*/
3389 if (s32Error) {
3390 PRINT_ER("Failed to SET incative time\n");
3391 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3392 }
3393
3394
d85f5326 3395 strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME;
c5c77ba1 3396 strWID.enuWIDtype = WID_INT;
ca356ada 3397 strWID.ps8WidVal = (s8 *)&gu32InactiveTime;
4e4467fd 3398 strWID.s32ValueSize = sizeof(u32);
c5c77ba1
JK
3399
3400
72ed4dc7 3401 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
3402 /*get the value by searching the local copy*/
3403 if (s32Error) {
3404 PRINT_ER("Failed to get incative time\n");
3405 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3406 }
3407
3408
3409 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
3410
83383ea3 3411 up(&(pstrWFIDrv->hSemInactiveTime));
c5c77ba1
JK
3412 WILC_CATCH(s32Error)
3413 {
3414
3415 }
3416
3417
3418 return s32Error;
3419
3420
3421
3422}
3423
3424
3425/**
3426 * @brief Handle_AddBeacon
3427 * @details Sending config packet to add beacon
3428 * @param[in] tstrHostIFSetBeacon* pstrSetBeaconParam
3429 * @return NONE
3430 * @author
3431 * @date
3432 * @version 1.0
3433 */
2b05df55 3434static void Handle_AddBeacon(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetBeacon *pstrSetBeaconParam)
c5c77ba1 3435{
fb4ec9ca 3436 s32 s32Error = WILC_SUCCESS;
c5c77ba1 3437 tstrWID strWID;
63d03e47 3438 u8 *pu8CurrByte;
c5c77ba1 3439 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
78c87591 3440
c5c77ba1
JK
3441 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
3442
d85f5326 3443 strWID.u16WIDid = (u16)WID_ADD_BEACON;
c5c77ba1
JK
3444 strWID.enuWIDtype = WID_BIN;
3445 strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
3446 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
2b9d5b48 3447 if (strWID.ps8WidVal == NULL)
c5c77ba1 3448 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
c5c77ba1
JK
3449
3450 pu8CurrByte = strWID.ps8WidVal;
3451 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
3452 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
3453 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
3454 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
3455
3456 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
3457 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
3458 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
3459 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
3460
3461 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
3462 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
3463 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
3464 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
3465
3466 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
3467 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
3468
3469 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
3470 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
3471 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
3472 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
3473
3474 /* Bug 4599 : if tail length = 0 skip copying */
3475 if (pstrSetBeaconParam->pu8Tail > 0)
3476 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
3477 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
3478
3479
3480
3481 /*Sending Cfg*/
72ed4dc7 3482 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
c5c77ba1
JK
3483 if (s32Error) {
3484 PRINT_ER("Failed to send add beacon config packet\n");
3485 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3486 }
3487
3488 WILC_CATCH(s32Error)
3489 {
3490 }
969effe9
GKH
3491 kfree(strWID.ps8WidVal);
3492 kfree(pstrSetBeaconParam->pu8Head);
3493 kfree(pstrSetBeaconParam->pu8Tail);
c5c77ba1
JK
3494}
3495
3496
3497/**
3498 * @brief Handle_AddBeacon
3499 * @details Sending config packet to delete beacon
3500 * @param[in] tstrHostIFDelBeacon* pstrDelBeacon
3501 * @return NONE
3502 * @author
3503 * @date
3504 * @version 1.0
3505 */
2b05df55 3506static void Handle_DelBeacon(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelBeacon *pstrDelBeacon)
c5c77ba1 3507{
fb4ec9ca 3508 s32 s32Error = WILC_SUCCESS;
c5c77ba1 3509 tstrWID strWID;
63d03e47 3510 u8 *pu8CurrByte;
c5c77ba1 3511 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
78c87591 3512
d85f5326 3513 strWID.u16WIDid = (u16)WID_DEL_BEACON;
c5c77ba1 3514 strWID.enuWIDtype = WID_CHAR;
576917ad 3515 strWID.s32ValueSize = sizeof(char);
c5c77ba1
JK
3516 strWID.ps8WidVal = &gu8DelBcn;
3517
2b9d5b48 3518 if (strWID.ps8WidVal == NULL)
c5c77ba1 3519 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
c5c77ba1
JK
3520
3521 pu8CurrByte = strWID.ps8WidVal;
3522
3523 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
3524 /* TODO: build del beacon message*/
3525
3526 /*Sending Cfg*/
72ed4dc7 3527 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
c5c77ba1
JK
3528 if (s32Error) {
3529
3530 PRINT_ER("Failed to send delete beacon config packet\n");
3531 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3532 }
3533
3534 WILC_CATCH(s32Error)
3535 {
3536 }
3537}
3538
3539
3540/**
3541 * @brief WILC_HostIf_PackStaParam
3542 * @details Handling packing of the station params in a buffer
63d03e47 3543 * @param[in] u8* pu8Buffer, tstrWILC_AddStaParam* pstrStationParam
c5c77ba1
JK
3544 * @return NONE
3545 * @author
3546 * @date
3547 * @version 1.0
3548 */
4e4467fd 3549static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, tstrWILC_AddStaParam *pstrStationParam)
c5c77ba1 3550{
63d03e47 3551 u8 *pu8CurrByte;
c5c77ba1
JK
3552
3553 pu8CurrByte = pu8Buffer;
3554
3555 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
d00d2ba3 3556 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
c5c77ba1
JK
3557 pu8CurrByte += ETH_ALEN;
3558
3559 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
3560 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
3561
3562 *pu8CurrByte++ = pstrStationParam->u8NumRates;
2b9d5b48 3563 if (pstrStationParam->u8NumRates > 0)
d00d2ba3 3564 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
c5c77ba1
JK
3565 pu8CurrByte += pstrStationParam->u8NumRates;
3566
3567 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
3568 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
3569 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
3570
3571 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
d00d2ba3 3572 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
c5c77ba1
JK
3573 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
3574
3575 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
3576 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
3577
3578 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
3579 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
3580 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
3581 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
3582
3583 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
3584
3585 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
3586 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
3587
3588 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
3589 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
3590
3591 return pu8CurrByte - pu8Buffer;
3592}
3593
3594/**
3595 * @brief Handle_AddStation
3596 * @details Sending config packet to add station
3597 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3598 * @return NONE
3599 * @author
3600 * @date
3601 * @version 1.0
3602 */
2b05df55 3603static void Handle_AddStation(tstrWILC_WFIDrv *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
c5c77ba1 3604{
fb4ec9ca 3605 s32 s32Error = WILC_SUCCESS;
c5c77ba1 3606 tstrWID strWID;
63d03e47 3607 u8 *pu8CurrByte;
c5c77ba1 3608 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
78c87591 3609
c5c77ba1 3610 PRINT_D(HOSTINF_DBG, "Handling add station\n");
d85f5326 3611 strWID.u16WIDid = (u16)WID_ADD_STA;
c5c77ba1
JK
3612 strWID.enuWIDtype = WID_BIN;
3613 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3614
3615 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
2b9d5b48 3616 if (strWID.ps8WidVal == NULL)
c5c77ba1 3617 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
c5c77ba1
JK
3618
3619 pu8CurrByte = strWID.ps8WidVal;
3620 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3621
3622 /*Sending Cfg*/
72ed4dc7 3623 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
c5c77ba1
JK
3624 if (s32Error != WILC_SUCCESS) {
3625
3626 PRINT_ER("Failed to send add station config packet\n");
3627 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3628 }
3629
3630 WILC_CATCH(s32Error)
3631 {
3632 }
969effe9
GKH
3633 kfree(pstrStationParam->pu8Rates);
3634 kfree(strWID.ps8WidVal);
c5c77ba1
JK
3635}
3636
3637/**
3638 * @brief Handle_DelAllSta
3639 * @details Sending config packet to delete station
3640 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3641 * @return NONE
3642 * @author
3643 * @date
3644 * @version 1.0
3645 */
2b05df55 3646static void Handle_DelAllSta(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelAllSta *pstrDelAllStaParam)
c5c77ba1 3647{
fb4ec9ca 3648 s32 s32Error = WILC_SUCCESS;
78c87591 3649
c5c77ba1 3650 tstrWID strWID;
63d03e47 3651 u8 *pu8CurrByte;
c5c77ba1 3652 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
63d03e47 3653 u8 i;
3703480b 3654 u8 au8Zero_Buff[6] = {0};
78c87591 3655
d85f5326 3656 strWID.u16WIDid = (u16)WID_DEL_ALL_STA;
c5c77ba1
JK
3657 strWID.enuWIDtype = WID_STR;
3658 strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
3659
03b2d5e7 3660 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
c5c77ba1
JK
3661
3662 strWID.ps8WidVal = WILC_MALLOC((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1);
2b9d5b48 3663 if (strWID.ps8WidVal == NULL)
c5c77ba1 3664 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
c5c77ba1
JK
3665
3666 pu8CurrByte = strWID.ps8WidVal;
3667
3668 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
3669
3670 for (i = 0; i < MAX_NUM_STA; i++) {
3671 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
d00d2ba3 3672 memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
c5c77ba1
JK
3673 else
3674 continue;
3675
3676 pu8CurrByte += ETH_ALEN;
3677 }
3678
3679 /*Sending Cfg*/
72ed4dc7 3680 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
3681 if (s32Error) {
3682
83cc9be5 3683 PRINT_ER("Failed to send add station config packet\n");
c5c77ba1
JK
3684 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3685 }
3686
3687 WILC_CATCH(s32Error)
3688 {
3689 }
969effe9 3690 kfree(strWID.ps8WidVal);
c5c77ba1 3691
83383ea3 3692 up(&hWaitResponse);
c5c77ba1
JK
3693}
3694
3695
3696/**
3697 * @brief Handle_DelStation
3698 * @details Sending config packet to delete station
3699 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3700 * @return NONE
3701 * @author
3702 * @date
3703 * @version 1.0
3704 */
2b05df55 3705static void Handle_DelStation(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelSta *pstrDelStaParam)
c5c77ba1 3706{
fb4ec9ca 3707 s32 s32Error = WILC_SUCCESS;
c5c77ba1 3708 tstrWID strWID;
63d03e47 3709 u8 *pu8CurrByte;
c5c77ba1
JK
3710 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3711
d85f5326 3712 strWID.u16WIDid = (u16)WID_REMOVE_STA;
c5c77ba1
JK
3713 strWID.enuWIDtype = WID_BIN;
3714 strWID.s32ValueSize = ETH_ALEN;
3715
03b2d5e7 3716 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
c5c77ba1
JK
3717
3718 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
2b9d5b48 3719 if (strWID.ps8WidVal == NULL)
c5c77ba1 3720 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
c5c77ba1
JK
3721
3722 pu8CurrByte = strWID.ps8WidVal;
3723
d00d2ba3 3724 memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
c5c77ba1
JK
3725
3726 /*Sending Cfg*/
72ed4dc7 3727 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
c5c77ba1
JK
3728 if (s32Error) {
3729
83cc9be5 3730 PRINT_ER("Failed to send add station config packet\n");
c5c77ba1
JK
3731 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3732 }
3733
3734 WILC_CATCH(s32Error)
3735 {
3736 }
969effe9 3737 kfree(strWID.ps8WidVal);
c5c77ba1
JK
3738}
3739
3740
3741/**
3742 * @brief Handle_EditStation
3743 * @details Sending config packet to edit station
3744 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3745 * @return NONE
3746 * @author
3747 * @date
3748 * @version 1.0
3749 */
2b05df55 3750static void Handle_EditStation(tstrWILC_WFIDrv *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
c5c77ba1 3751{
fb4ec9ca 3752 s32 s32Error = WILC_SUCCESS;
c5c77ba1 3753 tstrWID strWID;
63d03e47 3754 u8 *pu8CurrByte;
c5c77ba1
JK
3755 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3756
d85f5326 3757 strWID.u16WIDid = (u16)WID_EDIT_STA;
c5c77ba1
JK
3758 strWID.enuWIDtype = WID_BIN;
3759 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3760
3761 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
3762 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
2b9d5b48 3763 if (strWID.ps8WidVal == NULL)
c5c77ba1 3764 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
c5c77ba1
JK
3765
3766 pu8CurrByte = strWID.ps8WidVal;
3767 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3768
3769 /*Sending Cfg*/
72ed4dc7 3770 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)pstrWFIDrv);
c5c77ba1
JK
3771 if (s32Error) {
3772
3773 PRINT_ER("Failed to send edit station config packet\n");
3774 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3775 }
3776
3777 WILC_CATCH(s32Error)
3778 {
3779 }
969effe9
GKH
3780 kfree(pstrStationParam->pu8Rates);
3781 kfree(strWID.ps8WidVal);
c5c77ba1
JK
3782}
3783#endif /*WILC_AP_EXTERNAL_MLME*/
3784
3785#ifdef WILC_P2P
3786/**
3787 * @brief Handle_RemainOnChan
3788 * @details Sending config packet to edit station
3789 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3790 * @return NONE
3791 * @author
3792 * @date
3793 * @version 1.0
3794 */
2b05df55 3795static int Handle_RemainOnChan(tstrWILC_WFIDrv *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
c5c77ba1 3796{
fb4ec9ca 3797 s32 s32Error = WILC_SUCCESS;
63d03e47 3798 u8 u8remain_on_chan_flag;
c5c77ba1
JK
3799 tstrWID strWID;
3800 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3801
3802 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3803 if (!pstrWFIDrv->u8RemainOnChan_pendingreq) {
3804 pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
3805 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
3806 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
3807 pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
3808 pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
3809 } else {
3810 /*Set the channel to use it as a wid val*/
3811 pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel;
3812 }
3813
3814 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3815 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
3816 pstrWFIDrv->u8RemainOnChan_pendingreq = 1;
3817 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3818 }
3819 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3820 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
3821 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3822 }
3823
3824 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3825 if (g_obtainingIP || connecting) {
3826 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
3827 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3828 }
3829 #endif
3830
3831 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
3832
72ed4dc7 3833 u8remain_on_chan_flag = true;
d85f5326 3834 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
c5c77ba1
JK
3835 strWID.enuWIDtype = WID_STR;
3836 strWID.s32ValueSize = 2;
dc0ad74b 3837 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
c5c77ba1 3838
2b9d5b48 3839 if (strWID.ps8WidVal == NULL)
c5c77ba1 3840 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
c5c77ba1
JK
3841
3842 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
ca356ada 3843 strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
c5c77ba1
JK
3844
3845 /*Sending Cfg*/
72ed4dc7 3846 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
2b9d5b48 3847 if (s32Error != WILC_SUCCESS)
c5c77ba1 3848 PRINT_ER("Failed to set remain on channel\n");
c5c77ba1
JK
3849
3850 WILC_CATCH(-1)
3851 {
3852 P2P_LISTEN_STATE = 1;
9eb06643
GKH
3853 pstrWFIDrv->hRemainOnChannel.data = (unsigned long)pstrWFIDrv;
3854 mod_timer(&pstrWFIDrv->hRemainOnChannel,
3855 jiffies +
3856 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
c5c77ba1
JK
3857
3858 /*Calling CFG ready_on_channel*/
2b9d5b48 3859 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady)
c5c77ba1 3860 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
c5c77ba1
JK
3861
3862 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3863 pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
3864 }
3865 return s32Error;
3866}
3867
3868/**
3869 * @brief Handle_RegisterFrame
3870 * @details
3871 * @param[in]
3872 * @return NONE
3873 * @author
3874 * @date
3875 * @version 1.0
3876 */
2b05df55 3877static int Handle_RegisterFrame(tstrWILC_WFIDrv *drvHandler, tstrHostIfRegisterFrame *pstrHostIfRegisterFrame)
c5c77ba1 3878{
fb4ec9ca 3879 s32 s32Error = WILC_SUCCESS;
c5c77ba1 3880 tstrWID strWID;
63d03e47 3881 u8 *pu8CurrByte;
c5c77ba1
JK
3882 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3883
3884 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
3885
3886 /*prepare configuration packet*/
d85f5326 3887 strWID.u16WIDid = (u16)WID_REGISTER_FRAME;
c5c77ba1 3888 strWID.enuWIDtype = WID_STR;
d85f5326 3889 strWID.ps8WidVal = WILC_MALLOC(sizeof(u16) + 2);
2b9d5b48 3890 if (strWID.ps8WidVal == NULL)
c5c77ba1 3891 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
c5c77ba1
JK
3892
3893 pu8CurrByte = strWID.ps8WidVal;
3894
3895 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
3896 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
d00d2ba3 3897 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
c5c77ba1
JK
3898
3899
d85f5326 3900 strWID.s32ValueSize = sizeof(u16) + 2;
c5c77ba1
JK
3901
3902
3903 /*Sending Cfg*/
72ed4dc7 3904 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
3905 if (s32Error) {
3906 PRINT_ER("Failed to frame register config packet\n");
3907 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
3908 }
3909
3910
3911 WILC_CATCH(s32Error)
3912 {
3913 }
3914
3915 return s32Error;
3916
3917}
3918
3919/**
3920 * @brief Handle_ListenStateExpired
3921 * @details Handle of listen state expiration
3922 * @param[in] NONE
3923 * @return Error code.
3924 * @author
3925 * @date
3926 * @version 1.0
3927 */
3928#define FALSE_FRMWR_CHANNEL 100
2b05df55 3929static u32 Handle_ListenStateExpired(tstrWILC_WFIDrv *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
c5c77ba1 3930{
63d03e47 3931 u8 u8remain_on_chan_flag;
c5c77ba1 3932 tstrWID strWID;
fb4ec9ca 3933 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
3934 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3935
3936 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
3937
3938 /*BugID_5477*/
3939 /*Make sure we are already in listen state*/
3940 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
3941 if (P2P_LISTEN_STATE) {
72ed4dc7 3942 u8remain_on_chan_flag = false;
d85f5326 3943 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
c5c77ba1
JK
3944 strWID.enuWIDtype = WID_STR;
3945 strWID.s32ValueSize = 2;
3946 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
3947
2b9d5b48 3948 if (strWID.ps8WidVal == NULL)
c5c77ba1 3949 PRINT_ER("Failed to allocate memory\n");
c5c77ba1
JK
3950
3951 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3952 strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL;
3953
3954 /*Sending Cfg*/
72ed4dc7 3955 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
3956 if (s32Error != WILC_SUCCESS) {
3957 PRINT_ER("Failed to set remain on channel\n");
3958 goto _done_;
3959 }
3960
3961 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) {
3962 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid
3963 , pstrHostIfRemainOnChan->u32ListenSessionID);
3964 }
3965 P2P_LISTEN_STATE = 0;
3966 } else {
3967 PRINT_D(GENERIC_DBG, "Not in listen state\n");
3968 s32Error = WILC_FAIL;
3969 }
3970
3971_done_:
3972 return s32Error;
3973}
3974
3975
3976/**
3977 * @brief ListenTimerCB
3978 * @details Callback function of remain-on-channel timer
3979 * @param[in] NONE
3980 * @return Error code.
3981 * @author
3982 * @date
3983 * @version 1.0
3984 */
93dee8ee 3985static void ListenTimerCB(unsigned long arg)
c5c77ba1 3986{
fb4ec9ca 3987 s32 s32Error = WILC_SUCCESS;
c5c77ba1 3988 tstrHostIFmsg strHostIFmsg;
93dee8ee 3989 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
c5c77ba1 3990 /*Stopping remain-on-channel timer*/
8972d0fe 3991 del_timer(&pstrWFIDrv->hRemainOnChannel);
c5c77ba1
JK
3992
3993 /* prepare the Timer Callback message */
2cc46837 3994 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
3995 strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
3996 strHostIFmsg.drvHandler = pstrWFIDrv;
3997 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID;
3998
3999 /* send the message */
c4f83a55 4000 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 4001 if (s32Error)
c5c77ba1 4002 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
4003 WILC_CATCH(s32Error)
4004 {
4005
4006 }
4007}
4008#endif
4009
4010
4011/**
4012 * @brief Handle_EditStation
4013 * @details Sending config packet to edit station
4014 * @param[in] tstrWILC_AddStaParam* pstrStationParam
4015 * @return NONE
4016 * @author
4017 * @date
4018 * @version 1.0
4019 */
2b05df55 4020static void Handle_PowerManagement(tstrWILC_WFIDrv *drvHandler, tstrHostIfPowerMgmtParam *strPowerMgmtParam)
c5c77ba1 4021{
fb4ec9ca 4022 s32 s32Error = WILC_SUCCESS;
c5c77ba1 4023 tstrWID strWID;
ca356ada 4024 s8 s8PowerMode;
c5c77ba1 4025 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
78c87591 4026
d85f5326 4027 strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT;
c5c77ba1 4028
78174ada 4029 if (strPowerMgmtParam->bIsEnabled == true)
c5c77ba1 4030 s8PowerMode = MIN_FAST_PS;
78174ada 4031 else
c5c77ba1 4032 s8PowerMode = NO_POWERSAVE;
c5c77ba1
JK
4033 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
4034 strWID.ps8WidVal = &s8PowerMode;
576917ad 4035 strWID.s32ValueSize = sizeof(char);
c5c77ba1
JK
4036
4037 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
4038
4039 /*Sending Cfg*/
72ed4dc7 4040 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
4041 if (s32Error) {
4042 PRINT_ER("Failed to send power management config packet\n");
4043 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
4044 }
4045
4046 WILC_CATCH(s32Error)
4047 {
4048
4049 }
4050}
4051
4052/**
4053 * @brief Handle_SetMulticastFilter
4054 * @details Set Multicast filter in firmware
4055 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4056 * @return NONE
4057 * @author asobhy
4058 * @date
4059 * @version 1.0
4060 */
2b05df55 4061static void Handle_SetMulticastFilter(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetMulti *strHostIfSetMulti)
c5c77ba1 4062{
fb4ec9ca 4063 s32 s32Error = WILC_SUCCESS;
c5c77ba1 4064 tstrWID strWID;
63d03e47 4065 u8 *pu8CurrByte;
c5c77ba1
JK
4066
4067 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
4068
d85f5326 4069 strWID.u16WIDid = (u16)WID_SETUP_MULTICAST_FILTER;
c5c77ba1
JK
4070 strWID.enuWIDtype = WID_BIN;
4071 strWID.s32ValueSize = sizeof(tstrHostIFSetMulti) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
4072 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
2b9d5b48 4073 if (strWID.ps8WidVal == NULL)
c5c77ba1 4074 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
c5c77ba1
JK
4075
4076 pu8CurrByte = strWID.ps8WidVal;
4077 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
4078 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
4079 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
4080 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
4081
4082 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
4083 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
4084 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
4085 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
4086
4087 if ((strHostIfSetMulti->u32count) > 0)
4088 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
4089
4090 /*Sending Cfg*/
72ed4dc7 4091 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false, (u32)drvHandler);
c5c77ba1
JK
4092 if (s32Error) {
4093 PRINT_ER("Failed to send setup multicast config packet\n");
4094 WILC_ERRORREPORT(s32Error, WILC_FAIL);
4095 }
4096
4097 WILC_CATCH(s32Error)
4098 {
4099 }
969effe9 4100 kfree(strWID.ps8WidVal);
c5c77ba1
JK
4101
4102}
4103
4104
4105/*BugID_5222*/
4106/**
4107 * @brief Handle_AddBASession
4108 * @details Add block ack session
4109 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4110 * @return NONE
4111 * @author Amr Abdel-Moghny
4112 * @date Feb. 2014
4113 * @version 9.0
4114 */
2b05df55 4115static s32 Handle_AddBASession(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
c5c77ba1 4116{
fb4ec9ca 4117 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
4118 tstrWID strWID;
4119 int AddbaTimeout = 100;
4120 char *ptr = NULL;
4121 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4122
03b2d5e7 4123 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
c5c77ba1
JK
4124 strHostIfBASessionInfo->au8Bssid[0],
4125 strHostIfBASessionInfo->au8Bssid[1],
4126 strHostIfBASessionInfo->au8Bssid[2],
4127 strHostIfBASessionInfo->u16BufferSize,
4128 strHostIfBASessionInfo->u16SessionTimeout,
4129 strHostIfBASessionInfo->u8Ted);
4130
d85f5326 4131 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
c5c77ba1 4132 strWID.enuWIDtype = WID_STR;
dc0ad74b 4133 strWID.ps8WidVal = WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
c5c77ba1
JK
4134 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4135 ptr = strWID.ps8WidVal;
4136 /* *ptr++ = 0x14; */
4137 *ptr++ = 0x14;
4138 *ptr++ = 0x3;
4139 *ptr++ = 0x0;
d00d2ba3 4140 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
c5c77ba1
JK
4141 ptr += ETH_ALEN;
4142 *ptr++ = strHostIfBASessionInfo->u8Ted;
4143 /* BA Policy*/
4144 *ptr++ = 1;
4145 /* Buffer size*/
4146 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4147 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
4148 /* BA timeout*/
4149 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
4150 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4151 /* ADDBA timeout*/
4152 *ptr++ = (AddbaTimeout & 0xFF);
4153 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
4154 /* Group Buffer Max Frames*/
4155 *ptr++ = 8;
4156 /* Group Buffer Timeout */
4157 *ptr++ = 0;
4158
72ed4dc7 4159 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
4160 if (s32Error)
4161 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
4162
4163
d85f5326 4164 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
c5c77ba1
JK
4165 strWID.enuWIDtype = WID_STR;
4166 strWID.s32ValueSize = 15;
4167 ptr = strWID.ps8WidVal;
4168 /* *ptr++ = 0x14; */
4169 *ptr++ = 15;
4170 *ptr++ = 7;
4171 *ptr++ = 0x2;
d00d2ba3 4172 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
c5c77ba1
JK
4173 ptr += ETH_ALEN;
4174 /* TID*/
4175 *ptr++ = strHostIfBASessionInfo->u8Ted;
4176 /* Max Num MSDU */
4177 *ptr++ = 8;
4178 /* BA timeout*/
4179 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4180 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4181 /*Ack-Policy */
4182 *ptr++ = 3;
72ed4dc7 4183 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
4184
4185 if (strWID.ps8WidVal != NULL)
49188af2 4186 kfree(strWID.ps8WidVal);
c5c77ba1
JK
4187
4188 return s32Error;
4189
4190}
4191
4192
4193/*BugID_5222*/
4194/**
4195 * @brief Handle_DelBASession
4196 * @details Delete block ack session
4197 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4198 * @return NONE
4199 * @author Amr Abdel-Moghny
4200 * @date Feb. 2013
4201 * @version 9.0
4202 */
2b05df55 4203static s32 Handle_DelBASession(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
c5c77ba1 4204{
fb4ec9ca 4205 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
4206 tstrWID strWID;
4207 char *ptr = NULL;
4208 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4209
03b2d5e7 4210 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
c5c77ba1
JK
4211 strHostIfBASessionInfo->au8Bssid[0],
4212 strHostIfBASessionInfo->au8Bssid[1],
4213 strHostIfBASessionInfo->au8Bssid[2],
4214 strHostIfBASessionInfo->u8Ted);
4215
d85f5326 4216 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
c5c77ba1 4217 strWID.enuWIDtype = WID_STR;
dc0ad74b 4218 strWID.ps8WidVal = WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
c5c77ba1
JK
4219 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4220 ptr = strWID.ps8WidVal;
4221 /* *ptr++ = 0x14; */
4222 *ptr++ = 0x14;
4223 *ptr++ = 0x3;
4224 *ptr++ = 0x2;
d00d2ba3 4225 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
c5c77ba1
JK
4226 ptr += ETH_ALEN;
4227 *ptr++ = strHostIfBASessionInfo->u8Ted;
4228 /* BA direction = recipent*/
4229 *ptr++ = 0;
4230 /* Delba Reason */
4231 *ptr++ = 32; /* Unspecific QOS reason */
4232
72ed4dc7 4233 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
4234 if (s32Error)
4235 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4236
4237
d85f5326 4238 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
c5c77ba1
JK
4239 strWID.enuWIDtype = WID_STR;
4240 strWID.s32ValueSize = 15;
4241 ptr = strWID.ps8WidVal;
4242 /* *ptr++ = 0x14; */
4243 *ptr++ = 15;
4244 *ptr++ = 7;
4245 *ptr++ = 0x3;
d00d2ba3 4246 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
c5c77ba1
JK
4247 ptr += ETH_ALEN;
4248 /* TID*/
4249 *ptr++ = strHostIfBASessionInfo->u8Ted;
4250
72ed4dc7 4251 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
4252
4253 if (strWID.ps8WidVal != NULL)
49188af2 4254 kfree(strWID.ps8WidVal);
c5c77ba1
JK
4255
4256 /*BugID_5222*/
83383ea3 4257 up(&hWaitResponse);
c5c77ba1
JK
4258
4259 return s32Error;
4260
4261}
4262
4263
4264/**
4265 * @brief Handle_DelAllRxBASessions
4266 * @details Delete all Rx BA sessions
4267 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4268 * @return NONE
4269 * @author Abdelrahman Sobhy
4270 * @date Feb. 2013
4271 * @version 9.0
4272 */
2b05df55 4273static s32 Handle_DelAllRxBASessions(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
c5c77ba1 4274{
fb4ec9ca 4275 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
4276 tstrWID strWID;
4277 char *ptr = NULL;
4278 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4279
03b2d5e7 4280 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
c5c77ba1
JK
4281 strHostIfBASessionInfo->au8Bssid[0],
4282 strHostIfBASessionInfo->au8Bssid[1],
4283 strHostIfBASessionInfo->au8Bssid[2],
4284 strHostIfBASessionInfo->u8Ted);
4285
d85f5326 4286 strWID.u16WIDid = (u16)WID_DEL_ALL_RX_BA;
c5c77ba1 4287 strWID.enuWIDtype = WID_STR;
dc0ad74b 4288 strWID.ps8WidVal = WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
c5c77ba1
JK
4289 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4290 ptr = strWID.ps8WidVal;
4291 *ptr++ = 0x14;
4292 *ptr++ = 0x3;
4293 *ptr++ = 0x2;
d00d2ba3 4294 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
c5c77ba1
JK
4295 ptr += ETH_ALEN;
4296 *ptr++ = strHostIfBASessionInfo->u8Ted;
4297 /* BA direction = recipent*/
4298 *ptr++ = 0;
4299 /* Delba Reason */
4300 *ptr++ = 32; /* Unspecific QOS reason */
4301
72ed4dc7 4302 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
4303 if (s32Error)
4304 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4305
4306
4307 if (strWID.ps8WidVal != NULL)
49188af2 4308 kfree(strWID.ps8WidVal);
c5c77ba1
JK
4309
4310 /*BugID_5222*/
83383ea3 4311 up(&hWaitResponse);
c5c77ba1
JK
4312
4313 return s32Error;
4314
4315}
4316
4317/**
4318 * @brief hostIFthread
4319 * @details Main thread to handle message queue requests
4320 * @param[in] void* pvArg
4321 * @return NONE
4322 * @author
4323 * @date
4324 * @version 1.0
4325 */
1999bd52 4326static int hostIFthread(void *pvArg)
c5c77ba1 4327{
4e4467fd 4328 u32 u32Ret;
c5c77ba1
JK
4329 tstrHostIFmsg strHostIFmsg;
4330 tstrWILC_WFIDrv *pstrWFIDrv;
4331
2cc46837 4332 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
4333
4334 while (1) {
c4f83a55 4335 WILC_MsgQueueRecv(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), &u32Ret);
c5c77ba1
JK
4336 pstrWFIDrv = (tstrWILC_WFIDrv *)strHostIFmsg.drvHandler;
4337 if (strHostIFmsg.u16MsgId == HOST_IF_MSG_EXIT) {
4338 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
4339 break;
4340 }
4341
4342
4343 /*Re-Queue HIF message*/
4344 if ((!g_wilc_initialized)) {
4345 PRINT_D(GENERIC_DBG, "--WAIT--");
80e29c7a 4346 usleep_range(200 * 1000, 200 * 1000);
c4f83a55 4347 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
4348 continue;
4349 }
4350
4351 if (strHostIFmsg.u16MsgId == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
4352 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
c4f83a55 4353 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
80e29c7a 4354 usleep_range(2 * 1000, 2 * 1000);
c5c77ba1
JK
4355 continue;
4356 }
4357
4358 switch (strHostIFmsg.u16MsgId) {
4359 case HOST_IF_MSG_Q_IDLE:
4360 Handle_wait_msg_q_empty();
4361 break;
4362
4363 case HOST_IF_MSG_SCAN:
4364 Handle_Scan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr);
4365 break;
4366
4367 case HOST_IF_MSG_CONNECT:
4368 Handle_Connect(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr);
4369 break;
4370
4371 /*BugID_5137*/
4372 case HOST_IF_MSG_FLUSH_CONNECT:
4373 Handle_FlushConnect(strHostIFmsg.drvHandler);
4374 break;
4375
4376 case HOST_IF_MSG_RCVD_NTWRK_INFO:
4377 Handle_RcvdNtwrkInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo);
4378 break;
4379
4380 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
4381 Handle_RcvdGnrlAsyncInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo);
4382 break;
4383
4384 case HOST_IF_MSG_KEY:
4385 Handle_Key(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr);
4386 break;
4387
4388 case HOST_IF_MSG_CFG_PARAMS:
4389
4390 Handle_CfgParam(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr);
4391 break;
4392
4393 case HOST_IF_MSG_SET_CHANNEL:
4394 Handle_SetChannel(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan);
4395 break;
4396
4397 case HOST_IF_MSG_DISCONNECT:
4398 Handle_Disconnect(strHostIFmsg.drvHandler);
4399 break;
4400
4401 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
8972d0fe 4402 del_timer(&pstrWFIDrv->hScanTimer);
c5c77ba1
JK
4403 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
4404
4405 /*BugID_5213*/
4406 /*Allow chip sleep, only if both interfaces are not connected*/
2b9d5b48 4407 if (!linux_wlan_get_num_conn_ifcs())
c5c77ba1 4408 chip_sleep_manually(INFINITE_SLEEP_TIME);
c5c77ba1
JK
4409
4410 Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_DONE);
4411
4412 #ifdef WILC_P2P
4413 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
4414 Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4415 #endif
4416
4417 break;
4418
4419 case HOST_IF_MSG_GET_RSSI:
4420 Handle_GetRssi(strHostIFmsg.drvHandler);
4421 break;
4422
4423 case HOST_IF_MSG_GET_LINKSPEED:
4424 Handle_GetLinkspeed(strHostIFmsg.drvHandler);
4425 break;
4426
4427 case HOST_IF_MSG_GET_STATISTICS:
4428 Handle_GetStatistics(strHostIFmsg.drvHandler, (tstrStatistics *)strHostIFmsg.uniHostIFmsgBody.pUserData);
4429 break;
4430
4431 case HOST_IF_MSG_GET_CHNL:
4432 Handle_GetChnl(strHostIFmsg.drvHandler);
4433 break;
4434
4435#ifdef WILC_AP_EXTERNAL_MLME
4436 case HOST_IF_MSG_ADD_BEACON:
4437 Handle_AddBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon);
4438 break;
4439
4440 case HOST_IF_MSG_DEL_BEACON:
4441 Handle_DelBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelBeacon);
4442 break;
4443
4444 case HOST_IF_MSG_ADD_STATION:
4445 Handle_AddStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strAddStaParam);
4446 break;
4447
4448 case HOST_IF_MSG_DEL_STATION:
4449 Handle_DelStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strDelStaParam);
4450 break;
4451
4452 case HOST_IF_MSG_EDIT_STATION:
4453 Handle_EditStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strEditStaParam);
4454 break;
4455
4456 case HOST_IF_MSG_GET_INACTIVETIME:
4457 Handle_Get_InActiveTime(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT);
4458 break;
4459
4460#endif /*WILC_AP_EXTERNAL_MLME*/
4461 case HOST_IF_MSG_SCAN_TIMER_FIRED:
4462 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
4463
4464 Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_ABORTED);
4465 break;
4466
4467 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
03b2d5e7 4468 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
c5c77ba1
JK
4469 Handle_ConnectTimeout(strHostIFmsg.drvHandler);
4470 break;
4471
4472 case HOST_IF_MSG_POWER_MGMT:
4473 Handle_PowerManagement(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam);
4474 break;
4475
4476 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
4477 Handle_SetWfiDrvHandler(&strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler);
4478 break;
4479
4480 case HOST_IF_MSG_SET_OPERATION_MODE:
4481 Handle_SetOperationMode(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode);
4482 break;
4483
4484 case HOST_IF_MSG_SET_IPADDRESS:
4485 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4486 Handle_set_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
4487 break;
4488
4489 case HOST_IF_MSG_GET_IPADDRESS:
4490 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4491 Handle_get_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
4492 break;
4493
4494 /*BugID_5077*/
4495 case HOST_IF_MSG_SET_MAC_ADDRESS:
4496 Handle_SetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress);
4497 break;
4498
4499 /*BugID_5213*/
4500 case HOST_IF_MSG_GET_MAC_ADDRESS:
4501 Handle_GetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress);
4502 break;
4503
4504#ifdef WILC_P2P
4505 case HOST_IF_MSG_REMAIN_ON_CHAN:
4506 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
4507 Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4508 break;
4509
4510 case HOST_IF_MSG_REGISTER_FRAME:
4511 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
4512 Handle_RegisterFrame(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame);
4513 break;
4514
4515 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
4516 Handle_ListenStateExpired(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4517 break;
4518
4519 #endif
4520 case HOST_IF_MSG_SET_MULTICAST_FILTER:
4521 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
4522 Handle_SetMulticastFilter(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti);
4523 break;
4524
4525 /*BugID_5222*/
4526 case HOST_IF_MSG_ADD_BA_SESSION:
4527 Handle_AddBASession(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
4528 break;
4529
4530 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
4531 Handle_DelAllRxBASessions(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
4532 break;
4533
4534 case HOST_IF_MSG_DEL_ALL_STA:
4535 Handle_DelAllSta(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta);
4536 break;
4537
4538 default:
03b2d5e7 4539 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
c5c77ba1
JK
4540 break;
4541 }
4542 }
4543
4544 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
83383ea3 4545 up(&hSemHostIFthrdEnd);
1999bd52 4546 return 0;
c5c77ba1
JK
4547}
4548
93dee8ee 4549static void TimerCB_Scan(unsigned long arg)
c5c77ba1 4550{
93dee8ee 4551 void *pvArg = (void *)arg;
c5c77ba1
JK
4552 tstrHostIFmsg strHostIFmsg;
4553
4554 /* prepare the Timer Callback message */
2cc46837 4555 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
4556 strHostIFmsg.drvHandler = pvArg;
4557 strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN_TIMER_FIRED;
4558
4559 /* send the message */
c4f83a55 4560 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
4561}
4562
93dee8ee 4563static void TimerCB_Connect(unsigned long arg)
c5c77ba1 4564{
93dee8ee 4565 void *pvArg = (void *)arg;
c5c77ba1
JK
4566 tstrHostIFmsg strHostIFmsg;
4567
4568 /* prepare the Timer Callback message */
2cc46837 4569 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
4570 strHostIFmsg.drvHandler = pvArg;
4571 strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT_TIMER_FIRED;
4572
4573 /* send the message */
c4f83a55 4574 WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
4575}
4576
4577
4578/**
4579 * @brief removes wpa/wpa2 keys
4580 * @details only in BSS STA mode if External Supplicant support is enabled.
4581 * removes all WPA/WPA2 station key entries from MAC hardware.
4582 * @param[in,out] handle to the wifi driver
4583 * @param[in] 6 bytes of Station Adress in the station entry table
4584 * @return Error code indicating success/failure
4585 * @note
4586 * @author zsalah
4587 * @date 8 March 2012
4588 * @version 1.0
4589 */
4590/* Check implementation in core adding 9 bytes to the input! */
218dc407 4591s32 host_int_remove_key(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8StaAddress)
c5c77ba1 4592{
fb4ec9ca 4593 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
4594 tstrWID strWID;
4595 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4596
d85f5326 4597 strWID.u16WIDid = (u16)WID_REMOVE_KEY;
c5c77ba1 4598 strWID.enuWIDtype = WID_STR;
ca356ada 4599 strWID.ps8WidVal = (s8 *)pu8StaAddress;
c5c77ba1
JK
4600 strWID.s32ValueSize = 6;
4601
4602 return s32Error;
4603
4604}
4605
4606/**
4607 * @brief removes WEP key
4608 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4609 * remove a WEP key entry from MAC HW.
4610 * The BSS Station automatically finds the index of the entry using its
4611 * BSS ID and removes that entry from the MAC hardware.
4612 * @param[in,out] handle to the wifi driver
4613 * @param[in] 6 bytes of Station Adress in the station entry table
4614 * @return Error code indicating success/failure
4615 * @note NO need for the STA add since it is not used for processing
4616 * @author zsalah
4617 * @date 8 March 2012
4618 * @version 1.0
4619 */
218dc407 4620s32 host_int_remove_wep_key(tstrWILC_WFIDrv *hWFIDrv, u8 u8keyIdx)
c5c77ba1 4621{
fb4ec9ca 4622 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
4623 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4624 tstrHostIFmsg strHostIFmsg;
4625
4626
2b9d5b48 4627 if (pstrWFIDrv == NULL)
c5c77ba1 4628 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1
JK
4629
4630 /* prepare the Remove Wep Key Message */
2cc46837 4631 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
4632
4633
4634 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4635 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4636 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = REMOVEKEY;
4637 strHostIFmsg.drvHandler = hWFIDrv;
4638
4639
4640
4641 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4642 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8keyIdx;
4643
4644 /* send the message */
c4f83a55 4645 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1 4646 if (s32Error)
03b2d5e7 4647 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
83383ea3 4648 down(&(pstrWFIDrv->hSemTestKeyBlock));
c5c77ba1
JK
4649
4650 WILC_CATCH(s32Error)
4651 {
4652
4653 }
4654 return s32Error;
4655}
4656
4657/**
4658 * @brief sets WEP default key
4659 * @details Sets the index of the WEP encryption key in use,
4660 * in the key table
4661 * @param[in,out] handle to the wifi driver
4662 * @param[in] key index ( 0, 1, 2, 3)
4663 * @return Error code indicating success/failure
4664 * @note
4665 * @author zsalah
4666 * @date 8 March 2012
4667 * @version 1.0
4668 */
218dc407 4669s32 host_int_set_WEPDefaultKeyID(tstrWILC_WFIDrv *hWFIDrv, u8 u8Index)
c5c77ba1 4670{
fb4ec9ca 4671 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
4672 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4673 tstrHostIFmsg strHostIFmsg;
4674
4675
2b9d5b48 4676 if (pstrWFIDrv == NULL)
c5c77ba1 4677 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1
JK
4678
4679 /* prepare the Key Message */
2cc46837 4680 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
4681
4682
4683 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4684 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4685 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = DEFAULTKEY;
4686 strHostIFmsg.drvHandler = hWFIDrv;
4687
4688
4689 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4690 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
4691
4692 /* send the message */
c4f83a55 4693 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
4694 if (s32Error)
4695 PRINT_ER("Error in sending message queue : Default key index\n");
83383ea3 4696 down(&(pstrWFIDrv->hSemTestKeyBlock));
c5c77ba1
JK
4697
4698 WILC_CATCH(s32Error)
4699 {
4700
4701 }
4702
4703 return s32Error;
4704}
4705
4706/**
4707 * @brief sets WEP deafault key
4708 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4709 * sets WEP key entry into MAC hardware when it receives the
4710 * corresponding request from NDIS.
4711 * @param[in,out] handle to the wifi driver
4712 * @param[in] message containing WEP Key in the following format
4713 *|---------------------------------------|
4714 *|Key ID Value | Key Length | Key |
4715 *|-------------|------------|------------|
4716 | 1byte | 1byte | Key Length |
4717 ||---------------------------------------|
4718 |
4719 * @return Error code indicating success/failure
4720 * @note
4721 * @author zsalah
4722 * @date 8 March 2012
4723 * @version 1.0
4724 */
218dc407 4725s32 host_int_add_wep_key_bss_sta(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx)
c5c77ba1
JK
4726{
4727
fb4ec9ca 4728 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
4729 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4730 tstrHostIFmsg strHostIFmsg;
4731
2b9d5b48 4732 if (pstrWFIDrv == NULL)
c5c77ba1
JK
4733 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4734
c5c77ba1
JK
4735
4736 /* prepare the Key Message */
2cc46837 4737 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
4738
4739
4740 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4741 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4742 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
4743 strHostIFmsg.drvHandler = hWFIDrv;
4744
4745
4746 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
dc0ad74b 4747 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = WILC_MALLOC(u8WepKeylen);
c5c77ba1 4748
d00d2ba3 4749 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
c5c77ba1
JK
4750 pu8WepKey, u8WepKeylen);
4751
4752
4753 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4754 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4755
4756 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4757 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4758
4759 /* send the message */
c4f83a55 4760 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
4761 if (s32Error)
4762 PRINT_ER("Error in sending message queue :WEP Key\n");
83383ea3 4763 down(&(pstrWFIDrv->hSemTestKeyBlock));
c5c77ba1
JK
4764
4765 WILC_CATCH(s32Error)
4766 {
4767
4768 }
4769 return s32Error;
4770
4771}
4772
4773#ifdef WILC_AP_EXTERNAL_MLME
4774/**
4775 *
4776 * @brief host_int_add_wep_key_bss_ap
4777 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4778 * sets WEP key entry into MAC hardware when it receives the
4779 *
4780 * corresponding request from NDIS.
4781 * @param[in,out] handle to the wifi driver
4782 *
4783 *
4784 * @return Error code indicating success/failure
4785 * @note
4786 * @author mdaftedar
4787 * @date 28 FEB 2013
4788 * @version 1.0
4789 */
218dc407 4790s32 host_int_add_wep_key_bss_ap(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, AUTHTYPE_T tenuAuth_type)
c5c77ba1
JK
4791{
4792
fb4ec9ca 4793 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
4794 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4795 tstrHostIFmsg strHostIFmsg;
63d03e47 4796 u8 i;
c5c77ba1 4797
2b9d5b48 4798 if (pstrWFIDrv == NULL)
c5c77ba1
JK
4799 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4800
c5c77ba1
JK
4801
4802 /* prepare the Key Message */
2cc46837 4803 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
4804
4805 if (INFO) {
4806 for (i = 0; i < u8WepKeylen; i++)
4807 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4808 }
4809 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4810 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4811 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4812 strHostIFmsg.drvHandler = hWFIDrv;
4813
4814
4815 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
dc0ad74b 4816 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = WILC_MALLOC((u8WepKeylen));
c5c77ba1
JK
4817
4818
d00d2ba3 4819 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
c5c77ba1
JK
4820 pu8WepKey, (u8WepKeylen));
4821
4822
4823 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4824 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4825
4826 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4827 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4828
4829 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4830 uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
4831
4832 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4833 uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
4834 /* send the message */
c4f83a55 4835 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
4836
4837 if (s32Error)
4838 PRINT_ER("Error in sending message queue :WEP Key\n");
83383ea3 4839 down(&(pstrWFIDrv->hSemTestKeyBlock));
c5c77ba1
JK
4840
4841 WILC_CATCH(s32Error)
4842 {
4843
4844 }
4845 return s32Error;
4846
4847}
4848#endif
4849/**
4850 * @brief adds ptk Key
4851 * @details
4852 * @param[in,out] handle to the wifi driver
4853 * @param[in] message containing PTK Key in the following format
4854 *|-----------------------------------------------------------------------------|
4855 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4856 *|----------------|------------|--------------|----------------|---------------|
4857 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4858 ||-----------------------------------------------------------------------------|
4859 * @return Error code indicating success/failure
4860 * @note
4861 * @author zsalah
4862 * @date 8 March 2012
4863 * @version 1.0
4864 */
218dc407 4865s32 host_int_add_ptk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
63d03e47 4866 const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx)
c5c77ba1 4867{
fb4ec9ca 4868 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
4869 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4870 tstrHostIFmsg strHostIFmsg;
63d03e47 4871 u8 u8KeyLen = u8PtkKeylen;
4e4467fd 4872 u32 i;
78c87591 4873
2b9d5b48 4874 if (pstrWFIDrv == NULL)
c5c77ba1 4875 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
2b9d5b48 4876 if (pu8RxMic != NULL)
c5c77ba1 4877 u8KeyLen += RX_MIC_KEY_LEN;
2b9d5b48 4878 if (pu8TxMic != NULL)
c5c77ba1 4879 u8KeyLen += TX_MIC_KEY_LEN;
c5c77ba1
JK
4880
4881 /* prepare the Key Message */
2cc46837 4882 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
4883
4884
4885 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4886 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPAPtk;
4887 #ifdef WILC_AP_EXTERNAL_MLME
4888 if (mode == AP_MODE) {
4889 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4890 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4891 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
4892 }
4893 #endif
4894 if (mode == STATION_MODE)
4895 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
4896
4897
4898 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
dc0ad74b 4899 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = WILC_MALLOC(u8PtkKeylen);
c5c77ba1
JK
4900
4901
d00d2ba3 4902 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
c5c77ba1
JK
4903 pu8Ptk, u8PtkKeylen);
4904
4905 if (pu8RxMic != NULL) {
4906
d00d2ba3 4907 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
c5c77ba1
JK
4908 pu8RxMic, RX_MIC_KEY_LEN);
4909 if (INFO) {
4910 for (i = 0; i < RX_MIC_KEY_LEN; i++)
4911 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
4912 }
4913 }
4914 if (pu8TxMic != NULL) {
4915
d00d2ba3 4916 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
c5c77ba1
JK
4917 pu8TxMic, TX_MIC_KEY_LEN);
4918 if (INFO) {
4919 for (i = 0; i < TX_MIC_KEY_LEN; i++)
4920 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
4921 }
4922 }
4923
4924 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4925 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4926
4927 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4928 uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
4929 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4930 uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
4931 strHostIFmsg.drvHandler = hWFIDrv;
4932
4933 /* send the message */
c4f83a55 4934 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
4935
4936 if (s32Error)
4937 PRINT_ER("Error in sending message queue: PTK Key\n");
4938
4939 /* ////////////// */
83383ea3 4940 down(&(pstrWFIDrv->hSemTestKeyBlock));
c5c77ba1
JK
4941 /* /////// */
4942
4943 WILC_CATCH(s32Error)
4944 {
4945
4946 }
4947
4948 return s32Error;
4949}
4950
4951/**
4952 * @brief adds Rx GTk Key
4953 * @details
4954 * @param[in,out] handle to the wifi driver
4955 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
4956 * u8GtkKeylen :The total key length
4957 *
4958 * @return Error code indicating success/failure
4959 * @note
4960 * @author zsalah
4961 * @date 8 March 2012
4962 * @version 1.0
4963 */
218dc407 4964s32 host_int_add_rx_gtk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
4e4467fd 4965 u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC,
63d03e47 4966 const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode)
c5c77ba1 4967{
fb4ec9ca 4968 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
4969 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4970 tstrHostIFmsg strHostIFmsg;
63d03e47 4971 u8 u8KeyLen = u8GtkKeylen;
c5c77ba1 4972
2b9d5b48 4973 if (pstrWFIDrv == NULL)
c5c77ba1 4974 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1 4975 /* prepare the Key Message */
2cc46837 4976 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
4977
4978
2b9d5b48 4979 if (pu8RxMic != NULL)
c5c77ba1 4980 u8KeyLen += RX_MIC_KEY_LEN;
2b9d5b48 4981 if (pu8TxMic != NULL)
c5c77ba1 4982 u8KeyLen += TX_MIC_KEY_LEN;
c5c77ba1
JK
4983 if (KeyRSC != NULL) {
4984 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
dc0ad74b 4985 uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = WILC_MALLOC(u32KeyRSClen);
c5c77ba1 4986
d00d2ba3 4987 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
c5c77ba1
JK
4988 KeyRSC, u32KeyRSClen);
4989 }
4990
4991
4992 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4993 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPARxGtk;
4994 strHostIFmsg.drvHandler = hWFIDrv;
4995
4996 #ifdef WILC_AP_EXTERNAL_MLME
4997 if (mode == AP_MODE) {
4998 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4999 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
5000 }
5001 #endif
5002 if (mode == STATION_MODE)
5003 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
5004
5005
5006 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
dc0ad74b 5007 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = WILC_MALLOC(u8KeyLen);
c5c77ba1 5008
d00d2ba3 5009 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
c5c77ba1
JK
5010 pu8RxGtk, u8GtkKeylen);
5011
5012 if (pu8RxMic != NULL) {
5013
d00d2ba3 5014 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
c5c77ba1
JK
5015 pu8RxMic, RX_MIC_KEY_LEN);
5016
5017 }
5018 if (pu8TxMic != NULL) {
5019
d00d2ba3 5020 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
c5c77ba1
JK
5021 pu8TxMic, TX_MIC_KEY_LEN);
5022
5023 }
5024
5025 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5026 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
5027 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5028 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
5029
5030 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5031 uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
5032
5033
5034
5035 /* send the message */
c4f83a55 5036 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5037 if (s32Error)
5038 PRINT_ER("Error in sending message queue: RX GTK\n");
5039 /* ////////////// */
83383ea3 5040 down(&(pstrWFIDrv->hSemTestKeyBlock));
c5c77ba1
JK
5041 /* /////// */
5042
5043 WILC_CATCH(s32Error)
5044 {
5045
5046 }
5047 return s32Error;
5048}
c5c77ba1 5049
c5c77ba1
JK
5050/**
5051 * @brief host_int_set_pmkid_info
5052 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
5053 * support is enabled. This Function sets the PMKID in firmware
5054 * when host drivr receives the corresponding request from NDIS.
5055 * The firmware then includes theset PMKID in the appropriate
5056 * management frames
5057 * @param[in,out] handle to the wifi driver
5058 * @param[in] message containing PMKID Info in the following format
5059 *|-----------------------------------------------------------------|
5060 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5061 *|-----------|------------|----------|-------|----------|----------|
5062 | 1 | 6 | 16 | ... | 6 | 16 |
5063 ||-----------------------------------------------------------------|
5064 * @return Error code indicating success/failure
5065 * @note
5066 * @author zsalah
5067 * @date 8 March 2012
5068 * @version 1.0
5069 */
218dc407 5070s32 host_int_set_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray)
c5c77ba1 5071{
fb4ec9ca 5072 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5073 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5074 tstrHostIFmsg strHostIFmsg;
4e4467fd 5075 u32 i;
c5c77ba1
JK
5076
5077
2b9d5b48 5078 if (pstrWFIDrv == NULL)
c5c77ba1 5079 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1
JK
5080
5081 /* prepare the Key Message */
2cc46837 5082 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5083
5084 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
5085 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = PMKSA;
5086 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
5087 strHostIFmsg.drvHandler = hWFIDrv;
5088
5089 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
5090
d00d2ba3 5091 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
c5c77ba1
JK
5092 ETH_ALEN);
5093
d00d2ba3 5094 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
c5c77ba1
JK
5095 PMKID_LEN);
5096 }
5097
5098 /* send the message */
c4f83a55 5099 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5100 if (s32Error)
5101 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
5102
5103 WILC_CATCH(s32Error)
5104 {
5105
5106 }
5107
5108 return s32Error;
5109}
5110
5111/**
5112 * @brief gets the cached the pmkid info
5113 * @details valid only in BSS STA mode if External Supplicant
5114 * support is enabled. This Function sets the PMKID in firmware
5115 * when host drivr receives the corresponding request from NDIS.
5116 * The firmware then includes theset PMKID in the appropriate
5117 * management frames
5118 * @param[in,out] handle to the wifi driver,
5119 * message containing PMKID Info in the following format
5120 *|-----------------------------------------------------------------|
5121 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5122 *|-----------|------------|----------|-------|----------|----------|
5123 | 1 | 6 | 16 | ... | 6 | 16 |
5124 ||-----------------------------------------------------------------|
5125 * @param[in]
5126 * @return Error code indicating success/failure
5127 * @note
5128 * @author zsalah
5129 * @date 8 March 2012
5130 * @version 1.0
5131 */
218dc407 5132s32 host_int_get_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PmkidInfoArray,
4e4467fd 5133 u32 u32PmkidInfoLen)
c5c77ba1 5134{
fb4ec9ca 5135 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5136 tstrWID strWID;
5137 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5138
d85f5326 5139 strWID.u16WIDid = (u16)WID_PMKID_INFO;
c5c77ba1
JK
5140 strWID.enuWIDtype = WID_STR;
5141 strWID.s32ValueSize = u32PmkidInfoLen;
5142 strWID.ps8WidVal = pu8PmkidInfoArray;
5143
5144 return s32Error;
5145}
5146
5147/**
5148 * @brief sets the pass phrase
5149 * @details AP/STA mode. This function gives the pass phrase used to
5150 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5151 * The length of the field can vary from 8 to 64 bytes,
5152 * the lower layer should get the
5153 * @param[in,out] handle to the wifi driver,
5154 * @param[in] String containing PSK
5155 * @return Error code indicating success/failure
5156 * @note
5157 * @author zsalah
5158 * @date 8 March 2012
5159 * @version 1.0
5160 */
218dc407 5161s32 host_int_set_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PassPhrase,
63d03e47 5162 u8 u8Psklength)
c5c77ba1 5163{
fb4ec9ca 5164 s32 s32Error = WILC_SUCCESS;
c5c77ba1 5165 tstrWID strWID;
c5c77ba1 5166
c5c77ba1
JK
5167 /*validating psk length*/
5168 if ((u8Psklength > 7) && (u8Psklength < 65)) {
d85f5326 5169 strWID.u16WIDid = (u16)WID_11I_PSK;
c5c77ba1
JK
5170 strWID.enuWIDtype = WID_STR;
5171 strWID.ps8WidVal = pu8PassPhrase;
5172 strWID.s32ValueSize = u8Psklength;
5173 }
5174
5175 return s32Error;
5176}
5177/**
5178 * @brief host_int_get_MacAddress
5179 * @details gets mac address
5180 * @param[in,out] handle to the wifi driver,
5181 *
5182 * @return Error code indicating success/failure
5183 * @note
5184 * @author mdaftedar
5185 * @date 19 April 2012
5186 * @version 1.0
5187 */
218dc407 5188s32 host_int_get_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
c5c77ba1 5189{
fb4ec9ca 5190 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5191 tstrHostIFmsg strHostIFmsg;
5192
5193
5194 /* prepare the Message */
2cc46837 5195 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5196
5197 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_MAC_ADDRESS;
5198 strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress.u8MacAddress = pu8MacAddress;
5199 strHostIFmsg.drvHandler = hWFIDrv;
5200 /* send the message */
c4f83a55 5201 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5202 if (s32Error) {
5203 PRINT_ER("Failed to send get mac address\n");
5204 return WILC_FAIL;
5205 }
5206
83383ea3 5207 down(&hWaitResponse);
c5c77ba1
JK
5208 return s32Error;
5209}
5210
5211/**
5212 * @brief host_int_set_MacAddress
5213 * @details sets mac address
5214 * @param[in,out] handle to the wifi driver,
5215 *
5216 * @return Error code indicating success/failure
5217 * @note
5218 * @author mabubakr
5219 * @date 16 July 2012
5220 * @version 1.0
5221 */
218dc407 5222s32 host_int_set_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
c5c77ba1 5223{
fb4ec9ca 5224 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5225 tstrHostIFmsg strHostIFmsg;
5226
5227 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
5228
5229 /* prepare setting mac address message */
2cc46837 5230 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1 5231 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MAC_ADDRESS;
d00d2ba3 5232 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress.u8MacAddress, pu8MacAddress, ETH_ALEN);
c5c77ba1
JK
5233 strHostIFmsg.drvHandler = hWFIDrv;
5234
c4f83a55 5235 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5236 if (s32Error) {
5237 PRINT_ER("Failed to send message queue: Set mac address\n");
5238 WILC_ERRORREPORT(s32Error, s32Error);
5239 }
5240 WILC_CATCH(s32Error)
5241 {
5242
5243 }
5244
5245 return s32Error;
5246
5247}
5248
5249/**
5250 * @brief host_int_get_RSNAConfigPSKPassPhrase
5251 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
5252 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5253 * The length of the field can vary from 8 to 64 bytes,
5254 * the lower layer should get the
5255 * @param[in,out] handle to the wifi driver,
5256 * String containing PSK
5257 * @return Error code indicating success/failure
5258 * @note
5259 * @author zsalah
5260 * @date 8 March 2012
5261 * @version 1.0
5262 */
218dc407 5263s32 host_int_get_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv,
63d03e47 5264 u8 *pu8PassPhrase, u8 u8Psklength)
c5c77ba1 5265{
fb4ec9ca 5266 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5267 tstrWID strWID;
5268 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5269
d85f5326 5270 strWID.u16WIDid = (u16)WID_11I_PSK;
c5c77ba1
JK
5271 strWID.enuWIDtype = WID_STR;
5272 strWID.s32ValueSize = u8Psklength;
5273 strWID.ps8WidVal = pu8PassPhrase;
5274
5275 return s32Error;
5276}
5277
5278/**
5279 * @brief host_int_get_site_survey_results
5280 * @details gets the site survey results
5281 * @param[in,out] handle to the wifi driver,
5282 * Message containing site survey results in the
5283 * following format
5284 *|---------------------------------------------------|
5285 | MsgLength | fragNo. | MsgBodyLength | MsgBody |
5286 ||-----------|-----------|---------------|-----------|
5287 | 1 | 1 | 1 | 1 |
5288 | ----------------------------------------- | ----------------
5289 |
5290 ||---------------------------------------|
5291 | Network1 | Netweork2 | ... | Network5 |
5292 ||---------------------------------------|
5293 | 44 | 44 | ... | 44 |
5294 | -------------------------- | ---------------------------------------
5295 |
5296 ||---------------------------------------------------------------------|
5297 | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved |
5298 |
5299 |
5300 ||------|----------|---------|----------------|-------|------|---------|
5301 | 33 | 1 | 1 | 1 | 6 | 1 | 1 |
5302 ||---------------------------------------------------------------------|
5303 * @return Error code indicating success/failure
5304 * @note
5305 * @author zsalah
5306 * @date 8 March 2012
5307 * @version 1.0
5308 */
5309#ifndef CONNECT_DIRECT
218dc407 5310s32 host_int_get_site_survey_results(tstrWILC_WFIDrv *hWFIDrv,
63d03e47 5311 u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE],
4e4467fd 5312 u32 u32MaxSiteSrvyFragLen)
c5c77ba1 5313{
fb4ec9ca 5314 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5315 tstrWID astrWIDList[2];
5316 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5317
d85f5326 5318 astrWIDList[0].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
c5c77ba1
JK
5319 astrWIDList[0].enuWIDtype = WID_STR;
5320 astrWIDList[0].ps8WidVal = ppu8RcvdSiteSurveyResults[0];
5321 astrWIDList[0].s32ValueSize = u32MaxSiteSrvyFragLen;
5322
d85f5326 5323 astrWIDList[1].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
c5c77ba1
JK
5324 astrWIDList[1].enuWIDtype = WID_STR;
5325 astrWIDList[1].ps8WidVal = ppu8RcvdSiteSurveyResults[1];
5326 astrWIDList[1].s32ValueSize = u32MaxSiteSrvyFragLen;
5327
72ed4dc7 5328 s32Error = SendConfigPkt(GET_CFG, astrWIDList, 2, true, (u32)pstrWFIDrv);
c5c77ba1
JK
5329
5330 /*get the value by searching the local copy*/
5331 if (s32Error) {
5332 PRINT_ER("Failed to send config packet to get survey results\n");
5333 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5334 }
5335
5336 WILC_CATCH(s32Error)
5337 {
5338
5339 }
5340
5341 return s32Error;
5342}
5343#endif
5344
5345/**
5346 * @brief sets a start scan request
5347 * @details
5348 * @param[in,out] handle to the wifi driver,
5349 * @param[in] Scan Source one of the following values
5350 * DEFAULT_SCAN 0
5351 * USER_SCAN BIT0
5352 * OBSS_PERIODIC_SCAN BIT1
5353 * OBSS_ONETIME_SCAN BIT2
5354 * @return Error code indicating success/failure
5355 * @note
5356 * @author zsalah
5357 * @date 8 March 2012
5358 * @version 1.0
5359 */
218dc407 5360s32 host_int_set_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 scanSource)
c5c77ba1 5361{
fb4ec9ca 5362 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5363 tstrWID strWID;
5364 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5365
d85f5326 5366 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
c5c77ba1 5367 strWID.enuWIDtype = WID_CHAR;
ca356ada 5368 strWID.ps8WidVal = (s8 *)&scanSource;
576917ad 5369 strWID.s32ValueSize = sizeof(char);
c5c77ba1
JK
5370
5371 return s32Error;
5372}
5373
5374/**
5375 * @brief host_int_get_start_scan_req
5376 * @details gets a start scan request
5377 * @param[in,out] handle to the wifi driver,
5378 * @param[in] Scan Source one of the following values
5379 * DEFAULT_SCAN 0
5380 * USER_SCAN BIT0
5381 * OBSS_PERIODIC_SCAN BIT1
5382 * OBSS_ONETIME_SCAN BIT2
5383 * @return Error code indicating success/failure
5384 * @note
5385 * @author zsalah
5386 * @date 8 March 2012
5387 * @version 1.0
5388 */
5389
218dc407 5390s32 host_int_get_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ScanSource)
c5c77ba1 5391{
fb4ec9ca 5392 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5393 tstrWID strWID;
5394 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5395
d85f5326 5396 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
c5c77ba1 5397 strWID.enuWIDtype = WID_CHAR;
ca356ada 5398 strWID.ps8WidVal = (s8 *)pu8ScanSource;
576917ad 5399 strWID.s32ValueSize = sizeof(char);
c5c77ba1
JK
5400
5401 return s32Error;
5402}
5403
5404/**
5405 * @brief host_int_set_join_req
5406 * @details sets a join request
5407 * @param[in,out] handle to the wifi driver,
5408 * @param[in] Index of the bss descriptor
5409 * @return Error code indicating success/failure
5410 * @note
5411 * @author zsalah
5412 * @date 8 March 2012
5413 * @version 1.0
5414 */
218dc407 5415s32 host_int_set_join_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8bssid,
057d1e97 5416 const u8 *pu8ssid, size_t ssidLen,
63d03e47 5417 const u8 *pu8IEs, size_t IEsLen,
c5c77ba1 5418 tWILCpfConnectResult pfConnectResult, void *pvUserArg,
63d03e47
GKH
5419 u8 u8security, AUTHTYPE_T tenuAuth_type,
5420 u8 u8channel,
c5c77ba1
JK
5421 void *pJoinParams)
5422{
fb4ec9ca 5423 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5424 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5425 tstrHostIFmsg strHostIFmsg;
5426 tenuScanConnTimer enuScanConnTimer;
5427
2b9d5b48 5428 if (pstrWFIDrv == NULL || pfConnectResult == NULL)
c5c77ba1 5429 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1
JK
5430
5431 if (hWFIDrv == NULL) {
5432 PRINT_ER("Driver not initialized: gWFiDrvHandle = NULL\n");
5433 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5434 }
5435
5436 if (pJoinParams == NULL) {
5437 PRINT_ER("Unable to Join - JoinParams is NULL\n");
5438 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5439
5440 }
5441/*
5442 * if(gWFiDrvHandle->strWILC_UsrScanReq.u32RcvdChCount == 0)
5443 * {
5444 * PRINT_ER("No scan results exist: Scanning should be done\n");
5445 * WILC_ERRORREPORT(s32Error, WILC_FAIL);
5446 * }
5447 */
5448 /* prepare the Connect Message */
2cc46837 5449 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5450
5451 strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT;
5452
5453 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8security = u8security;
5454 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.tenuAuth_type = tenuAuth_type;
5455 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8channel = u8channel;
5456 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pfConnectResult = pfConnectResult;
5457 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pvUserArg = pvUserArg;
5458 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pJoinParams = pJoinParams;
5459 strHostIFmsg.drvHandler = hWFIDrv;
5460
5461 if (pu8bssid != NULL) {
dc0ad74b 5462 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid = WILC_MALLOC(6); /* will be deallocated by the receiving thread */
d00d2ba3 5463 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid,
c5c77ba1
JK
5464 pu8bssid, 6);
5465 }
5466
5467 if (pu8ssid != NULL) {
5468 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.ssidLen = ssidLen;
dc0ad74b 5469 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid = WILC_MALLOC(ssidLen); /* will be deallocated by the receiving thread */
d00d2ba3 5470 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid,
c5c77ba1
JK
5471
5472 pu8ssid, ssidLen);
5473 }
5474
5475 if (pu8IEs != NULL) {
5476 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.IEsLen = IEsLen;
dc0ad74b 5477 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs = WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */
d00d2ba3 5478 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs,
c5c77ba1
JK
5479 pu8IEs, IEsLen);
5480 }
78174ada 5481 if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING)
c5c77ba1 5482 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING;
78174ada 5483 else
c5c77ba1
JK
5484 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate);
5485
5486 /* send the message */
c4f83a55 5487 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5488 if (s32Error) {
5489 PRINT_ER("Failed to send message queue: Set join request\n");
5490 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5491 }
5492
5493 enuScanConnTimer = CONNECT_TIMER;
9eb06643
GKH
5494 pstrWFIDrv->hConnectTimer.data = (unsigned long)hWFIDrv;
5495 mod_timer(&pstrWFIDrv->hConnectTimer,
5496 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
c5c77ba1
JK
5497
5498 WILC_CATCH(s32Error)
5499 {
5500
5501 }
5502
5503 return s32Error;
5504}
5505
5506/**
5507 * @brief Flush a join request parameters to FW, but actual connection
5508 * @details The function is called in situation where WILC is connected to AP and
5509 * required to switch to hybrid FW for P2P connection
5510 * @param[in] handle to the wifi driver,
5511 * @return Error code indicating success/failure
5512 * @note
5513 * @author Amr Abdel-Moghny
5514 * @date 19 DEC 2013
5515 * @version 8.0
5516 */
5517
218dc407 5518s32 host_int_flush_join_req(tstrWILC_WFIDrv *hWFIDrv)
c5c77ba1 5519{
fb4ec9ca 5520 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5521 tstrHostIFmsg strHostIFmsg;
5522
5523 if (!gu8FlushedJoinReq) {
5524 s32Error = WILC_FAIL;
5525 return s32Error;
5526 }
5527
5528
2b9d5b48 5529 if (hWFIDrv == NULL)
c5c77ba1 5530 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1
JK
5531
5532
5533 strHostIFmsg.u16MsgId = HOST_IF_MSG_FLUSH_CONNECT;
5534 strHostIFmsg.drvHandler = hWFIDrv;
5535
5536 /* send the message */
c4f83a55 5537 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5538 if (s32Error) {
5539 PRINT_ER("Failed to send message queue: Flush join request\n");
5540 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5541 }
5542
5543 WILC_CATCH(s32Error)
5544 {
5545
5546 }
5547 return s32Error;
5548}
5549
5550/**
5551 * @brief host_int_disconnect
5552 * @details disconnects from the currently associated network
5553 * @param[in,out] handle to the wifi driver,
5554 * @param[in] Reason Code of the Disconnection
5555 * @return Error code indicating success/failure
5556 * @note
5557 * @author zsalah
5558 * @date 8 March 2012
5559 * @version 1.0
5560 */
218dc407 5561s32 host_int_disconnect(tstrWILC_WFIDrv *hWFIDrv, u16 u16ReasonCode)
c5c77ba1 5562{
fb4ec9ca 5563 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5564 tstrHostIFmsg strHostIFmsg;
5565 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5566
b1413b60 5567 if (pstrWFIDrv == NULL) {
03b2d5e7 5568 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
c5c77ba1
JK
5569 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5570 }
5571
5572 if (pstrWFIDrv == NULL) {
5573 PRINT_ER("gWFiDrvHandle = NULL\n");
5574 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5575 }
5576
5577 /* prepare the Disconnect Message */
2cc46837 5578 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5579
5580 strHostIFmsg.u16MsgId = HOST_IF_MSG_DISCONNECT;
5581 strHostIFmsg.drvHandler = hWFIDrv;
5582
5583 /* send the message */
c4f83a55 5584 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5585 if (s32Error)
5586 PRINT_ER("Failed to send message queue: disconnect\n");
5587 /* ////////////// */
83383ea3 5588 down(&(pstrWFIDrv->hSemTestDisconnectBlock));
c5c77ba1
JK
5589 /* /////// */
5590
5591 WILC_CATCH(s32Error)
5592 {
5593
5594 }
5595
5596 return s32Error;
5597}
5598
5599/**
5600 * @brief host_int_disconnect_station
5601 * @details disconnects a sta
5602 * @param[in,out] handle to the wifi driver,
5603 * @param[in] Association Id of the station to be disconnected
5604 * @return Error code indicating success/failure
5605 * @note
5606 * @author zsalah
5607 * @date 8 March 2012
5608 * @version 1.0
5609 */
218dc407 5610s32 host_int_disconnect_station(tstrWILC_WFIDrv *hWFIDrv, u8 assoc_id)
c5c77ba1 5611{
fb4ec9ca 5612 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5613 tstrWID strWID;
5614 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5615
d85f5326 5616 strWID.u16WIDid = (u16)WID_DISCONNECT;
c5c77ba1 5617 strWID.enuWIDtype = WID_CHAR;
ca356ada 5618 strWID.ps8WidVal = (s8 *)&assoc_id;
576917ad 5619 strWID.s32ValueSize = sizeof(char);
c5c77ba1
JK
5620
5621 return s32Error;
5622}
5623
5624/**
5625 * @brief host_int_get_assoc_req_info
5626 * @details gets a Association request info
5627 * @param[in,out] handle to the wifi driver,
5628 * Message containg assoc. req info in the following format
5629 * ------------------------------------------------------------------------
5630 | Management Frame Format |
5631 ||-------------------------------------------------------------------|
5632 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5633 ||-------------|--------|--|--|-----|----------------|----------|----|
5634 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5635 ||-------------------------------------------------------------------|
5636 | |
5637 | Association Request Frame - Frame Body |
5638 ||-------------------------------------------------------------------|
5639 | Capability Information | Listen Interval | SSID | Supported Rates |
5640 ||------------------------|-----------------|------|-----------------|
5641 | 2 | 2 | 2-34 | 3-10 |
5642 | ---------------------------------------------------------------------
5643 * @return Error code indicating success/failure
5644 * @note
5645 * @author zsalah
5646 * @date 8 March 2012
5647 * @version 1.0
5648 */
5649
218dc407 5650s32 host_int_get_assoc_req_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocReqInfo,
4e4467fd 5651 u32 u32AssocReqInfoLen)
c5c77ba1 5652{
fb4ec9ca 5653 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5654 tstrWID strWID;
5655 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5656
d85f5326 5657 strWID.u16WIDid = (u16)WID_ASSOC_REQ_INFO;
c5c77ba1
JK
5658 strWID.enuWIDtype = WID_STR;
5659 strWID.ps8WidVal = pu8AssocReqInfo;
5660 strWID.s32ValueSize = u32AssocReqInfoLen;
5661
5662
5663 return s32Error;
5664}
5665
5666/**
5667 * @brief gets a Association Response info
5668 * @details
5669 * @param[in,out] handle to the wifi driver,
5670 * Message containg assoc. resp info
5671 * @return Error code indicating success/failure
5672 * @note
5673 * @author zsalah
5674 * @date 8 March 2012
5675 * @version 1.0
5676 */
218dc407 5677s32 host_int_get_assoc_res_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocRespInfo,
4e4467fd 5678 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
c5c77ba1 5679{
fb4ec9ca 5680 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5681 tstrWID strWID;
5682 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5683
b1413b60 5684 if (pstrWFIDrv == NULL) {
03b2d5e7 5685 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
c5c77ba1
JK
5686 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5687 }
5688
d85f5326 5689 strWID.u16WIDid = (u16)WID_ASSOC_RES_INFO;
c5c77ba1
JK
5690 strWID.enuWIDtype = WID_STR;
5691 strWID.ps8WidVal = pu8AssocRespInfo;
5692 strWID.s32ValueSize = u32MaxAssocRespInfoLen;
5693
5694
5695 /* Sending Configuration packet */
72ed4dc7 5696 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
5697 if (s32Error) {
5698 PRINT_ER("Failed to send association response config packet\n");
5699 *pu32RcvdAssocRespInfoLen = 0;
5700 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5701 } else {
5702 *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize;
5703 }
5704
5705 WILC_CATCH(s32Error)
5706 {
5707
5708 }
5709 return s32Error;
5710}
5711
5712/**
5713 * @brief gets a Association Response info
5714 * @details Valid only in STA mode. This function gives the RSSI
5715 * values observed in all the channels at the time of scanning.
5716 * The length of the field is 1 greater that the total number of
5717 * channels supported. Byte 0 contains the number of channels while
5718 * each of Byte N contains the observed RSSI value for the channel index N.
5719 * @param[in,out] handle to the wifi driver,
5720 * array of scanned channels' RSSI
5721 * @return Error code indicating success/failure
5722 * @note
5723 * @author zsalah
5724 * @date 8 March 2012
5725 * @version 1.0
5726 */
218dc407 5727s32 host_int_get_rx_power_level(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8RxPowerLevel,
4e4467fd 5728 u32 u32RxPowerLevelLen)
c5c77ba1 5729{
fb4ec9ca 5730 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5731 tstrWID strWID;
5732 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5733
d85f5326 5734 strWID.u16WIDid = (u16)WID_RX_POWER_LEVEL;
c5c77ba1
JK
5735 strWID.enuWIDtype = WID_STR;
5736 strWID.ps8WidVal = pu8RxPowerLevel;
5737 strWID.s32ValueSize = u32RxPowerLevelLen;
5738
5739
5740 return s32Error;
5741}
5742
5743/**
5744 * @brief sets a channel
5745 * @details
5746 * @param[in,out] handle to the wifi driver,
5747 * @param[in] Index of the channel to be set
5748 *|-------------------------------------------------------------------|
5749 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5750 | Input: 1 2 14 |
5751 ||-------------------------------------------------------------------|
5752 * @return Error code indicating success/failure
5753 * @note
5754 * @author zsalah
5755 * @date 8 March 2012
5756 * @version 1.0
5757 */
218dc407 5758s32 host_int_set_mac_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 u8ChNum)
c5c77ba1 5759{
fb4ec9ca 5760 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5761 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5762 tstrHostIFmsg strHostIFmsg;
5763
2b9d5b48 5764 if (pstrWFIDrv == NULL)
c5c77ba1 5765 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1
JK
5766
5767 /* prepare the set channel message */
2cc46837 5768 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5769 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_CHANNEL;
5770 strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan.u8SetChan = u8ChNum;
5771 strHostIFmsg.drvHandler = hWFIDrv;
5772
c4f83a55 5773 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 5774 if (s32Error)
c5c77ba1 5775 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
5776 WILC_CATCH(s32Error)
5777 {
5778
5779 }
5780
5781 return s32Error;
5782}
5783
5784
fb4ec9ca 5785s32 host_int_wait_msg_queue_idle(void)
c5c77ba1 5786{
fb4ec9ca 5787 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5788
5789 tstrHostIFmsg strHostIFmsg;
5790
5791 /* prepare the set driver handler message */
5792
2cc46837 5793 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1 5794 strHostIFmsg.u16MsgId = HOST_IF_MSG_Q_IDLE;
c4f83a55 5795 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 5796 if (s32Error)
c5c77ba1 5797 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
5798 WILC_CATCH(s32Error)
5799 {
5800
5801 }
5802
5803 /* wait untill MSG Q is empty */
83383ea3 5804 down(&hWaitResponse);
c5c77ba1
JK
5805
5806 return s32Error;
5807
5808}
5809
218dc407 5810s32 host_int_set_wfi_drv_handler(tstrWILC_WFIDrv *u32address)
c5c77ba1 5811{
fb4ec9ca 5812 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5813
5814 tstrHostIFmsg strHostIFmsg;
5815
5816
5817 /* prepare the set driver handler message */
5818
2cc46837 5819 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5820 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_WFIDRV_HANDLER;
5821 strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler.u32Address = u32address;
5822 /* strHostIFmsg.drvHandler=hWFIDrv; */
5823
c4f83a55 5824 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 5825 if (s32Error)
c5c77ba1 5826 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
5827 WILC_CATCH(s32Error)
5828 {
5829
5830 }
5831
5832 return s32Error;
5833}
5834
5835
5836
218dc407 5837s32 host_int_set_operation_mode(tstrWILC_WFIDrv *hWFIDrv, u32 u32mode)
c5c77ba1 5838{
fb4ec9ca 5839 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5840
5841 tstrHostIFmsg strHostIFmsg;
5842
5843
5844 /* prepare the set driver handler message */
5845
2cc46837 5846 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5847 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_OPERATION_MODE;
5848 strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode.u32Mode = u32mode;
5849 strHostIFmsg.drvHandler = hWFIDrv;
5850
c4f83a55 5851 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 5852 if (s32Error)
c5c77ba1 5853 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
5854 WILC_CATCH(s32Error)
5855 {
5856
5857 }
5858
5859 return s32Error;
5860}
5861
5862/**
5863 * @brief gets the current channel index
5864 * @details
5865 * @param[in,out] handle to the wifi driver,
5866 * current channel index
5867 *|-----------------------------------------------------------------------|
5868 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5869 | Input: 1 2 14 |
5870 ||-----------------------------------------------------------------------|
5871 * @return Error code indicating success/failure
5872 * @note
5873 * @author zsalah
5874 * @date 8 March 2012
5875 * @version 1.0
5876 */
218dc407 5877s32 host_int_get_host_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ChNo)
c5c77ba1 5878{
fb4ec9ca 5879 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5880 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5881 tstrHostIFmsg strHostIFmsg;
5882
b1413b60 5883 if (pstrWFIDrv == NULL) {
03b2d5e7 5884 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
c5c77ba1
JK
5885 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5886 }
5887
5888 /* prepare the Get Channel Message */
2cc46837 5889 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5890
5891 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_CHNL;
5892 strHostIFmsg.drvHandler = hWFIDrv;
5893
5894 /* send the message */
c4f83a55 5895 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5896 if (s32Error)
5897 PRINT_ER("Failed to send get host channel param's message queue ");
83383ea3 5898 down(&(pstrWFIDrv->hSemGetCHNL));
c5c77ba1
JK
5899 /* gu8Chnl = 11; */
5900
5901 *pu8ChNo = gu8Chnl;
5902
5903 WILC_CATCH(s32Error)
5904 {
5905 }
5906
5907 return s32Error;
5908
5909
5910}
5911
5912
5913/**
5914 * @brief host_int_test_set_int_wid
5915 * @details Test function for setting wids
4e4467fd 5916 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr
c5c77ba1
JK
5917 * @return Error code indicating success/failure
5918 * @note
5919 * @author zsalah
5920 * @date 8 March 2012
5921 * @version 1.0
5922 */
218dc407 5923s32 host_int_test_set_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 u32TestMemAddr)
c5c77ba1 5924{
fb4ec9ca 5925 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5926 tstrWID strWID;
5927 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5928
5929
b1413b60 5930 if (pstrWFIDrv == NULL) {
03b2d5e7 5931 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
c5c77ba1
JK
5932 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5933 }
5934
5935 /*prepare configuration packet*/
d85f5326 5936 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
c5c77ba1 5937 strWID.enuWIDtype = WID_INT;
576917ad 5938 strWID.ps8WidVal = (char *)&u32TestMemAddr;
4e4467fd 5939 strWID.s32ValueSize = sizeof(u32);
c5c77ba1
JK
5940
5941 /*Sending Cfg*/
72ed4dc7 5942 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
5943 if (s32Error) {
5944 PRINT_ER("Test Function: Failed to set wid value\n");
5945 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5946 } else {
5947 PRINT_D(HOSTINF_DBG, "Successfully set wid value\n");
5948
5949 }
5950
5951 WILC_CATCH(s32Error)
5952 {
5953
5954 }
5955 return s32Error;
5956}
5957
5958#ifdef WILC_AP_EXTERNAL_MLME
5959/**
5960 * @brief host_int_get_inactive_time
5961 * @details
5962 * @param[in,out] handle to the wifi driver,
5963 * current sta macaddress, inactive_time
5964 * @return
5965 * @note
5966 * @author
5967 * @date
5968 * @version 1.0
5969 */
218dc407 5970s32 host_int_get_inactive_time(tstrWILC_WFIDrv *hWFIDrv, const u8 *mac, u32 *pu32InactiveTime)
c5c77ba1 5971{
fb4ec9ca 5972 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
5973 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5974 tstrHostIFmsg strHostIFmsg;
5975
b1413b60 5976 if (pstrWFIDrv == NULL) {
03b2d5e7 5977 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
c5c77ba1
JK
5978 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5979 }
5980
2cc46837 5981 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5982
5983
d00d2ba3 5984 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT.mac,
c5c77ba1
JK
5985 mac, ETH_ALEN);
5986
5987 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_INACTIVETIME;
5988 strHostIFmsg.drvHandler = hWFIDrv;
5989
5990 /* send the message */
c4f83a55 5991 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
5992 if (s32Error)
5993 PRINT_ER("Failed to send get host channel param's message queue ");
5994
83383ea3 5995 down(&(pstrWFIDrv->hSemInactiveTime));
c5c77ba1
JK
5996
5997 *pu32InactiveTime = gu32InactiveTime;
5998
5999 WILC_CATCH(s32Error)
6000 {
6001 }
6002
6003 return s32Error;
6004}
6005#endif
6006/**
6007 * @brief host_int_test_get_int_wid
6008 * @details Test function for getting wids
4e4467fd 6009 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
c5c77ba1
JK
6010 * @return Error code indicating success/failure
6011 * @note
6012 * @author zsalah
6013 * @date 8 March 2012
6014 * @version 1.0
6015 */
218dc407 6016s32 host_int_test_get_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 *pu32TestMemAddr)
c5c77ba1
JK
6017{
6018
fb4ec9ca 6019 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
6020 tstrWID strWID;
6021 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6022
6023
b1413b60 6024 if (pstrWFIDrv == NULL) {
03b2d5e7 6025 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
c5c77ba1
JK
6026 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6027 }
6028
d85f5326 6029 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
c5c77ba1 6030 strWID.enuWIDtype = WID_INT;
ca356ada 6031 strWID.ps8WidVal = (s8 *)pu32TestMemAddr;
4e4467fd 6032 strWID.s32ValueSize = sizeof(u32);
c5c77ba1 6033
72ed4dc7 6034 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true, (u32)pstrWFIDrv);
c5c77ba1
JK
6035 /*get the value by searching the local copy*/
6036 if (s32Error) {
6037 PRINT_ER("Test Function: Failed to get wid value\n");
6038 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
6039 } else {
6040 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
6041
6042 }
6043
6044 WILC_CATCH(s32Error)
6045 {
6046
6047 }
6048 return s32Error;
6049}
6050
6051
6052/**
6053 * @brief host_int_get_rssi
6054 * @details gets the currently maintained RSSI value for the station.
6055 * The received signal strength value in dB.
6056 * The range of valid values is -128 to 0.
6057 * @param[in,out] handle to the wifi driver,
6058 * rssi value in dB
6059 * @return Error code indicating success/failure
6060 * @note
6061 * @author zsalah
6062 * @date 8 March 2012
6063 * @version 1.0
6064 */
218dc407 6065s32 host_int_get_rssi(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8Rssi)
c5c77ba1 6066{
fb4ec9ca 6067 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
6068 tstrHostIFmsg strHostIFmsg;
6069 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6070
6071
6072 /* prepare the Get RSSI Message */
2cc46837 6073 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6074
6075 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
6076 strHostIFmsg.drvHandler = hWFIDrv;
6077
6078 /* send the message */
c4f83a55 6079 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6080 if (s32Error) {
6081 PRINT_ER("Failed to send get host channel param's message queue ");
6082 return WILC_FAIL;
6083 }
6084
83383ea3 6085 down(&(pstrWFIDrv->hSemGetRSSI));
c5c77ba1
JK
6086
6087
6088 if (ps8Rssi == NULL) {
6089 PRINT_ER("RSS pointer value is null");
6090 return WILC_FAIL;
6091 }
6092
6093
6094 *ps8Rssi = gs8Rssi;
6095
6096
6097 return s32Error;
6098}
6099
218dc407 6100s32 host_int_get_link_speed(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8lnkspd)
c5c77ba1
JK
6101{
6102 tstrHostIFmsg strHostIFmsg;
fb4ec9ca 6103 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
6104
6105 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6106
6107
6108
6109 /* prepare the Get LINKSPEED Message */
2cc46837 6110 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6111
6112 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_LINKSPEED;
6113 strHostIFmsg.drvHandler = hWFIDrv;
6114
6115 /* send the message */
c4f83a55 6116 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6117 if (s32Error) {
6118 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
6119 return WILC_FAIL;
6120 }
6121
83383ea3 6122 down(&(pstrWFIDrv->hSemGetLINKSPEED));
c5c77ba1
JK
6123
6124
6125 if (ps8lnkspd == NULL) {
6126 PRINT_ER("LINKSPEED pointer value is null");
6127 return WILC_FAIL;
6128 }
6129
6130
6131 *ps8lnkspd = gs8lnkspd;
6132
6133
6134 return s32Error;
6135}
6136
218dc407 6137s32 host_int_get_statistics(tstrWILC_WFIDrv *hWFIDrv, tstrStatistics *pstrStatistics)
c5c77ba1 6138{
fb4ec9ca 6139 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
6140 tstrHostIFmsg strHostIFmsg;
6141
6142
6143 /* prepare the Get RSSI Message */
2cc46837 6144 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6145
6146 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_STATISTICS;
576917ad 6147 strHostIFmsg.uniHostIFmsgBody.pUserData = (char *)pstrStatistics;
c5c77ba1
JK
6148 strHostIFmsg.drvHandler = hWFIDrv;
6149 /* send the message */
c4f83a55 6150 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6151 if (s32Error) {
6152 PRINT_ER("Failed to send get host channel param's message queue ");
6153 return WILC_FAIL;
6154 }
6155
83383ea3 6156 down(&hWaitResponse);
c5c77ba1
JK
6157 return s32Error;
6158}
6159
6160
6161/**
6162 * @brief host_int_scan
6163 * @details scans a set of channels
6164 * @param[in,out] handle to the wifi driver,
6165 * @param[in] Scan source
6166 * Scan Type PASSIVE_SCAN = 0,
6167 * ACTIVE_SCAN = 1
6168 * Channels Array
6169 * Channels Array length
6170 * Scan Callback function
6171 * @return Error code indicating success/failure
6172 * @note
6173 * @author zsalah
6174 * @date 8 March 2012
6175 * @version 1.0
6176 */
218dc407 6177s32 host_int_scan(tstrWILC_WFIDrv *hWFIDrv, u8 u8ScanSource,
63d03e47
GKH
6178 u8 u8ScanType, u8 *pu8ChnlFreqList,
6179 u8 u8ChnlListLen, const u8 *pu8IEs,
c5c77ba1
JK
6180 size_t IEsLen, tWILCpfScanResult ScanResult,
6181 void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork)
6182{
fb4ec9ca 6183 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
6184 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6185 tstrHostIFmsg strHostIFmsg;
6186 tenuScanConnTimer enuScanConnTimer;
6187
2b9d5b48 6188 if (pstrWFIDrv == NULL || ScanResult == NULL)
c5c77ba1 6189 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1
JK
6190
6191
6192 /* prepare the Scan Message */
2cc46837 6193 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6194
6195 strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN;
6196
6197 if (pstrHiddenNetwork != NULL) {
6198 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
6199 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
6200
6201 } else
6202 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
6203
6204 strHostIFmsg.drvHandler = hWFIDrv;
6205 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanSource = u8ScanSource;
6206 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanType = u8ScanType;
6207 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pfScanResult = ScanResult;
6208 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pvUserArg = pvUserArg;
6209
6210 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ChnlListLen = u8ChnlListLen;
dc0ad74b 6211 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList = WILC_MALLOC(u8ChnlListLen); /* will be deallocated by the receiving thread */
d00d2ba3 6212 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList,
c5c77ba1
JK
6213 pu8ChnlFreqList, u8ChnlListLen);
6214
6215 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.IEsLen = IEsLen;
dc0ad74b 6216 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs = WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */
d00d2ba3 6217 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs,
c5c77ba1
JK
6218 pu8IEs, IEsLen);
6219
6220 /* send the message */
c4f83a55 6221 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6222 if (s32Error) {
6223 PRINT_ER("Error in sending message queue scanning parameters: Error(%d)\n", s32Error);
6224 WILC_ERRORREPORT(s32Error, WILC_FAIL);
6225 }
6226
6227 enuScanConnTimer = SCAN_TIMER;
6228 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
9eb06643
GKH
6229 pstrWFIDrv->hScanTimer.data = (unsigned long)hWFIDrv;
6230 mod_timer(&pstrWFIDrv->hScanTimer,
6231 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
c5c77ba1
JK
6232
6233 WILC_CATCH(s32Error)
6234 {
6235
6236 }
6237 return s32Error;
6238
6239}
6240/**
6241 * @brief hif_set_cfg
6242 * @details sets configuration wids values
6243 * @param[in,out] handle to the wifi driver,
6244 * @param[in] WID, WID value
6245 * @return Error code indicating success/failure
6246 * @note
6247 * @author zsalah
6248 * @date 8 March 2012
6249 * @version 1.0
6250 */
218dc407 6251s32 hif_set_cfg(tstrWILC_WFIDrv *hWFIDrv, tstrCfgParamVal *pstrCfgParamVal)
c5c77ba1
JK
6252{
6253
fb4ec9ca 6254 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
6255 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6256
6257 tstrHostIFmsg strHostIFmsg;
6258
6259
2b9d5b48 6260 if (pstrWFIDrv == NULL)
c5c77ba1 6261 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1 6262 /* prepare the WiphyParams Message */
2cc46837 6263 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6264 strHostIFmsg.u16MsgId = HOST_IF_MSG_CFG_PARAMS;
6265 strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr.pstrCfgParamVal = *pstrCfgParamVal;
6266 strHostIFmsg.drvHandler = hWFIDrv;
6267
c4f83a55 6268 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6269
6270 WILC_CATCH(s32Error)
6271 {
6272 }
6273
6274 return s32Error;
6275
6276}
6277
6278
6279/**
6280 * @brief hif_get_cfg
6281 * @details gets configuration wids values
6282 * @param[in,out] handle to the wifi driver,
6283 * WID value
6284 * @param[in] WID,
6285 * @return Error code indicating success/failure
6286 * @note
6287 * @author zsalah
6288 *
6289 * @date 8 March 2012
6290 * @version 1.0
6291 */
218dc407 6292s32 hif_get_cfg(tstrWILC_WFIDrv *hWFIDrv, u16 u16WID, u16 *pu16WID_Value)
c5c77ba1 6293{
fb4ec9ca 6294 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
6295 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6296
83383ea3 6297 down(&(pstrWFIDrv->gtOsCfgValuesSem));
c5c77ba1 6298
b1413b60 6299 if (pstrWFIDrv == NULL) {
03b2d5e7 6300 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
c5c77ba1
JK
6301 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6302 }
6303 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
6304 switch (u16WID) {
6305
6306 case WID_BSS_TYPE:
d85f5326 6307 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type;
c5c77ba1
JK
6308 break;
6309
6310 case WID_AUTH_TYPE:
d85f5326 6311 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type;
c5c77ba1
JK
6312 break;
6313
6314 case WID_AUTH_TIMEOUT:
6315 *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout;
6316 break;
6317
6318 case WID_POWER_MANAGEMENT:
d85f5326 6319 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode;
c5c77ba1
JK
6320 break;
6321
6322 case WID_SHORT_RETRY_LIMIT:
6323 *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit;
6324 break;
6325
6326 case WID_LONG_RETRY_LIMIT:
6327 *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit;
6328 break;
6329
6330 case WID_FRAG_THRESHOLD:
6331 *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold;
6332 break;
6333
6334 case WID_RTS_THRESHOLD:
6335 *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold;
6336 break;
6337
6338 case WID_PREAMBLE:
d85f5326 6339 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type;
c5c77ba1
JK
6340 break;
6341
6342 case WID_SHORT_SLOT_ALLOWED:
d85f5326 6343 *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed;
c5c77ba1
JK
6344 break;
6345
6346 case WID_11N_TXOP_PROT_DISABLE:
d85f5326 6347 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled;
c5c77ba1
JK
6348 break;
6349
6350 case WID_BEACON_INTERVAL:
6351 *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval;
6352 break;
6353
6354 case WID_DTIM_PERIOD:
d85f5326 6355 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period;
c5c77ba1
JK
6356 break;
6357
6358 case WID_SITE_SURVEY:
d85f5326 6359 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled;
c5c77ba1
JK
6360 break;
6361
6362 case WID_SITE_SURVEY_SCAN_TIME:
6363 *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time;
6364 break;
6365
6366 case WID_ACTIVE_SCAN_TIME:
6367 *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time;
6368 break;
6369
6370 case WID_PASSIVE_SCAN_TIME:
6371 *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time;
6372 break;
6373
6374 case WID_CURRENT_TX_RATE:
6375 *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate;
6376 break;
6377
6378 default:
6379 break;
6380 }
6381
83383ea3 6382 up(&(pstrWFIDrv->gtOsCfgValuesSem));
c5c77ba1
JK
6383
6384 WILC_CATCH(s32Error)
6385 {
6386 }
6387 return s32Error;
6388
6389}
6390
6391/*****************************************************************************/
6392/* Notification Functions */
6393/*****************************************************************************/
6394/**
6395 * @brief notifies host with join and leave requests
6396 * @details This function prepares an Information frame having the
6397 * information about a joining/leaving station.
6398 * @param[in,out] handle to the wifi driver,
6399 * @param[in] 6 byte Sta Adress
6400 * Join or leave flag:
6401 * Join = 1,
6402 * Leave =0
6403 * @return Error code indicating success/failure
6404 * @note
6405 * @author zsalah
6406 * @date 8 March 2012
6407 * @version 1.0
6408 */
6409void host_int_send_join_leave_info_to_host
72ed4dc7 6410 (u16 assocId, u8 *stationAddr, bool joining)
c5c77ba1
JK
6411{
6412}
6413/**
6414 * @brief notifies host with stations found in scan
6415 * @details sends the beacon/probe response from scan
6416 * @param[in,out] handle to the wifi driver,
6417 * @param[in] Sta Address,
6418 * Frame length,
6419 * Rssi of the Station found
6420 * @return Error code indicating success/failure
6421 * @note
6422 * @author zsalah
6423 * @date 8 March 2012
6424 * @version 1.0
6425 */
6426
93dee8ee 6427static void GetPeriodicRSSI(unsigned long arg)
c5c77ba1 6428{
93dee8ee 6429 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
78c87591 6430
c5c77ba1
JK
6431 if (pstrWFIDrv == NULL) {
6432 PRINT_ER("Driver handler is NULL\n");
6433 return;
6434 }
6435
6436 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
fb4ec9ca 6437 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
6438 tstrHostIFmsg strHostIFmsg;
6439
6440 /* prepare the Get RSSI Message */
2cc46837 6441 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6442
6443 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
6444 strHostIFmsg.drvHandler = pstrWFIDrv;
6445
6446 /* send the message */
c4f83a55 6447 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6448 if (s32Error) {
6449 PRINT_ER("Failed to send get host channel param's message queue ");
6450 return;
6451 }
6452 }
9eb06643
GKH
6453 g_hPeriodicRSSI.data = (unsigned long)pstrWFIDrv;
6454 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
c5c77ba1
JK
6455}
6456
6457
6458void host_int_send_network_info_to_host
ca356ada 6459 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
c5c77ba1
JK
6460{
6461}
6462/**
6463 * @brief host_int_init
6464 * @details host interface initialization function
6465 * @param[in,out] handle to the wifi driver,
6466 * @note
6467 * @author zsalah
6468 * @date 8 March 2012
6469 * @version 1.0
6470 */
4e4467fd
CL
6471static u32 u32Intialized;
6472static u32 msgQ_created;
6473static u32 clients_count;
c5c77ba1 6474
218dc407 6475s32 host_int_init(tstrWILC_WFIDrv **phWFIDrv)
c5c77ba1 6476{
fb4ec9ca 6477 s32 s32Error = WILC_SUCCESS;
c5c77ba1 6478 tstrWILC_WFIDrv *pstrWFIDrv;
c5c77ba1
JK
6479
6480 /*if(u32Intialized == 1)
6481 * {
6482 * PRINT_D(HOSTINF_DBG,"Host interface is previously initialized\n");
6483 * *phWFIDrv = (WILC_WFIDrvHandle)gWFiDrvHandle; //Will be adjusted later for P2P
6484 * return 0;
6485 * } */
6486 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
6487
72ed4dc7 6488 gbScanWhileConnected = false;
c5c77ba1 6489
83383ea3 6490 sema_init(&hWaitResponse, 0);
c5c77ba1
JK
6491
6492
6493
6494 /*Allocate host interface private structure*/
dc0ad74b 6495 pstrWFIDrv = WILC_MALLOC(sizeof(tstrWILC_WFIDrv));
b1413b60 6496 if (pstrWFIDrv == NULL) {
c5c77ba1
JK
6497 /* WILC_ERRORREPORT(s32Error,WILC_NO_MEM); */
6498 s32Error = WILC_NO_MEM;
6499 PRINT_ER("Failed to allocate memory\n");
6500 goto _fail_timer_2;
6501 }
2cc46837 6502 memset(pstrWFIDrv, 0, sizeof(tstrWILC_WFIDrv));
c5c77ba1 6503 /*return driver handle to user*/
218dc407 6504 *phWFIDrv = pstrWFIDrv;
c5c77ba1
JK
6505 /*save into globl handle*/
6506
6507 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
6508
72ed4dc7 6509 g_obtainingIP = false;
c5c77ba1
JK
6510 #endif
6511
8a14330f 6512 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv);
c5c77ba1
JK
6513 /* /////////////////////////////////////// */
6514 if (clients_count == 0) {
83383ea3
AB
6515 sema_init(&hSemHostIFthrdEnd, 0);
6516 sema_init(&hSemDeinitDrvHandle, 0);
c5c77ba1 6517 /*BugID_5348*/
83383ea3
AB
6518 sema_init(&hSemHostIntDeinit, 1);
6519 }
6520
6521 sema_init(&(pstrWFIDrv->hSemTestKeyBlock), 0);
6522 sema_init(&(pstrWFIDrv->hSemTestDisconnectBlock), 0);
6523 sema_init(&(pstrWFIDrv->hSemGetRSSI), 0);
6524 sema_init(&(pstrWFIDrv->hSemGetLINKSPEED), 0);
6525 sema_init(&(pstrWFIDrv->hSemGetCHNL), 0);
6526 sema_init(&(pstrWFIDrv->hSemInactiveTime), 0);
c5c77ba1
JK
6527
6528 /* /////////////////////////////////////// */
6529
6530
6531
6532 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
6533
6534 if (clients_count == 0) {
c4f83a55 6535 s32Error = WILC_MsgQueueCreate(&gMsgQHostIF);
c5c77ba1
JK
6536
6537 if (s32Error < 0) {
6538 PRINT_ER("Failed to creat MQ\n");
6539 goto _fail_;
6540 }
6541 msgQ_created = 1;
1999bd52
AB
6542 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
6543 if (IS_ERR(HostIFthreadHandler)) {
c5c77ba1 6544 PRINT_ER("Failed to creat Thread\n");
1999bd52 6545 s32Error = WILC_FAIL;
c5c77ba1
JK
6546 goto _fail_mq_;
6547 }
507d7fc5
GKH
6548 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
6549 (unsigned long)pstrWFIDrv);
9eb06643 6550 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
c5c77ba1
JK
6551 }
6552
6553
93dee8ee 6554 setup_timer(&pstrWFIDrv->hScanTimer, TimerCB_Scan, 0);
c5c77ba1 6555
93dee8ee 6556 setup_timer(&pstrWFIDrv->hConnectTimer, TimerCB_Connect, 0);
c5c77ba1
JK
6557
6558 #ifdef WILC_P2P
6559 /*Remain on channel timer*/
93dee8ee 6560 setup_timer(&pstrWFIDrv->hRemainOnChannel, ListenTimerCB, 0);
c5c77ba1
JK
6561 #endif
6562
83383ea3
AB
6563 sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1);
6564 down(&(pstrWFIDrv->gtOsCfgValuesSem));
c5c77ba1 6565
c5c77ba1 6566 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
72ed4dc7 6567 /* gWFiDrvHandle->bPendingConnRequest = false; */
c5c77ba1
JK
6568
6569 /*Initialize CFG WIDS Defualt Values*/
6570
6571 pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
6572 pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN;
6573 pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
6574 pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
6575 pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE;
6576
6577
6578 #ifdef WILC_P2P
6579
6580 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
6581
6582 #endif
6583
6584 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",
6585
6586 pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source,
6587 pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time,
6588 pstrWFIDrv->strCfgValues.curr_tx_rate);
6589
6590
83383ea3 6591 up(&(pstrWFIDrv->gtOsCfgValuesSem));
c5c77ba1
JK
6592
6593 /*TODO Code to setup simulation to be removed later*/
6594 /*Intialize configurator module*/
6595 s32Error = CoreConfiguratorInit();
6596 if (s32Error < 0) {
6597 PRINT_ER("Failed to initialize core configurator\n");
6598 goto _fail_mem_;
6599 }
6600
c5c77ba1
JK
6601 u32Intialized = 1;
6602 clients_count++; /* increase number of created entities */
6603
6604 return s32Error;
6605
6606
6607_fail_mem_:
b1413b60 6608 if (pstrWFIDrv != NULL)
49188af2 6609 kfree(pstrWFIDrv);
c5c77ba1 6610#ifdef WILC_P2P
4183e979 6611 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
c5c77ba1
JK
6612#endif
6613_fail_timer_2:
83383ea3 6614 up(&(pstrWFIDrv->gtOsCfgValuesSem));
4183e979 6615 del_timer_sync(&pstrWFIDrv->hConnectTimer);
4183e979 6616 del_timer_sync(&pstrWFIDrv->hScanTimer);
1999bd52 6617 kthread_stop(HostIFthreadHandler);
c5c77ba1 6618_fail_mq_:
c4f83a55 6619 WILC_MsgQueueDestroy(&gMsgQHostIF);
c5c77ba1
JK
6620_fail_:
6621 return s32Error;
6622
6623
6624}
6625/**
6626 * @brief host_int_deinit
6627 * @details host interface initialization function
6628 * @param[in,out] handle to the wifi driver,
6629 * @note
6630 * @author zsalah
6631 * @date 8 March 2012
6632 * @version 1.0
6633 */
6634
218dc407 6635s32 host_int_deinit(tstrWILC_WFIDrv *hWFIDrv)
c5c77ba1 6636{
fb4ec9ca 6637 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
6638 tstrHostIFmsg strHostIFmsg;
6639
6640
6641 /*obtain driver handle*/
6642 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6643 /*if(u32Intialized == 0)
6644 * {
6645 * PRINT_ER("Host Interface is not initialized\n");
6646 * return 0;
6647 * }*/
6648
6649 /*BugID_5348*/
6650
6651 if (pstrWFIDrv == NULL) {
6652 PRINT_ER("pstrWFIDrv = NULL\n");
6653 return 0;
6654 }
6655
83383ea3 6656 down(&hSemHostIntDeinit);
c5c77ba1
JK
6657
6658 terminated_handle = pstrWFIDrv;
6659 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
6660
6661 /*BugID_5348*/
6662 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
6663 /*to guarantee handling all messages befor proceeding*/
4183e979 6664 if (del_timer_sync(&pstrWFIDrv->hScanTimer)) {
03b2d5e7 6665 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
c5c77ba1
JK
6666 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
6667 }
6668
4183e979 6669 if (del_timer_sync(&pstrWFIDrv->hConnectTimer)) {
03b2d5e7 6670 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
c5c77ba1
JK
6671 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6672 }
6673
6674
4183e979 6675 if (del_timer_sync(&g_hPeriodicRSSI)) {
03b2d5e7 6676 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
c5c77ba1
JK
6677 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6678 }
6679
6680 #ifdef WILC_P2P
6681 /*Destroy Remain-onchannel Timer*/
4183e979 6682 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
c5c77ba1
JK
6683 #endif
6684
218dc407 6685 host_int_set_wfi_drv_handler(NULL);
83383ea3 6686 down(&hSemDeinitDrvHandle);
c5c77ba1
JK
6687
6688
6689 /*Calling the CFG80211 scan done function with the abort flag set to true*/
6690 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
b1413b60 6691 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
c5c77ba1
JK
6692 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
6693
b1413b60 6694 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
c5c77ba1
JK
6695 }
6696 /*deinit configurator and simulator*/
c5c77ba1 6697 CoreConfiguratorDeInit();
c5c77ba1
JK
6698
6699 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6700
72ed4dc7 6701 gbScanWhileConnected = false;
c5c77ba1 6702
2cc46837 6703 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6704
6705 if (clients_count == 1) {
4183e979 6706 if (del_timer_sync(&g_hPeriodicRSSI)) {
03b2d5e7 6707 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
c5c77ba1
JK
6708 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6709 }
6710 strHostIFmsg.u16MsgId = HOST_IF_MSG_EXIT;
6711 strHostIFmsg.drvHandler = hWFIDrv;
6712
6713
c4f83a55 6714 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 6715 if (s32Error != WILC_SUCCESS)
c5c77ba1 6716 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
c5c77ba1 6717
83383ea3 6718 down(&hSemHostIFthrdEnd);
c5c77ba1 6719
c4f83a55 6720 WILC_MsgQueueDestroy(&gMsgQHostIF);
c5c77ba1 6721 msgQ_created = 0;
c5c77ba1
JK
6722 }
6723
83383ea3 6724 down(&(pstrWFIDrv->gtOsCfgValuesSem));
c5c77ba1
JK
6725
6726 /*Setting the gloabl driver handler with NULL*/
6727 u32Intialized = 0;
6728 /* gWFiDrvHandle = NULL; */
b1413b60 6729 if (pstrWFIDrv != NULL) {
49188af2 6730 kfree(pstrWFIDrv);
b1413b60 6731 /* pstrWFIDrv=NULL; */
c5c77ba1
JK
6732
6733 }
6734
6735 clients_count--; /* Decrease number of created entities */
b1413b60 6736 terminated_handle = NULL;
83383ea3 6737 up(&hSemHostIntDeinit);
c5c77ba1
JK
6738 return s32Error;
6739}
6740
6741
6742/**
6743 * @brief NetworkInfoReceived
6744 * @details function to to be called when network info packet is received
6745 * @param[in] pu8Buffer the received packet
6746 * @param[in] u32Length length of the received packet
6747 * @return none
6748 * @note
6749 * @author
6750 * @date 1 Mar 2012
6751 * @version 1.0
6752 */
4e4467fd 6753void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
c5c77ba1 6754{
fb4ec9ca 6755 s32 s32Error = WILC_SUCCESS;
c5c77ba1 6756 tstrHostIFmsg strHostIFmsg;
4e4467fd 6757 u32 drvHandler;
b1413b60 6758 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
c5c77ba1
JK
6759
6760 drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6761 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
6762
6763
6764
6765
b1413b60 6766 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
8a14330f 6767 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv);
c5c77ba1
JK
6768 return;
6769 }
6770
6771 /* prepare the Asynchronous Network Info message */
2cc46837 6772 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6773
6774 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_NTWRK_INFO;
6775 strHostIFmsg.drvHandler = pstrWFIDrv;
6776
6777 strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.u32Length = u32Length;
dc0ad74b 6778 strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer = WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */
d00d2ba3 6779 memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer,
c5c77ba1
JK
6780 pu8Buffer, u32Length);
6781
6782 /* send the message */
c4f83a55 6783 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 6784 if (s32Error)
c5c77ba1 6785 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
c5c77ba1
JK
6786}
6787
6788/**
6789 * @brief GnrlAsyncInfoReceived
6790 * @details function to be called when general Asynchronous info packet is received
6791 * @param[in] pu8Buffer the received packet
6792 * @param[in] u32Length length of the received packet
6793 * @return none
6794 * @note
6795 * @author
6796 * @date 15 Mar 2012
6797 * @version 1.0
6798 */
4e4467fd 6799void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
c5c77ba1 6800{
fb4ec9ca 6801 s32 s32Error = WILC_SUCCESS;
c5c77ba1 6802 tstrHostIFmsg strHostIFmsg;
4e4467fd 6803 u32 drvHandler;
b1413b60 6804 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
c5c77ba1
JK
6805
6806 /*BugID_5348*/
83383ea3 6807 down(&hSemHostIntDeinit);
c5c77ba1
JK
6808
6809 drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6810 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
03b2d5e7 6811 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
c5c77ba1
JK
6812
6813
6814 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6815 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
6816 /*BugID_5348*/
83383ea3 6817 up(&hSemHostIntDeinit);
c5c77ba1
JK
6818 return;
6819 }
6820
b1413b60 6821 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) {
c5c77ba1
JK
6822 /* received mac status is not needed when there is no current Connect Request */
6823 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
6824 /*BugID_5348*/
83383ea3 6825 up(&hSemHostIntDeinit);
c5c77ba1
JK
6826 return;
6827 }
6828
6829 /* prepare the General Asynchronous Info message */
2cc46837 6830 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6831
6832
6833 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
6834 strHostIFmsg.drvHandler = pstrWFIDrv;
6835
6836
6837 strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.u32Length = u32Length;
dc0ad74b 6838 strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer = WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */
d00d2ba3 6839 memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer,
c5c77ba1
JK
6840 pu8Buffer, u32Length);
6841
6842 /* send the message */
c4f83a55 6843 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 6844 if (s32Error)
c5c77ba1 6845 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
c5c77ba1
JK
6846
6847 /*BugID_5348*/
83383ea3 6848 up(&hSemHostIntDeinit);
c5c77ba1
JK
6849}
6850
6851/**
6852 * @brief host_int_ScanCompleteReceived
6853 * @details Setting scan complete received notifcation in message queue
4e4467fd 6854 * @param[in] u8* pu8Buffer, u32 u32Length
c5c77ba1
JK
6855 * @return Error code.
6856 * @author
6857 * @date
6858 * @version 1.0
6859 */
4e4467fd 6860void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
c5c77ba1 6861{
fb4ec9ca 6862 s32 s32Error = WILC_SUCCESS;
c5c77ba1 6863 tstrHostIFmsg strHostIFmsg;
4e4467fd 6864 u32 drvHandler;
b1413b60 6865 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
78c87591 6866
c5c77ba1
JK
6867 drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6868 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
6869
6870
8a14330f 6871 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv);
c5c77ba1 6872
2b9d5b48 6873 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle)
c5c77ba1 6874 return;
c5c77ba1
JK
6875
6876 /*if there is an ongoing scan request*/
6877 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6878 /* prepare theScan Done message */
2cc46837 6879 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6880
6881 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
6882 strHostIFmsg.drvHandler = pstrWFIDrv;
6883
6884
6885 /* will be deallocated by the receiving thread */
6886 /*no need to send message body*/
6887
6888 /*strHostIFmsg.uniHostIFmsgBody.strScanComplete.u32Length = u32Length;
63d03e47 6889 * strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
d00d2ba3 6890 * memcpy(strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer,
c5c77ba1
JK
6891 * pu8Buffer, u32Length); */
6892
6893 /* send the message */
c4f83a55 6894 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 6895 if (s32Error)
c5c77ba1 6896 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
c5c77ba1
JK
6897 }
6898
6899
6900 return;
6901
6902}
6903
6904#ifdef WILC_P2P
6905/**
6906 * @brief host_int_remain_on_channel
6907 * @details
6908 * @param[in] Handle to wifi driver
6909 * Duration to remain on channel
6910 * Channel to remain on
6911 * Pointer to fn to be called on receive frames in listen state
6912 * Pointer to remain-on-channel expired fn
6913 * Priv
6914 * @return Error code.
6915 * @author
6916 * @date
6917 * @version 1.0
6918 */
218dc407 6919s32 host_int_remain_on_channel(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID, u32 u32duration, u16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg)
c5c77ba1 6920{
fb4ec9ca 6921 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
6922 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6923 tstrHostIFmsg strHostIFmsg;
6924
2b9d5b48 6925 if (pstrWFIDrv == NULL)
c5c77ba1 6926 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1
JK
6927
6928 /* prepare the remainonchan Message */
2cc46837 6929 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6930
6931 /* prepare the WiphyParams Message */
6932 strHostIFmsg.u16MsgId = HOST_IF_MSG_REMAIN_ON_CHAN;
6933 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u16Channel = chan;
6934 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanExpired = RemainOnChanExpired;
6935 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanReady = RemainOnChanReady;
6936 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pVoid = pvUserArg;
6937 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32duration = u32duration;
6938 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
6939 strHostIFmsg.drvHandler = hWFIDrv;
6940
c4f83a55 6941 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 6942 if (s32Error)
c5c77ba1 6943 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
6944 WILC_CATCH(s32Error)
6945 {
6946
6947 }
6948
6949 return s32Error;
6950}
6951
6952/**
6953 * @brief host_int_ListenStateExpired
6954 * @details
6955 * @param[in] Handle to wifi driver
6956 * Duration to remain on channel
6957 * Channel to remain on
6958 * Pointer to fn to be called on receive frames in listen state
6959 * Pointer to remain-on-channel expired fn
6960 * Priv
6961 * @return Error code.
6962 * @author
6963 * @date
6964 * @version 1.0
6965 */
218dc407 6966s32 host_int_ListenStateExpired(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID)
c5c77ba1 6967{
fb4ec9ca 6968 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
6969 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6970 tstrHostIFmsg strHostIFmsg;
6971
2b9d5b48 6972 if (pstrWFIDrv == NULL)
c5c77ba1 6973 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1
JK
6974
6975 /*Stopping remain-on-channel timer*/
8972d0fe 6976 del_timer(&pstrWFIDrv->hRemainOnChannel);
c5c77ba1
JK
6977
6978 /* prepare the timer fire Message */
2cc46837 6979 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
6980 strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
6981 strHostIFmsg.drvHandler = hWFIDrv;
6982 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
6983
c4f83a55 6984 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 6985 if (s32Error)
c5c77ba1 6986 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
6987 WILC_CATCH(s32Error)
6988 {
6989
6990 }
6991 return s32Error;
6992}
6993
6994/**
6995 * @brief host_int_frame_register
6996 * @details
6997 * @param[in] Handle to wifi driver
6998 * @return Error code.
6999 * @author
7000 * @date
7001 * @version 1.0*/
218dc407 7002s32 host_int_frame_register(tstrWILC_WFIDrv *hWFIDrv, u16 u16FrameType, bool bReg)
c5c77ba1 7003{
fb4ec9ca 7004 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
7005 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7006 tstrHostIFmsg strHostIFmsg;
7007
2b9d5b48 7008 if (pstrWFIDrv == NULL)
c5c77ba1 7009 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1 7010
2cc46837 7011 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
7012
7013 /* prepare the WiphyParams Message */
7014 strHostIFmsg.u16MsgId = HOST_IF_MSG_REGISTER_FRAME;
7015 switch (u16FrameType) {
7016 case ACTION:
7017 PRINT_D(HOSTINF_DBG, "ACTION\n");
7018 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = ACTION_FRM_IDX;
7019 break;
7020
7021 case PROBE_REQ:
7022 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
7023 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = PROBE_REQ_IDX;
7024 break;
7025
7026 default:
7027 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
7028 break;
7029 }
7030 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u16FrameType = u16FrameType;
7031 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.bReg = bReg;
7032 strHostIFmsg.drvHandler = hWFIDrv;
7033
c4f83a55 7034 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 7035 if (s32Error)
c5c77ba1 7036 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
7037 WILC_CATCH(s32Error)
7038 {
7039
7040 }
7041
7042 return s32Error;
7043
7044
7045}
7046#endif
7047
7048#ifdef WILC_AP_EXTERNAL_MLME
7049/**
7050 * @brief host_int_add_beacon
7051 * @details Setting add beacon params in message queue
4e4467fd
CL
7052 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
7053 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
7054 * u32 u32TailLen, u8* pu8Tail
c5c77ba1
JK
7055 * @return Error code.
7056 * @author
7057 * @date
7058 * @version 1.0
7059 */
218dc407 7060s32 host_int_add_beacon(tstrWILC_WFIDrv *hWFIDrv, u32 u32Interval,
4e4467fd
CL
7061 u32 u32DTIMPeriod,
7062 u32 u32HeadLen, u8 *pu8Head,
7063 u32 u32TailLen, u8 *pu8Tail)
c5c77ba1 7064{
fb4ec9ca 7065 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
7066 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7067 tstrHostIFmsg strHostIFmsg;
7068 tstrHostIFSetBeacon *pstrSetBeaconParam = &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon;
7069
2b9d5b48 7070 if (pstrWFIDrv == NULL)
c5c77ba1 7071 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1 7072
2cc46837 7073 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
7074
7075 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
7076
7077
7078 /* prepare the WiphyParams Message */
7079 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BEACON;
7080 strHostIFmsg.drvHandler = hWFIDrv;
7081 pstrSetBeaconParam->u32Interval = u32Interval;
7082 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
7083 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
dc0ad74b 7084 pstrSetBeaconParam->pu8Head = WILC_MALLOC(u32HeadLen);
2b9d5b48 7085 if (pstrSetBeaconParam->pu8Head == NULL)
c5c77ba1 7086 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
d00d2ba3 7087 memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
c5c77ba1
JK
7088 pstrSetBeaconParam->u32TailLen = u32TailLen;
7089
7090 /* Bug 4599 : if tail length = 0 skip allocating & copying */
7091 if (u32TailLen > 0) {
dc0ad74b 7092 pstrSetBeaconParam->pu8Tail = WILC_MALLOC(u32TailLen);
2b9d5b48 7093 if (pstrSetBeaconParam->pu8Tail == NULL)
c5c77ba1 7094 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
d00d2ba3 7095 memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
c5c77ba1
JK
7096 } else {
7097 pstrSetBeaconParam->pu8Tail = NULL;
7098 }
7099
c4f83a55 7100 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 7101 if (s32Error)
c5c77ba1 7102 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
7103
7104 WILC_CATCH(s32Error)
7105 {
2b9d5b48 7106 if (pstrSetBeaconParam->pu8Head != NULL)
49188af2 7107 kfree(pstrSetBeaconParam->pu8Head);
c5c77ba1 7108
2b9d5b48 7109 if (pstrSetBeaconParam->pu8Tail != NULL)
49188af2 7110 kfree(pstrSetBeaconParam->pu8Tail);
c5c77ba1
JK
7111 }
7112
7113 return s32Error;
7114
7115}
7116
7117
7118/**
7119 * @brief host_int_del_beacon
7120 * @details Setting add beacon params in message queue
7121 * @param[in] WILC_WFIDrvHandle hWFIDrv
7122 * @return Error code.
7123 * @author
7124 * @date
7125 * @version 1.0
7126 */
218dc407 7127s32 host_int_del_beacon(tstrWILC_WFIDrv *hWFIDrv)
c5c77ba1 7128{
fb4ec9ca 7129 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
7130 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7131 tstrHostIFmsg strHostIFmsg;
7132
2b9d5b48 7133 if (pstrWFIDrv == NULL)
c5c77ba1 7134 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1
JK
7135
7136 /* prepare the WiphyParams Message */
7137 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BEACON;
7138 strHostIFmsg.drvHandler = hWFIDrv;
7139 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
7140
c4f83a55 7141 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
7142 WILC_ERRORCHECK(s32Error);
7143
7144 WILC_CATCH(s32Error)
7145 {
7146 }
7147 return s32Error;
7148}
7149
7150
7151/**
7152 * @brief host_int_add_station
7153 * @details Setting add station params in message queue
7154 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7155 * @return Error code.
7156 * @author
7157 * @date
7158 * @version 1.0
7159 */
218dc407 7160s32 host_int_add_station(tstrWILC_WFIDrv *hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
c5c77ba1 7161{
fb4ec9ca 7162 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
7163 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7164 tstrHostIFmsg strHostIFmsg;
7165 tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
7166
7167
2b9d5b48 7168 if (pstrWFIDrv == NULL)
c5c77ba1 7169 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1 7170
2cc46837 7171 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
7172
7173 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
7174
7175
7176 /* prepare the WiphyParams Message */
7177 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_STATION;
7178 strHostIFmsg.drvHandler = hWFIDrv;
7179
d00d2ba3 7180 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
c5c77ba1 7181 if (pstrAddStationMsg->u8NumRates > 0) {
057d1e97 7182 u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
78c87591 7183
057d1e97 7184 WILC_NULLCHECK(s32Error, rates);
c5c77ba1 7185
d00d2ba3 7186 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
057d1e97 7187 pstrAddStationMsg->pu8Rates = rates;
c5c77ba1
JK
7188 }
7189
7190
c4f83a55 7191 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 7192 if (s32Error)
c5c77ba1 7193 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
7194
7195 WILC_CATCH(s32Error)
7196 {
7197 }
7198 return s32Error;
7199}
7200
7201/**
7202 * @brief host_int_del_station
7203 * @details Setting delete station params in message queue
63d03e47 7204 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
c5c77ba1
JK
7205 * @return Error code.
7206 * @author
7207 * @date
7208 * @version 1.0
7209 */
218dc407 7210s32 host_int_del_station(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8MacAddr)
c5c77ba1 7211{
fb4ec9ca 7212 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
7213 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7214 tstrHostIFmsg strHostIFmsg;
7215 tstrHostIFDelSta *pstrDelStationMsg = &strHostIFmsg.uniHostIFmsgBody.strDelStaParam;
7216
2b9d5b48 7217 if (pstrWFIDrv == NULL)
c5c77ba1 7218 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1 7219
2cc46837 7220 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
7221
7222 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
7223
7224
7225
7226 /* prepare the WiphyParams Message */
7227 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_STATION;
7228 strHostIFmsg.drvHandler = hWFIDrv;
7229
7230 /*BugID_4795: Handling situation of deleting all stations*/
b1413b60 7231 if (pu8MacAddr == NULL)
2cc46837 7232 memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
c5c77ba1 7233 else
d00d2ba3 7234 memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
c5c77ba1 7235
c4f83a55 7236 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 7237 if (s32Error)
c5c77ba1 7238 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
7239
7240 WILC_CATCH(s32Error)
7241 {
7242 }
7243 return s32Error;
7244}
7245/**
7246 * @brief host_int_del_allstation
7247 * @details Setting del station params in message queue
63d03e47 7248 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
c5c77ba1
JK
7249 * @return Error code.
7250 * @author
7251 * @date
7252 * @version 1.0
7253 */
218dc407 7254s32 host_int_del_allstation(tstrWILC_WFIDrv *hWFIDrv, u8 pu8MacAddr[][ETH_ALEN])
c5c77ba1 7255{
fb4ec9ca 7256 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
7257 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7258 tstrHostIFmsg strHostIFmsg;
7259 tstrHostIFDelAllSta *pstrDelAllStationMsg = &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta;
63d03e47 7260 u8 au8Zero_Buff[ETH_ALEN] = {0};
4e4467fd 7261 u32 i;
63d03e47 7262 u8 u8AssocNumb = 0;
c5c77ba1
JK
7263
7264
2b9d5b48 7265 if (pstrWFIDrv == NULL)
c5c77ba1 7266 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1 7267
2cc46837 7268 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
7269
7270 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
7271
7272 /* prepare the WiphyParams Message */
7273 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_STA;
7274 strHostIFmsg.drvHandler = hWFIDrv;
7275
7276 /* Handling situation of deauthenticing all associated stations*/
7277 for (i = 0; i < MAX_NUM_STA; i++) {
7278 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
d00d2ba3 7279 memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
c5c77ba1
JK
7280 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],
7281 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
7282 u8AssocNumb++;
7283 }
7284 }
7285 if (!u8AssocNumb) {
7286 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
7287 return s32Error;
7288 }
7289
7290 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
c4f83a55 7291 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
c5c77ba1
JK
7292
7293
2b9d5b48 7294 if (s32Error)
c5c77ba1
JK
7295 WILC_ERRORREPORT(s32Error, s32Error);
7296
c5c77ba1
JK
7297 WILC_CATCH(s32Error)
7298 {
7299
7300 }
83383ea3 7301 down(&hWaitResponse);
c5c77ba1
JK
7302
7303 return s32Error;
7304
7305}
7306
7307/**
7308 * @brief host_int_edit_station
7309 * @details Setting edit station params in message queue
7310 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7311 * @return Error code.
7312 * @author
7313 * @date
7314 * @version 1.0
7315 */
218dc407 7316s32 host_int_edit_station(tstrWILC_WFIDrv *hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
c5c77ba1 7317{
fb4ec9ca 7318 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
7319 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7320 tstrHostIFmsg strHostIFmsg;
7321 tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
7322
2b9d5b48 7323 if (pstrWFIDrv == NULL)
c5c77ba1 7324 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1
JK
7325
7326 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
7327
2cc46837 7328 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
7329
7330
7331 /* prepare the WiphyParams Message */
7332 strHostIFmsg.u16MsgId = HOST_IF_MSG_EDIT_STATION;
7333 strHostIFmsg.drvHandler = hWFIDrv;
7334
d00d2ba3 7335 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
c5c77ba1 7336 if (pstrAddStationMsg->u8NumRates > 0) {
057d1e97 7337 u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
78c87591 7338
057d1e97 7339 WILC_NULLCHECK(s32Error, rates);
d00d2ba3 7340 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
057d1e97 7341 pstrAddStationMsg->pu8Rates = rates;
c5c77ba1
JK
7342 }
7343
c4f83a55 7344 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 7345 if (s32Error)
c5c77ba1 7346 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
7347 WILC_CATCH(s32Error)
7348 {
7349 }
7350 return s32Error;
7351}
7352#endif /*WILC_AP_EXTERNAL_MLME*/
7353uint32_t wilc_get_chipid(uint8_t);
7354
218dc407 7355s32 host_int_set_power_mgmt(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32Timeout)
c5c77ba1 7356{
fb4ec9ca 7357 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
7358 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7359 tstrHostIFmsg strHostIFmsg;
7360 tstrHostIfPowerMgmtParam *pstrPowerMgmtParam = &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam;
7361
03b2d5e7 7362 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
c5c77ba1 7363
2b9d5b48 7364 if (pstrWFIDrv == NULL)
c5c77ba1 7365 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1
JK
7366
7367 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
7368
2cc46837 7369 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
7370
7371
7372 /* prepare the WiphyParams Message */
7373 strHostIFmsg.u16MsgId = HOST_IF_MSG_POWER_MGMT;
7374 strHostIFmsg.drvHandler = hWFIDrv;
7375
7376 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
7377 pstrPowerMgmtParam->u32Timeout = u32Timeout;
7378
7379
c4f83a55 7380 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 7381 if (s32Error)
c5c77ba1 7382 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
7383 WILC_CATCH(s32Error)
7384 {
7385 }
7386 return s32Error;
7387}
7388
218dc407 7389s32 host_int_setup_multicast_filter(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32count)
c5c77ba1 7390{
fb4ec9ca 7391 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
7392
7393 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7394 tstrHostIFmsg strHostIFmsg;
7395 tstrHostIFSetMulti *pstrMulticastFilterParam = &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti;
7396
7397
2b9d5b48 7398 if (pstrWFIDrv == NULL)
c5c77ba1 7399 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1
JK
7400
7401 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
7402
2cc46837 7403 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
7404
7405
7406 /* prepare the WiphyParams Message */
7407 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MULTICAST_FILTER;
7408 strHostIFmsg.drvHandler = hWFIDrv;
7409
7410 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
7411 pstrMulticastFilterParam->u32count = u32count;
7412
c4f83a55 7413 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 7414 if (s32Error)
c5c77ba1 7415 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
7416 WILC_CATCH(s32Error)
7417 {
7418 }
7419 return s32Error;
7420}
7421
7422
7423
7424/*Bug4218: Parsing Join Param*/
7425#ifdef WILC_PARSE_SCAN_IN_HOST
7426
7427/*Bug4218: Parsing Join Param*/
7428/**
7429 * @brief host_int_ParseJoinBssParam
7430 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
7431 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7432 * @return
7433 * @author zsalah
7434 * @date
7435 * @version 1.0**/
7436static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
7437{
7438 tstrJoinBssParam *pNewJoinBssParam = NULL;
63d03e47 7439 u8 *pu8IEs;
d85f5326
CL
7440 u16 u16IEsLen;
7441 u16 index = 0;
63d03e47
GKH
7442 u8 suppRatesNo = 0;
7443 u8 extSuppRatesNo;
d85f5326 7444 u16 jumpOffset;
63d03e47
GKH
7445 u8 pcipherCount;
7446 u8 authCount;
7447 u8 pcipherTotalCount = 0;
7448 u8 authTotalCount = 0;
7449 u8 i, j;
c5c77ba1
JK
7450
7451 pu8IEs = ptstrNetworkInfo->pu8IEs;
7452 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
7453
7454 pNewJoinBssParam = WILC_MALLOC(sizeof(tstrJoinBssParam));
7455 if (pNewJoinBssParam != NULL) {
2cc46837 7456 memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam));
c5c77ba1
JK
7457 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
7458 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
7459 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
d00d2ba3 7460 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
c5c77ba1
JK
7461 /*for(i=0; i<6;i++)
7462 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
d00d2ba3 7463 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
c5c77ba1 7464 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
2cc46837
CL
7465 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
7466 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
c5c77ba1
JK
7467 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
7468 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
7469
7470 /* parse supported rates: */
7471 while (index < u16IEsLen) {
7472 /* supportedRates IE */
7473 if (pu8IEs[index] == SUPP_RATES_IE) {
7474 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
7475 suppRatesNo = pu8IEs[index + 1];
7476 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
7477 index += 2; /* skipping ID and length bytes; */
7478
7479 for (i = 0; i < suppRatesNo; i++) {
7480 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
7481 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
7482 }
7483 index += suppRatesNo;
7484 continue;
7485 }
7486 /* Ext SupportedRates IE */
7487 else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
7488 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
7489 /* checking if no of ext. supp and supp rates < max limit */
7490 extSuppRatesNo = pu8IEs[index + 1];
7491 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
7492 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
7493 else
7494 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
7495 index += 2;
7496 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
7497 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
7498 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
7499 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
7500 }
7501 index += extSuppRatesNo;
7502 continue;
7503 }
7504 /* HT Cap. IE */
7505 else if (pu8IEs[index] == HT_CAPABILITY_IE) {
7506 /* if IE found set the flag */
0be1eb74 7507 pNewJoinBssParam->ht_capable = true;
c5c77ba1
JK
7508 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7509 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
7510 continue;
7511 } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
7512 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
7513 (pu8IEs[index + 4] == 0xF2) && /* OUI */
7514 (pu8IEs[index + 5] == 0x02) && /* OUI Type */
7515 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
7516 (pu8IEs[index + 7] == 0x01)) {
7517 /* Presence of WMM Info/Param element indicates WMM capability */
0be1eb74 7518 pNewJoinBssParam->wmm_cap = true;
c5c77ba1
JK
7519
7520 /* Check if Bit 7 is set indicating U-APSD capability */
2b9d5b48 7521 if (pu8IEs[index + 8] & (1 << 7))
0be1eb74 7522 pNewJoinBssParam->uapsd_cap = true;
c5c77ba1
JK
7523 index += pu8IEs[index + 1] + 2;
7524 continue;
7525 }
7526 #ifdef WILC_P2P
7527 else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
7528 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
7529 (pu8IEs[index + 4] == 0x9a) && /* OUI */
7530 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
d85f5326 7531 u16 u16P2P_count;
78c87591 7532
c5c77ba1
JK
7533 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
7534 pNewJoinBssParam->u8NoaEnbaled = 1;
7535 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
7536
7537 /* Check if Bit 7 is set indicating Opss capability */
7538 if (pu8IEs[index + 10] & (1 << 7)) {
7539 pNewJoinBssParam->u8OppEnable = 1;
7540 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
7541 } else
7542 pNewJoinBssParam->u8OppEnable = 0;
7543 /* HOSTINF_DBG */
03b2d5e7 7544 PRINT_D(GENERIC_DBG, "P2P Dump\n");
c5c77ba1 7545 for (i = 0; i < pu8IEs[index + 7]; i++)
03b2d5e7 7546 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
c5c77ba1
JK
7547
7548 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
7549 u16P2P_count = index + 12;
7550
d00d2ba3 7551 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
c5c77ba1
JK
7552 u16P2P_count += 4;
7553
d00d2ba3 7554 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
c5c77ba1
JK
7555 u16P2P_count += 4;
7556
d00d2ba3 7557 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
c5c77ba1
JK
7558
7559 index += pu8IEs[index + 1] + 2;
7560 continue;
7561
7562 }
7563 #endif
7564 else if ((pu8IEs[index] == RSN_IE) ||
7565 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
7566 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
7567 (pu8IEs[index + 5] == 0x01))) {
d85f5326 7568 u16 rsnIndex = index;
c5c77ba1
JK
7569 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
7570 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
7571 * {
7572 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
7573 * }*/
7574 if (pu8IEs[rsnIndex] == RSN_IE) {
7575 pNewJoinBssParam->mode_802_11i = 2;
7576 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
7577 } else { /* check if rsn was previously parsed */
7578 if (pNewJoinBssParam->mode_802_11i == 0)
7579 pNewJoinBssParam->mode_802_11i = 1;
7580 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
7581 rsnIndex += 4;
7582 }
7583 rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
7584 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
7585 rsnIndex++;
03b2d5e7 7586 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
c5c77ba1
JK
7587 /* initialize policies with invalid values */
7588
7589 jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
7590
7591 /*parsing pairwise cipher*/
7592
7593 /* saving 3 pcipher max. */
7594 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7595 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7596
03b2d5e7 7597 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
c5c77ba1
JK
7598 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
7599 /* each count corresponds to 4 bytes, only last byte is saved */
7600 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7601 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
7602 }
7603 pcipherTotalCount += pcipherCount;
7604 rsnIndex += jumpOffset;
7605
7606 jumpOffset = pu8IEs[rsnIndex] * 4;
7607
7608 /*parsing AKM suite (auth_policy)*/
7609 /* saving 3 auth policies max. */
7610 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7611 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7612
7613 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
7614 /* each count corresponds to 4 bytes, only last byte is saved */
7615 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7616 }
7617 authTotalCount += authCount;
7618 rsnIndex += jumpOffset;
7619 /*pasring rsn cap. only if rsn IE*/
7620 if (pu8IEs[index] == RSN_IE) {
7621 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
7622 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
7623 rsnIndex += 2;
7624 }
f717c0eb 7625 pNewJoinBssParam->rsn_found = true;
c5c77ba1
JK
7626 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7627 continue;
7628 } else
7629 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7630
7631 }
7632
7633
7634 }
7635
7636 return (void *)pNewJoinBssParam;
7637
7638}
7639
7640void host_int_freeJoinParams(void *pJoinParams)
7641{
7642 if ((tstrJoinBssParam *)pJoinParams != NULL)
49188af2 7643 kfree((tstrJoinBssParam *)pJoinParams);
c5c77ba1
JK
7644 else
7645 PRINT_ER("Unable to FREE null pointer\n");
7646}
7647#endif /*WILC_PARSE_SCAN_IN_HOST*/
7648
7649
7650/**
7651 * @brief host_int_addBASession
7652 * @details Open a block Ack session with the given parameters
7653 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7654 * @return
7655 * @author anoureldin
7656 * @date
7657 * @version 1.0**/
7658
2b05df55 7659static int host_int_addBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID, short int BufferSize,
c5c77ba1
JK
7660 short int SessionTimeout, void *drvHandler)
7661{
fb4ec9ca 7662 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
7663 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7664 tstrHostIFmsg strHostIFmsg;
7665 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7666
2b9d5b48 7667 if (pstrWFIDrv == NULL)
c5c77ba1 7668 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1 7669
2cc46837 7670 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
7671
7672 /* prepare the WiphyParams Message */
7673 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BA_SESSION;
7674
7675 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7676 pBASessionInfo->u8Ted = TID;
7677 pBASessionInfo->u16BufferSize = BufferSize;
7678 pBASessionInfo->u16SessionTimeout = SessionTimeout;
7679 strHostIFmsg.drvHandler = hWFIDrv;
7680
c4f83a55 7681 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 7682 if (s32Error)
c5c77ba1 7683 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
7684 WILC_CATCH(s32Error)
7685 {
7686
7687 }
7688
7689 return s32Error;
7690}
7691
7692
218dc407 7693s32 host_int_delBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
c5c77ba1 7694{
fb4ec9ca 7695 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
7696 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7697 tstrHostIFmsg strHostIFmsg;
7698 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7699
2b9d5b48 7700 if (pstrWFIDrv == NULL)
c5c77ba1 7701 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1 7702
2cc46837 7703 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
7704
7705 /* prepare the WiphyParams Message */
7706 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BA_SESSION;
7707
7708 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7709 pBASessionInfo->u8Ted = TID;
7710 strHostIFmsg.drvHandler = hWFIDrv;
7711
c4f83a55 7712 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 7713 if (s32Error)
c5c77ba1 7714 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
7715 WILC_CATCH(s32Error)
7716 {
7717
7718 }
7719
7720 /*BugID_5222*/
83383ea3 7721 down(&hWaitResponse);
c5c77ba1
JK
7722
7723 return s32Error;
7724}
7725
218dc407 7726s32 host_int_del_All_Rx_BASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
c5c77ba1 7727{
fb4ec9ca 7728 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
7729 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7730 tstrHostIFmsg strHostIFmsg;
7731 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7732
2b9d5b48 7733 if (pstrWFIDrv == NULL)
c5c77ba1 7734 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1 7735
2cc46837 7736 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
7737
7738 /* prepare the WiphyParams Message */
7739 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
7740
7741 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7742 pBASessionInfo->u8Ted = TID;
7743 strHostIFmsg.drvHandler = hWFIDrv;
7744
c4f83a55 7745 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 7746 if (s32Error)
c5c77ba1 7747 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
7748 WILC_CATCH(s32Error)
7749 {
7750
7751 }
7752
7753 /*BugID_5222*/
83383ea3 7754 down(&hWaitResponse);
c5c77ba1
JK
7755
7756 return s32Error;
7757}
7758
7759/**
7760 * @brief host_int_setup_ipaddress
7761 * @details setup IP in firmware
7762 * @param[in] Handle to wifi driver
7763 * @return Error code.
7764 * @author Abdelrahman Sobhy
7765 * @date
7766 * @version 1.0*/
218dc407 7767s32 host_int_setup_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
c5c77ba1 7768{
fb4ec9ca 7769 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
7770 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7771 tstrHostIFmsg strHostIFmsg;
7772
7773 /* TODO: Enable This feature on softap firmware */
7774 return 0;
7775
2b9d5b48 7776 if (pstrWFIDrv == NULL)
c5c77ba1 7777 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1 7778
2cc46837 7779 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
7780
7781 /* prepare the WiphyParams Message */
7782 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_IPADDRESS;
7783
7784 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
7785 strHostIFmsg.drvHandler = hWFIDrv;
7786 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
7787
c4f83a55 7788 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 7789 if (s32Error)
c5c77ba1 7790 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
7791 WILC_CATCH(s32Error)
7792 {
7793
7794 }
7795
7796 return s32Error;
7797
7798
7799}
7800
7801/**
7802 * @brief host_int_get_ipaddress
7803 * @details Get IP from firmware
7804 * @param[in] Handle to wifi driver
7805 * @return Error code.
7806 * @author Abdelrahman Sobhy
7807 * @date
7808 * @version 1.0*/
218dc407 7809s32 host_int_get_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
c5c77ba1 7810{
fb4ec9ca 7811 s32 s32Error = WILC_SUCCESS;
c5c77ba1
JK
7812 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7813 tstrHostIFmsg strHostIFmsg;
7814
2b9d5b48 7815 if (pstrWFIDrv == NULL)
c5c77ba1 7816 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
c5c77ba1 7817
2cc46837 7818 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
c5c77ba1
JK
7819
7820 /* prepare the WiphyParams Message */
7821 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_IPADDRESS;
7822
7823 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
bf903c1e
SS
7824 strHostIFmsg.drvHandler = hWFIDrv;
7825 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
c5c77ba1 7826
c4f83a55 7827 s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
2b9d5b48 7828 if (s32Error)
c5c77ba1 7829 WILC_ERRORREPORT(s32Error, s32Error);
c5c77ba1
JK
7830 WILC_CATCH(s32Error)
7831 {
7832
7833 }
7834
7835 return s32Error;
7836
7837
7838}