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