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