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