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