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