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