blob: 8458d8d40232b86abd74df4b6412e8845553eac2 [file] [log] [blame]
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001#include "host_interface.h"
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002#include "coreconfigurator.h"
3
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004extern s32 TransportInit(void);
5extern s32 TransportDeInit(void);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006extern u8 connecting;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007
8#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -07009extern struct timer_list hDuringIpTimer;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090010#endif
11
Johnny Kimc5c77ba2015-05-11 14:30:56 +090012/*BugID_5137*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090013extern u8 g_wilc_initialized;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090014/*****************************************************************************/
15/* Macros */
16/*****************************************************************************/
17
18/* Message types of the Host IF Message Queue*/
Chaehyun Lim9eac3a12015-06-18 22:08:51 +090019#define HOST_IF_MSG_SCAN 0
20#define HOST_IF_MSG_CONNECT 1
21#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
22#define HOST_IF_MSG_KEY 3
23#define HOST_IF_MSG_RCVD_NTWRK_INFO 4
24#define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
25#define HOST_IF_MSG_CFG_PARAMS 6
26#define HOST_IF_MSG_SET_CHANNEL 7
27#define HOST_IF_MSG_DISCONNECT 8
28#define HOST_IF_MSG_GET_RSSI 9
29#define HOST_IF_MSG_GET_CHNL 10
30#define HOST_IF_MSG_ADD_BEACON 11
31#define HOST_IF_MSG_DEL_BEACON 12
32#define HOST_IF_MSG_ADD_STATION 13
33#define HOST_IF_MSG_DEL_STATION 14
34#define HOST_IF_MSG_EDIT_STATION 15
35#define HOST_IF_MSG_SCAN_TIMER_FIRED 16
36#define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
37#define HOST_IF_MSG_POWER_MGMT 18
38#define HOST_IF_MSG_GET_INACTIVETIME 19
39#define HOST_IF_MSG_REMAIN_ON_CHAN 20
40#define HOST_IF_MSG_REGISTER_FRAME 21
41#define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
42#define HOST_IF_MSG_GET_LINKSPEED 23
43#define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
44#define HOST_IF_MSG_SET_MAC_ADDRESS 25
45#define HOST_IF_MSG_GET_MAC_ADDRESS 26
46#define HOST_IF_MSG_SET_OPERATION_MODE 27
47#define HOST_IF_MSG_SET_IPADDRESS 28
48#define HOST_IF_MSG_GET_IPADDRESS 29
49#define HOST_IF_MSG_FLUSH_CONNECT 30
50#define HOST_IF_MSG_GET_STATISTICS 31
51#define HOST_IF_MSG_SET_MULTICAST_FILTER 32
52#define HOST_IF_MSG_ADD_BA_SESSION 33
53#define HOST_IF_MSG_DEL_BA_SESSION 34
54#define HOST_IF_MSG_Q_IDLE 35
55#define HOST_IF_MSG_DEL_ALL_STA 36
56#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
57#define HOST_IF_MSG_EXIT 100
Johnny Kimc5c77ba2015-05-11 14:30:56 +090058
Chaehyun Lime54d5b72015-06-18 22:08:50 +090059#define HOST_IF_SCAN_TIMEOUT 4000
60#define HOST_IF_CONNECT_TIMEOUT 9500
Johnny Kimc5c77ba2015-05-11 14:30:56 +090061
Chaehyun Lime54d5b72015-06-18 22:08:50 +090062#define BA_SESSION_DEFAULT_BUFFER_SIZE 16
63#define BA_SESSION_DEFAULT_TIMEOUT 1000
64#define BLOCK_ACK_REQ_SIZE 0x14
Johnny Kimc5c77ba2015-05-11 14:30:56 +090065/*****************************************************************************/
66/* Type Definitions */
67/*****************************************************************************/
68
69/*!
70 * @struct tstrHostIFCfgParamAttr
71 * @brief Structure to hold Host IF CFG Params Attributes
72 * @details
73 * @todo
74 * @sa
75 * @author Mai Daftedar
76 * @date 02 April 2012
77 * @version 1.0
78 */
79typedef struct _tstrHostIFCfgParamAttr {
80 tstrCfgParamVal pstrCfgParamVal;
81
82} tstrHostIFCfgParamAttr;
83
84/*!
85 * @struct tstrHostIFwpaAttr
86 * @brief Structure to hold Host IF Scan Attributes
87 * @details
88 * @todo
89 * @sa
90 * @author Mai Daftedar
91 * @date 25 March 2012
92 * @version 1.0
93 */
94typedef struct _tstrHostIFwpaAttr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090095 u8 *pu8key;
96 const u8 *pu8macaddr;
97 u8 *pu8seq;
98 u8 u8seqlen;
99 u8 u8keyidx;
100 u8 u8Keylen;
101 u8 u8Ciphermode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900102} tstrHostIFwpaAttr;
103
104
105/*!
106 * @struct tstrHostIFwepAttr
107 * @brief Structure to hold Host IF Scan Attributes
108 * @details
109 * @todo
110 * @sa
111 * @author Mai Daftedar
112 * @date 25 March 2012
113 * @version 1.0
114 */
115typedef struct _tstrHostIFwepAttr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900116 u8 *pu8WepKey;
117 u8 u8WepKeylen;
118 u8 u8Wepidx;
119 u8 u8mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900120 AUTHTYPE_T tenuAuth_type;
121
122} tstrHostIFwepAttr;
123
124/*!
125 * @struct tuniHostIFkeyAttr
126 * @brief Structure to hold Host IF Scan Attributes
127 * @details
128 * @todo
129 * @sa
130 * @author Mai Daftedar
131 * @date 25 March 2012
132 * @version 1.0
133 */
134typedef union _tuniHostIFkeyAttr {
135 tstrHostIFwepAttr strHostIFwepAttr;
136 tstrHostIFwpaAttr strHostIFwpaAttr;
137 tstrHostIFpmkidAttr strHostIFpmkidAttr;
138} tuniHostIFkeyAttr;
139
140/*!
141 * @struct tstrHostIFkeyAttr
142 * @brief Structure to hold Host IF Scan Attributes
143 * @details
144 * @todo
145 * @sa
146 * @author Mai Daftedar
147 * @date 25 March 2012
148 * @version 1.0
149 */
150typedef struct _tstrHostIFkeyAttr {
151 tenuKeyType enuKeyType;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900152 u8 u8KeyAction;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900153 tuniHostIFkeyAttr uniHostIFkeyAttr;
154} tstrHostIFkeyAttr;
155
156
157
158
159/*!
160 * @struct tstrHostIFscanAttr
161 * @brief Structure to hold Host IF Scan Attributes
162 * @details
163 * @todo
164 * @sa
165 * @author Mostafa Abu Bakr
166 * @date 25 March 2012
167 * @version 1.0
168 */
169typedef struct _tstrHostIFscanAttr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900170 u8 u8ScanSource;
171 u8 u8ScanType;
172 u8 *pu8ChnlFreqList;
173 u8 u8ChnlListLen;
174 u8 *pu8IEs;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900175 size_t IEsLen;
176 tWILCpfScanResult pfScanResult;
177 void *pvUserArg;
178 /*BugID_4189*/
179 tstrHiddenNetwork strHiddenNetwork;
180
181} tstrHostIFscanAttr;
182
183/*!
184 * @struct tstrHostIFconnectAttr
185 * @brief Structure to hold Host IF Connect Attributes
186 * @details
187 * @todo
188 * @sa
189 * @author Mostafa Abu Bakr
190 * @date 25 March 2012
191 * @version 1.0
192 */
193typedef struct _tstrHostIFconnectAttr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900194 u8 *pu8bssid;
195 u8 *pu8ssid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900196 size_t ssidLen;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900197 u8 *pu8IEs;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900198 size_t IEsLen;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900199 u8 u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900200 tWILCpfConnectResult pfConnectResult;
201 void *pvUserArg;
202 AUTHTYPE_T tenuAuth_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900203 u8 u8channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900204 void *pJoinParams;
205} tstrHostIFconnectAttr;
206
207/*!
208 * @struct tstrRcvdGnrlAsyncInfo
209 * @brief Structure to hold Received General Asynchronous info
210 * @details
211 * @todo
212 * @sa
213 * @author Mostafa Abu Bakr
214 * @date 25 March 2012
215 * @version 1.0
216 */
217typedef struct _tstrRcvdGnrlAsyncInfo {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900218 u8 *pu8Buffer;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900219 u32 u32Length;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900220} tstrRcvdGnrlAsyncInfo;
221
222/*!
223 * @struct tstrHostIFSetChan
224 * @brief Set Channel message body
225 * @details
226 * @todo
227 * @sa
228 * @author Mai Daftedar
229 * @date 25 March 2012
230 * @version 1.0
231 */
232typedef struct _tstrHostIFSetChan {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900233 u8 u8SetChan;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900234} tstrHostIFSetChan;
235
236/*!
237 * @struct tstrHostIFSetChan
238 * @brief Get Channel message body
239 * @details
240 * @todo
241 * @sa
242 * @author Mai Daftedar
243 * @date 01 Jule 2012
244 * @version 1.0
245 */
246typedef struct _tstrHostIFGetChan {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900247 u8 u8GetChan;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900248} tstrHostIFGetChan;
249
250/*bug3819: Add Scan acomplete notification to host*/
251/*!
252 * @struct tstrScanComplete
253 * @brief hold received Async. Scan Complete message body
254 * @details
255 * @todo
256 * @sa
257 * @author zsalah
258 * @date 25 March 2012
259 * @version 1.0
260 */
261/*typedef struct _tstrScanComplete
262 * {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900263 * u8* pu8Buffer;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900264 * u32 u32Length;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900265 * } tstrScanComplete;*/
266
267/*!
268 * @struct tstrHostIFSetBeacon
269 * @brief Set Beacon message body
270 * @details
271 * @todo
272 * @sa
273 * @author Adham Abozaeid
274 * @date 10 July 2012
275 * @version 1.0
276 */
277typedef struct _tstrHostIFSetBeacon {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900278 u32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */
279 u32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900280 * (including the current frame) appear before the next DTIM */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900281 u32 u32HeadLen; /*!< Length of the head buffer in bytes */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900282 u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900283 * from the beacon's start till the TIM element, NOT including the TIM */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900284 u32 u32TailLen; /*!< Length of the tail buffer in bytes */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900285 u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900286 * after the TIM inormation element */
287} tstrHostIFSetBeacon;
288
289
290
291/*!
292 * @struct tstrHostIFDelBeacon
293 * @brief Del Beacon message body
294 * @details
295 * @todo
296 * @sa
297 * @author Adham Abozaeid
298 * @date 15 July 2012
299 * @version 1.0
300 */
301typedef struct _tstrHostIFDelBeacon {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900302 u8 u8dummy;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900303} tstrHostIFDelBeacon;
304
305/*!
306 * @struct tstrHostIFSetMulti
307 * @brief set Multicast filter Address
308 * @details
309 * @todo
310 * @sa
311 * @author Abdelrahman Sobhy
312 * @date 30 August 2013
313 * @version 1.0 Description
314 */
315
316typedef struct {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900317 bool bIsEnabled;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900318 u32 u32count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900319} tstrHostIFSetMulti;
320
321/*!
322 * @struct tstrHostIFDelAllSta
323 * @brief Deauth station message body
324 * @details
325 * @todo
326 * @sa
327 * @author Mai Daftedar
328 * @date 09 April 2014
329 * @version 1.0 Description
330 */
331
332typedef struct {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900333 u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN];
334 u8 u8Num_AssocSta;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900335} tstrHostIFDelAllSta;
336
337/*!
338 * @struct tstrHostIFDelSta
339 * @brief Delete station message body
340 * @details
341 * @todo
342 * @sa
343 * @author Adham Abozaeid
344 * @date 15 July 2012
345 * @version 1.0 Description
346 */
347
348typedef struct {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900349 u8 au8MacAddr[ETH_ALEN];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900350} tstrHostIFDelSta;
351
352/*!
353 * @struct tstrTimerCb
354 * @brief Timer callback message body
355 * @details
356 * @todo
357 * @sa
358 * @author Mostafa Abu Bakr
359 * @date 25 March 2012
360 * @version 1.0
361 */
362typedef struct _tstrTimerCb {
363 void *pvUsrArg; /*!< Private data passed at timer start */
364} tstrTimerCb;
365
366/*!
367 * @struct tstrHostIfPowerMgmtParam
368 * @brief Power management message body
369 * @details
370 * @todo
371 * @sa
372 * @author Adham Abozaeid
373 * @date 24 November 2012
374 * @version 1.0
375 */
376typedef struct {
377
Dean Lee72ed4dc2015-06-12 14:11:44 +0900378 bool bIsEnabled;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900379 u32 u32Timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900380} tstrHostIfPowerMgmtParam;
381
382/*!
383 * @struct tstrHostIFSetIPAddr
384 * @brief set IP Address message body
385 * @details
386 * @todo
387 * @sa
388 * @author Abdelrahman Sobhy
389 * @date 30 August 2013
390 * @version 1.0 Description
391 */
392
393typedef struct {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900394 u8 *au8IPAddr;
395 u8 idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900396} tstrHostIFSetIPAddr;
397
398/*!
399 * @struct tstrHostIfStaInactiveT
400 * @brief Get station message body
401 * @details
402 * @todo
403 * @sa
404 * @author Mai Daftedar
405 * @date 16 April 2013
406 * @version 1.0
407 */
408typedef struct {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900409 u8 mac[6];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900410
411} tstrHostIfStaInactiveT;
412/**/
413/*!
414 * @union tuniHostIFmsgBody
415 * @brief Message body for the Host Interface message_q
416 * @details
417 * @todo
418 * @sa
419 * @author Mostafa Abu Bakr
420 * @date 25 March 2012
421 * @version 1.0
422 */
423typedef union _tuniHostIFmsgBody {
424 tstrHostIFscanAttr strHostIFscanAttr; /*!< Host IF Scan Request Attributes message body */
425 tstrHostIFconnectAttr strHostIFconnectAttr; /*!< Host IF Connect Request Attributes message body */
426 tstrRcvdNetworkInfo strRcvdNetworkInfo; /*!< Received Asynchronous Network Info message body */
427 tstrRcvdGnrlAsyncInfo strRcvdGnrlAsyncInfo; /*!< Received General Asynchronous Info message body */
428 tstrHostIFkeyAttr strHostIFkeyAttr; /*!<>*/
429 tstrHostIFCfgParamAttr strHostIFCfgParamAttr; /*! <CFG Parameter message Body> */
430 tstrHostIFSetChan strHostIFSetChan;
431 tstrHostIFGetChan strHostIFGetChan;
432 tstrHostIFSetBeacon strHostIFSetBeacon; /*!< Set beacon message body */
433 tstrHostIFDelBeacon strHostIFDelBeacon; /*!< Del beacon message body */
434 tstrWILC_AddStaParam strAddStaParam; /*!< Add station message body */
435 tstrHostIFDelSta strDelStaParam; /*!< Del Station message body */
436 tstrWILC_AddStaParam strEditStaParam; /*!< Edit station message body */
437 /* tstrScanComplete strScanComplete; / *Received Async. Scan Complete message body* / */
438 tstrTimerCb strTimerCb; /*!< Timer callback message body */
439 tstrHostIfPowerMgmtParam strPowerMgmtparam; /*!< Power Management message body */
440 tstrHostIfStaInactiveT strHostIfStaInactiveT;
441 tstrHostIFSetIPAddr strHostIfSetIP;
442 tstrHostIfSetDrvHandler strHostIfSetDrvHandler;
443 tstrHostIFSetMulti strHostIfSetMulti;
444 tstrHostIfSetOperationMode strHostIfSetOperationMode;
445 tstrHostIfSetMacAddress strHostIfSetMacAddress;
446 tstrHostIfGetMacAddress strHostIfGetMacAddress;
447 tstrHostIfBASessionInfo strHostIfBASessionInfo;
448 #ifdef WILC_P2P
449 tstrHostIfRemainOnChan strHostIfRemainOnChan;
450 tstrHostIfRegisterFrame strHostIfRegisterFrame;
451 #endif
Dean Lee576917a2015-06-15 11:58:57 +0900452 char *pUserData;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900453 tstrHostIFDelAllSta strHostIFDelAllSta;
454} tuniHostIFmsgBody;
455
456/*!
457 * @struct tstrHostIFmsg
458 * @brief Host Interface message
459 * @details
460 * @todo
461 * @sa
462 * @author Mostafa Abu Bakr
463 * @date 25 March 2012
464 * @version 1.0
465 */
466typedef struct _tstrHostIFmsg {
Chaehyun Limd85f5322015-06-11 14:35:54 +0900467 u16 u16MsgId; /*!< Message ID */
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900468 tuniHostIFmsgBody uniHostIFmsgBody; /*!< Message body */
Johnny Kim11f58c82015-08-13 13:41:20 +0900469 tstrWILC_WFIDrv *drvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900470} tstrHostIFmsg;
471
472#ifdef CONNECT_DIRECT
473typedef struct _tstrWidJoinReqExt {
Dean Lee576917a2015-06-15 11:58:57 +0900474 char SSID[MAX_SSID_LEN];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900475 u8 u8channel;
476 u8 BSSID[6];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900477} tstrWidJoinReqExt;
478#endif
479
480/*Bug4218: Parsing Join Param*/
481#ifdef WILC_PARSE_SCAN_IN_HOST
482/*Struct containg joinParam of each AP*/
483typedef struct _tstrJoinBssParam {
484 BSSTYPE_T bss_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900485 u8 dtim_period;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900486 u16 beacon_period;
487 u16 cap_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900488 u8 au8bssid[6];
Dean Lee576917a2015-06-15 11:58:57 +0900489 char ssid[MAX_SSID_LEN];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900490 u8 ssidLen;
491 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
492 u8 ht_capable;
493 u8 wmm_cap;
494 u8 uapsd_cap;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900495 bool rsn_found;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900496 u8 rsn_grp_policy;
497 u8 mode_802_11i;
498 u8 rsn_pcip_policy[3];
499 u8 rsn_auth_policy[3];
500 u8 rsn_cap[2];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900501 struct _tstrJoinParam *nextJoinBss;
502 #ifdef WILC_P2P
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900503 u32 tsf;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900504 u8 u8NoaEnbaled;
505 u8 u8OppEnable;
506 u8 u8CtWindow;
507 u8 u8Count;
508 u8 u8Index;
509 u8 au8Duration[4];
510 u8 au8Interval[4];
511 u8 au8StartTime[4];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900512 #endif
513} tstrJoinBssParam;
514/*Bug4218: Parsing Join Param*/
515/*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
516typedef struct _tstrBssTable {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900517 u8 u8noBssEntries;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900518 tstrJoinBssParam *head;
519 tstrJoinBssParam *tail;
520} tstrBssTable;
521#endif /*WILC_PARSE_SCAN_IN_HOST*/
522
523typedef enum {
524 SCAN_TIMER = 0,
525 CONNECT_TIMER = 1,
526 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
527} tenuScanConnTimer;
528
529/*****************************************************************************/
530/* */
531/* Global Variabls */
532/* */
533/*****************************************************************************/
Johnny Kimd42ab082015-08-20 16:32:52 +0900534/* Zero is not used, because a zero ID means termination */
535static tstrWILC_WFIDrv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
Daniel Machon6fdb3022015-07-06 19:48:04 +0200536tstrWILC_WFIDrv *terminated_handle;
537tstrWILC_WFIDrv *gWFiDrvHandle;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900538#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +0900539bool g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900540#endif
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900541u8 P2P_LISTEN_STATE;
Arnd Bergmann1999bd52015-05-29 22:52:14 +0200542static struct task_struct *HostIFthreadHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900543static WILC_MsgQueueHandle gMsgQHostIF;
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200544static struct semaphore hSemHostIFthrdEnd;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900545
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200546struct semaphore hSemDeinitDrvHandle;
547static struct semaphore hWaitResponse;
548struct semaphore hSemHostIntDeinit;
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -0700549struct timer_list g_hPeriodicRSSI;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900550
551
552
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900553u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900554
555#ifndef CONNECT_DIRECT
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900556static u8 gapu8RcvdSurveyResults[2][MAX_SURVEY_RESULT_FRAG_SIZE];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900557#endif
558
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900559static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900560
Dean Lee72ed4dc2015-06-12 14:11:44 +0900561bool gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900562
Chaehyun Limca356ad2015-06-11 14:35:57 +0900563static s8 gs8Rssi;
564static s8 gs8lnkspd;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900565static u8 gu8Chnl;
566static u8 gs8SetIP[2][4];
567static u8 gs8GetIP[2][4];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900568#ifdef WILC_AP_EXTERNAL_MLME
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900569static u32 gu32InactiveTime;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900570static u8 gu8DelBcn;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900571#endif
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900572static u32 gu32WidConnRstHack;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900573
574/*BugID_5137*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900575u8 *gu8FlushedJoinReq;
576u8 *gu8FlushedInfoElemAsoc;
577u8 gu8Flushed11iMode;
578u8 gu8FlushedAuthType;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900579u32 gu32FlushedJoinReqSize;
580u32 gu32FlushedInfoElemAsocSize;
Johnny Kim8a625ca2015-08-20 16:32:50 +0900581tstrWILC_WFIDrv *gu8FlushedJoinReqDrvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900582#define REAL_JOIN_REQ 0
583#define FLUSHED_JOIN_REQ 1
584#define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
585
586/*Bug4218: Parsing Join Param*/
587#ifdef WILC_PARSE_SCAN_IN_HOST
588/*Bug4218: Parsing Join Param*/
589static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
590#endif /*WILC_PARSE_SCAN_IN_HOST*/
591
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900592extern void chip_sleep_manually(u32 u32SleepTime);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900593extern int linux_wlan_get_num_conn_ifcs(void);
594
Johnny Kimd42ab082015-08-20 16:32:52 +0900595static int add_handler_in_list(tstrWILC_WFIDrv *handler)
596{
597 int i;
598
599 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
600 if (!wfidrv_list[i]) {
601 wfidrv_list[i] = handler;
602 return 0;
603 }
604 }
605
606 return -ENOBUFS;
607}
608
609static int remove_handler_in_list(tstrWILC_WFIDrv *handler)
610{
611 int i;
612
613 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
614 if (wfidrv_list[i] == handler) {
615 wfidrv_list[i] = NULL;
616 return 0;
617 }
618 }
619
620 return -EINVAL;
621}
622
623static int get_id_from_handler(tstrWILC_WFIDrv *handler)
624{
625 int i;
626
627 if (!handler)
628 return 0;
629
630 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
631 if (wfidrv_list[i] == handler)
632 return i;
633 }
634
635 return 0;
636}
637
638static tstrWILC_WFIDrv *get_handler_from_id(int id)
639{
640 if (id <= 0 || id > ARRAY_SIZE(wfidrv_list))
641 return NULL;
642 return wfidrv_list[id];
643}
644
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900645/**
646 * @brief Handle_SetChannel
647 * @details Sending config packet to firmware to set channel
648 * @param[in] tstrHostIFSetChan* pstrHostIFSetChan
649 * @return Error code.
650 * @author
651 * @date
652 * @version 1.0
653 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900654static s32 Handle_SetChannel(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetChan *pstrHostIFSetChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900655{
656
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900657 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900658 tstrWID strWID;
659 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
660
661 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900662 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900663 strWID.enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900664 strWID.ps8WidVal = (char *)&(pstrHostIFSetChan->u8SetChan);
665 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900666
667 PRINT_D(HOSTINF_DBG, "Setting channel\n");
668 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +0900669 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
670 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900671 if (s32Error) {
672 PRINT_ER("Failed to set channel\n");
673 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
674 }
675 WILC_CATCH(s32Error)
676 {
677
678 }
679
680 return s32Error;
681}
682/**
683 * @brief Handle_SetWfiDrvHandler
684 * @details Sending config packet to firmware to set driver handler
685 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
686 * @return Error code.
687 * @author
688 * @date
689 * @version 1.0
690 */
Johnny Kim53a84402015-08-20 16:32:51 +0900691static s32 Handle_SetWfiDrvHandler(tstrWILC_WFIDrv *drvHandler,
692 tstrHostIfSetDrvHandler *pstrHostIfSetDrvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900693{
694
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900695 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900696 tstrWID strWID;
Johnny Kim53a84402015-08-20 16:32:51 +0900697 tstrWILC_WFIDrv *pstrWFIDrv = drvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900698
699
700 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900701 strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900702 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900703 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900704 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900705
706 /*Sending Cfg*/
707
Johnny Kimd42ab082015-08-20 16:32:52 +0900708 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
709 pstrHostIfSetDrvHandler->u32Address);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900710
Johnny Kim53a84402015-08-20 16:32:51 +0900711 if (pstrWFIDrv == NULL)
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200712 up(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900713
714
715 if (s32Error) {
716 PRINT_ER("Failed to set driver handler\n");
717 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
718 }
719 WILC_CATCH(s32Error)
720 {
721
722 }
723
724 return s32Error;
725}
726
727/**
728 * @brief Handle_SetWfiAPDrvHandler
729 * @details Sending config packet to firmware to set driver handler
730 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
731 * @return Error code.
732 * @author
733 * @date
734 * @version 1.0
735 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900736static s32 Handle_SetOperationMode(tstrWILC_WFIDrv *drvHandler, tstrHostIfSetOperationMode *pstrHostIfSetOperationMode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900737{
738
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900739 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900740 tstrWID strWID;
741 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
742
743
744 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900745 strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900746 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900747 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900748 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900749
750 /*Sending Cfg*/
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +0200751 PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900752
Johnny Kimd42ab082015-08-20 16:32:52 +0900753 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
754 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900755
756
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +0200757 if ((pstrHostIfSetOperationMode->u32Mode) == (u32)NULL)
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200758 up(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900759
760
761 if (s32Error) {
762 PRINT_ER("Failed to set driver handler\n");
763 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
764 }
765 WILC_CATCH(s32Error)
766 {
767
768 }
769
770 return s32Error;
771}
772
773/**
774 * @brief host_int_set_IPAddress
775 * @details Setting IP address params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900776 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900777 * @return Error code.
778 * @author
779 * @date
780 * @version 1.0
781 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900782s32 Handle_set_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900783{
784
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900785 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900786 tstrWID strWID;
787 char firmwareIPAddress[4] = {0};
788 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
789
790 if (pu8IPAddr[0] < 192)
791 pu8IPAddr[0] = 0;
792
Luis de Bethencourtb3a02832015-06-26 17:40:25 +0200793 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900794
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900795 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900796
797 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900798 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900799 strWID.enuWIDtype = WID_STR;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900800 strWID.ps8WidVal = (u8 *)pu8IPAddr;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900801 strWID.s32ValueSize = IP_ALEN;
802
Johnny Kimd42ab082015-08-20 16:32:52 +0900803 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
804 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900805
806
Johnny Kim218dc402015-08-13 13:41:19 +0900807 host_int_get_ipaddress(drvHandler, firmwareIPAddress, idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900808
809 if (s32Error) {
810 PRINT_D(HOSTINF_DBG, "Failed to set IP address\n");
811 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
812 } else {
813 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
814 }
815
816 WILC_CATCH(s32Error)
817 {
818
819 }
820
821 return s32Error;
822}
823
824
825/**
826 * @brief Handle_get_IPAddress
827 * @details Setting IP address params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900828 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900829 * @return Error code.
830 * @author
831 * @date
832 * @version 1.0
833 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900834s32 Handle_get_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900835{
836
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900837 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900838 tstrWID strWID;
839 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
840
841 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900842 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900843 strWID.enuWIDtype = WID_STR;
Chaehyun Limdc0ad742015-08-17 11:05:12 +0900844 strWID.ps8WidVal = WILC_MALLOC(IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900845 strWID.s32ValueSize = IP_ALEN;
846
Johnny Kimd42ab082015-08-20 16:32:52 +0900847 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
848 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900849
Luis de Bethencourtb3a02832015-06-26 17:40:25 +0200850 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900851
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900852 memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900853
854 /*get the value by searching the local copy*/
Chaehyun Lim49188af2015-08-11 10:32:41 +0900855 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900856
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900857 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
Johnny Kim218dc402015-08-13 13:41:19 +0900858 host_int_setup_ipaddress(pstrWFIDrv, gs8SetIP[idx], idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900859
860 if (s32Error != WILC_SUCCESS) {
861 PRINT_ER("Failed to get IP address\n");
862 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
863 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +0200864 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
Luis de Bethencourtb3a02832015-06-26 17:40:25 +0200865 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900866 PRINT_INFO(HOSTINF_DBG, "\n");
867 }
868
869 WILC_CATCH(s32Error)
870 {
871
872 }
873
874 return s32Error;
875}
876
877
878/*BugId_5077*/
879/**
880 * @brief Handle_SetMacAddress
881 * @details Setting mac address
882 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
883 * @return Error code.
884 * @author Amr Abdel-Moghny
885 * @date November 2013
886 * @version 7.0
887 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900888static s32 Handle_SetMacAddress(tstrWILC_WFIDrv *drvHandler, tstrHostIfSetMacAddress *pstrHostIfSetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900889{
890
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900891 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900892 tstrWID strWID;
893 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Chaehyun Limdc0ad742015-08-17 11:05:12 +0900894 u8 *mac_buf = WILC_MALLOC(ETH_ALEN);
Luis de Bethencourt78c87592015-06-26 16:45:14 +0200895
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900896 if (mac_buf == NULL) {
897 PRINT_ER("No buffer to send mac address\n");
898 return WILC_FAIL;
899 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900900 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900901
902 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900903 strWID.u16WIDid = (u16)WID_MAC_ADDR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900904 strWID.enuWIDtype = WID_STR;
905 strWID.ps8WidVal = mac_buf;
906 strWID.s32ValueSize = ETH_ALEN;
Alexander Kuleshov310a28f2015-09-04 00:48:14 +0600907 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900908 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +0900909 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
910 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900911 if (s32Error) {
912 PRINT_ER("Failed to set mac address\n");
913 WILC_ERRORREPORT(s32Error, WILC_FAIL);
914 }
915
916 WILC_CATCH(s32Error)
917 {
918
919 }
Chaehyun Lim49188af2015-08-11 10:32:41 +0900920 kfree(mac_buf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900921 return s32Error;
922}
923
924
925/*BugID_5213*/
926/**
927 * @brief Handle_GetMacAddress
928 * @details Getting mac address
929 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
930 * @return Error code.
931 * @author Amr Abdel-Moghny
932 * @date JAN 2013
933 * @version 8.0
934 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900935static s32 Handle_GetMacAddress(tstrWILC_WFIDrv *drvHandler, tstrHostIfGetMacAddress *pstrHostIfGetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900936{
937
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900938 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900939 tstrWID strWID;
940
941 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900942 strWID.u16WIDid = (u16)WID_MAC_ADDR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900943 strWID.enuWIDtype = WID_STR;
944 strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress;
945 strWID.s32ValueSize = ETH_ALEN;
946
947 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +0900948 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, false,
949 get_id_from_handler(drvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900950 if (s32Error) {
951 PRINT_ER("Failed to get mac address\n");
952 WILC_ERRORREPORT(s32Error, WILC_FAIL);
953 }
954 WILC_CATCH(s32Error)
955 {
956
957 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200958 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900959
960 return s32Error;
961}
962
963
964/**
965 * @brief Handle_CfgParam
966 * @details Sending config packet to firmware to set CFG params
967 * @param[in] tstrHostIFCfgParamAttr* strHostIFCfgParamAttr
968 * @return Error code.
969 * @author
970 * @date
971 * @version 1.0
972 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900973static s32 Handle_CfgParam(tstrWILC_WFIDrv *drvHandler, tstrHostIFCfgParamAttr *strHostIFCfgParamAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900974{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900975 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900976 tstrWID strWIDList[32];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900977 u8 u8WidCnt = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900978 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
979
980
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200981 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900982
983
984 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
985
986 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) {
987 /*----------------------------------------------------------*/
988 /*Input Value: INFRASTRUCTURE = 1, */
989 /* INDEPENDENT= 2, */
990 /* ANY_BSS= 3 */
991 /*----------------------------------------------------------*/
992 /* validate input then copy>> need to check value 4 and 5 */
993 if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) {
994 strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900995 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900996 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900997 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900998 pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900999 } else {
1000 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1001 }
1002 u8WidCnt++;
1003 }
1004 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) {
1005 /*------------------------------------------------------*/
1006 /*Input Values: OPEN_SYSTEM = 0, */
1007 /* SHARED_KEY = 1, */
1008 /* ANY = 2 */
1009 /*------------------------------------------------------*/
1010 /*validate Possible values*/
1011 if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) {
1012 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001013 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001014 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001015 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001016 pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001017 } else {
1018 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1019 }
1020 u8WidCnt++;
1021 }
1022 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) {
1023 /* range is 1 to 65535. */
1024 if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) {
1025 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001026 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001027 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001028 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001029 pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
1030 } else {
1031 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1032 }
1033 u8WidCnt++;
1034 }
1035 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) {
1036 /*-----------------------------------------------------------*/
1037 /*Input Values: NO_POWERSAVE = 0, */
1038 /* MIN_FAST_PS = 1, */
1039 /* MAX_FAST_PS = 2, */
1040 /* MIN_PSPOLL_PS = 3, */
1041 /* MAX_PSPOLL_PS = 4 */
1042 /*----------------------------------------------------------*/
1043 if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) {
1044 strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001045 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001046 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001047 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001048 pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001049 } else {
1050 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1051 }
1052 u8WidCnt++;
1053 }
1054 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) {
1055 /* range from 1 to 256 */
1056 if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) {
1057 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001058 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001059 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001060 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001061 pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
1062 } else {
1063 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1064 }
1065 u8WidCnt++;
1066 }
1067 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) {
1068 /* range from 1 to 256 */
1069 if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) {
1070 strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001071 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001072
1073 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001074 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001075 pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
1076 } else {
1077 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1078 }
1079 u8WidCnt++;
1080 }
1081 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) {
1082
1083 if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) {
1084 strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001085 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001086 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001087 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001088 pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
1089 } else {
1090 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1091 }
1092 u8WidCnt++;
1093 }
1094 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) {
1095 /* range 256 to 65535 */
1096 if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) {
1097 strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001098 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001099 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001100 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001101 pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1102 } else {
1103 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1104 }
1105 u8WidCnt++;
1106 }
1107 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) {
1108 /*-----------------------------------------------------*/
1109 /*Input Values: Short= 0, */
1110 /* Long= 1, */
1111 /* Auto= 2 */
1112 /*------------------------------------------------------*/
1113 if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) {
1114 strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001115 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001116 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001117 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001118 pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1119 } else {
1120 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1121 }
1122 u8WidCnt++;
1123 }
1124 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) {
1125 if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) {
1126 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001127 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001128 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001129 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001130 pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001131 } else {
1132 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1133 }
1134 u8WidCnt++;
1135 }
1136 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) {
1137 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1138 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1139 /* this information is useful for external supplicant */
1140 /*Input Values: 1 for enable and 0 for disable. */
1141 if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) {
1142 strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001143 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001144 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001145 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001146 pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001147 } else {
1148 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1149 }
1150 u8WidCnt++;
1151 }
1152 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) {
1153 /* range is 1 to 65535. */
1154 if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) {
1155 strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001156 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001157 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001158 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001159 pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1160 } else {
1161 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1162 }
1163 u8WidCnt++;
1164 }
1165 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) {
1166 /* range is 1 to 255. */
1167 if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) {
1168 strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001169 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001170 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001171 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001172 pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1173 } else {
1174 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1175 }
1176 u8WidCnt++;
1177 }
1178 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) {
1179 /*----------------------------------------------------------------------*/
1180 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1181 /* SITE_SURVEY_ALL_CH = 1, */
1182 /* SITE_SURVEY_OFF = 2 */
1183 /*----------------------------------------------------------------------*/
1184 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) {
1185 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001186 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001187 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001188 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001189 pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001190 } else {
1191 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1192 }
1193 u8WidCnt++;
1194 }
1195 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) {
1196 /* range is 1 to 65535. */
1197 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) {
1198 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001199 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001200 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001201 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001202 pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1203 } else {
1204 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1205 }
1206 u8WidCnt++;
1207 }
1208 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) {
1209 /* range is 1 to 65535. */
1210 if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) {
1211 strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001212 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001213 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001214 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001215 pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1216 } else {
1217 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1218 }
1219 u8WidCnt++;
1220 }
1221 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) {
1222 /* range is 1 to 65535. */
1223 if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) {
1224 strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001225 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001226 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001227 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001228 pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1229 } else {
1230 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1231 }
1232 u8WidCnt++;
1233 }
1234 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) {
1235 CURRENT_TX_RATE_T curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate;
1236 /*----------------------------------------------------------------------*/
1237 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1238 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1239 /*----------------------------------------------------------------------*/
1240 /* validate rate */
1241 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
1242 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
1243 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
1244 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
1245 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
1246 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
1247 strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001248 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001249 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001250 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001251 pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001252 } else {
1253 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1254 }
1255 u8WidCnt++;
1256 }
Johnny Kimd42ab082015-08-20 16:32:52 +09001257 s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, false,
1258 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001259
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001260 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001261 PRINT_ER("Error in setting CFG params\n");
1262
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001263 WILC_CATCH(s32Error)
1264 {
1265 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02001266 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001267 return s32Error;
1268}
1269
1270
1271/**
1272 * @brief Handle_wait_msg_q_empty
1273 * @details this should be the last msg and then the msg Q becomes idle
1274 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1275 * @return Error code.
1276 * @author
1277 * @date
1278 * @version 1.0
1279 */
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001280static s32 Handle_wait_msg_q_empty(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001281{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001282 s32 s32Error = WILC_SUCCESS;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02001283
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001284 g_wilc_initialized = 0;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02001285 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001286 return s32Error;
1287}
1288
1289/**
1290 * @brief Handle_Scan
1291 * @details Sending config packet to firmware to set the scan params
1292 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1293 * @return Error code.
1294 * @author
1295 * @date
1296 * @version 1.0
1297 */
Johnny Kim2b05df52015-08-13 13:41:21 +09001298static s32 Handle_Scan(tstrWILC_WFIDrv *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001299{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001300 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001301 tstrWID strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001302 u32 u32WidsCount = 0;
1303 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001304 u8 *pu8Buffer;
1305 u8 valuesize = 0;
1306 u8 *pu8HdnNtwrksWidVal = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001307 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1308
1309 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001310 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", pstrWFIDrv->enuHostIFstate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001311
1312 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
1313 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
1314
1315 #ifdef WILC_P2P
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001316 #endif
1317
1318 if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) {
1319 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1320 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate);
1321 WILC_ERRORREPORT(s32Error, WILC_BUSY);
1322 }
1323
1324 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
1325 if (g_obtainingIP || connecting) {
1326 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
1327 WILC_ERRORREPORT(s32Error, WILC_BUSY);
1328 }
1329 #endif
1330
1331 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1332
1333
1334 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0;
1335
1336 /*BugID_4189*/
Chaehyun Limd85f5322015-06-11 14:35:54 +09001337 strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001338 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1339
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001340 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001341 valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001342 pu8HdnNtwrksWidVal = WILC_MALLOC(valuesize + 1);
1343 strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001344 if (strWIDList[u32WidsCount].ps8WidVal != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001345 pu8Buffer = strWIDList[u32WidsCount].ps8WidVal;
1346
1347 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
1348
1349 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
1350
1351 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1352 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001353 memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001354 pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1355 }
1356
1357
1358
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001359 strWIDList[u32WidsCount].s32ValueSize = (s32)(valuesize + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001360 u32WidsCount++;
1361 }
1362
1363 /*filling cfg param array*/
1364
1365 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1366 {
1367 /* IEs to be inserted in Probe Request */
1368 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE;
1369 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1370 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs;
1371 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen;
1372 u32WidsCount++;
1373 }
1374
1375 /*Scan Type*/
1376 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE;
1377 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001378 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001379 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001380 u32WidsCount++;
1381
1382 /*list of channels to be scanned*/
1383 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST;
1384 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1385
1386 /* Bug 4648: Convert channel numbers to start from 0 not 1. */
1387 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
1388 int i;
1389
1390 for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001391 if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001392 pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001393 }
1394 }
1395
1396 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList;
1397 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen;
1398 u32WidsCount++;
1399
1400 /*Scan Request*/
1401 strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ;
1402 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001403 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001404 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001405 u32WidsCount++;
1406
1407 /*keep the state as is , no need to change it*/
1408 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1409
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301410 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001411 gbScanWhileConnected = true;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301412 else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001413 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001414
Johnny Kimd42ab082015-08-20 16:32:52 +09001415 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false,
1416 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001417
1418 if (s32Error) {
1419 PRINT_ER("Failed to send scan paramters config packet\n");
1420 WILC_ERRORREPORT(s32Error, s32Error);
1421 } else {
1422 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
1423 }
1424
1425 WILC_CATCH(s32Error)
1426 {
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07001427 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001428 /*if there is an ongoing scan request*/
1429 Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED);
1430 }
1431
1432 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1433 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001434 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001435 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1436 }
1437
1438 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1439 if (pstrHostIFscanAttr->pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001440 kfree(pstrHostIFscanAttr->pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001441 pstrHostIFscanAttr->pu8IEs = NULL;
1442 }
1443 if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001444 kfree(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001445 pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
1446 }
1447
1448 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1449 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001450 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001451 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1452 }
1453
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001454 if (pu8HdnNtwrksWidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001455 kfree(pu8HdnNtwrksWidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001456
1457 return s32Error;
1458}
1459
1460/**
1461 * @brief Handle_ScanDone
1462 * @details Call scan notification callback function
1463 * @param[in] NONE
1464 * @return Error code.
1465 * @author
1466 * @date
1467 * @version 1.0
1468 */
Johnny Kim2b05df52015-08-13 13:41:21 +09001469static s32 Handle_ScanDone(tstrWILC_WFIDrv *drvHandler, tenuScanEvent enuEvent)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001470{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001471 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001472
1473 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
1474
1475
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001476 u8 u8abort_running_scan;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001477 tstrWID strWID;
1478
1479
1480 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
1481
1482 /*BugID_4978*/
1483 /*Ask FW to abort the running scan, if any*/
1484 if (enuEvent == SCAN_EVENT_ABORTED) {
1485 PRINT_D(GENERIC_DBG, "Abort running scan\n");
1486 u8abort_running_scan = 1;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001487 strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001488 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001489 strWID.ps8WidVal = (s8 *)&u8abort_running_scan;
Dean Lee576917a2015-06-15 11:58:57 +09001490 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001491
1492 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09001493 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
1494 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001495 if (s32Error != WILC_SUCCESS) {
1496 PRINT_ER("Failed to set abort running scan\n");
1497 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1498 }
1499 WILC_CATCH(s32Error)
1500 {
1501 }
1502 }
1503
1504 if (pstrWFIDrv == NULL) {
1505 PRINT_ER("Driver handler is NULL\n");
1506 return s32Error;
1507 }
1508
1509 /*if there is an ongoing scan request*/
1510 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001511 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001512 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1513 /*delete current scan request*/
1514 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1515 }
1516
1517 return s32Error;
1518}
1519
1520/**
1521 * @brief Handle_Connect
1522 * @details Sending config packet to firmware to starting connection
1523 * @param[in] tstrHostIFconnectAttr* pstrHostIFconnectAttr
1524 * @return Error code.
1525 * @author
1526 * @date
1527 * @version 1.0
1528 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001529u8 u8ConnectedSSID[6] = {0};
Johnny Kim2b05df52015-08-13 13:41:21 +09001530static s32 Handle_Connect(tstrWILC_WFIDrv *drvHandler, tstrHostIFconnectAttr *pstrHostIFconnectAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001531{
1532 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001533 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001534 tstrWID strWIDList[8];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001535 u32 u32WidsCount = 0, dummyval = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001536 /* char passphrase[] = "12345678"; */
1537 #ifndef CONNECT_DIRECT
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001538 s32 s32Err = WILC_SUCCESS;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001539 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001540 u8 u8bssDscListIndex;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001541 wid_site_survey_reslts_s *pstrSurveyResults = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001542 #else
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001543 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001544 /*Bug4218: Parsing Join Param*/
1545 #ifdef WILC_PARSE_SCAN_IN_HOST
1546 tstrJoinBssParam *ptstrJoinBssParam;
1547 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1548
1549 #endif
1550
1551 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1552
1553 #ifndef CONNECT_DIRECT
Hari Prasath Gujulan Elango3a79a7f2015-08-20 09:59:44 +00001554 memset(gapu8RcvdSurveyResults, 0, sizeof(gapu8RcvdSurveyResults));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001555
1556
1557 PRINT_D(HOSTINF_DBG, "Getting site survey results\n");
Johnny Kim218dc402015-08-13 13:41:19 +09001558 s32Err = host_int_get_site_survey_results(pstrWFIDrv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001559 gapu8RcvdSurveyResults,
1560 MAX_SURVEY_RESULT_FRAG_SIZE);
1561 if (s32Err) {
1562 PRINT_ER("Failed to get site survey results\n");
1563 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1564
1565 }
1566 s32Err = ParseSurveyResults(gapu8RcvdSurveyResults, &pstrSurveyResults,
1567 &pstrWFIDrv->u32SurveyResultsCount);
1568
1569
1570 if (s32Err == WILC_SUCCESS) {
1571 /* use the parsed info in pstrSurveyResults, then deallocate it */
1572 PRINT_D(HOSTINF_DBG, "Copying site survey results in global structure, then deallocate\n");
1573 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001574 memcpy(&pstrWFIDrv->astrSurveyResults[i], &pstrSurveyResults[i],
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001575 sizeof(wid_site_survey_reslts_s));
1576 }
1577
1578 DeallocateSurveyResults(pstrSurveyResults);
1579 } else {
1580 WILC_ERRORREPORT(s32Error, WILC_FAIL);
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001581 PRINT_ER("ParseSurveyResults() Error(%d)\n", s32Err);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001582 }
1583
1584
1585 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001586 if (memcmp(pstrWFIDrv->astrSurveyResults[i].SSID,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001587 pstrHostIFconnectAttr->pu8ssid,
1588 pstrHostIFconnectAttr->ssidLen) == 0) {
1589 PRINT_INFO(HOSTINF_DBG, "Network with required SSID is found %s\n", pstrHostIFconnectAttr->pu8ssid);
1590 if (pstrHostIFconnectAttr->pu8bssid == NULL) {
1591 /* BSSID is not passed from the user, so decision of matching
1592 * is done by SSID only */
1593 PRINT_INFO(HOSTINF_DBG, "BSSID is not passed from the user\n");
1594 break;
1595 } else {
1596 /* BSSID is also passed from the user, so decision of matching
1597 * should consider also this passed BSSID */
1598
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001599 if (memcmp(pstrWFIDrv->astrSurveyResults[i].BSSID,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001600 pstrHostIFconnectAttr->pu8bssid,
1601 6) == 0) {
1602 PRINT_INFO(HOSTINF_DBG, "BSSID is passed from the user and matched\n");
1603 break;
1604 }
1605 }
1606 }
1607 }
1608
1609 if (i < pstrWFIDrv->u32SurveyResultsCount) {
1610 u8bssDscListIndex = i;
1611
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001612 PRINT_INFO(HOSTINF_DBG, "Connecting to network of Bss Idx%d and SSID %s and channel%d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001613 u8bssDscListIndex, pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].SSID,
1614 pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].Channel);
1615
1616 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1617
1618 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Limdc0ad742015-08-17 11:05:12 +09001619 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = WILC_MALLOC(6);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001620 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001621 }
1622
1623 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1624 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Limdc0ad742015-08-17 11:05:12 +09001625 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001626 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001627 pstrHostIFconnectAttr->ssidLen);
1628 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1629 }
1630
1631 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1632 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Chaehyun Limdc0ad742015-08-17 11:05:12 +09001633 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001634 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001635 pstrHostIFconnectAttr->IEsLen);
1636 }
1637
1638 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1639 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1640 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1641 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1642
1643
1644 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1645 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1646 {
1647 /* IEs to be inserted in Association Request */
1648 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1649 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1650 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1651 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1652 u32WidsCount++;
1653 }
Chaehyun Limd85f5322015-06-11 14:35:54 +09001654 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001655 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001656 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001657 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001658 u32WidsCount++;
1659
1660 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1661
Chaehyun Limd85f5322015-06-11 14:35:54 +09001662 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001663 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001664 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001665 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001666 u32WidsCount++;
1667
1668 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1669 /*
Chaehyun Limd85f5322015-06-11 14:35:54 +09001670 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001671 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1672 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001673 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001674 * u32WidsCount++;
1675 */
1676
Chaehyun Limd85f5322015-06-11 14:35:54 +09001677 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001678 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001679 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001680 strWIDList[u32WidsCount].ps8WidVal = (s8 *)&u8bssDscListIndex;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001681 u32WidsCount++;
1682
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001683 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1684 * firmware at chip reset when processing the WIDs of the Connect Request.
1685 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1686 /* ////////////////////// */
1687 gu32WidConnRstHack = 0;
1688 /* ////////////////////// */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001689
Johnny Kimd42ab082015-08-20 16:32:52 +09001690 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false,
1691 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001692 if (s32Error) {
1693 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1694 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
1695 } else {
1696 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1697 }
1698
1699 } else {
1700 PRINT_ER("Required BSSID not found\n");
1701 WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
1702 }
1703
1704 #else
1705
1706 /* if we try to connect to an already connected AP then discard the request */
1707
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001708 if (memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001709
1710 s32Error = WILC_SUCCESS;
1711 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1712 return s32Error;
1713 }
1714
1715 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1716
1717 /*Bug4218: Parsing Join Param*/
1718 #ifdef WILC_PARSE_SCAN_IN_HOST
1719 ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams;
1720 if (ptstrJoinBssParam == NULL) {
1721 PRINT_ER("Required BSSID not found\n");
1722 WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
1723 }
1724 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1725
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001726 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Limdc0ad742015-08-17 11:05:12 +09001727 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = WILC_MALLOC(6);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001728 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001729 }
1730
1731 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1732 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Limdc0ad742015-08-17 11:05:12 +09001733 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001734 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001735 pstrHostIFconnectAttr->ssidLen);
1736 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1737 }
1738
1739 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1740 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Chaehyun Limdc0ad742015-08-17 11:05:12 +09001741 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001742 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001743 pstrHostIFconnectAttr->IEsLen);
1744 }
1745
1746 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1747 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1748 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1749 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1750
1751 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
1752 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001753 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001754 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001755 u32WidsCount++;
1756
1757 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
1758 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001759 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001760 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001761 u32WidsCount++;
1762
1763 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
1764 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001765 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001766 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001767 u32WidsCount++;
1768
1769 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1770 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1771 {
1772 /* IEs to be inserted in Association Request */
1773 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1774 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1775 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1776 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1777 u32WidsCount++;
1778
1779 /*BugID_5137*/
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001780 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001781
1782 gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1783 gu8FlushedInfoElemAsoc = WILC_MALLOC(gu32FlushedInfoElemAsocSize);
1784 memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1785 gu32FlushedInfoElemAsocSize);
1786 }
1787 }
Chaehyun Limd85f5322015-06-11 14:35:54 +09001788 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001789 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001790 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001791 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001792 u32WidsCount++;
1793
1794 /*BugID_5137*/
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001795 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001796 gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security;
1797
1798 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1799
1800
Chaehyun Limd85f5322015-06-11 14:35:54 +09001801 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001802 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001803 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001804 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001805 u32WidsCount++;
1806
1807 /*BugID_5137*/
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001808 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001809 gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001810
1811 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1812 /*
Chaehyun Limd85f5322015-06-11 14:35:54 +09001813 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001814 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1815 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001816 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001817 * u32WidsCount++;
1818 */
1819
1820 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1821 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
1822
1823
1824#ifndef WILC_PARSE_SCAN_IN_HOST
Chaehyun Limd85f5322015-06-11 14:35:54 +09001825 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001826 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1827 strWIDList[u32WidsCount].s32ValueSize = MAX_SSID_LEN + 7;
1828 strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize);
1829
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001830 if (strWIDList[u32WidsCount].ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001831 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001832
1833 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1834
1835 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001836 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001837 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1838 }
1839 pu8CurrByte += MAX_SSID_LEN;
1840 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1841 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1842 } else {
1843 PRINT_ER("Channel out of range\n");
1844 *(pu8CurrByte++) = 0xFF;
1845 }
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001846 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001847 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001848 pu8CurrByte += 6;
1849
1850 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1851 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1852
1853 #else
1854
Chaehyun Limd85f5322015-06-11 14:35:54 +09001855 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001856 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1857
1858 /*Sending NoA attributes during connection*/
1859 strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */
1860 strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize);
1861
1862 /*BugID_5137*/
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001863 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001864 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize;
1865 gu8FlushedJoinReq = WILC_MALLOC(gu32FlushedJoinReqSize);
1866 }
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001867 if (strWIDList[u32WidsCount].ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001868 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001869
1870 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1871
1872
1873 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001874 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001875 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1876 }
1877 pu8CurrByte += MAX_SSID_LEN;
1878
1879 /* BSS type*/
1880 *(pu8CurrByte++) = INFRASTRUCTURE;
1881 /* Channel*/
1882 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1883 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1884 } else {
1885 PRINT_ER("Channel out of range\n");
1886 *(pu8CurrByte++) = 0xFF;
1887 }
1888 /* Cap Info*/
1889 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1890 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1891 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1892
1893 /* sa*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001894 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001895 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001896 pu8CurrByte += 6;
1897
1898 /* bssid*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001899 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001900 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001901 pu8CurrByte += 6;
1902
1903 /* Beacon Period*/
1904 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1905 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1906 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1907 /* DTIM Period*/
1908 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1909 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1910 /* Supported rates*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001911 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001912 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1913
1914 /* wmm cap*/
1915 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1916 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1917 /* uapsd cap*/
1918 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1919
1920 /* ht cap*/
1921 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1922 /* copy this information to the user request */
1923 pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1924
1925 /* rsn found*/
1926 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1927 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1928 /* rsn group policy*/
1929 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1930 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1931 /* mode_802_11i*/
1932 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1933 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1934 /* rsn pcip policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001935 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001936 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1937
1938 /* rsn auth policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001939 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001940 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1941
1942 /* rsn auth policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001943 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001944 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1945
1946 /*BugID_5137*/
1947 *(pu8CurrByte++) = REAL_JOIN_REQ;
1948
1949 #ifdef WILC_P2P
1950 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1951 if (ptstrJoinBssParam->u8NoaEnbaled) {
1952 PRINT_D(HOSTINF_DBG, "NOA present\n");
1953
1954 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1955 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1956 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1957 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1958
1959 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1960
1961 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1962
1963 if (ptstrJoinBssParam->u8OppEnable)
1964 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1965
1966 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1967
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001968 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001969
1970 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1971
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001972 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001973
1974 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1975
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001976 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001977
1978 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1979
1980 } else
1981 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1982 #endif
1983
1984
1985 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1986 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1987
1988
1989 #endif /* #ifdef WILC_PARSE_SCAN_IN_HOST*/
1990 u32WidsCount++;
1991
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001992 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1993 * firmware at chip reset when processing the WIDs of the Connect Request.
1994 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1995 /* ////////////////////// */
1996 gu32WidConnRstHack = 0;
1997 /* ////////////////////// */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001998
1999 /*BugID_5137*/
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002000 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002001 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
Johnny Kim8a625ca2015-08-20 16:32:50 +09002002 gu8FlushedJoinReqDrvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002003 }
2004
2005 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
2006
2007 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002008 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002009
Alexander Kuleshov310a28f2015-09-04 00:48:14 +06002010 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->pu8bssid);
2011 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002012 }
2013
Johnny Kimd42ab082015-08-20 16:32:52 +09002014 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false,
2015 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002016 if (s32Error) {
2017 PRINT_ER("Handle_Connect()] failed to send config packet\n");
2018 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
2019 } else {
2020 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
2021 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
2022 }
2023 #endif
2024
2025 WILC_CATCH(s32Error)
2026 {
2027 tstrConnectInfo strConnectInfo;
2028
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002029 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002030
2031 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
2032
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002033 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002034
2035 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002036 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002037 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002038
2039 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
2040 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
Chaehyun Limdc0ad742015-08-17 11:05:12 +09002041 strConnectInfo.pu8ReqIEs = WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002042 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002043 pstrHostIFconnectAttr->pu8IEs,
2044 pstrHostIFconnectAttr->IEsLen);
2045 }
2046
2047 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2048 &strConnectInfo,
2049 MAC_DISCONNECTED,
2050 NULL,
2051 pstrHostIFconnectAttr->pvUserArg);
2052 /*Change state to idle*/
2053 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2054 /* Deallocation */
2055 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002056 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002057 strConnectInfo.pu8ReqIEs = NULL;
2058 }
2059
2060 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002061 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002062 }
2063 }
2064
2065 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
2066 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
2067 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002068 kfree(pstrHostIFconnectAttr->pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002069 pstrHostIFconnectAttr->pu8bssid = NULL;
2070 }
2071
2072 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
2073 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002074 kfree(pstrHostIFconnectAttr->pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002075 pstrHostIFconnectAttr->pu8ssid = NULL;
2076 }
2077
2078 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
2079 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002080 kfree(pstrHostIFconnectAttr->pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002081 pstrHostIFconnectAttr->pu8IEs = NULL;
2082 }
2083
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002084 if (pu8CurrByte != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09002085 kfree(pu8CurrByte);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002086 return s32Error;
2087}
2088
2089/**
2090 * @brief Handle_FlushConnect
2091 * @details Sending config packet to firmware to flush an old connection
2092 * after switching FW from station one to hybrid one
2093 * @param[in] void * drvHandler
2094 * @return Error code.
2095 * @author Amr Abdel-Moghny
2096 * @date 19 DEC 2013
2097 * @version 8.0
2098 */
2099
Johnny Kim2b05df52015-08-13 13:41:21 +09002100static s32 Handle_FlushConnect(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002101{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002102 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002103 tstrWID strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002104 u32 u32WidsCount = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002105 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002106
2107
2108 /* IEs to be inserted in Association Request */
2109 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
2110 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
2111 strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc;
2112 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize;
2113 u32WidsCount++;
2114
Chaehyun Limd85f5322015-06-11 14:35:54 +09002115 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002116 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002117 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002118 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002119 u32WidsCount++;
2120
2121
2122
Chaehyun Limd85f5322015-06-11 14:35:54 +09002123 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002124 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002125 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002126 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002127 u32WidsCount++;
2128
2129
2130 #ifdef WILC_PARSE_SCAN_IN_HOST
Chaehyun Limd85f5322015-06-11 14:35:54 +09002131 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002132 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
2133 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002134 strWIDList[u32WidsCount].ps8WidVal = (s8 *)gu8FlushedJoinReq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002135 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
2136
2137 pu8CurrByte += FLUSHED_BYTE_POS;
2138 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
2139
2140 u32WidsCount++;
2141
2142 #endif
2143
Johnny Kimd42ab082015-08-20 16:32:52 +09002144 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false,
2145 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002146 if (s32Error) {
2147 PRINT_ER("Handle_Flush_Connect()] failed to send config packet\n");
2148 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
2149 }
2150
2151 WILC_CATCH(s32Error)
2152 {
2153
2154 }
2155
2156 return s32Error;
2157}
2158
2159/**
2160 * @brief Handle_ConnectTimeout
2161 * @details Call connect notification callback function indicating connection failure
2162 * @param[in] NONE
2163 * @return Error code.
2164 * @author
2165 * @date
2166 * @version 1.0
2167 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002168static s32 Handle_ConnectTimeout(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002169{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002170 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002171 tstrConnectInfo strConnectInfo;
2172 tstrWID strWID;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002173 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002174 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
2175
2176 if (pstrWFIDrv == NULL) {
2177 PRINT_ER("Driver handler is NULL\n");
2178 return s32Error;
2179 }
2180
2181 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2182
Dean Lee72ed4dc2015-06-12 14:11:44 +09002183 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002184
2185
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002186 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002187
2188
2189 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
2190 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2191 * WID_DISCONNECT} */
2192 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2193 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002194 memcpy(strConnectInfo.au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002195 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2196 }
2197
2198 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2199 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Chaehyun Limdc0ad742015-08-17 11:05:12 +09002200 strConnectInfo.pu8ReqIEs = WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002201 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002202 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2203 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2204 }
2205
2206 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2207 &strConnectInfo,
2208 MAC_DISCONNECTED,
2209 NULL,
2210 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2211
2212 /* Deallocation of strConnectInfo.pu8ReqIEs */
2213 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002214 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002215 strConnectInfo.pu8ReqIEs = NULL;
2216 }
2217 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002218 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002219 }
2220
2221 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2222 * WID_DISCONNECT} */
Chaehyun Limd85f5322015-06-11 14:35:54 +09002223 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002224 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002225 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
Dean Lee576917a2015-06-15 11:58:57 +09002226 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002227
2228 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2229
Johnny Kimd42ab082015-08-20 16:32:52 +09002230 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
2231 get_id_from_handler(pstrWFIDrv));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002232 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002233 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002234
2235 /* Deallocation of the Saved Connect Request in the global Handle */
2236 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2237 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002238 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002239 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2240 }
2241
2242 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002243 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002244 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2245 }
2246
2247 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2248 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002249 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002250 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2251 }
2252
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002253 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002254 /*BugID_5213*/
2255 /*Freeing flushed join request params on connect timeout*/
Johnny Kim8a625ca2015-08-20 16:32:50 +09002256 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002257 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002258 gu8FlushedJoinReq = NULL;
2259 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09002260 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002261 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002262 gu8FlushedInfoElemAsoc = NULL;
2263 }
2264
2265 return s32Error;
2266}
2267
2268/**
2269 * @brief Handle_RcvdNtwrkInfo
2270 * @details Handling received network information
2271 * @param[in] tstrRcvdNetworkInfo* pstrRcvdNetworkInfo
2272 * @return Error code.
2273 * @author
2274 * @date
2275 * @version 1.0
2276 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002277static s32 Handle_RcvdNtwrkInfo(tstrWILC_WFIDrv *drvHandler, tstrRcvdNetworkInfo *pstrRcvdNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002278{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002279 u32 i;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002280 bool bNewNtwrkFound;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002281
2282
2283
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002284 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002285 tstrNetworkInfo *pstrNetworkInfo = NULL;
2286 void *pJoinParams = NULL;
2287
2288 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2289
2290
2291
Dean Lee72ed4dc2015-06-12 14:11:44 +09002292 bNewNtwrkFound = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002293 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
2294
2295 /*if there is a an ongoing scan request*/
2296 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2297 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
2298 ParseNetworkInfo(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
2299 if ((pstrNetworkInfo == NULL)
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002300 || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002301 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
2302 }
2303
2304 /* check whether this network is discovered before */
2305 for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
2306
2307 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
2308 (pstrNetworkInfo->au8bssid != NULL)) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002309 if (memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002310 pstrNetworkInfo->au8bssid, 6) == 0) {
2311 if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
2312 /*we have already found this network with better rssi, so keep the old cached one and don't
2313 * send anything to the upper layer */
2314 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
2315 goto done;
2316 } else {
2317 /* here the same already found network is found again but with a better rssi, so just update
2318 * the rssi for this cached network and send this updated network to the upper layer but
2319 * don't add a new record for it */
2320 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002321 bNewNtwrkFound = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002322 break;
2323 }
2324 }
2325 }
2326 }
2327
Dean Lee72ed4dc2015-06-12 14:11:44 +09002328 if (bNewNtwrkFound == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002329 /* here it is confirmed that it is a new discovered network,
2330 * so add its record then call the User CallBack function */
2331
2332 PRINT_D(HOSTINF_DBG, "New network found\n");
2333
2334 if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
2335 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
2336
2337 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
2338 && (pstrNetworkInfo->au8bssid != NULL)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002339 memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002340 pstrNetworkInfo->au8bssid, 6);
2341
2342 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++;
2343
Dean Lee72ed4dc2015-06-12 14:11:44 +09002344 pstrNetworkInfo->bNewNetwork = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002345 /*Bug4218: Parsing Join Param*/
2346 /* add new BSS to JoinBssTable */
2347 #ifdef WILC_PARSE_SCAN_IN_HOST
2348 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
2349 #endif /*WILC_PARSE_SCAN_IN_HOST*/
2350
2351 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2352 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid,
2353 pJoinParams);
2354
2355
2356 }
2357 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002358 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002359 }
2360 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002361 pstrNetworkInfo->bNewNetwork = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002362 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2363 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2364 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2365 }
2366 }
2367
2368
2369 WILC_CATCH(s32Error)
2370 {
2371
2372 }
2373
2374done:
2375 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2376 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002377 kfree(pstrRcvdNetworkInfo->pu8Buffer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002378 pstrRcvdNetworkInfo->pu8Buffer = NULL;
2379 }
2380
2381 /*free structure allocated*/
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002382 if (pstrNetworkInfo != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002383 DeallocateNetworkInfo(pstrNetworkInfo);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002384 pstrNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002385 }
2386
2387 return s32Error;
2388}
2389
2390/**
2391 * @brief Handle_RcvdGnrlAsyncInfo
2392 * @details Handling received asynchrous general network information
2393 * @param[in] tstrRcvdGnrlAsyncInfo* pstrRcvdGnrlAsyncInfo
2394 * @return Error code.
2395 * @author
2396 * @date
2397 * @version 1.0
2398 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002399static s32 Handle_RcvdGnrlAsyncInfo(tstrWILC_WFIDrv *drvHandler, tstrRcvdGnrlAsyncInfo *pstrRcvdGnrlAsyncInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002400{
2401 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2402 /* which carries only 1 WID which have WID ID = WID_STATUS */
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002403 s32 s32Error = WILC_SUCCESS;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002404 u8 u8MsgType = 0;
2405 u8 u8MsgID = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002406 u16 u16MsgLen = 0;
2407 u16 u16WidID = (u16)WID_NIL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002408 u8 u8WidLen = 0;
2409 u8 u8MacStatus;
2410 u8 u8MacStatusReasonCode;
2411 u8 u8MacStatusAdditionalInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002412 tstrConnectInfo strConnectInfo;
2413 tstrDisconnectNotifInfo strDisconnectNotifInfo;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002414 s32 s32Err = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002415 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002416
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002417 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002418 PRINT_ER("Driver handler is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002419 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
2420 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
2421
2422 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
2423 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) ||
2424 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2425 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002426 (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002427 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
2428 }
2429
2430 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
2431
2432 /* Check whether the received message type is 'I' */
2433 if ('I' != u8MsgType) {
2434 PRINT_ER("Received Message format incorrect.\n");
2435 WILC_ERRORREPORT(s32Error, WILC_FAIL);
2436 }
2437
2438 /* Extract message ID */
2439 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
2440
2441 /* Extract message Length */
2442 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
2443
2444 /* Extract WID ID [expected to be = WID_STATUS] */
2445 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
2446
2447 /* Extract WID Length [expected to be = 1] */
2448 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
2449
2450 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2451 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
2452 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
2453 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
2454 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2455 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2456 /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002457 u32 u32RcvdAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002458 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
2459
2460 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2461
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002462 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002463
2464 if (u8MacStatus == MAC_CONNECTED) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002465 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002466
Johnny Kim218dc402015-08-13 13:41:19 +09002467 host_int_get_assoc_res_info(pstrWFIDrv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002468 gapu8RcvdAssocResp,
2469 MAX_ASSOC_RESP_FRAME_SIZE,
2470 &u32RcvdAssocRespInfoLen);
2471
2472 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
2473
2474 if (u32RcvdAssocRespInfoLen != 0) {
2475
2476 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
2477 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
2478 &pstrConnectRespInfo);
2479 if (s32Err) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002480 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002481 } else {
2482 /* use the necessary parsed Info from the Received Association Response */
2483 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
2484
2485 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
2486 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
2487 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
2488 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
2489
2490
Chaehyun Limdc0ad742015-08-17 11:05:12 +09002491 strConnectInfo.pu8RespIEs = WILC_MALLOC(pstrConnectRespInfo->u16RespIEsLen);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002492 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002493 pstrConnectRespInfo->u16RespIEsLen);
2494 }
2495 }
2496
2497 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2498 if (pstrConnectRespInfo != NULL) {
2499 DeallocateAssocRespInfo(pstrConnectRespInfo);
2500 pstrConnectRespInfo = NULL;
2501 }
2502 }
2503 }
2504 }
2505
2506 /* The station has just received mac status and it also received assoc. response which
2507 * it was waiting for.
2508 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2509 if ((u8MacStatus == MAC_CONNECTED) &&
2510 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002511 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002512 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002513
2514 } else if (u8MacStatus == MAC_DISCONNECTED) {
2515 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002516 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002517 }
2518
2519 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2520 /* through a structure of type tstrConnectRespInfo */
2521 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2522 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002523 memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002524
2525 if ((u8MacStatus == MAC_CONNECTED) &&
2526 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002527 memcpy(pstrWFIDrv->au8AssociatedBSSID,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002528 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
2529 }
2530 }
2531
2532
2533 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2534 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Chaehyun Limdc0ad742015-08-17 11:05:12 +09002535 strConnectInfo.pu8ReqIEs = WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002536 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002537 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2538 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2539 }
2540
2541
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002542 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002543 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2544 &strConnectInfo,
2545 u8MacStatus,
2546 NULL,
2547 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2548
2549
2550 /* if received mac status is MAC_CONNECTED and
2551 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2552 * else change state to IDLE */
2553 if ((u8MacStatus == MAC_CONNECTED) &&
2554 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2555 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2556
Johnny Kim218dc402015-08-13 13:41:19 +09002557 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002558 #endif
2559
2560 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
2561 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED;
2562
2563 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2564 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +09002565 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002566 mod_timer(&hDuringIpTimer,
2567 jiffies + msecs_to_jiffies(10000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002568 #endif
2569
2570 #ifdef WILC_PARSE_SCAN_IN_HOST
2571 /* open a BA session if possible */
2572 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
2573
2574 #endif
2575
2576 /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
2577 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2578 } else {
2579 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
2580 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002581 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002582 }
2583
2584 /* Deallocation */
2585 if (strConnectInfo.pu8RespIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002586 kfree(strConnectInfo.pu8RespIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002587 strConnectInfo.pu8RespIEs = NULL;
2588 }
2589
2590 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002591 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002592 strConnectInfo.pu8ReqIEs = NULL;
2593 }
2594
2595
2596 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2597 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002598 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002599 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2600 }
2601
2602 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002603 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002604 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2605 }
2606
2607 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2608 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002609 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002610 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2611 }
2612
2613 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2614 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) {
2615 /* Disassociation or Deauthentication frame has been received */
2616 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
2617
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002618 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002619
2620 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002621 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002622 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002623 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2624 }
2625
2626 strDisconnectNotifInfo.u16reason = 0;
2627 strDisconnectNotifInfo.ie = NULL;
2628 strDisconnectNotifInfo.ie_len = 0;
2629
2630 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2631 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2632
Dean Lee72ed4dc2015-06-12 14:11:44 +09002633 g_obtainingIP = false;
Johnny Kim218dc402015-08-13 13:41:19 +09002634 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002635 #endif
2636
2637 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2638 NULL,
2639 0,
2640 &strDisconnectNotifInfo,
2641 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2642
2643 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002644 PRINT_ER("Connect result callback function is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002645 }
2646
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002647 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002648
2649
2650 /* Deallocation */
2651
2652 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2653 * should be deallocated here */
2654 /*
2655 * if(strDisconnectNotifInfo.ie != NULL)
2656 * {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002657 * kfree(strDisconnectNotifInfo.ie);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002658 * strDisconnectNotifInfo.ie = NULL;
2659 * }
2660 */
2661
2662 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2663 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002664 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002665 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2666 }
2667
2668 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002669 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002670 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2671 }
2672
2673 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2674 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002675 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002676 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2677 }
2678
2679 /*BugID_5213*/
2680 /*Freeing flushed join request params on receiving*/
2681 /*MAC_DISCONNECTED while connected*/
Johnny Kim8a625ca2015-08-20 16:32:50 +09002682 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002683 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002684 gu8FlushedJoinReq = NULL;
2685 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09002686 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002687 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002688 gu8FlushedInfoElemAsoc = NULL;
2689 }
2690
2691 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002692 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002693
2694 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2695 (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
2696 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002697 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002698 /*Abort the running scan*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002699 del_timer(&pstrWFIDrv->hScanTimer);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002700 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult)
Johnny Kim2b05df52015-08-13 13:41:21 +09002701 Handle_ScanDone(pstrWFIDrv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002702
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002703 }
2704
2705 }
2706
2707 WILC_CATCH(s32Error)
2708 {
2709
2710 }
2711
2712 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2713 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002714 kfree(pstrRcvdGnrlAsyncInfo->pu8Buffer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002715 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
2716 }
2717
2718 return s32Error;
2719}
2720
2721/**
2722 * @brief Handle_Key
2723 * @details Sending config packet to firmware to set key
2724 * @param[in] tstrHostIFkeyAttr* pstrHostIFkeyAttr
2725 * @return Error code.
2726 * @author
2727 * @date
2728 * @version 1.0
2729 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002730static int Handle_Key(tstrWILC_WFIDrv *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002731{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002732 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002733 tstrWID strWID;
2734 #ifdef WILC_AP_EXTERNAL_MLME
2735 tstrWID strWIDList[5];
2736 #endif
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002737 u8 i;
2738 u8 *pu8keybuf;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002739 s8 s8idxarray[1];
2740 s8 ret = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002741 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2742
2743
2744 switch (pstrHostIFkeyAttr->enuKeyType) {
2745
2746
2747 case WEP:
2748
2749#ifdef WILC_AP_EXTERNAL_MLME
2750 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2751
2752 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2753 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Chaehyun Limd85f5322015-06-11 14:35:54 +09002754 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002755 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002756 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002757 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002758
2759 strWIDList[1].u16WIDid = WID_AUTH_TYPE;
2760 strWIDList[1].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002761 strWIDList[1].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002762 strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002763
Chaehyun Limd85f5322015-06-11 14:35:54 +09002764 strWIDList[2].u16WIDid = (u16)WID_KEY_ID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002765 strWIDList[2].enuWIDtype = WID_CHAR;
2766
Chaehyun Limca356ad2015-06-11 14:35:57 +09002767 strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Dean Lee576917a2015-06-15 11:58:57 +09002768 strWIDList[2].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002769
2770
Chaehyun Limdc0ad742015-08-17 11:05:12 +09002771 pu8keybuf = WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002772
2773
2774 if (pu8keybuf == NULL) {
2775 PRINT_ER("No buffer to send Key\n");
2776 return -1;
2777 }
2778
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002779 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002780 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2781
2782
Chaehyun Lim49188af2015-08-11 10:32:41 +09002783 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002784
Chaehyun Limd85f5322015-06-11 14:35:54 +09002785 strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002786 strWIDList[3].enuWIDtype = WID_STR;
2787 strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002788 strWIDList[3].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002789
2790
Johnny Kimd42ab082015-08-20 16:32:52 +09002791 s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, true,
2792 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002793 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002794
2795
2796 }
2797#endif
2798
2799 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2800 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Chaehyun Limdc0ad742015-08-17 11:05:12 +09002801 pu8keybuf = WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002802 if (pu8keybuf == NULL) {
2803 PRINT_ER("No buffer to send Key\n");
2804 return -1;
2805 }
2806 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2807
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002808 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002809
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002810 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002811 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2812
Chaehyun Lim49188af2015-08-11 10:32:41 +09002813 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002814
Chaehyun Limd85f5322015-06-11 14:35:54 +09002815 strWID.u16WIDid = (u16)WID_ADD_WEP_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002816 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002817 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002818 strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2;
2819
Johnny Kimd42ab082015-08-20 16:32:52 +09002820 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2821 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002822 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002823 } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) {
2824
2825 PRINT_D(HOSTINF_DBG, "Removing key\n");
Chaehyun Limd85f5322015-06-11 14:35:54 +09002826 strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002827 strWID.enuWIDtype = WID_STR;
2828
Chaehyun Limca356ad2015-06-11 14:35:57 +09002829 s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002830 strWID.ps8WidVal = s8idxarray;
2831 strWID.s32ValueSize = 1;
2832
Johnny Kimd42ab082015-08-20 16:32:52 +09002833 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2834 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002835 } else {
Chaehyun Limd85f5322015-06-11 14:35:54 +09002836 strWID.u16WIDid = (u16)WID_KEY_ID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002837 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002838 strWID.ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Dean Lee576917a2015-06-15 11:58:57 +09002839 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002840
2841 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
2842
Johnny Kimd42ab082015-08-20 16:32:52 +09002843 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2844 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002845 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002846 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002847 break;
2848
2849 case WPARxGtk:
2850 #ifdef WILC_AP_EXTERNAL_MLME
2851 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
Chaehyun Limdc0ad742015-08-17 11:05:12 +09002852 pu8keybuf = WILC_MALLOC(RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002853 if (pu8keybuf == NULL) {
2854 PRINT_ER("No buffer to send RxGTK Key\n");
2855 ret = -1;
2856 goto _WPARxGtk_end_case_;
2857 }
2858
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002859 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002860
2861
2862 /*|----------------------------------------------------------------------------|
2863 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2864 * |------------|---------|-------|------------|---------------|----------------|
2865 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2866
2867
2868
2869 if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002870 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002871
2872
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002873 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002874
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002875 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002876
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002877 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002878 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2879 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
Chaehyun Limd85f5322015-06-11 14:35:54 +09002880 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002881 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002882 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002883 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002884
Chaehyun Limd85f5322015-06-11 14:35:54 +09002885 strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002886 strWIDList[1].enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002887 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002888 strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN;
2889
Johnny Kimd42ab082015-08-20 16:32:52 +09002890 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true,
2891 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002892
Chaehyun Lim49188af2015-08-11 10:32:41 +09002893 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002894
2895 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002896 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002897 /* ///////////////////////// */
2898 }
2899
2900 #endif
2901 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2902 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
2903
Chaehyun Limdc0ad742015-08-17 11:05:12 +09002904 pu8keybuf = WILC_MALLOC(RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002905 if (pu8keybuf == NULL) {
2906 PRINT_ER("No buffer to send RxGTK Key\n");
2907 ret = -1;
2908 goto _WPARxGtk_end_case_;
2909 }
2910
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002911 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002912
2913
2914 /*|----------------------------------------------------------------------------|
2915 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2916 * |------------|---------|-------|------------|---------------|----------------|
2917 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2918
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302919 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002920 memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302921 else
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002922 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002923
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002924 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002925
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002926 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002927
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002928 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2929 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002930 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2931
Chaehyun Limd85f5322015-06-11 14:35:54 +09002932 strWID.u16WIDid = (u16)WID_ADD_RX_GTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002933 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002934 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002935 strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN;
2936
Johnny Kimd42ab082015-08-20 16:32:52 +09002937 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2938 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002939
Chaehyun Lim49188af2015-08-11 10:32:41 +09002940 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002941
2942 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002943 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002944 /* ///////////////////////// */
2945 }
2946_WPARxGtk_end_case_:
Chaehyun Lim49188af2015-08-11 10:32:41 +09002947 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2948 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002949 if (ret == -1)
2950 return ret;
2951
2952 break;
2953
2954 case WPAPtk:
2955 #ifdef WILC_AP_EXTERNAL_MLME
2956 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2957
2958
Chaehyun Limdc0ad742015-08-17 11:05:12 +09002959 pu8keybuf = WILC_MALLOC(PTK_KEY_MSG_LEN + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002960
2961
2962
2963 if (pu8keybuf == NULL) {
2964 PRINT_ER("No buffer to send PTK Key\n");
2965 ret = -1;
2966 goto _WPAPtk_end_case_;
2967
2968 }
2969
2970 /*|-----------------------------------------------------------------------------|
2971 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2972 * |----------------|------------ |--------------|----------------|---------------|
2973 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2974 |-----------------------------------------------------------------------------|*/
2975
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002976 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002977
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002978 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2979 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002980 /*16 byte TK*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002981 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002982 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2983
2984
Chaehyun Limd85f5322015-06-11 14:35:54 +09002985 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002986 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002987 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002988 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002989
Chaehyun Limd85f5322015-06-11 14:35:54 +09002990 strWIDList[1].u16WIDid = (u16)WID_ADD_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002991 strWIDList[1].enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002992 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002993 strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1;
2994
Johnny Kimd42ab082015-08-20 16:32:52 +09002995 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true,
2996 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002997 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002998
2999 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003000 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003001 /* ///////////////////////// */
3002 }
3003 #endif
3004 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
3005
3006
Chaehyun Limdc0ad742015-08-17 11:05:12 +09003007 pu8keybuf = WILC_MALLOC(PTK_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003008
3009
3010
3011 if (pu8keybuf == NULL) {
3012 PRINT_ER("No buffer to send PTK Key\n");
3013 ret = -1;
3014 goto _WPAPtk_end_case_;
3015
3016 }
3017
3018 /*|-----------------------------------------------------------------------------|
3019 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
3020 * |----------------|------------|--------------|----------------|---------------|
3021 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
3022 |-----------------------------------------------------------------------------|*/
3023
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003024 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003025
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003026 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003027 /*16 byte TK*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003028 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003029 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
3030
3031
Chaehyun Limd85f5322015-06-11 14:35:54 +09003032 strWID.u16WIDid = (u16)WID_ADD_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003033 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003034 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003035 strWID.s32ValueSize = PTK_KEY_MSG_LEN;
3036
Johnny Kimd42ab082015-08-20 16:32:52 +09003037 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3038 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09003039 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003040
3041 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003042 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003043 /* ///////////////////////// */
3044 }
3045
3046_WPAPtk_end_case_:
Chaehyun Lim49188af2015-08-11 10:32:41 +09003047 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003048 if (ret == -1)
3049 return ret;
3050
3051 break;
3052
3053
3054 case PMKSA:
3055
3056 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
3057
Chaehyun Limdc0ad742015-08-17 11:05:12 +09003058 pu8keybuf = WILC_MALLOC((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003059 if (pu8keybuf == NULL) {
3060 PRINT_ER("No buffer to send PMKSA Key\n");
3061 return -1;
3062 }
3063
3064 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
3065
3066 for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
3067
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003068 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
3069 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003070 }
3071
Chaehyun Limd85f5322015-06-11 14:35:54 +09003072 strWID.u16WIDid = (u16)WID_PMKID_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003073 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003074 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003075 strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1;
3076
Johnny Kimd42ab082015-08-20 16:32:52 +09003077 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3078 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003079
Chaehyun Lim49188af2015-08-11 10:32:41 +09003080 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003081 break;
3082 }
3083
3084 if (s32Error)
3085 PRINT_ER("Failed to send key config packet\n");
3086
3087
3088 return s32Error;
3089}
3090
3091
3092/**
3093 * @brief Handle_Disconnect
3094 * @details Sending config packet to firmware to disconnect
3095 * @param[in] NONE
3096 * @return NONE
3097 * @author
3098 * @date
3099 * @version 1.0
3100 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003101static void Handle_Disconnect(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003102{
3103 tstrWID strWID;
3104
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003105 s32 s32Error = WILC_SUCCESS;
Chaehyun Limd85f5322015-06-11 14:35:54 +09003106 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003107 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3108
3109
Chaehyun Limd85f5322015-06-11 14:35:54 +09003110 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003111 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003112 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
Dean Lee576917a2015-06-15 11:58:57 +09003113 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003114
3115
3116
3117 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
3118
3119 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3120
Dean Lee72ed4dc2015-06-12 14:11:44 +09003121 g_obtainingIP = false;
Johnny Kim218dc402015-08-13 13:41:19 +09003122 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003123 #endif
3124
Chaehyun Lim2cc46832015-08-07 09:02:01 +09003125 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003126
Johnny Kimd42ab082015-08-20 16:32:52 +09003127 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3128 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003129
3130 if (s32Error) {
3131 PRINT_ER("Failed to send dissconect config packet\n");
3132 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3133 } else {
3134 tstrDisconnectNotifInfo strDisconnectNotifInfo;
3135
Chaehyun Lim2cc46832015-08-07 09:02:01 +09003136 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003137
3138 strDisconnectNotifInfo.u16reason = 0;
3139 strDisconnectNotifInfo.ie = NULL;
3140 strDisconnectNotifInfo.ie_len = 0;
3141
3142 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07003143 del_timer(&pstrWFIDrv->hScanTimer);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003144 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003145 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
3146
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003147 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003148 }
3149
3150 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
3151
3152 /*BugID_5193*/
3153 /*Stop connect timer, if connection in progress*/
3154 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3155 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07003156 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003157 }
3158
3159 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
3160 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
3161 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003162 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003163 }
3164
Dean Lee72ed4dc2015-06-12 14:11:44 +09003165 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003166
3167 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
3168
Chaehyun Lim2cc46832015-08-07 09:02:01 +09003169 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003170
3171
3172 /* Deallocation */
3173 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
3174 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003175 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003176 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
3177 }
3178
3179 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003180 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003181 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
3182 }
3183
3184 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
3185 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003186 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003187 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
3188 }
3189
3190
3191 /*BugID_5137*/
Johnny Kim8a625ca2015-08-20 16:32:50 +09003192 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003193 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003194 gu8FlushedJoinReq = NULL;
3195 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09003196 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003197 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003198 gu8FlushedInfoElemAsoc = NULL;
3199 }
3200
3201 }
3202
3203 WILC_CATCH(s32Error)
3204 {
3205
3206 }
3207
3208 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003209 up(&(pstrWFIDrv->hSemTestDisconnectBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003210 /* ///////////////////////// */
3211
3212}
3213
3214
Johnny Kim2b05df52015-08-13 13:41:21 +09003215void resolve_disconnect_aberration(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003216{
3217 tstrWILC_WFIDrv *pstrWFIDrv;
3218
3219 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003220 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003221 return;
3222 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
3223 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
Johnny Kim218dc402015-08-13 13:41:19 +09003224 host_int_disconnect(pstrWFIDrv, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003225 }
3226}
Johnny Kim2b05df52015-08-13 13:41:21 +09003227static s32 Switch_Log_Terminal(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003228{
3229
3230
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003231 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003232 tstrWID strWID;
3233 static char dummy = 9;
3234 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3235
Chaehyun Limd85f5322015-06-11 14:35:54 +09003236 strWID.u16WIDid = (u16)WID_LOGTerminal_Switch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003237 strWID.enuWIDtype = WID_CHAR;
3238 strWID.ps8WidVal = &dummy;
Dean Lee576917a2015-06-15 11:58:57 +09003239 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003240
Johnny Kimd42ab082015-08-20 16:32:52 +09003241 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3242 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003243
3244
3245 if (s32Error) {
3246 PRINT_D(HOSTINF_DBG, "Failed to switch log terminal\n");
3247 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
3248 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003249 PRINT_INFO(HOSTINF_DBG, "MAC address set ::\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003250
3251
3252 }
3253
3254 WILC_CATCH(s32Error)
3255 {
3256
3257 }
3258
3259 return s32Error;
3260}
3261
3262/**
3263 * @brief Handle_GetChnl
3264 * @details Sending config packet to get channel
3265 * @param[in] NONE
3266 * @return NONE
3267 *
3268 * @author
3269 * @date
3270 * @version 1.0
3271 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003272static s32 Handle_GetChnl(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003273{
3274
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003275 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003276 tstrWID strWID;
3277 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
3278 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003279
Chaehyun Limd85f5322015-06-11 14:35:54 +09003280 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003281 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003282 strWID.ps8WidVal = (s8 *)&gu8Chnl;
Dean Lee576917a2015-06-15 11:58:57 +09003283 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003284
3285 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
3286
Johnny Kimd42ab082015-08-20 16:32:52 +09003287 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
3288 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003289 /*get the value by searching the local copy*/
3290 if (s32Error) {
3291 PRINT_ER("Failed to get channel number\n");
3292 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3293 }
3294
3295
3296 WILC_CATCH(s32Error)
3297 {
3298
3299 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003300 up(&(pstrWFIDrv->hSemGetCHNL));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003301
3302 return s32Error;
3303
3304
3305
3306}
3307
3308
3309/**
3310 * @brief Handle_GetRssi
3311 * @details Sending config packet to get RSSI
3312 * @param[in] NONE
3313 * @return NONE
3314 * @author
3315 * @date
3316 * @version 1.0
3317 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003318static void Handle_GetRssi(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003319{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003320 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003321 tstrWID strWID;
3322 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3323
Chaehyun Limd85f5322015-06-11 14:35:54 +09003324 strWID.u16WIDid = (u16)WID_RSSI;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003325 strWID.enuWIDtype = WID_CHAR;
3326 strWID.ps8WidVal = &gs8Rssi;
Dean Lee576917a2015-06-15 11:58:57 +09003327 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003328
3329 /*Sending Cfg*/
3330 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
3331
Johnny Kimd42ab082015-08-20 16:32:52 +09003332 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
3333 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003334 if (s32Error) {
3335 PRINT_ER("Failed to get RSSI value\n");
3336 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3337 }
3338
3339 WILC_CATCH(s32Error)
3340 {
3341
3342 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003343 up(&(pstrWFIDrv->hSemGetRSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003344
3345
3346}
3347
3348
Johnny Kim2b05df52015-08-13 13:41:21 +09003349static void Handle_GetLinkspeed(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003350{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003351 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003352 tstrWID strWID;
3353 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3354
3355 gs8lnkspd = 0;
3356
Chaehyun Limd85f5322015-06-11 14:35:54 +09003357 strWID.u16WIDid = (u16)WID_LINKSPEED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003358 strWID.enuWIDtype = WID_CHAR;
3359 strWID.ps8WidVal = &gs8lnkspd;
Dean Lee576917a2015-06-15 11:58:57 +09003360 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003361 /*Sending Cfg*/
3362 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
3363
Johnny Kimd42ab082015-08-20 16:32:52 +09003364 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
3365 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003366 if (s32Error) {
3367 PRINT_ER("Failed to get LINKSPEED value\n");
3368 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3369 }
3370
3371 WILC_CATCH(s32Error)
3372 {
3373
3374 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003375 up(&(pstrWFIDrv->hSemGetLINKSPEED));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003376
3377
3378}
3379
Johnny Kim2b05df52015-08-13 13:41:21 +09003380s32 Handle_GetStatistics(tstrWILC_WFIDrv *drvHandler, tstrStatistics *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003381{
3382 tstrWID strWIDList[5];
3383 uint32_t u32WidsCount = 0, s32Error = 0;
3384
3385 strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED;
3386 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003387 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003388 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003389 u32WidsCount++;
3390
3391 strWIDList[u32WidsCount].u16WIDid = WID_RSSI;
3392 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003393 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003394 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->s8RSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003395 u32WidsCount++;
3396
3397 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
3398 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003399 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003400 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003401 u32WidsCount++;
3402
3403 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
3404 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003405 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003406 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32RxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003407 u32WidsCount++;
3408
3409 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
3410 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003411 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003412 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxFailureCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003413 u32WidsCount++;
3414
Johnny Kimd42ab082015-08-20 16:32:52 +09003415 s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, false,
3416 get_id_from_handler(drvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003417
3418 if (s32Error) {
3419 PRINT_ER("Failed to send scan paramters config packet\n");
3420 /* WILC_ERRORREPORT(s32Error, s32Error); */
3421 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003422 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003423 return 0;
3424
3425}
3426
3427
3428#ifdef WILC_AP_EXTERNAL_MLME
3429
3430
3431/**
3432 * @brief Handle_Get_InActiveTime
3433 * @details Sending config packet to set mac adddress for station and
3434 * get inactive time
3435 * @param[in] NONE
3436 * @return NONE
3437 *
3438 * @author
3439 * @date
3440 * @version 1.0
3441 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003442static s32 Handle_Get_InActiveTime(tstrWILC_WFIDrv *drvHandler, tstrHostIfStaInactiveT *strHostIfStaInactiveT)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003443{
3444
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003445 s32 s32Error = WILC_SUCCESS;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003446 u8 *stamac;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003447 tstrWID strWID;
3448 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3449
3450
Chaehyun Limd85f5322015-06-11 14:35:54 +09003451 strWID.u16WIDid = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003452 strWID.enuWIDtype = WID_STR;
3453 strWID.s32ValueSize = ETH_ALEN;
Chaehyun Limdc0ad742015-08-17 11:05:12 +09003454 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003455
3456
3457 stamac = strWID.ps8WidVal;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003458 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003459
3460
3461 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
3462
3463
Johnny Kimd42ab082015-08-20 16:32:52 +09003464 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3465 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003466 /*get the value by searching the local copy*/
3467 if (s32Error) {
3468 PRINT_ER("Failed to SET incative time\n");
3469 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3470 }
3471
3472
Chaehyun Limd85f5322015-06-11 14:35:54 +09003473 strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003474 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003475 strWID.ps8WidVal = (s8 *)&gu32InactiveTime;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003476 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003477
3478
Johnny Kimd42ab082015-08-20 16:32:52 +09003479 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
3480 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003481 /*get the value by searching the local copy*/
3482 if (s32Error) {
3483 PRINT_ER("Failed to get incative time\n");
3484 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3485 }
3486
3487
3488 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
3489
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003490 up(&(pstrWFIDrv->hSemInactiveTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003491 WILC_CATCH(s32Error)
3492 {
3493
3494 }
3495
3496
3497 return s32Error;
3498
3499
3500
3501}
3502
3503
3504/**
3505 * @brief Handle_AddBeacon
3506 * @details Sending config packet to add beacon
3507 * @param[in] tstrHostIFSetBeacon* pstrSetBeaconParam
3508 * @return NONE
3509 * @author
3510 * @date
3511 * @version 1.0
3512 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003513static void Handle_AddBeacon(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetBeacon *pstrSetBeaconParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003514{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003515 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003516 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003517 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003518 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003519
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003520 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
3521
Chaehyun Limd85f5322015-06-11 14:35:54 +09003522 strWID.u16WIDid = (u16)WID_ADD_BEACON;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003523 strWID.enuWIDtype = WID_BIN;
3524 strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
3525 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003526 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003527 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003528
3529 pu8CurrByte = strWID.ps8WidVal;
3530 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
3531 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
3532 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
3533 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
3534
3535 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
3536 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
3537 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
3538 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
3539
3540 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
3541 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
3542 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
3543 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
3544
3545 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
3546 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
3547
3548 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
3549 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
3550 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
3551 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
3552
3553 /* Bug 4599 : if tail length = 0 skip copying */
3554 if (pstrSetBeaconParam->pu8Tail > 0)
3555 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
3556 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
3557
3558
3559
3560 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003561 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3562 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003563 if (s32Error) {
3564 PRINT_ER("Failed to send add beacon config packet\n");
3565 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3566 }
3567
3568 WILC_CATCH(s32Error)
3569 {
3570 }
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003571 kfree(strWID.ps8WidVal);
3572 kfree(pstrSetBeaconParam->pu8Head);
3573 kfree(pstrSetBeaconParam->pu8Tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003574}
3575
3576
3577/**
3578 * @brief Handle_AddBeacon
3579 * @details Sending config packet to delete beacon
3580 * @param[in] tstrHostIFDelBeacon* pstrDelBeacon
3581 * @return NONE
3582 * @author
3583 * @date
3584 * @version 1.0
3585 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003586static void Handle_DelBeacon(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelBeacon *pstrDelBeacon)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003587{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003588 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003589 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003590 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003591 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003592
Chaehyun Limd85f5322015-06-11 14:35:54 +09003593 strWID.u16WIDid = (u16)WID_DEL_BEACON;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003594 strWID.enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003595 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003596 strWID.ps8WidVal = &gu8DelBcn;
3597
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003598 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003599 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003600
3601 pu8CurrByte = strWID.ps8WidVal;
3602
3603 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
3604 /* TODO: build del beacon message*/
3605
3606 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003607 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3608 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003609 if (s32Error) {
3610
3611 PRINT_ER("Failed to send delete beacon config packet\n");
3612 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3613 }
3614
3615 WILC_CATCH(s32Error)
3616 {
3617 }
3618}
3619
3620
3621/**
3622 * @brief WILC_HostIf_PackStaParam
3623 * @details Handling packing of the station params in a buffer
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003624 * @param[in] u8* pu8Buffer, tstrWILC_AddStaParam* pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003625 * @return NONE
3626 * @author
3627 * @date
3628 * @version 1.0
3629 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003630static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, tstrWILC_AddStaParam *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003631{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003632 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003633
3634 pu8CurrByte = pu8Buffer;
3635
3636 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003637 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003638 pu8CurrByte += ETH_ALEN;
3639
3640 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
3641 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
3642
3643 *pu8CurrByte++ = pstrStationParam->u8NumRates;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003644 if (pstrStationParam->u8NumRates > 0)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003645 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003646 pu8CurrByte += pstrStationParam->u8NumRates;
3647
3648 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
3649 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
3650 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
3651
3652 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003653 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003654 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
3655
3656 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
3657 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
3658
3659 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
3660 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
3661 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
3662 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
3663
3664 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
3665
3666 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
3667 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
3668
3669 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
3670 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
3671
3672 return pu8CurrByte - pu8Buffer;
3673}
3674
3675/**
3676 * @brief Handle_AddStation
3677 * @details Sending config packet to add station
3678 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3679 * @return NONE
3680 * @author
3681 * @date
3682 * @version 1.0
3683 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003684static void Handle_AddStation(tstrWILC_WFIDrv *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003685{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003686 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003687 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003688 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003689 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003690
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003691 PRINT_D(HOSTINF_DBG, "Handling add station\n");
Chaehyun Limd85f5322015-06-11 14:35:54 +09003692 strWID.u16WIDid = (u16)WID_ADD_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003693 strWID.enuWIDtype = WID_BIN;
3694 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3695
3696 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003697 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003698 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003699
3700 pu8CurrByte = strWID.ps8WidVal;
3701 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3702
3703 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003704 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3705 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003706 if (s32Error != WILC_SUCCESS) {
3707
3708 PRINT_ER("Failed to send add station config packet\n");
3709 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3710 }
3711
3712 WILC_CATCH(s32Error)
3713 {
3714 }
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003715 kfree(pstrStationParam->pu8Rates);
3716 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003717}
3718
3719/**
3720 * @brief Handle_DelAllSta
3721 * @details Sending config packet to delete station
3722 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3723 * @return NONE
3724 * @author
3725 * @date
3726 * @version 1.0
3727 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003728static void Handle_DelAllSta(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelAllSta *pstrDelAllStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003729{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003730 s32 s32Error = WILC_SUCCESS;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003731
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003732 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003733 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003734 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003735 u8 i;
Chaehyun Lim37034802015-06-11 14:34:32 +09003736 u8 au8Zero_Buff[6] = {0};
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003737
Chaehyun Limd85f5322015-06-11 14:35:54 +09003738 strWID.u16WIDid = (u16)WID_DEL_ALL_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003739 strWID.enuWIDtype = WID_STR;
3740 strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
3741
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003742 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003743
3744 strWID.ps8WidVal = WILC_MALLOC((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003745 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003746 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003747
3748 pu8CurrByte = strWID.ps8WidVal;
3749
3750 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
3751
3752 for (i = 0; i < MAX_NUM_STA; i++) {
3753 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003754 memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003755 else
3756 continue;
3757
3758 pu8CurrByte += ETH_ALEN;
3759 }
3760
3761 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003762 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3763 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003764 if (s32Error) {
3765
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02003766 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003767 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3768 }
3769
3770 WILC_CATCH(s32Error)
3771 {
3772 }
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003773 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003774
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003775 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003776}
3777
3778
3779/**
3780 * @brief Handle_DelStation
3781 * @details Sending config packet to delete station
3782 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3783 * @return NONE
3784 * @author
3785 * @date
3786 * @version 1.0
3787 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003788static void Handle_DelStation(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelSta *pstrDelStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003789{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003790 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003791 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003792 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003793 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3794
Chaehyun Limd85f5322015-06-11 14:35:54 +09003795 strWID.u16WIDid = (u16)WID_REMOVE_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003796 strWID.enuWIDtype = WID_BIN;
3797 strWID.s32ValueSize = ETH_ALEN;
3798
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003799 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003800
3801 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003802 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003803 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003804
3805 pu8CurrByte = strWID.ps8WidVal;
3806
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003807 memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003808
3809 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003810 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3811 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003812 if (s32Error) {
3813
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02003814 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003815 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3816 }
3817
3818 WILC_CATCH(s32Error)
3819 {
3820 }
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003821 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003822}
3823
3824
3825/**
3826 * @brief Handle_EditStation
3827 * @details Sending config packet to edit station
3828 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3829 * @return NONE
3830 * @author
3831 * @date
3832 * @version 1.0
3833 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003834static void Handle_EditStation(tstrWILC_WFIDrv *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003835{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003836 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003837 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003838 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003839 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3840
Chaehyun Limd85f5322015-06-11 14:35:54 +09003841 strWID.u16WIDid = (u16)WID_EDIT_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003842 strWID.enuWIDtype = WID_BIN;
3843 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3844
3845 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
3846 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003847 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003848 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003849
3850 pu8CurrByte = strWID.ps8WidVal;
3851 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3852
3853 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003854 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3855 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003856 if (s32Error) {
3857
3858 PRINT_ER("Failed to send edit station config packet\n");
3859 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3860 }
3861
3862 WILC_CATCH(s32Error)
3863 {
3864 }
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003865 kfree(pstrStationParam->pu8Rates);
3866 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003867}
3868#endif /*WILC_AP_EXTERNAL_MLME*/
3869
3870#ifdef WILC_P2P
3871/**
3872 * @brief Handle_RemainOnChan
3873 * @details Sending config packet to edit station
3874 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3875 * @return NONE
3876 * @author
3877 * @date
3878 * @version 1.0
3879 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003880static int Handle_RemainOnChan(tstrWILC_WFIDrv *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003881{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003882 s32 s32Error = WILC_SUCCESS;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003883 u8 u8remain_on_chan_flag;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003884 tstrWID strWID;
3885 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3886
3887 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3888 if (!pstrWFIDrv->u8RemainOnChan_pendingreq) {
3889 pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
3890 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
3891 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
3892 pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
3893 pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
3894 } else {
3895 /*Set the channel to use it as a wid val*/
3896 pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel;
3897 }
3898
3899 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3900 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
3901 pstrWFIDrv->u8RemainOnChan_pendingreq = 1;
3902 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3903 }
3904 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3905 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
3906 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3907 }
3908
3909 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3910 if (g_obtainingIP || connecting) {
3911 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
3912 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3913 }
3914 #endif
3915
3916 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
3917
Dean Lee72ed4dc2015-06-12 14:11:44 +09003918 u8remain_on_chan_flag = true;
Chaehyun Limd85f5322015-06-11 14:35:54 +09003919 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003920 strWID.enuWIDtype = WID_STR;
3921 strWID.s32ValueSize = 2;
Chaehyun Limdc0ad742015-08-17 11:05:12 +09003922 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003923
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003924 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003925 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003926
3927 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003928 strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003929
3930 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003931 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3932 get_id_from_handler(pstrWFIDrv));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003933 if (s32Error != WILC_SUCCESS)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003934 PRINT_ER("Failed to set remain on channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003935
3936 WILC_CATCH(-1)
3937 {
3938 P2P_LISTEN_STATE = 1;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003939 pstrWFIDrv->hRemainOnChannel.data = (unsigned long)pstrWFIDrv;
3940 mod_timer(&pstrWFIDrv->hRemainOnChannel,
3941 jiffies +
3942 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003943
3944 /*Calling CFG ready_on_channel*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003945 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003946 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003947
3948 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3949 pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
3950 }
3951 return s32Error;
3952}
3953
3954/**
3955 * @brief Handle_RegisterFrame
3956 * @details
3957 * @param[in]
3958 * @return NONE
3959 * @author
3960 * @date
3961 * @version 1.0
3962 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003963static int Handle_RegisterFrame(tstrWILC_WFIDrv *drvHandler, tstrHostIfRegisterFrame *pstrHostIfRegisterFrame)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003964{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003965 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003966 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003967 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003968 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3969
3970 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
3971
3972 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +09003973 strWID.u16WIDid = (u16)WID_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003974 strWID.enuWIDtype = WID_STR;
Chaehyun Limd85f5322015-06-11 14:35:54 +09003975 strWID.ps8WidVal = WILC_MALLOC(sizeof(u16) + 2);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003976 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003977 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003978
3979 pu8CurrByte = strWID.ps8WidVal;
3980
3981 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
3982 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003983 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003984
3985
Chaehyun Limd85f5322015-06-11 14:35:54 +09003986 strWID.s32ValueSize = sizeof(u16) + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003987
3988
3989 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003990 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3991 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003992 if (s32Error) {
3993 PRINT_ER("Failed to frame register config packet\n");
3994 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
3995 }
3996
3997
3998 WILC_CATCH(s32Error)
3999 {
4000 }
4001
4002 return s32Error;
4003
4004}
4005
4006/**
4007 * @brief Handle_ListenStateExpired
4008 * @details Handle of listen state expiration
4009 * @param[in] NONE
4010 * @return Error code.
4011 * @author
4012 * @date
4013 * @version 1.0
4014 */
4015#define FALSE_FRMWR_CHANNEL 100
Johnny Kim2b05df52015-08-13 13:41:21 +09004016static u32 Handle_ListenStateExpired(tstrWILC_WFIDrv *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004017{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004018 u8 u8remain_on_chan_flag;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004019 tstrWID strWID;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004020 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004021 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
4022
4023 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
4024
4025 /*BugID_5477*/
4026 /*Make sure we are already in listen state*/
4027 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
4028 if (P2P_LISTEN_STATE) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09004029 u8remain_on_chan_flag = false;
Chaehyun Limd85f5322015-06-11 14:35:54 +09004030 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004031 strWID.enuWIDtype = WID_STR;
4032 strWID.s32ValueSize = 2;
4033 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
4034
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004035 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004036 PRINT_ER("Failed to allocate memory\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004037
4038 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
4039 strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL;
4040
4041 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09004042 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4043 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004044 if (s32Error != WILC_SUCCESS) {
4045 PRINT_ER("Failed to set remain on channel\n");
4046 goto _done_;
4047 }
4048
4049 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) {
4050 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid
4051 , pstrHostIfRemainOnChan->u32ListenSessionID);
4052 }
4053 P2P_LISTEN_STATE = 0;
4054 } else {
4055 PRINT_D(GENERIC_DBG, "Not in listen state\n");
4056 s32Error = WILC_FAIL;
4057 }
4058
4059_done_:
4060 return s32Error;
4061}
4062
4063
4064/**
4065 * @brief ListenTimerCB
4066 * @details Callback function of remain-on-channel timer
4067 * @param[in] NONE
4068 * @return Error code.
4069 * @author
4070 * @date
4071 * @version 1.0
4072 */
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004073static void ListenTimerCB(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004074{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004075 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004076 tstrHostIFmsg strHostIFmsg;
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004077 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004078 /*Stopping remain-on-channel timer*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07004079 del_timer(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004080
4081 /* prepare the Timer Callback message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004082 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004083 strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
4084 strHostIFmsg.drvHandler = pstrWFIDrv;
4085 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID;
4086
4087 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09004088 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004089 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004090 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004091 WILC_CATCH(s32Error)
4092 {
4093
4094 }
4095}
4096#endif
4097
4098
4099/**
4100 * @brief Handle_EditStation
4101 * @details Sending config packet to edit station
4102 * @param[in] tstrWILC_AddStaParam* pstrStationParam
4103 * @return NONE
4104 * @author
4105 * @date
4106 * @version 1.0
4107 */
Johnny Kim2b05df52015-08-13 13:41:21 +09004108static void Handle_PowerManagement(tstrWILC_WFIDrv *drvHandler, tstrHostIfPowerMgmtParam *strPowerMgmtParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004109{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004110 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004111 tstrWID strWID;
Chaehyun Limca356ad2015-06-11 14:35:57 +09004112 s8 s8PowerMode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004113 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004114
Chaehyun Limd85f5322015-06-11 14:35:54 +09004115 strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004116
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05304117 if (strPowerMgmtParam->bIsEnabled == true)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004118 s8PowerMode = MIN_FAST_PS;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05304119 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004120 s8PowerMode = NO_POWERSAVE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004121 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
4122 strWID.ps8WidVal = &s8PowerMode;
Dean Lee576917a2015-06-15 11:58:57 +09004123 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004124
4125 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
4126
4127 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09004128 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4129 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004130 if (s32Error) {
4131 PRINT_ER("Failed to send power management config packet\n");
4132 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
4133 }
4134
4135 WILC_CATCH(s32Error)
4136 {
4137
4138 }
4139}
4140
4141/**
4142 * @brief Handle_SetMulticastFilter
4143 * @details Set Multicast filter in firmware
4144 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4145 * @return NONE
4146 * @author asobhy
4147 * @date
4148 * @version 1.0
4149 */
Johnny Kim2b05df52015-08-13 13:41:21 +09004150static void Handle_SetMulticastFilter(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetMulti *strHostIfSetMulti)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004151{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004152 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004153 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004154 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004155
4156 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
4157
Chaehyun Limd85f5322015-06-11 14:35:54 +09004158 strWID.u16WIDid = (u16)WID_SETUP_MULTICAST_FILTER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004159 strWID.enuWIDtype = WID_BIN;
4160 strWID.s32ValueSize = sizeof(tstrHostIFSetMulti) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
4161 strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004162 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004163 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004164
4165 pu8CurrByte = strWID.ps8WidVal;
4166 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
4167 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
4168 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
4169 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
4170
4171 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
4172 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
4173 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
4174 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
4175
4176 if ((strHostIfSetMulti->u32count) > 0)
4177 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
4178
4179 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09004180 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
4181 get_id_from_handler(drvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004182 if (s32Error) {
4183 PRINT_ER("Failed to send setup multicast config packet\n");
4184 WILC_ERRORREPORT(s32Error, WILC_FAIL);
4185 }
4186
4187 WILC_CATCH(s32Error)
4188 {
4189 }
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07004190 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004191
4192}
4193
4194
4195/*BugID_5222*/
4196/**
4197 * @brief Handle_AddBASession
4198 * @details Add block ack session
4199 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4200 * @return NONE
4201 * @author Amr Abdel-Moghny
4202 * @date Feb. 2014
4203 * @version 9.0
4204 */
Johnny Kim2b05df52015-08-13 13:41:21 +09004205static s32 Handle_AddBASession(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004206{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004207 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004208 tstrWID strWID;
4209 int AddbaTimeout = 100;
4210 char *ptr = NULL;
4211 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4212
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004213 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004214 strHostIfBASessionInfo->au8Bssid[0],
4215 strHostIfBASessionInfo->au8Bssid[1],
4216 strHostIfBASessionInfo->au8Bssid[2],
4217 strHostIfBASessionInfo->u16BufferSize,
4218 strHostIfBASessionInfo->u16SessionTimeout,
4219 strHostIfBASessionInfo->u8Ted);
4220
Chaehyun Limd85f5322015-06-11 14:35:54 +09004221 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004222 strWID.enuWIDtype = WID_STR;
Chaehyun Limdc0ad742015-08-17 11:05:12 +09004223 strWID.ps8WidVal = WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004224 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4225 ptr = strWID.ps8WidVal;
4226 /* *ptr++ = 0x14; */
4227 *ptr++ = 0x14;
4228 *ptr++ = 0x3;
4229 *ptr++ = 0x0;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004230 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004231 ptr += ETH_ALEN;
4232 *ptr++ = strHostIfBASessionInfo->u8Ted;
4233 /* BA Policy*/
4234 *ptr++ = 1;
4235 /* Buffer size*/
4236 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4237 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
4238 /* BA timeout*/
4239 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
4240 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4241 /* ADDBA timeout*/
4242 *ptr++ = (AddbaTimeout & 0xFF);
4243 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
4244 /* Group Buffer Max Frames*/
4245 *ptr++ = 8;
4246 /* Group Buffer Timeout */
4247 *ptr++ = 0;
4248
Johnny Kimd42ab082015-08-20 16:32:52 +09004249 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4250 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004251 if (s32Error)
4252 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
4253
4254
Chaehyun Limd85f5322015-06-11 14:35:54 +09004255 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004256 strWID.enuWIDtype = WID_STR;
4257 strWID.s32ValueSize = 15;
4258 ptr = strWID.ps8WidVal;
4259 /* *ptr++ = 0x14; */
4260 *ptr++ = 15;
4261 *ptr++ = 7;
4262 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004263 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004264 ptr += ETH_ALEN;
4265 /* TID*/
4266 *ptr++ = strHostIfBASessionInfo->u8Ted;
4267 /* Max Num MSDU */
4268 *ptr++ = 8;
4269 /* BA timeout*/
4270 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4271 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4272 /*Ack-Policy */
4273 *ptr++ = 3;
Johnny Kimd42ab082015-08-20 16:32:52 +09004274 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4275 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004276
4277 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09004278 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004279
4280 return s32Error;
4281
4282}
4283
4284
4285/*BugID_5222*/
4286/**
4287 * @brief Handle_DelBASession
4288 * @details Delete block ack session
4289 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4290 * @return NONE
4291 * @author Amr Abdel-Moghny
4292 * @date Feb. 2013
4293 * @version 9.0
4294 */
Johnny Kim2b05df52015-08-13 13:41:21 +09004295static s32 Handle_DelBASession(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004296{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004297 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004298 tstrWID strWID;
4299 char *ptr = NULL;
4300 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4301
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004302 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004303 strHostIfBASessionInfo->au8Bssid[0],
4304 strHostIfBASessionInfo->au8Bssid[1],
4305 strHostIfBASessionInfo->au8Bssid[2],
4306 strHostIfBASessionInfo->u8Ted);
4307
Chaehyun Limd85f5322015-06-11 14:35:54 +09004308 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004309 strWID.enuWIDtype = WID_STR;
Chaehyun Limdc0ad742015-08-17 11:05:12 +09004310 strWID.ps8WidVal = WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004311 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4312 ptr = strWID.ps8WidVal;
4313 /* *ptr++ = 0x14; */
4314 *ptr++ = 0x14;
4315 *ptr++ = 0x3;
4316 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004317 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004318 ptr += ETH_ALEN;
4319 *ptr++ = strHostIfBASessionInfo->u8Ted;
4320 /* BA direction = recipent*/
4321 *ptr++ = 0;
4322 /* Delba Reason */
4323 *ptr++ = 32; /* Unspecific QOS reason */
4324
Johnny Kimd42ab082015-08-20 16:32:52 +09004325 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4326 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004327 if (s32Error)
4328 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4329
4330
Chaehyun Limd85f5322015-06-11 14:35:54 +09004331 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004332 strWID.enuWIDtype = WID_STR;
4333 strWID.s32ValueSize = 15;
4334 ptr = strWID.ps8WidVal;
4335 /* *ptr++ = 0x14; */
4336 *ptr++ = 15;
4337 *ptr++ = 7;
4338 *ptr++ = 0x3;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004339 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004340 ptr += ETH_ALEN;
4341 /* TID*/
4342 *ptr++ = strHostIfBASessionInfo->u8Ted;
4343
Johnny Kimd42ab082015-08-20 16:32:52 +09004344 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4345 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004346
4347 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09004348 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004349
4350 /*BugID_5222*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004351 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004352
4353 return s32Error;
4354
4355}
4356
4357
4358/**
4359 * @brief Handle_DelAllRxBASessions
4360 * @details Delete all Rx BA sessions
4361 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4362 * @return NONE
4363 * @author Abdelrahman Sobhy
4364 * @date Feb. 2013
4365 * @version 9.0
4366 */
Johnny Kim2b05df52015-08-13 13:41:21 +09004367static s32 Handle_DelAllRxBASessions(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004368{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004369 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004370 tstrWID strWID;
4371 char *ptr = NULL;
4372 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4373
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004374 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004375 strHostIfBASessionInfo->au8Bssid[0],
4376 strHostIfBASessionInfo->au8Bssid[1],
4377 strHostIfBASessionInfo->au8Bssid[2],
4378 strHostIfBASessionInfo->u8Ted);
4379
Chaehyun Limd85f5322015-06-11 14:35:54 +09004380 strWID.u16WIDid = (u16)WID_DEL_ALL_RX_BA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004381 strWID.enuWIDtype = WID_STR;
Chaehyun Limdc0ad742015-08-17 11:05:12 +09004382 strWID.ps8WidVal = WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004383 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4384 ptr = strWID.ps8WidVal;
4385 *ptr++ = 0x14;
4386 *ptr++ = 0x3;
4387 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004388 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004389 ptr += ETH_ALEN;
4390 *ptr++ = strHostIfBASessionInfo->u8Ted;
4391 /* BA direction = recipent*/
4392 *ptr++ = 0;
4393 /* Delba Reason */
4394 *ptr++ = 32; /* Unspecific QOS reason */
4395
Johnny Kimd42ab082015-08-20 16:32:52 +09004396 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4397 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004398 if (s32Error)
4399 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4400
4401
4402 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09004403 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004404
4405 /*BugID_5222*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004406 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004407
4408 return s32Error;
4409
4410}
4411
4412/**
4413 * @brief hostIFthread
4414 * @details Main thread to handle message queue requests
4415 * @param[in] void* pvArg
4416 * @return NONE
4417 * @author
4418 * @date
4419 * @version 1.0
4420 */
Arnd Bergmann1999bd52015-05-29 22:52:14 +02004421static int hostIFthread(void *pvArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004422{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004423 u32 u32Ret;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004424 tstrHostIFmsg strHostIFmsg;
4425 tstrWILC_WFIDrv *pstrWFIDrv;
4426
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004427 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004428
4429 while (1) {
Chaehyun Limb986e332015-08-19 15:59:07 +09004430 wilc_mq_recv(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), &u32Ret);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004431 pstrWFIDrv = (tstrWILC_WFIDrv *)strHostIFmsg.drvHandler;
4432 if (strHostIFmsg.u16MsgId == HOST_IF_MSG_EXIT) {
4433 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
4434 break;
4435 }
4436
4437
4438 /*Re-Queue HIF message*/
4439 if ((!g_wilc_initialized)) {
4440 PRINT_D(GENERIC_DBG, "--WAIT--");
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07004441 usleep_range(200 * 1000, 200 * 1000);
Chaehyun Lim79198132015-08-19 15:59:06 +09004442 wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004443 continue;
4444 }
4445
4446 if (strHostIFmsg.u16MsgId == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
4447 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
Chaehyun Lim79198132015-08-19 15:59:06 +09004448 wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07004449 usleep_range(2 * 1000, 2 * 1000);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004450 continue;
4451 }
4452
4453 switch (strHostIFmsg.u16MsgId) {
4454 case HOST_IF_MSG_Q_IDLE:
4455 Handle_wait_msg_q_empty();
4456 break;
4457
4458 case HOST_IF_MSG_SCAN:
4459 Handle_Scan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr);
4460 break;
4461
4462 case HOST_IF_MSG_CONNECT:
4463 Handle_Connect(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr);
4464 break;
4465
4466 /*BugID_5137*/
4467 case HOST_IF_MSG_FLUSH_CONNECT:
4468 Handle_FlushConnect(strHostIFmsg.drvHandler);
4469 break;
4470
4471 case HOST_IF_MSG_RCVD_NTWRK_INFO:
4472 Handle_RcvdNtwrkInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo);
4473 break;
4474
4475 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
4476 Handle_RcvdGnrlAsyncInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo);
4477 break;
4478
4479 case HOST_IF_MSG_KEY:
4480 Handle_Key(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr);
4481 break;
4482
4483 case HOST_IF_MSG_CFG_PARAMS:
4484
4485 Handle_CfgParam(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr);
4486 break;
4487
4488 case HOST_IF_MSG_SET_CHANNEL:
4489 Handle_SetChannel(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan);
4490 break;
4491
4492 case HOST_IF_MSG_DISCONNECT:
4493 Handle_Disconnect(strHostIFmsg.drvHandler);
4494 break;
4495
4496 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07004497 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004498 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
4499
4500 /*BugID_5213*/
4501 /*Allow chip sleep, only if both interfaces are not connected*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004502 if (!linux_wlan_get_num_conn_ifcs())
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004503 chip_sleep_manually(INFINITE_SLEEP_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004504
4505 Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_DONE);
4506
4507 #ifdef WILC_P2P
4508 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
4509 Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4510 #endif
4511
4512 break;
4513
4514 case HOST_IF_MSG_GET_RSSI:
4515 Handle_GetRssi(strHostIFmsg.drvHandler);
4516 break;
4517
4518 case HOST_IF_MSG_GET_LINKSPEED:
4519 Handle_GetLinkspeed(strHostIFmsg.drvHandler);
4520 break;
4521
4522 case HOST_IF_MSG_GET_STATISTICS:
4523 Handle_GetStatistics(strHostIFmsg.drvHandler, (tstrStatistics *)strHostIFmsg.uniHostIFmsgBody.pUserData);
4524 break;
4525
4526 case HOST_IF_MSG_GET_CHNL:
4527 Handle_GetChnl(strHostIFmsg.drvHandler);
4528 break;
4529
4530#ifdef WILC_AP_EXTERNAL_MLME
4531 case HOST_IF_MSG_ADD_BEACON:
4532 Handle_AddBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon);
4533 break;
4534
4535 case HOST_IF_MSG_DEL_BEACON:
4536 Handle_DelBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelBeacon);
4537 break;
4538
4539 case HOST_IF_MSG_ADD_STATION:
4540 Handle_AddStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strAddStaParam);
4541 break;
4542
4543 case HOST_IF_MSG_DEL_STATION:
4544 Handle_DelStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strDelStaParam);
4545 break;
4546
4547 case HOST_IF_MSG_EDIT_STATION:
4548 Handle_EditStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strEditStaParam);
4549 break;
4550
4551 case HOST_IF_MSG_GET_INACTIVETIME:
4552 Handle_Get_InActiveTime(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT);
4553 break;
4554
4555#endif /*WILC_AP_EXTERNAL_MLME*/
4556 case HOST_IF_MSG_SCAN_TIMER_FIRED:
4557 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
4558
4559 Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_ABORTED);
4560 break;
4561
4562 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004563 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004564 Handle_ConnectTimeout(strHostIFmsg.drvHandler);
4565 break;
4566
4567 case HOST_IF_MSG_POWER_MGMT:
4568 Handle_PowerManagement(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam);
4569 break;
4570
4571 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
Johnny Kim53a84402015-08-20 16:32:51 +09004572 Handle_SetWfiDrvHandler(strHostIFmsg.drvHandler,
4573 &strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004574 break;
4575
4576 case HOST_IF_MSG_SET_OPERATION_MODE:
4577 Handle_SetOperationMode(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode);
4578 break;
4579
4580 case HOST_IF_MSG_SET_IPADDRESS:
4581 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4582 Handle_set_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
4583 break;
4584
4585 case HOST_IF_MSG_GET_IPADDRESS:
4586 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4587 Handle_get_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
4588 break;
4589
4590 /*BugID_5077*/
4591 case HOST_IF_MSG_SET_MAC_ADDRESS:
4592 Handle_SetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress);
4593 break;
4594
4595 /*BugID_5213*/
4596 case HOST_IF_MSG_GET_MAC_ADDRESS:
4597 Handle_GetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress);
4598 break;
4599
4600#ifdef WILC_P2P
4601 case HOST_IF_MSG_REMAIN_ON_CHAN:
4602 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
4603 Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4604 break;
4605
4606 case HOST_IF_MSG_REGISTER_FRAME:
4607 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
4608 Handle_RegisterFrame(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame);
4609 break;
4610
4611 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
4612 Handle_ListenStateExpired(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4613 break;
4614
4615 #endif
4616 case HOST_IF_MSG_SET_MULTICAST_FILTER:
4617 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
4618 Handle_SetMulticastFilter(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti);
4619 break;
4620
4621 /*BugID_5222*/
4622 case HOST_IF_MSG_ADD_BA_SESSION:
4623 Handle_AddBASession(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
4624 break;
4625
4626 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
4627 Handle_DelAllRxBASessions(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
4628 break;
4629
4630 case HOST_IF_MSG_DEL_ALL_STA:
4631 Handle_DelAllSta(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta);
4632 break;
4633
4634 default:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004635 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004636 break;
4637 }
4638 }
4639
4640 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004641 up(&hSemHostIFthrdEnd);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02004642 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004643}
4644
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004645static void TimerCB_Scan(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004646{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004647 void *pvArg = (void *)arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004648 tstrHostIFmsg strHostIFmsg;
4649
4650 /* prepare the Timer Callback message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004651 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004652 strHostIFmsg.drvHandler = pvArg;
4653 strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN_TIMER_FIRED;
4654
4655 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09004656 wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004657}
4658
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004659static void TimerCB_Connect(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004660{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004661 void *pvArg = (void *)arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004662 tstrHostIFmsg strHostIFmsg;
4663
4664 /* prepare the Timer Callback message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004665 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004666 strHostIFmsg.drvHandler = pvArg;
4667 strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT_TIMER_FIRED;
4668
4669 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09004670 wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004671}
4672
4673
4674/**
4675 * @brief removes wpa/wpa2 keys
4676 * @details only in BSS STA mode if External Supplicant support is enabled.
4677 * removes all WPA/WPA2 station key entries from MAC hardware.
4678 * @param[in,out] handle to the wifi driver
4679 * @param[in] 6 bytes of Station Adress in the station entry table
4680 * @return Error code indicating success/failure
4681 * @note
4682 * @author zsalah
4683 * @date 8 March 2012
4684 * @version 1.0
4685 */
4686/* Check implementation in core adding 9 bytes to the input! */
Johnny Kim218dc402015-08-13 13:41:19 +09004687s32 host_int_remove_key(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8StaAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004688{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004689 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004690 tstrWID strWID;
4691 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4692
Chaehyun Limd85f5322015-06-11 14:35:54 +09004693 strWID.u16WIDid = (u16)WID_REMOVE_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004694 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09004695 strWID.ps8WidVal = (s8 *)pu8StaAddress;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004696 strWID.s32ValueSize = 6;
4697
4698 return s32Error;
4699
4700}
4701
4702/**
4703 * @brief removes WEP key
4704 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4705 * remove a WEP key entry from MAC HW.
4706 * The BSS Station automatically finds the index of the entry using its
4707 * BSS ID and removes that entry from the MAC hardware.
4708 * @param[in,out] handle to the wifi driver
4709 * @param[in] 6 bytes of Station Adress in the station entry table
4710 * @return Error code indicating success/failure
4711 * @note NO need for the STA add since it is not used for processing
4712 * @author zsalah
4713 * @date 8 March 2012
4714 * @version 1.0
4715 */
Johnny Kim218dc402015-08-13 13:41:19 +09004716s32 host_int_remove_wep_key(tstrWILC_WFIDrv *hWFIDrv, u8 u8keyIdx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004717{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004718 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004719 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4720 tstrHostIFmsg strHostIFmsg;
4721
4722
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004723 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004724 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004725
4726 /* prepare the Remove Wep Key Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004727 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004728
4729
4730 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4731 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4732 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = REMOVEKEY;
4733 strHostIFmsg.drvHandler = hWFIDrv;
4734
4735
4736
4737 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4738 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8keyIdx;
4739
4740 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09004741 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004742 if (s32Error)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004743 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004744 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004745
4746 WILC_CATCH(s32Error)
4747 {
4748
4749 }
4750 return s32Error;
4751}
4752
4753/**
4754 * @brief sets WEP default key
4755 * @details Sets the index of the WEP encryption key in use,
4756 * in the key table
4757 * @param[in,out] handle to the wifi driver
4758 * @param[in] key index ( 0, 1, 2, 3)
4759 * @return Error code indicating success/failure
4760 * @note
4761 * @author zsalah
4762 * @date 8 March 2012
4763 * @version 1.0
4764 */
Johnny Kim218dc402015-08-13 13:41:19 +09004765s32 host_int_set_WEPDefaultKeyID(tstrWILC_WFIDrv *hWFIDrv, u8 u8Index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004766{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004767 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004768 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4769 tstrHostIFmsg strHostIFmsg;
4770
4771
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004772 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004773 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004774
4775 /* prepare the Key Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004776 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004777
4778
4779 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4780 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4781 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = DEFAULTKEY;
4782 strHostIFmsg.drvHandler = hWFIDrv;
4783
4784
4785 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4786 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
4787
4788 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09004789 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004790 if (s32Error)
4791 PRINT_ER("Error in sending message queue : Default key index\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004792 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004793
4794 WILC_CATCH(s32Error)
4795 {
4796
4797 }
4798
4799 return s32Error;
4800}
4801
4802/**
4803 * @brief sets WEP deafault key
4804 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4805 * sets WEP key entry into MAC hardware when it receives the
4806 * corresponding request from NDIS.
4807 * @param[in,out] handle to the wifi driver
4808 * @param[in] message containing WEP Key in the following format
4809 *|---------------------------------------|
4810 *|Key ID Value | Key Length | Key |
4811 *|-------------|------------|------------|
4812 | 1byte | 1byte | Key Length |
4813 ||---------------------------------------|
4814 |
4815 * @return Error code indicating success/failure
4816 * @note
4817 * @author zsalah
4818 * @date 8 March 2012
4819 * @version 1.0
4820 */
Johnny Kim218dc402015-08-13 13:41:19 +09004821s32 host_int_add_wep_key_bss_sta(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004822{
4823
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004824 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004825 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4826 tstrHostIFmsg strHostIFmsg;
4827
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004828 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004829 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4830
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004831
4832 /* prepare the Key Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004833 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004834
4835
4836 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4837 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4838 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
4839 strHostIFmsg.drvHandler = hWFIDrv;
4840
4841
4842 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
Chaehyun Limdc0ad742015-08-17 11:05:12 +09004843 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = WILC_MALLOC(u8WepKeylen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004844
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004845 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004846 pu8WepKey, u8WepKeylen);
4847
4848
4849 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4850 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4851
4852 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4853 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4854
4855 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09004856 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004857 if (s32Error)
4858 PRINT_ER("Error in sending message queue :WEP Key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004859 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004860
4861 WILC_CATCH(s32Error)
4862 {
4863
4864 }
4865 return s32Error;
4866
4867}
4868
4869#ifdef WILC_AP_EXTERNAL_MLME
4870/**
4871 *
4872 * @brief host_int_add_wep_key_bss_ap
4873 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4874 * sets WEP key entry into MAC hardware when it receives the
4875 *
4876 * corresponding request from NDIS.
4877 * @param[in,out] handle to the wifi driver
4878 *
4879 *
4880 * @return Error code indicating success/failure
4881 * @note
4882 * @author mdaftedar
4883 * @date 28 FEB 2013
4884 * @version 1.0
4885 */
Johnny Kim218dc402015-08-13 13:41:19 +09004886s32 host_int_add_wep_key_bss_ap(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, AUTHTYPE_T tenuAuth_type)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004887{
4888
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004889 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004890 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4891 tstrHostIFmsg strHostIFmsg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004892 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004893
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004894 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004895 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4896
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004897
4898 /* prepare the Key Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004899 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004900
4901 if (INFO) {
4902 for (i = 0; i < u8WepKeylen; i++)
4903 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4904 }
4905 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4906 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4907 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4908 strHostIFmsg.drvHandler = hWFIDrv;
4909
4910
4911 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
Chaehyun Limdc0ad742015-08-17 11:05:12 +09004912 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = WILC_MALLOC((u8WepKeylen));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004913
4914
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004915 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004916 pu8WepKey, (u8WepKeylen));
4917
4918
4919 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4920 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4921
4922 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4923 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4924
4925 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4926 uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
4927
4928 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4929 uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
4930 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09004931 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004932
4933 if (s32Error)
4934 PRINT_ER("Error in sending message queue :WEP Key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004935 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004936
4937 WILC_CATCH(s32Error)
4938 {
4939
4940 }
4941 return s32Error;
4942
4943}
4944#endif
4945/**
4946 * @brief adds ptk Key
4947 * @details
4948 * @param[in,out] handle to the wifi driver
4949 * @param[in] message containing PTK Key in the following format
4950 *|-----------------------------------------------------------------------------|
4951 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4952 *|----------------|------------|--------------|----------------|---------------|
4953 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4954 ||-----------------------------------------------------------------------------|
4955 * @return Error code indicating success/failure
4956 * @note
4957 * @author zsalah
4958 * @date 8 March 2012
4959 * @version 1.0
4960 */
Johnny Kim218dc402015-08-13 13:41:19 +09004961s32 host_int_add_ptk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004962 const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004963{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004964 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004965 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4966 tstrHostIFmsg strHostIFmsg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004967 u8 u8KeyLen = u8PtkKeylen;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004968 u32 i;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004969
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004970 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004971 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004972 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004973 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004974 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004975 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004976
4977 /* prepare the Key Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004978 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004979
4980
4981 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4982 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPAPtk;
4983 #ifdef WILC_AP_EXTERNAL_MLME
4984 if (mode == AP_MODE) {
4985 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4986 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4987 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
4988 }
4989 #endif
4990 if (mode == STATION_MODE)
4991 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
4992
4993
4994 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
Chaehyun Limdc0ad742015-08-17 11:05:12 +09004995 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = WILC_MALLOC(u8PtkKeylen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004996
4997
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004998 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004999 pu8Ptk, u8PtkKeylen);
5000
5001 if (pu8RxMic != NULL) {
5002
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005003 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005004 pu8RxMic, RX_MIC_KEY_LEN);
5005 if (INFO) {
5006 for (i = 0; i < RX_MIC_KEY_LEN; i++)
5007 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
5008 }
5009 }
5010 if (pu8TxMic != NULL) {
5011
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005012 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005013 pu8TxMic, TX_MIC_KEY_LEN);
5014 if (INFO) {
5015 for (i = 0; i < TX_MIC_KEY_LEN; i++)
5016 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
5017 }
5018 }
5019
5020 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5021 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
5022
5023 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5024 uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
5025 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5026 uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
5027 strHostIFmsg.drvHandler = hWFIDrv;
5028
5029 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09005030 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005031
5032 if (s32Error)
5033 PRINT_ER("Error in sending message queue: PTK Key\n");
5034
5035 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005036 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005037 /* /////// */
5038
5039 WILC_CATCH(s32Error)
5040 {
5041
5042 }
5043
5044 return s32Error;
5045}
5046
5047/**
5048 * @brief adds Rx GTk Key
5049 * @details
5050 * @param[in,out] handle to the wifi driver
5051 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
5052 * u8GtkKeylen :The total key length
5053 *
5054 * @return Error code indicating success/failure
5055 * @note
5056 * @author zsalah
5057 * @date 8 March 2012
5058 * @version 1.0
5059 */
Johnny Kim218dc402015-08-13 13:41:19 +09005060s32 host_int_add_rx_gtk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005061 u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005062 const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005063{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005064 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005065 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5066 tstrHostIFmsg strHostIFmsg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005067 u8 u8KeyLen = u8GtkKeylen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005068
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005069 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005070 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005071 /* prepare the Key Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005072 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005073
5074
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005075 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005076 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005077 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005078 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005079 if (KeyRSC != NULL) {
5080 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
Chaehyun Limdc0ad742015-08-17 11:05:12 +09005081 uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = WILC_MALLOC(u32KeyRSClen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005082
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005083 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005084 KeyRSC, u32KeyRSClen);
5085 }
5086
5087
5088 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
5089 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPARxGtk;
5090 strHostIFmsg.drvHandler = hWFIDrv;
5091
5092 #ifdef WILC_AP_EXTERNAL_MLME
5093 if (mode == AP_MODE) {
5094 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
5095 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
5096 }
5097 #endif
5098 if (mode == STATION_MODE)
5099 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
5100
5101
5102 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
Chaehyun Limdc0ad742015-08-17 11:05:12 +09005103 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = WILC_MALLOC(u8KeyLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005104
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005105 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005106 pu8RxGtk, u8GtkKeylen);
5107
5108 if (pu8RxMic != NULL) {
5109
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005110 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005111 pu8RxMic, RX_MIC_KEY_LEN);
5112
5113 }
5114 if (pu8TxMic != NULL) {
5115
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005116 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005117 pu8TxMic, TX_MIC_KEY_LEN);
5118
5119 }
5120
5121 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5122 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
5123 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5124 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
5125
5126 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5127 uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
5128
5129
5130
5131 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09005132 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005133 if (s32Error)
5134 PRINT_ER("Error in sending message queue: RX GTK\n");
5135 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005136 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005137 /* /////// */
5138
5139 WILC_CATCH(s32Error)
5140 {
5141
5142 }
5143 return s32Error;
5144}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005145
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005146/**
5147 * @brief host_int_set_pmkid_info
5148 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
5149 * support is enabled. This Function sets the PMKID in firmware
5150 * when host drivr receives the corresponding request from NDIS.
5151 * The firmware then includes theset PMKID in the appropriate
5152 * management frames
5153 * @param[in,out] handle to the wifi driver
5154 * @param[in] message containing PMKID Info in the following format
5155 *|-----------------------------------------------------------------|
5156 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5157 *|-----------|------------|----------|-------|----------|----------|
5158 | 1 | 6 | 16 | ... | 6 | 16 |
5159 ||-----------------------------------------------------------------|
5160 * @return Error code indicating success/failure
5161 * @note
5162 * @author zsalah
5163 * @date 8 March 2012
5164 * @version 1.0
5165 */
Johnny Kim218dc402015-08-13 13:41:19 +09005166s32 host_int_set_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005167{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005168 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005169 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5170 tstrHostIFmsg strHostIFmsg;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005171 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005172
5173
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005174 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005175 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005176
5177 /* prepare the Key Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005178 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005179
5180 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
5181 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = PMKSA;
5182 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
5183 strHostIFmsg.drvHandler = hWFIDrv;
5184
5185 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
5186
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005187 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005188 ETH_ALEN);
5189
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005190 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005191 PMKID_LEN);
5192 }
5193
5194 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09005195 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005196 if (s32Error)
5197 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
5198
5199 WILC_CATCH(s32Error)
5200 {
5201
5202 }
5203
5204 return s32Error;
5205}
5206
5207/**
5208 * @brief gets the cached the pmkid info
5209 * @details valid only in BSS STA mode if External Supplicant
5210 * support is enabled. This Function sets the PMKID in firmware
5211 * when host drivr receives the corresponding request from NDIS.
5212 * The firmware then includes theset PMKID in the appropriate
5213 * management frames
5214 * @param[in,out] handle to the wifi driver,
5215 * message containing PMKID Info in the following format
5216 *|-----------------------------------------------------------------|
5217 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5218 *|-----------|------------|----------|-------|----------|----------|
5219 | 1 | 6 | 16 | ... | 6 | 16 |
5220 ||-----------------------------------------------------------------|
5221 * @param[in]
5222 * @return Error code indicating success/failure
5223 * @note
5224 * @author zsalah
5225 * @date 8 March 2012
5226 * @version 1.0
5227 */
Johnny Kim218dc402015-08-13 13:41:19 +09005228s32 host_int_get_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PmkidInfoArray,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005229 u32 u32PmkidInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005230{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005231 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005232 tstrWID strWID;
5233 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5234
Chaehyun Limd85f5322015-06-11 14:35:54 +09005235 strWID.u16WIDid = (u16)WID_PMKID_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005236 strWID.enuWIDtype = WID_STR;
5237 strWID.s32ValueSize = u32PmkidInfoLen;
5238 strWID.ps8WidVal = pu8PmkidInfoArray;
5239
5240 return s32Error;
5241}
5242
5243/**
5244 * @brief sets the pass phrase
5245 * @details AP/STA mode. This function gives the pass phrase used to
5246 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5247 * The length of the field can vary from 8 to 64 bytes,
5248 * the lower layer should get the
5249 * @param[in,out] handle to the wifi driver,
5250 * @param[in] String containing PSK
5251 * @return Error code indicating success/failure
5252 * @note
5253 * @author zsalah
5254 * @date 8 March 2012
5255 * @version 1.0
5256 */
Johnny Kim218dc402015-08-13 13:41:19 +09005257s32 host_int_set_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PassPhrase,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005258 u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005259{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005260 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005261 tstrWID strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005262
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005263 /*validating psk length*/
5264 if ((u8Psklength > 7) && (u8Psklength < 65)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09005265 strWID.u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005266 strWID.enuWIDtype = WID_STR;
5267 strWID.ps8WidVal = pu8PassPhrase;
5268 strWID.s32ValueSize = u8Psklength;
5269 }
5270
5271 return s32Error;
5272}
5273/**
5274 * @brief host_int_get_MacAddress
5275 * @details gets mac address
5276 * @param[in,out] handle to the wifi driver,
5277 *
5278 * @return Error code indicating success/failure
5279 * @note
5280 * @author mdaftedar
5281 * @date 19 April 2012
5282 * @version 1.0
5283 */
Johnny Kim218dc402015-08-13 13:41:19 +09005284s32 host_int_get_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005285{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005286 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005287 tstrHostIFmsg strHostIFmsg;
5288
5289
5290 /* prepare the Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005291 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005292
5293 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_MAC_ADDRESS;
5294 strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress.u8MacAddress = pu8MacAddress;
5295 strHostIFmsg.drvHandler = hWFIDrv;
5296 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09005297 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005298 if (s32Error) {
5299 PRINT_ER("Failed to send get mac address\n");
5300 return WILC_FAIL;
5301 }
5302
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005303 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005304 return s32Error;
5305}
5306
5307/**
5308 * @brief host_int_set_MacAddress
5309 * @details sets mac address
5310 * @param[in,out] handle to the wifi driver,
5311 *
5312 * @return Error code indicating success/failure
5313 * @note
5314 * @author mabubakr
5315 * @date 16 July 2012
5316 * @version 1.0
5317 */
Johnny Kim218dc402015-08-13 13:41:19 +09005318s32 host_int_set_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005319{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005320 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005321 tstrHostIFmsg strHostIFmsg;
5322
5323 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
5324
5325 /* prepare setting mac address message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005326 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005327 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MAC_ADDRESS;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005328 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress.u8MacAddress, pu8MacAddress, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005329 strHostIFmsg.drvHandler = hWFIDrv;
5330
Chaehyun Lim79198132015-08-19 15:59:06 +09005331 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005332 if (s32Error) {
5333 PRINT_ER("Failed to send message queue: Set mac address\n");
5334 WILC_ERRORREPORT(s32Error, s32Error);
5335 }
5336 WILC_CATCH(s32Error)
5337 {
5338
5339 }
5340
5341 return s32Error;
5342
5343}
5344
5345/**
5346 * @brief host_int_get_RSNAConfigPSKPassPhrase
5347 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
5348 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5349 * The length of the field can vary from 8 to 64 bytes,
5350 * the lower layer should get the
5351 * @param[in,out] handle to the wifi driver,
5352 * String containing PSK
5353 * @return Error code indicating success/failure
5354 * @note
5355 * @author zsalah
5356 * @date 8 March 2012
5357 * @version 1.0
5358 */
Johnny Kim218dc402015-08-13 13:41:19 +09005359s32 host_int_get_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005360 u8 *pu8PassPhrase, u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005361{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005362 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005363 tstrWID strWID;
5364 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5365
Chaehyun Limd85f5322015-06-11 14:35:54 +09005366 strWID.u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005367 strWID.enuWIDtype = WID_STR;
5368 strWID.s32ValueSize = u8Psklength;
5369 strWID.ps8WidVal = pu8PassPhrase;
5370
5371 return s32Error;
5372}
5373
5374/**
5375 * @brief host_int_get_site_survey_results
5376 * @details gets the site survey results
5377 * @param[in,out] handle to the wifi driver,
5378 * Message containing site survey results in the
5379 * following format
5380 *|---------------------------------------------------|
5381 | MsgLength | fragNo. | MsgBodyLength | MsgBody |
5382 ||-----------|-----------|---------------|-----------|
5383 | 1 | 1 | 1 | 1 |
5384 | ----------------------------------------- | ----------------
5385 |
5386 ||---------------------------------------|
5387 | Network1 | Netweork2 | ... | Network5 |
5388 ||---------------------------------------|
5389 | 44 | 44 | ... | 44 |
5390 | -------------------------- | ---------------------------------------
5391 |
5392 ||---------------------------------------------------------------------|
5393 | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved |
5394 |
5395 |
5396 ||------|----------|---------|----------------|-------|------|---------|
5397 | 33 | 1 | 1 | 1 | 6 | 1 | 1 |
5398 ||---------------------------------------------------------------------|
5399 * @return Error code indicating success/failure
5400 * @note
5401 * @author zsalah
5402 * @date 8 March 2012
5403 * @version 1.0
5404 */
5405#ifndef CONNECT_DIRECT
Johnny Kim218dc402015-08-13 13:41:19 +09005406s32 host_int_get_site_survey_results(tstrWILC_WFIDrv *hWFIDrv,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005407 u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE],
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005408 u32 u32MaxSiteSrvyFragLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005409{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005410 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005411 tstrWID astrWIDList[2];
5412 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5413
Chaehyun Limd85f5322015-06-11 14:35:54 +09005414 astrWIDList[0].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005415 astrWIDList[0].enuWIDtype = WID_STR;
5416 astrWIDList[0].ps8WidVal = ppu8RcvdSiteSurveyResults[0];
5417 astrWIDList[0].s32ValueSize = u32MaxSiteSrvyFragLen;
5418
Chaehyun Limd85f5322015-06-11 14:35:54 +09005419 astrWIDList[1].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005420 astrWIDList[1].enuWIDtype = WID_STR;
5421 astrWIDList[1].ps8WidVal = ppu8RcvdSiteSurveyResults[1];
5422 astrWIDList[1].s32ValueSize = u32MaxSiteSrvyFragLen;
5423
Johnny Kimd42ab082015-08-20 16:32:52 +09005424 s32Error = SendConfigPkt(GET_CFG, astrWIDList, 2, true,
5425 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005426
5427 /*get the value by searching the local copy*/
5428 if (s32Error) {
5429 PRINT_ER("Failed to send config packet to get survey results\n");
5430 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5431 }
5432
5433 WILC_CATCH(s32Error)
5434 {
5435
5436 }
5437
5438 return s32Error;
5439}
5440#endif
5441
5442/**
5443 * @brief sets a start scan request
5444 * @details
5445 * @param[in,out] handle to the wifi driver,
5446 * @param[in] Scan Source one of the following values
5447 * DEFAULT_SCAN 0
5448 * USER_SCAN BIT0
5449 * OBSS_PERIODIC_SCAN BIT1
5450 * OBSS_ONETIME_SCAN BIT2
5451 * @return Error code indicating success/failure
5452 * @note
5453 * @author zsalah
5454 * @date 8 March 2012
5455 * @version 1.0
5456 */
Johnny Kim218dc402015-08-13 13:41:19 +09005457s32 host_int_set_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 scanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005458{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005459 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005460 tstrWID strWID;
5461 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5462
Chaehyun Limd85f5322015-06-11 14:35:54 +09005463 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005464 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005465 strWID.ps8WidVal = (s8 *)&scanSource;
Dean Lee576917a2015-06-15 11:58:57 +09005466 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005467
5468 return s32Error;
5469}
5470
5471/**
5472 * @brief host_int_get_start_scan_req
5473 * @details gets a start scan request
5474 * @param[in,out] handle to the wifi driver,
5475 * @param[in] Scan Source one of the following values
5476 * DEFAULT_SCAN 0
5477 * USER_SCAN BIT0
5478 * OBSS_PERIODIC_SCAN BIT1
5479 * OBSS_ONETIME_SCAN BIT2
5480 * @return Error code indicating success/failure
5481 * @note
5482 * @author zsalah
5483 * @date 8 March 2012
5484 * @version 1.0
5485 */
5486
Johnny Kim218dc402015-08-13 13:41:19 +09005487s32 host_int_get_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ScanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005488{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005489 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005490 tstrWID strWID;
5491 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5492
Chaehyun Limd85f5322015-06-11 14:35:54 +09005493 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005494 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005495 strWID.ps8WidVal = (s8 *)pu8ScanSource;
Dean Lee576917a2015-06-15 11:58:57 +09005496 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005497
5498 return s32Error;
5499}
5500
5501/**
5502 * @brief host_int_set_join_req
5503 * @details sets a join request
5504 * @param[in,out] handle to the wifi driver,
5505 * @param[in] Index of the bss descriptor
5506 * @return Error code indicating success/failure
5507 * @note
5508 * @author zsalah
5509 * @date 8 March 2012
5510 * @version 1.0
5511 */
Johnny Kim218dc402015-08-13 13:41:19 +09005512s32 host_int_set_join_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8bssid,
Arnd Bergmann057d1e92015-06-01 21:06:44 +02005513 const u8 *pu8ssid, size_t ssidLen,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005514 const u8 *pu8IEs, size_t IEsLen,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005515 tWILCpfConnectResult pfConnectResult, void *pvUserArg,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005516 u8 u8security, AUTHTYPE_T tenuAuth_type,
5517 u8 u8channel,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005518 void *pJoinParams)
5519{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005520 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005521 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5522 tstrHostIFmsg strHostIFmsg;
5523 tenuScanConnTimer enuScanConnTimer;
5524
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005525 if (pstrWFIDrv == NULL || pfConnectResult == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005526 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005527
5528 if (hWFIDrv == NULL) {
5529 PRINT_ER("Driver not initialized: gWFiDrvHandle = NULL\n");
5530 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5531 }
5532
5533 if (pJoinParams == NULL) {
5534 PRINT_ER("Unable to Join - JoinParams is NULL\n");
5535 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5536
5537 }
5538/*
5539 * if(gWFiDrvHandle->strWILC_UsrScanReq.u32RcvdChCount == 0)
5540 * {
5541 * PRINT_ER("No scan results exist: Scanning should be done\n");
5542 * WILC_ERRORREPORT(s32Error, WILC_FAIL);
5543 * }
5544 */
5545 /* prepare the Connect Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005546 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005547
5548 strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT;
5549
5550 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8security = u8security;
5551 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.tenuAuth_type = tenuAuth_type;
5552 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8channel = u8channel;
5553 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pfConnectResult = pfConnectResult;
5554 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pvUserArg = pvUserArg;
5555 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pJoinParams = pJoinParams;
5556 strHostIFmsg.drvHandler = hWFIDrv;
5557
5558 if (pu8bssid != NULL) {
Chaehyun Limdc0ad742015-08-17 11:05:12 +09005559 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid = WILC_MALLOC(6); /* will be deallocated by the receiving thread */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005560 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005561 pu8bssid, 6);
5562 }
5563
5564 if (pu8ssid != NULL) {
5565 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.ssidLen = ssidLen;
Chaehyun Limdc0ad742015-08-17 11:05:12 +09005566 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid = WILC_MALLOC(ssidLen); /* will be deallocated by the receiving thread */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005567 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005568
5569 pu8ssid, ssidLen);
5570 }
5571
5572 if (pu8IEs != NULL) {
5573 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.IEsLen = IEsLen;
Chaehyun Limdc0ad742015-08-17 11:05:12 +09005574 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs = WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005575 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005576 pu8IEs, IEsLen);
5577 }
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05305578 if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005579 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05305580 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005581 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate);
5582
5583 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09005584 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005585 if (s32Error) {
5586 PRINT_ER("Failed to send message queue: Set join request\n");
5587 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5588 }
5589
5590 enuScanConnTimer = CONNECT_TIMER;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005591 pstrWFIDrv->hConnectTimer.data = (unsigned long)hWFIDrv;
5592 mod_timer(&pstrWFIDrv->hConnectTimer,
5593 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005594
5595 WILC_CATCH(s32Error)
5596 {
5597
5598 }
5599
5600 return s32Error;
5601}
5602
5603/**
5604 * @brief Flush a join request parameters to FW, but actual connection
5605 * @details The function is called in situation where WILC is connected to AP and
5606 * required to switch to hybrid FW for P2P connection
5607 * @param[in] handle to the wifi driver,
5608 * @return Error code indicating success/failure
5609 * @note
5610 * @author Amr Abdel-Moghny
5611 * @date 19 DEC 2013
5612 * @version 8.0
5613 */
5614
Johnny Kim218dc402015-08-13 13:41:19 +09005615s32 host_int_flush_join_req(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005616{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005617 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005618 tstrHostIFmsg strHostIFmsg;
5619
5620 if (!gu8FlushedJoinReq) {
5621 s32Error = WILC_FAIL;
5622 return s32Error;
5623 }
5624
5625
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005626 if (hWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005627 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005628
5629
5630 strHostIFmsg.u16MsgId = HOST_IF_MSG_FLUSH_CONNECT;
5631 strHostIFmsg.drvHandler = hWFIDrv;
5632
5633 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09005634 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005635 if (s32Error) {
5636 PRINT_ER("Failed to send message queue: Flush join request\n");
5637 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5638 }
5639
5640 WILC_CATCH(s32Error)
5641 {
5642
5643 }
5644 return s32Error;
5645}
5646
5647/**
5648 * @brief host_int_disconnect
5649 * @details disconnects from the currently associated network
5650 * @param[in,out] handle to the wifi driver,
5651 * @param[in] Reason Code of the Disconnection
5652 * @return Error code indicating success/failure
5653 * @note
5654 * @author zsalah
5655 * @date 8 March 2012
5656 * @version 1.0
5657 */
Johnny Kim218dc402015-08-13 13:41:19 +09005658s32 host_int_disconnect(tstrWILC_WFIDrv *hWFIDrv, u16 u16ReasonCode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005659{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005660 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005661 tstrHostIFmsg strHostIFmsg;
5662 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5663
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005664 if (pstrWFIDrv == NULL) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005665 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005666 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5667 }
5668
5669 if (pstrWFIDrv == NULL) {
5670 PRINT_ER("gWFiDrvHandle = NULL\n");
5671 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5672 }
5673
5674 /* prepare the Disconnect Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005675 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005676
5677 strHostIFmsg.u16MsgId = HOST_IF_MSG_DISCONNECT;
5678 strHostIFmsg.drvHandler = hWFIDrv;
5679
5680 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09005681 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005682 if (s32Error)
5683 PRINT_ER("Failed to send message queue: disconnect\n");
5684 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005685 down(&(pstrWFIDrv->hSemTestDisconnectBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005686 /* /////// */
5687
5688 WILC_CATCH(s32Error)
5689 {
5690
5691 }
5692
5693 return s32Error;
5694}
5695
5696/**
5697 * @brief host_int_disconnect_station
5698 * @details disconnects a sta
5699 * @param[in,out] handle to the wifi driver,
5700 * @param[in] Association Id of the station to be disconnected
5701 * @return Error code indicating success/failure
5702 * @note
5703 * @author zsalah
5704 * @date 8 March 2012
5705 * @version 1.0
5706 */
Johnny Kim218dc402015-08-13 13:41:19 +09005707s32 host_int_disconnect_station(tstrWILC_WFIDrv *hWFIDrv, u8 assoc_id)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005708{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005709 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005710 tstrWID strWID;
5711 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5712
Chaehyun Limd85f5322015-06-11 14:35:54 +09005713 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005714 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005715 strWID.ps8WidVal = (s8 *)&assoc_id;
Dean Lee576917a2015-06-15 11:58:57 +09005716 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005717
5718 return s32Error;
5719}
5720
5721/**
5722 * @brief host_int_get_assoc_req_info
5723 * @details gets a Association request info
5724 * @param[in,out] handle to the wifi driver,
5725 * Message containg assoc. req info in the following format
5726 * ------------------------------------------------------------------------
5727 | Management Frame Format |
5728 ||-------------------------------------------------------------------|
5729 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5730 ||-------------|--------|--|--|-----|----------------|----------|----|
5731 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5732 ||-------------------------------------------------------------------|
5733 | |
5734 | Association Request Frame - Frame Body |
5735 ||-------------------------------------------------------------------|
5736 | Capability Information | Listen Interval | SSID | Supported Rates |
5737 ||------------------------|-----------------|------|-----------------|
5738 | 2 | 2 | 2-34 | 3-10 |
5739 | ---------------------------------------------------------------------
5740 * @return Error code indicating success/failure
5741 * @note
5742 * @author zsalah
5743 * @date 8 March 2012
5744 * @version 1.0
5745 */
5746
Johnny Kim218dc402015-08-13 13:41:19 +09005747s32 host_int_get_assoc_req_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocReqInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005748 u32 u32AssocReqInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005749{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005750 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005751 tstrWID strWID;
5752 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5753
Chaehyun Limd85f5322015-06-11 14:35:54 +09005754 strWID.u16WIDid = (u16)WID_ASSOC_REQ_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005755 strWID.enuWIDtype = WID_STR;
5756 strWID.ps8WidVal = pu8AssocReqInfo;
5757 strWID.s32ValueSize = u32AssocReqInfoLen;
5758
5759
5760 return s32Error;
5761}
5762
5763/**
5764 * @brief gets a Association Response info
5765 * @details
5766 * @param[in,out] handle to the wifi driver,
5767 * Message containg assoc. resp info
5768 * @return Error code indicating success/failure
5769 * @note
5770 * @author zsalah
5771 * @date 8 March 2012
5772 * @version 1.0
5773 */
Johnny Kim218dc402015-08-13 13:41:19 +09005774s32 host_int_get_assoc_res_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocRespInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005775 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005776{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005777 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005778 tstrWID strWID;
5779 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5780
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005781 if (pstrWFIDrv == NULL) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005782 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005783 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5784 }
5785
Chaehyun Limd85f5322015-06-11 14:35:54 +09005786 strWID.u16WIDid = (u16)WID_ASSOC_RES_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005787 strWID.enuWIDtype = WID_STR;
5788 strWID.ps8WidVal = pu8AssocRespInfo;
5789 strWID.s32ValueSize = u32MaxAssocRespInfoLen;
5790
5791
5792 /* Sending Configuration packet */
Johnny Kimd42ab082015-08-20 16:32:52 +09005793 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
5794 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005795 if (s32Error) {
5796 PRINT_ER("Failed to send association response config packet\n");
5797 *pu32RcvdAssocRespInfoLen = 0;
5798 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5799 } else {
5800 *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize;
5801 }
5802
5803 WILC_CATCH(s32Error)
5804 {
5805
5806 }
5807 return s32Error;
5808}
5809
5810/**
5811 * @brief gets a Association Response info
5812 * @details Valid only in STA mode. This function gives the RSSI
5813 * values observed in all the channels at the time of scanning.
5814 * The length of the field is 1 greater that the total number of
5815 * channels supported. Byte 0 contains the number of channels while
5816 * each of Byte N contains the observed RSSI value for the channel index N.
5817 * @param[in,out] handle to the wifi driver,
5818 * array of scanned channels' RSSI
5819 * @return Error code indicating success/failure
5820 * @note
5821 * @author zsalah
5822 * @date 8 March 2012
5823 * @version 1.0
5824 */
Johnny Kim218dc402015-08-13 13:41:19 +09005825s32 host_int_get_rx_power_level(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8RxPowerLevel,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005826 u32 u32RxPowerLevelLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005827{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005828 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005829 tstrWID strWID;
5830 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5831
Chaehyun Limd85f5322015-06-11 14:35:54 +09005832 strWID.u16WIDid = (u16)WID_RX_POWER_LEVEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005833 strWID.enuWIDtype = WID_STR;
5834 strWID.ps8WidVal = pu8RxPowerLevel;
5835 strWID.s32ValueSize = u32RxPowerLevelLen;
5836
5837
5838 return s32Error;
5839}
5840
5841/**
5842 * @brief sets a channel
5843 * @details
5844 * @param[in,out] handle to the wifi driver,
5845 * @param[in] Index of the channel to be set
5846 *|-------------------------------------------------------------------|
5847 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5848 | Input: 1 2 14 |
5849 ||-------------------------------------------------------------------|
5850 * @return Error code indicating success/failure
5851 * @note
5852 * @author zsalah
5853 * @date 8 March 2012
5854 * @version 1.0
5855 */
Johnny Kim218dc402015-08-13 13:41:19 +09005856s32 host_int_set_mac_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 u8ChNum)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005857{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005858 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005859 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5860 tstrHostIFmsg strHostIFmsg;
5861
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005862 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005863 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005864
5865 /* prepare the set channel message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005866 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005867 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_CHANNEL;
5868 strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan.u8SetChan = u8ChNum;
5869 strHostIFmsg.drvHandler = hWFIDrv;
5870
Chaehyun Lim79198132015-08-19 15:59:06 +09005871 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005872 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005873 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005874 WILC_CATCH(s32Error)
5875 {
5876
5877 }
5878
5879 return s32Error;
5880}
5881
5882
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005883s32 host_int_wait_msg_queue_idle(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005884{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005885 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005886
5887 tstrHostIFmsg strHostIFmsg;
5888
5889 /* prepare the set driver handler message */
5890
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005891 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005892 strHostIFmsg.u16MsgId = HOST_IF_MSG_Q_IDLE;
Chaehyun Lim79198132015-08-19 15:59:06 +09005893 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005894 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005895 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005896 WILC_CATCH(s32Error)
5897 {
5898
5899 }
5900
5901 /* wait untill MSG Q is empty */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005902 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005903
5904 return s32Error;
5905
5906}
5907
Johnny Kim218dc402015-08-13 13:41:19 +09005908s32 host_int_set_wfi_drv_handler(tstrWILC_WFIDrv *u32address)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005909{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005910 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005911
5912 tstrHostIFmsg strHostIFmsg;
5913
5914
5915 /* prepare the set driver handler message */
5916
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005917 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005918 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_WFIDRV_HANDLER;
Johnny Kimd42ab082015-08-20 16:32:52 +09005919 strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler.u32Address = get_id_from_handler(u32address);
Johnny Kim53a84402015-08-20 16:32:51 +09005920 strHostIFmsg.drvHandler = u32address;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005921
Chaehyun Lim79198132015-08-19 15:59:06 +09005922 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005923 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005924 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005925 WILC_CATCH(s32Error)
5926 {
5927
5928 }
5929
5930 return s32Error;
5931}
5932
5933
5934
Johnny Kim218dc402015-08-13 13:41:19 +09005935s32 host_int_set_operation_mode(tstrWILC_WFIDrv *hWFIDrv, u32 u32mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005936{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005937 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005938
5939 tstrHostIFmsg strHostIFmsg;
5940
5941
5942 /* prepare the set driver handler message */
5943
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005944 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005945 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_OPERATION_MODE;
5946 strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode.u32Mode = u32mode;
5947 strHostIFmsg.drvHandler = hWFIDrv;
5948
Chaehyun Lim79198132015-08-19 15:59:06 +09005949 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005950 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005951 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005952 WILC_CATCH(s32Error)
5953 {
5954
5955 }
5956
5957 return s32Error;
5958}
5959
5960/**
5961 * @brief gets the current channel index
5962 * @details
5963 * @param[in,out] handle to the wifi driver,
5964 * current channel index
5965 *|-----------------------------------------------------------------------|
5966 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5967 | Input: 1 2 14 |
5968 ||-----------------------------------------------------------------------|
5969 * @return Error code indicating success/failure
5970 * @note
5971 * @author zsalah
5972 * @date 8 March 2012
5973 * @version 1.0
5974 */
Johnny Kim218dc402015-08-13 13:41:19 +09005975s32 host_int_get_host_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ChNo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005976{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005977 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005978 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5979 tstrHostIFmsg strHostIFmsg;
5980
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005981 if (pstrWFIDrv == NULL) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005982 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005983 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5984 }
5985
5986 /* prepare the Get Channel Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005987 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005988
5989 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_CHNL;
5990 strHostIFmsg.drvHandler = hWFIDrv;
5991
5992 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09005993 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005994 if (s32Error)
5995 PRINT_ER("Failed to send get host channel param's message queue ");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005996 down(&(pstrWFIDrv->hSemGetCHNL));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005997 /* gu8Chnl = 11; */
5998
5999 *pu8ChNo = gu8Chnl;
6000
6001 WILC_CATCH(s32Error)
6002 {
6003 }
6004
6005 return s32Error;
6006
6007
6008}
6009
6010
6011/**
6012 * @brief host_int_test_set_int_wid
6013 * @details Test function for setting wids
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006014 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006015 * @return Error code indicating success/failure
6016 * @note
6017 * @author zsalah
6018 * @date 8 March 2012
6019 * @version 1.0
6020 */
Johnny Kim218dc402015-08-13 13:41:19 +09006021s32 host_int_test_set_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 u32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006022{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006023 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006024 tstrWID strWID;
6025 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6026
6027
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006028 if (pstrWFIDrv == NULL) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006029 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006030 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6031 }
6032
6033 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +09006034 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006035 strWID.enuWIDtype = WID_INT;
Dean Lee576917a2015-06-15 11:58:57 +09006036 strWID.ps8WidVal = (char *)&u32TestMemAddr;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006037 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006038
6039 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09006040 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
6041 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006042 if (s32Error) {
6043 PRINT_ER("Test Function: Failed to set wid value\n");
6044 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
6045 } else {
6046 PRINT_D(HOSTINF_DBG, "Successfully set wid value\n");
6047
6048 }
6049
6050 WILC_CATCH(s32Error)
6051 {
6052
6053 }
6054 return s32Error;
6055}
6056
6057#ifdef WILC_AP_EXTERNAL_MLME
6058/**
6059 * @brief host_int_get_inactive_time
6060 * @details
6061 * @param[in,out] handle to the wifi driver,
6062 * current sta macaddress, inactive_time
6063 * @return
6064 * @note
6065 * @author
6066 * @date
6067 * @version 1.0
6068 */
Johnny Kim218dc402015-08-13 13:41:19 +09006069s32 host_int_get_inactive_time(tstrWILC_WFIDrv *hWFIDrv, const u8 *mac, u32 *pu32InactiveTime)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006070{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006071 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006072 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6073 tstrHostIFmsg strHostIFmsg;
6074
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006075 if (pstrWFIDrv == NULL) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006076 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006077 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6078 }
6079
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006080 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006081
6082
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006083 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT.mac,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006084 mac, ETH_ALEN);
6085
6086 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_INACTIVETIME;
6087 strHostIFmsg.drvHandler = hWFIDrv;
6088
6089 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09006090 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006091 if (s32Error)
6092 PRINT_ER("Failed to send get host channel param's message queue ");
6093
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006094 down(&(pstrWFIDrv->hSemInactiveTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006095
6096 *pu32InactiveTime = gu32InactiveTime;
6097
6098 WILC_CATCH(s32Error)
6099 {
6100 }
6101
6102 return s32Error;
6103}
6104#endif
6105/**
6106 * @brief host_int_test_get_int_wid
6107 * @details Test function for getting wids
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006108 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006109 * @return Error code indicating success/failure
6110 * @note
6111 * @author zsalah
6112 * @date 8 March 2012
6113 * @version 1.0
6114 */
Johnny Kim218dc402015-08-13 13:41:19 +09006115s32 host_int_test_get_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 *pu32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006116{
6117
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006118 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006119 tstrWID strWID;
6120 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6121
6122
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006123 if (pstrWFIDrv == NULL) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006124 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006125 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6126 }
6127
Chaehyun Limd85f5322015-06-11 14:35:54 +09006128 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006129 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09006130 strWID.ps8WidVal = (s8 *)pu32TestMemAddr;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006131 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006132
Johnny Kimd42ab082015-08-20 16:32:52 +09006133 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
6134 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006135 /*get the value by searching the local copy*/
6136 if (s32Error) {
6137 PRINT_ER("Test Function: Failed to get wid value\n");
6138 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
6139 } else {
6140 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
6141
6142 }
6143
6144 WILC_CATCH(s32Error)
6145 {
6146
6147 }
6148 return s32Error;
6149}
6150
6151
6152/**
6153 * @brief host_int_get_rssi
6154 * @details gets the currently maintained RSSI value for the station.
6155 * The received signal strength value in dB.
6156 * The range of valid values is -128 to 0.
6157 * @param[in,out] handle to the wifi driver,
6158 * rssi value in dB
6159 * @return Error code indicating success/failure
6160 * @note
6161 * @author zsalah
6162 * @date 8 March 2012
6163 * @version 1.0
6164 */
Johnny Kim218dc402015-08-13 13:41:19 +09006165s32 host_int_get_rssi(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006166{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006167 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006168 tstrHostIFmsg strHostIFmsg;
6169 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6170
6171
6172 /* prepare the Get RSSI Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006173 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006174
6175 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
6176 strHostIFmsg.drvHandler = hWFIDrv;
6177
6178 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09006179 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006180 if (s32Error) {
6181 PRINT_ER("Failed to send get host channel param's message queue ");
6182 return WILC_FAIL;
6183 }
6184
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006185 down(&(pstrWFIDrv->hSemGetRSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006186
6187
6188 if (ps8Rssi == NULL) {
6189 PRINT_ER("RSS pointer value is null");
6190 return WILC_FAIL;
6191 }
6192
6193
6194 *ps8Rssi = gs8Rssi;
6195
6196
6197 return s32Error;
6198}
6199
Johnny Kim218dc402015-08-13 13:41:19 +09006200s32 host_int_get_link_speed(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8lnkspd)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006201{
6202 tstrHostIFmsg strHostIFmsg;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006203 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006204
6205 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6206
6207
6208
6209 /* prepare the Get LINKSPEED Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006210 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006211
6212 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_LINKSPEED;
6213 strHostIFmsg.drvHandler = hWFIDrv;
6214
6215 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09006216 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006217 if (s32Error) {
6218 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
6219 return WILC_FAIL;
6220 }
6221
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006222 down(&(pstrWFIDrv->hSemGetLINKSPEED));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006223
6224
6225 if (ps8lnkspd == NULL) {
6226 PRINT_ER("LINKSPEED pointer value is null");
6227 return WILC_FAIL;
6228 }
6229
6230
6231 *ps8lnkspd = gs8lnkspd;
6232
6233
6234 return s32Error;
6235}
6236
Johnny Kim218dc402015-08-13 13:41:19 +09006237s32 host_int_get_statistics(tstrWILC_WFIDrv *hWFIDrv, tstrStatistics *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006238{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006239 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006240 tstrHostIFmsg strHostIFmsg;
6241
6242
6243 /* prepare the Get RSSI Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006244 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006245
6246 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_STATISTICS;
Dean Lee576917a2015-06-15 11:58:57 +09006247 strHostIFmsg.uniHostIFmsgBody.pUserData = (char *)pstrStatistics;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006248 strHostIFmsg.drvHandler = hWFIDrv;
6249 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09006250 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006251 if (s32Error) {
6252 PRINT_ER("Failed to send get host channel param's message queue ");
6253 return WILC_FAIL;
6254 }
6255
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006256 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006257 return s32Error;
6258}
6259
6260
6261/**
6262 * @brief host_int_scan
6263 * @details scans a set of channels
6264 * @param[in,out] handle to the wifi driver,
6265 * @param[in] Scan source
6266 * Scan Type PASSIVE_SCAN = 0,
6267 * ACTIVE_SCAN = 1
6268 * Channels Array
6269 * Channels Array length
6270 * Scan Callback function
6271 * @return Error code indicating success/failure
6272 * @note
6273 * @author zsalah
6274 * @date 8 March 2012
6275 * @version 1.0
6276 */
Johnny Kim218dc402015-08-13 13:41:19 +09006277s32 host_int_scan(tstrWILC_WFIDrv *hWFIDrv, u8 u8ScanSource,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006278 u8 u8ScanType, u8 *pu8ChnlFreqList,
6279 u8 u8ChnlListLen, const u8 *pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006280 size_t IEsLen, tWILCpfScanResult ScanResult,
6281 void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork)
6282{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006283 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006284 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6285 tstrHostIFmsg strHostIFmsg;
6286 tenuScanConnTimer enuScanConnTimer;
6287
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006288 if (pstrWFIDrv == NULL || ScanResult == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006289 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006290
6291
6292 /* prepare the Scan Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006293 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006294
6295 strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN;
6296
6297 if (pstrHiddenNetwork != NULL) {
6298 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
6299 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
6300
6301 } else
6302 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
6303
6304 strHostIFmsg.drvHandler = hWFIDrv;
6305 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanSource = u8ScanSource;
6306 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanType = u8ScanType;
6307 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pfScanResult = ScanResult;
6308 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pvUserArg = pvUserArg;
6309
6310 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ChnlListLen = u8ChnlListLen;
Chaehyun Limdc0ad742015-08-17 11:05:12 +09006311 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList = WILC_MALLOC(u8ChnlListLen); /* will be deallocated by the receiving thread */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006312 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006313 pu8ChnlFreqList, u8ChnlListLen);
6314
6315 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.IEsLen = IEsLen;
Chaehyun Limdc0ad742015-08-17 11:05:12 +09006316 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs = WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006317 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006318 pu8IEs, IEsLen);
6319
6320 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09006321 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006322 if (s32Error) {
6323 PRINT_ER("Error in sending message queue scanning parameters: Error(%d)\n", s32Error);
6324 WILC_ERRORREPORT(s32Error, WILC_FAIL);
6325 }
6326
6327 enuScanConnTimer = SCAN_TIMER;
6328 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07006329 pstrWFIDrv->hScanTimer.data = (unsigned long)hWFIDrv;
6330 mod_timer(&pstrWFIDrv->hScanTimer,
6331 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006332
6333 WILC_CATCH(s32Error)
6334 {
6335
6336 }
6337 return s32Error;
6338
6339}
6340/**
6341 * @brief hif_set_cfg
6342 * @details sets configuration wids values
6343 * @param[in,out] handle to the wifi driver,
6344 * @param[in] WID, WID value
6345 * @return Error code indicating success/failure
6346 * @note
6347 * @author zsalah
6348 * @date 8 March 2012
6349 * @version 1.0
6350 */
Johnny Kim218dc402015-08-13 13:41:19 +09006351s32 hif_set_cfg(tstrWILC_WFIDrv *hWFIDrv, tstrCfgParamVal *pstrCfgParamVal)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006352{
6353
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006354 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006355 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6356
6357 tstrHostIFmsg strHostIFmsg;
6358
6359
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006360 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006361 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006362 /* prepare the WiphyParams Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006363 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006364 strHostIFmsg.u16MsgId = HOST_IF_MSG_CFG_PARAMS;
6365 strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr.pstrCfgParamVal = *pstrCfgParamVal;
6366 strHostIFmsg.drvHandler = hWFIDrv;
6367
Chaehyun Lim79198132015-08-19 15:59:06 +09006368 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006369
6370 WILC_CATCH(s32Error)
6371 {
6372 }
6373
6374 return s32Error;
6375
6376}
6377
6378
6379/**
6380 * @brief hif_get_cfg
6381 * @details gets configuration wids values
6382 * @param[in,out] handle to the wifi driver,
6383 * WID value
6384 * @param[in] WID,
6385 * @return Error code indicating success/failure
6386 * @note
6387 * @author zsalah
6388 *
6389 * @date 8 March 2012
6390 * @version 1.0
6391 */
Johnny Kim218dc402015-08-13 13:41:19 +09006392s32 hif_get_cfg(tstrWILC_WFIDrv *hWFIDrv, u16 u16WID, u16 *pu16WID_Value)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006393{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006394 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006395 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6396
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006397 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006398
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006399 if (pstrWFIDrv == NULL) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006400 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006401 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6402 }
6403 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
6404 switch (u16WID) {
6405
6406 case WID_BSS_TYPE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006407 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006408 break;
6409
6410 case WID_AUTH_TYPE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006411 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006412 break;
6413
6414 case WID_AUTH_TIMEOUT:
6415 *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout;
6416 break;
6417
6418 case WID_POWER_MANAGEMENT:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006419 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006420 break;
6421
6422 case WID_SHORT_RETRY_LIMIT:
6423 *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit;
6424 break;
6425
6426 case WID_LONG_RETRY_LIMIT:
6427 *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit;
6428 break;
6429
6430 case WID_FRAG_THRESHOLD:
6431 *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold;
6432 break;
6433
6434 case WID_RTS_THRESHOLD:
6435 *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold;
6436 break;
6437
6438 case WID_PREAMBLE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006439 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006440 break;
6441
6442 case WID_SHORT_SLOT_ALLOWED:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006443 *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006444 break;
6445
6446 case WID_11N_TXOP_PROT_DISABLE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006447 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006448 break;
6449
6450 case WID_BEACON_INTERVAL:
6451 *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval;
6452 break;
6453
6454 case WID_DTIM_PERIOD:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006455 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006456 break;
6457
6458 case WID_SITE_SURVEY:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006459 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006460 break;
6461
6462 case WID_SITE_SURVEY_SCAN_TIME:
6463 *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time;
6464 break;
6465
6466 case WID_ACTIVE_SCAN_TIME:
6467 *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time;
6468 break;
6469
6470 case WID_PASSIVE_SCAN_TIME:
6471 *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time;
6472 break;
6473
6474 case WID_CURRENT_TX_RATE:
6475 *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate;
6476 break;
6477
6478 default:
6479 break;
6480 }
6481
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006482 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006483
6484 WILC_CATCH(s32Error)
6485 {
6486 }
6487 return s32Error;
6488
6489}
6490
6491/*****************************************************************************/
6492/* Notification Functions */
6493/*****************************************************************************/
6494/**
6495 * @brief notifies host with join and leave requests
6496 * @details This function prepares an Information frame having the
6497 * information about a joining/leaving station.
6498 * @param[in,out] handle to the wifi driver,
6499 * @param[in] 6 byte Sta Adress
6500 * Join or leave flag:
6501 * Join = 1,
6502 * Leave =0
6503 * @return Error code indicating success/failure
6504 * @note
6505 * @author zsalah
6506 * @date 8 March 2012
6507 * @version 1.0
6508 */
6509void host_int_send_join_leave_info_to_host
Dean Lee72ed4dc2015-06-12 14:11:44 +09006510 (u16 assocId, u8 *stationAddr, bool joining)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006511{
6512}
6513/**
6514 * @brief notifies host with stations found in scan
6515 * @details sends the beacon/probe response from scan
6516 * @param[in,out] handle to the wifi driver,
6517 * @param[in] Sta Address,
6518 * Frame length,
6519 * Rssi of the Station found
6520 * @return Error code indicating success/failure
6521 * @note
6522 * @author zsalah
6523 * @date 8 March 2012
6524 * @version 1.0
6525 */
6526
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006527static void GetPeriodicRSSI(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006528{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006529 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006530
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006531 if (pstrWFIDrv == NULL) {
6532 PRINT_ER("Driver handler is NULL\n");
6533 return;
6534 }
6535
6536 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006537 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006538 tstrHostIFmsg strHostIFmsg;
6539
6540 /* prepare the Get RSSI Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006541 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006542
6543 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
6544 strHostIFmsg.drvHandler = pstrWFIDrv;
6545
6546 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09006547 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006548 if (s32Error) {
6549 PRINT_ER("Failed to send get host channel param's message queue ");
6550 return;
6551 }
6552 }
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07006553 g_hPeriodicRSSI.data = (unsigned long)pstrWFIDrv;
6554 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006555}
6556
6557
6558void host_int_send_network_info_to_host
Chaehyun Limca356ad2015-06-11 14:35:57 +09006559 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006560{
6561}
6562/**
6563 * @brief host_int_init
6564 * @details host interface initialization function
6565 * @param[in,out] handle to the wifi driver,
6566 * @note
6567 * @author zsalah
6568 * @date 8 March 2012
6569 * @version 1.0
6570 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006571static u32 u32Intialized;
6572static u32 msgQ_created;
6573static u32 clients_count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006574
Johnny Kim218dc402015-08-13 13:41:19 +09006575s32 host_int_init(tstrWILC_WFIDrv **phWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006576{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006577 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006578 tstrWILC_WFIDrv *pstrWFIDrv;
Johnny Kimd42ab082015-08-20 16:32:52 +09006579 int err;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006580
6581 /*if(u32Intialized == 1)
6582 * {
6583 * PRINT_D(HOSTINF_DBG,"Host interface is previously initialized\n");
6584 * *phWFIDrv = (WILC_WFIDrvHandle)gWFiDrvHandle; //Will be adjusted later for P2P
6585 * return 0;
6586 * } */
6587 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
6588
Dean Lee72ed4dc2015-06-12 14:11:44 +09006589 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006590
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006591 sema_init(&hWaitResponse, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006592
6593
6594
6595 /*Allocate host interface private structure*/
Chaehyun Limdc0ad742015-08-17 11:05:12 +09006596 pstrWFIDrv = WILC_MALLOC(sizeof(tstrWILC_WFIDrv));
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006597 if (pstrWFIDrv == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006598 /* WILC_ERRORREPORT(s32Error,WILC_NO_MEM); */
6599 s32Error = WILC_NO_MEM;
6600 PRINT_ER("Failed to allocate memory\n");
6601 goto _fail_timer_2;
6602 }
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006603 memset(pstrWFIDrv, 0, sizeof(tstrWILC_WFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006604 /*return driver handle to user*/
Johnny Kim218dc402015-08-13 13:41:19 +09006605 *phWFIDrv = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006606 /*save into globl handle*/
Johnny Kimd42ab082015-08-20 16:32:52 +09006607 err = add_handler_in_list(pstrWFIDrv);
6608 if (err) {
6609 s32Error = WILC_FAIL;
6610 goto _fail_timer_2;
6611 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006612
6613 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
6614
Dean Lee72ed4dc2015-06-12 14:11:44 +09006615 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006616 #endif
6617
Johnny Kim8a143302015-06-10 17:06:46 +09006618 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006619 /* /////////////////////////////////////// */
6620 if (clients_count == 0) {
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006621 sema_init(&hSemHostIFthrdEnd, 0);
6622 sema_init(&hSemDeinitDrvHandle, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006623 /*BugID_5348*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006624 sema_init(&hSemHostIntDeinit, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006625 }
6626
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006627 sema_init(&(pstrWFIDrv->hSemTestKeyBlock), 0);
6628 sema_init(&(pstrWFIDrv->hSemTestDisconnectBlock), 0);
6629 sema_init(&(pstrWFIDrv->hSemGetRSSI), 0);
6630 sema_init(&(pstrWFIDrv->hSemGetLINKSPEED), 0);
6631 sema_init(&(pstrWFIDrv->hSemGetCHNL), 0);
6632 sema_init(&(pstrWFIDrv->hSemInactiveTime), 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006633
6634 /* /////////////////////////////////////// */
6635
6636
6637
6638 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
6639
6640 if (clients_count == 0) {
Chaehyun Limcd08fc72015-08-19 15:59:05 +09006641 s32Error = wilc_mq_create(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006642
6643 if (s32Error < 0) {
6644 PRINT_ER("Failed to creat MQ\n");
6645 goto _fail_;
6646 }
6647 msgQ_created = 1;
Arnd Bergmann1999bd52015-05-29 22:52:14 +02006648 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
6649 if (IS_ERR(HostIFthreadHandler)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006650 PRINT_ER("Failed to creat Thread\n");
Arnd Bergmann1999bd52015-05-29 22:52:14 +02006651 s32Error = WILC_FAIL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006652 goto _fail_mq_;
6653 }
Greg Kroah-Hartman507d7fc2015-08-17 12:59:42 -07006654 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
6655 (unsigned long)pstrWFIDrv);
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07006656 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006657 }
6658
6659
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006660 setup_timer(&pstrWFIDrv->hScanTimer, TimerCB_Scan, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006661
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006662 setup_timer(&pstrWFIDrv->hConnectTimer, TimerCB_Connect, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006663
6664 #ifdef WILC_P2P
6665 /*Remain on channel timer*/
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006666 setup_timer(&pstrWFIDrv->hRemainOnChannel, ListenTimerCB, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006667 #endif
6668
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006669 sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1);
6670 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006671
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006672 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09006673 /* gWFiDrvHandle->bPendingConnRequest = false; */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006674
6675 /*Initialize CFG WIDS Defualt Values*/
6676
6677 pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
6678 pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN;
6679 pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
6680 pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
6681 pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE;
6682
6683
6684 #ifdef WILC_P2P
6685
6686 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
6687
6688 #endif
6689
6690 PRINT_INFO(HOSTINF_DBG, "Initialization values, Site survey value: %d\n Scan source: %d\n Active scan time: %d\n Passive scan time: %d\nCurrent tx Rate = %d\n",
6691
6692 pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source,
6693 pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time,
6694 pstrWFIDrv->strCfgValues.curr_tx_rate);
6695
6696
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006697 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006698
6699 /*TODO Code to setup simulation to be removed later*/
6700 /*Intialize configurator module*/
6701 s32Error = CoreConfiguratorInit();
6702 if (s32Error < 0) {
6703 PRINT_ER("Failed to initialize core configurator\n");
6704 goto _fail_mem_;
6705 }
6706
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006707 u32Intialized = 1;
6708 clients_count++; /* increase number of created entities */
6709
6710 return s32Error;
6711
6712
6713_fail_mem_:
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006714 if (pstrWFIDrv != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006715 kfree(pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006716#ifdef WILC_P2P
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006717 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006718#endif
6719_fail_timer_2:
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006720 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006721 del_timer_sync(&pstrWFIDrv->hConnectTimer);
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006722 del_timer_sync(&pstrWFIDrv->hScanTimer);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02006723 kthread_stop(HostIFthreadHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006724_fail_mq_:
Chaehyun Lim1b128f62015-08-19 15:59:08 +09006725 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006726_fail_:
6727 return s32Error;
6728
6729
6730}
6731/**
6732 * @brief host_int_deinit
6733 * @details host interface initialization function
6734 * @param[in,out] handle to the wifi driver,
6735 * @note
6736 * @author zsalah
6737 * @date 8 March 2012
6738 * @version 1.0
6739 */
6740
Johnny Kim218dc402015-08-13 13:41:19 +09006741s32 host_int_deinit(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006742{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006743 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006744 tstrHostIFmsg strHostIFmsg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006745 int ret;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006746
6747 /*obtain driver handle*/
6748 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6749 /*if(u32Intialized == 0)
6750 * {
6751 * PRINT_ER("Host Interface is not initialized\n");
6752 * return 0;
6753 * }*/
6754
6755 /*BugID_5348*/
6756
6757 if (pstrWFIDrv == NULL) {
6758 PRINT_ER("pstrWFIDrv = NULL\n");
6759 return 0;
6760 }
6761
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006762 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006763
6764 terminated_handle = pstrWFIDrv;
6765 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
6766
6767 /*BugID_5348*/
6768 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
6769 /*to guarantee handling all messages befor proceeding*/
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006770 if (del_timer_sync(&pstrWFIDrv->hScanTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006771 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006772 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
6773 }
6774
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006775 if (del_timer_sync(&pstrWFIDrv->hConnectTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006776 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006777 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6778 }
6779
6780
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006781 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006782 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006783 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6784 }
6785
6786 #ifdef WILC_P2P
6787 /*Destroy Remain-onchannel Timer*/
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006788 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006789 #endif
6790
Johnny Kim218dc402015-08-13 13:41:19 +09006791 host_int_set_wfi_drv_handler(NULL);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006792 down(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006793
6794
6795 /*Calling the CFG80211 scan done function with the abort flag set to true*/
6796 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006797 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006798 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
6799
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006800 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006801 }
6802 /*deinit configurator and simulator*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006803 CoreConfiguratorDeInit();
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006804
6805 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6806
Dean Lee72ed4dc2015-06-12 14:11:44 +09006807 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006808
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006809 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006810
6811 if (clients_count == 1) {
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006812 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006813 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006814 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6815 }
6816 strHostIFmsg.u16MsgId = HOST_IF_MSG_EXIT;
6817 strHostIFmsg.drvHandler = hWFIDrv;
6818
6819
Chaehyun Lim79198132015-08-19 15:59:06 +09006820 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006821 if (s32Error != WILC_SUCCESS)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006822 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006823
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006824 down(&hSemHostIFthrdEnd);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006825
Chaehyun Lim1b128f62015-08-19 15:59:08 +09006826 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006827 msgQ_created = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006828 }
6829
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006830 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006831
6832 /*Setting the gloabl driver handler with NULL*/
6833 u32Intialized = 0;
6834 /* gWFiDrvHandle = NULL; */
Johnny Kimd42ab082015-08-20 16:32:52 +09006835 ret = remove_handler_in_list(pstrWFIDrv);
6836 if (ret)
6837 s32Error = WILC_NOT_FOUND;
6838
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006839 if (pstrWFIDrv != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09006840 kfree(pstrWFIDrv);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006841 /* pstrWFIDrv=NULL; */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006842
6843 }
6844
6845 clients_count--; /* Decrease number of created entities */
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006846 terminated_handle = NULL;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006847 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006848 return s32Error;
6849}
6850
6851
6852/**
6853 * @brief NetworkInfoReceived
6854 * @details function to to be called when network info packet is received
6855 * @param[in] pu8Buffer the received packet
6856 * @param[in] u32Length length of the received packet
6857 * @return none
6858 * @note
6859 * @author
6860 * @date 1 Mar 2012
6861 * @version 1.0
6862 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006863void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006864{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006865 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006866 tstrHostIFmsg strHostIFmsg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006867 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006868 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006869
Johnny Kimd42ab082015-08-20 16:32:52 +09006870 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6871 pstrWFIDrv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006872
6873
6874
6875
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006876 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
Johnny Kim8a143302015-06-10 17:06:46 +09006877 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006878 return;
6879 }
6880
6881 /* prepare the Asynchronous Network Info message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006882 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006883
6884 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_NTWRK_INFO;
6885 strHostIFmsg.drvHandler = pstrWFIDrv;
6886
6887 strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.u32Length = u32Length;
Chaehyun Limdc0ad742015-08-17 11:05:12 +09006888 strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer = WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006889 memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006890 pu8Buffer, u32Length);
6891
6892 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09006893 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006894 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006895 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006896}
6897
6898/**
6899 * @brief GnrlAsyncInfoReceived
6900 * @details function to be called when general Asynchronous info packet is received
6901 * @param[in] pu8Buffer the received packet
6902 * @param[in] u32Length length of the received packet
6903 * @return none
6904 * @note
6905 * @author
6906 * @date 15 Mar 2012
6907 * @version 1.0
6908 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006909void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006910{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006911 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006912 tstrHostIFmsg strHostIFmsg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006913 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006914 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006915
6916 /*BugID_5348*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006917 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006918
Johnny Kimd42ab082015-08-20 16:32:52 +09006919 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6920 pstrWFIDrv = get_handler_from_id(id);
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006921 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006922
6923
6924 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6925 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
6926 /*BugID_5348*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006927 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006928 return;
6929 }
6930
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006931 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006932 /* received mac status is not needed when there is no current Connect Request */
6933 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
6934 /*BugID_5348*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006935 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006936 return;
6937 }
6938
6939 /* prepare the General Asynchronous Info message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006940 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006941
6942
6943 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
6944 strHostIFmsg.drvHandler = pstrWFIDrv;
6945
6946
6947 strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.u32Length = u32Length;
Chaehyun Limdc0ad742015-08-17 11:05:12 +09006948 strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer = WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006949 memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006950 pu8Buffer, u32Length);
6951
6952 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09006953 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006954 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006955 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006956
6957 /*BugID_5348*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006958 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006959}
6960
6961/**
6962 * @brief host_int_ScanCompleteReceived
6963 * @details Setting scan complete received notifcation in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006964 * @param[in] u8* pu8Buffer, u32 u32Length
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006965 * @return Error code.
6966 * @author
6967 * @date
6968 * @version 1.0
6969 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006970void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006971{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006972 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006973 tstrHostIFmsg strHostIFmsg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006974 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006975 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006976
Johnny Kimd42ab082015-08-20 16:32:52 +09006977 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6978 pstrWFIDrv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006979
6980
Johnny Kim8a143302015-06-10 17:06:46 +09006981 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006982
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006983 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006984 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006985
6986 /*if there is an ongoing scan request*/
6987 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6988 /* prepare theScan Done message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006989 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006990
6991 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
6992 strHostIFmsg.drvHandler = pstrWFIDrv;
6993
6994
6995 /* will be deallocated by the receiving thread */
6996 /*no need to send message body*/
6997
6998 /*strHostIFmsg.uniHostIFmsgBody.strScanComplete.u32Length = u32Length;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006999 * strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007000 * memcpy(strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007001 * pu8Buffer, u32Length); */
7002
7003 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09007004 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007005 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007006 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007007 }
7008
7009
7010 return;
7011
7012}
7013
7014#ifdef WILC_P2P
7015/**
7016 * @brief host_int_remain_on_channel
7017 * @details
7018 * @param[in] Handle to wifi driver
7019 * Duration to remain on channel
7020 * Channel to remain on
7021 * Pointer to fn to be called on receive frames in listen state
7022 * Pointer to remain-on-channel expired fn
7023 * Priv
7024 * @return Error code.
7025 * @author
7026 * @date
7027 * @version 1.0
7028 */
Johnny Kim218dc402015-08-13 13:41:19 +09007029s32 host_int_remain_on_channel(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID, u32 u32duration, u16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007030{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007031 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007032 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7033 tstrHostIFmsg strHostIFmsg;
7034
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007035 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007036 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007037
7038 /* prepare the remainonchan Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007039 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007040
7041 /* prepare the WiphyParams Message */
7042 strHostIFmsg.u16MsgId = HOST_IF_MSG_REMAIN_ON_CHAN;
7043 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u16Channel = chan;
7044 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanExpired = RemainOnChanExpired;
7045 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanReady = RemainOnChanReady;
7046 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pVoid = pvUserArg;
7047 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32duration = u32duration;
7048 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
7049 strHostIFmsg.drvHandler = hWFIDrv;
7050
Chaehyun Lim79198132015-08-19 15:59:06 +09007051 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007052 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007053 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007054 WILC_CATCH(s32Error)
7055 {
7056
7057 }
7058
7059 return s32Error;
7060}
7061
7062/**
7063 * @brief host_int_ListenStateExpired
7064 * @details
7065 * @param[in] Handle to wifi driver
7066 * Duration to remain on channel
7067 * Channel to remain on
7068 * Pointer to fn to be called on receive frames in listen state
7069 * Pointer to remain-on-channel expired fn
7070 * Priv
7071 * @return Error code.
7072 * @author
7073 * @date
7074 * @version 1.0
7075 */
Johnny Kim218dc402015-08-13 13:41:19 +09007076s32 host_int_ListenStateExpired(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007077{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007078 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007079 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7080 tstrHostIFmsg strHostIFmsg;
7081
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007082 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007083 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007084
7085 /*Stopping remain-on-channel timer*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07007086 del_timer(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007087
7088 /* prepare the timer fire Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007089 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007090 strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
7091 strHostIFmsg.drvHandler = hWFIDrv;
7092 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
7093
Chaehyun Lim79198132015-08-19 15:59:06 +09007094 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007095 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007096 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007097 WILC_CATCH(s32Error)
7098 {
7099
7100 }
7101 return s32Error;
7102}
7103
7104/**
7105 * @brief host_int_frame_register
7106 * @details
7107 * @param[in] Handle to wifi driver
7108 * @return Error code.
7109 * @author
7110 * @date
7111 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09007112s32 host_int_frame_register(tstrWILC_WFIDrv *hWFIDrv, u16 u16FrameType, bool bReg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007113{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007114 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007115 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7116 tstrHostIFmsg strHostIFmsg;
7117
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007118 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007119 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007120
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007121 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007122
7123 /* prepare the WiphyParams Message */
7124 strHostIFmsg.u16MsgId = HOST_IF_MSG_REGISTER_FRAME;
7125 switch (u16FrameType) {
7126 case ACTION:
7127 PRINT_D(HOSTINF_DBG, "ACTION\n");
7128 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = ACTION_FRM_IDX;
7129 break;
7130
7131 case PROBE_REQ:
7132 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
7133 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = PROBE_REQ_IDX;
7134 break;
7135
7136 default:
7137 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
7138 break;
7139 }
7140 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u16FrameType = u16FrameType;
7141 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.bReg = bReg;
7142 strHostIFmsg.drvHandler = hWFIDrv;
7143
Chaehyun Lim79198132015-08-19 15:59:06 +09007144 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007145 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007146 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007147 WILC_CATCH(s32Error)
7148 {
7149
7150 }
7151
7152 return s32Error;
7153
7154
7155}
7156#endif
7157
7158#ifdef WILC_AP_EXTERNAL_MLME
7159/**
7160 * @brief host_int_add_beacon
7161 * @details Setting add beacon params in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09007162 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
7163 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
7164 * u32 u32TailLen, u8* pu8Tail
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007165 * @return Error code.
7166 * @author
7167 * @date
7168 * @version 1.0
7169 */
Johnny Kim218dc402015-08-13 13:41:19 +09007170s32 host_int_add_beacon(tstrWILC_WFIDrv *hWFIDrv, u32 u32Interval,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09007171 u32 u32DTIMPeriod,
7172 u32 u32HeadLen, u8 *pu8Head,
7173 u32 u32TailLen, u8 *pu8Tail)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007174{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007175 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007176 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7177 tstrHostIFmsg strHostIFmsg;
7178 tstrHostIFSetBeacon *pstrSetBeaconParam = &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon;
7179
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007180 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007181 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007182
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007183 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007184
7185 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
7186
7187
7188 /* prepare the WiphyParams Message */
7189 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BEACON;
7190 strHostIFmsg.drvHandler = hWFIDrv;
7191 pstrSetBeaconParam->u32Interval = u32Interval;
7192 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
7193 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
Chaehyun Limdc0ad742015-08-17 11:05:12 +09007194 pstrSetBeaconParam->pu8Head = WILC_MALLOC(u32HeadLen);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007195 if (pstrSetBeaconParam->pu8Head == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007196 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007197 memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007198 pstrSetBeaconParam->u32TailLen = u32TailLen;
7199
7200 /* Bug 4599 : if tail length = 0 skip allocating & copying */
7201 if (u32TailLen > 0) {
Chaehyun Limdc0ad742015-08-17 11:05:12 +09007202 pstrSetBeaconParam->pu8Tail = WILC_MALLOC(u32TailLen);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007203 if (pstrSetBeaconParam->pu8Tail == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007204 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007205 memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007206 } else {
7207 pstrSetBeaconParam->pu8Tail = NULL;
7208 }
7209
Chaehyun Lim79198132015-08-19 15:59:06 +09007210 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007211 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007212 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007213
7214 WILC_CATCH(s32Error)
7215 {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007216 if (pstrSetBeaconParam->pu8Head != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09007217 kfree(pstrSetBeaconParam->pu8Head);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007218
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007219 if (pstrSetBeaconParam->pu8Tail != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09007220 kfree(pstrSetBeaconParam->pu8Tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007221 }
7222
7223 return s32Error;
7224
7225}
7226
7227
7228/**
7229 * @brief host_int_del_beacon
7230 * @details Setting add beacon params in message queue
7231 * @param[in] WILC_WFIDrvHandle hWFIDrv
7232 * @return Error code.
7233 * @author
7234 * @date
7235 * @version 1.0
7236 */
Johnny Kim218dc402015-08-13 13:41:19 +09007237s32 host_int_del_beacon(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007238{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007239 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007240 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7241 tstrHostIFmsg strHostIFmsg;
7242
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007243 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007244 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007245
7246 /* prepare the WiphyParams Message */
7247 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BEACON;
7248 strHostIFmsg.drvHandler = hWFIDrv;
7249 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
7250
Chaehyun Lim79198132015-08-19 15:59:06 +09007251 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007252 WILC_ERRORCHECK(s32Error);
7253
7254 WILC_CATCH(s32Error)
7255 {
7256 }
7257 return s32Error;
7258}
7259
7260
7261/**
7262 * @brief host_int_add_station
7263 * @details Setting add station params in message queue
7264 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7265 * @return Error code.
7266 * @author
7267 * @date
7268 * @version 1.0
7269 */
Johnny Kim218dc402015-08-13 13:41:19 +09007270s32 host_int_add_station(tstrWILC_WFIDrv *hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007271{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007272 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007273 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7274 tstrHostIFmsg strHostIFmsg;
7275 tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
7276
7277
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007278 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007279 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007280
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007281 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007282
7283 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
7284
7285
7286 /* prepare the WiphyParams Message */
7287 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_STATION;
7288 strHostIFmsg.drvHandler = hWFIDrv;
7289
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007290 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007291 if (pstrAddStationMsg->u8NumRates > 0) {
Arnd Bergmann057d1e92015-06-01 21:06:44 +02007292 u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02007293
Arnd Bergmann057d1e92015-06-01 21:06:44 +02007294 WILC_NULLCHECK(s32Error, rates);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007295
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007296 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02007297 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007298 }
7299
7300
Chaehyun Lim79198132015-08-19 15:59:06 +09007301 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007302 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007303 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007304
7305 WILC_CATCH(s32Error)
7306 {
7307 }
7308 return s32Error;
7309}
7310
7311/**
7312 * @brief host_int_del_station
7313 * @details Setting delete station params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007314 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007315 * @return Error code.
7316 * @author
7317 * @date
7318 * @version 1.0
7319 */
Johnny Kim218dc402015-08-13 13:41:19 +09007320s32 host_int_del_station(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8MacAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007321{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007322 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007323 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7324 tstrHostIFmsg strHostIFmsg;
7325 tstrHostIFDelSta *pstrDelStationMsg = &strHostIFmsg.uniHostIFmsgBody.strDelStaParam;
7326
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007327 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007328 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007329
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007330 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007331
7332 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
7333
7334
7335
7336 /* prepare the WiphyParams Message */
7337 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_STATION;
7338 strHostIFmsg.drvHandler = hWFIDrv;
7339
7340 /*BugID_4795: Handling situation of deleting all stations*/
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09007341 if (pu8MacAddr == NULL)
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007342 memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007343 else
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007344 memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007345
Chaehyun Lim79198132015-08-19 15:59:06 +09007346 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007347 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007348 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007349
7350 WILC_CATCH(s32Error)
7351 {
7352 }
7353 return s32Error;
7354}
7355/**
7356 * @brief host_int_del_allstation
7357 * @details Setting del station params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007358 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007359 * @return Error code.
7360 * @author
7361 * @date
7362 * @version 1.0
7363 */
Johnny Kim218dc402015-08-13 13:41:19 +09007364s32 host_int_del_allstation(tstrWILC_WFIDrv *hWFIDrv, u8 pu8MacAddr[][ETH_ALEN])
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007365{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007366 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007367 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7368 tstrHostIFmsg strHostIFmsg;
7369 tstrHostIFDelAllSta *pstrDelAllStationMsg = &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007370 u8 au8Zero_Buff[ETH_ALEN] = {0};
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09007371 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007372 u8 u8AssocNumb = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007373
7374
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007375 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007376 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007377
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007378 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007379
7380 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
7381
7382 /* prepare the WiphyParams Message */
7383 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_STA;
7384 strHostIFmsg.drvHandler = hWFIDrv;
7385
7386 /* Handling situation of deauthenticing all associated stations*/
7387 for (i = 0; i < MAX_NUM_STA; i++) {
7388 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007389 memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007390 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", pstrDelAllStationMsg->au8Sta_DelAllSta[i][0], pstrDelAllStationMsg->au8Sta_DelAllSta[i][1], pstrDelAllStationMsg->au8Sta_DelAllSta[i][2], pstrDelAllStationMsg->au8Sta_DelAllSta[i][3], pstrDelAllStationMsg->au8Sta_DelAllSta[i][4],
7391 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
7392 u8AssocNumb++;
7393 }
7394 }
7395 if (!u8AssocNumb) {
7396 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
7397 return s32Error;
7398 }
7399
7400 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
Chaehyun Lim79198132015-08-19 15:59:06 +09007401 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007402
7403
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007404 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007405 WILC_ERRORREPORT(s32Error, s32Error);
7406
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007407 WILC_CATCH(s32Error)
7408 {
7409
7410 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02007411 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007412
7413 return s32Error;
7414
7415}
7416
7417/**
7418 * @brief host_int_edit_station
7419 * @details Setting edit station params in message queue
7420 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7421 * @return Error code.
7422 * @author
7423 * @date
7424 * @version 1.0
7425 */
Johnny Kim218dc402015-08-13 13:41:19 +09007426s32 host_int_edit_station(tstrWILC_WFIDrv *hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007427{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007428 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007429 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7430 tstrHostIFmsg strHostIFmsg;
7431 tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
7432
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007433 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007434 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007435
7436 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
7437
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007438 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007439
7440
7441 /* prepare the WiphyParams Message */
7442 strHostIFmsg.u16MsgId = HOST_IF_MSG_EDIT_STATION;
7443 strHostIFmsg.drvHandler = hWFIDrv;
7444
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007445 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007446 if (pstrAddStationMsg->u8NumRates > 0) {
Arnd Bergmann057d1e92015-06-01 21:06:44 +02007447 u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02007448
Arnd Bergmann057d1e92015-06-01 21:06:44 +02007449 WILC_NULLCHECK(s32Error, rates);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007450 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02007451 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007452 }
7453
Chaehyun Lim79198132015-08-19 15:59:06 +09007454 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007455 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007456 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007457 WILC_CATCH(s32Error)
7458 {
7459 }
7460 return s32Error;
7461}
7462#endif /*WILC_AP_EXTERNAL_MLME*/
7463uint32_t wilc_get_chipid(uint8_t);
7464
Johnny Kim218dc402015-08-13 13:41:19 +09007465s32 host_int_set_power_mgmt(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32Timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007466{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007467 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007468 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7469 tstrHostIFmsg strHostIFmsg;
7470 tstrHostIfPowerMgmtParam *pstrPowerMgmtParam = &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam;
7471
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007472 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007473
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007474 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007475 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007476
7477 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
7478
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007479 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007480
7481
7482 /* prepare the WiphyParams Message */
7483 strHostIFmsg.u16MsgId = HOST_IF_MSG_POWER_MGMT;
7484 strHostIFmsg.drvHandler = hWFIDrv;
7485
7486 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
7487 pstrPowerMgmtParam->u32Timeout = u32Timeout;
7488
7489
Chaehyun Lim79198132015-08-19 15:59:06 +09007490 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007491 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007492 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007493 WILC_CATCH(s32Error)
7494 {
7495 }
7496 return s32Error;
7497}
7498
Johnny Kim218dc402015-08-13 13:41:19 +09007499s32 host_int_setup_multicast_filter(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32count)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007500{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007501 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007502
7503 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7504 tstrHostIFmsg strHostIFmsg;
7505 tstrHostIFSetMulti *pstrMulticastFilterParam = &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti;
7506
7507
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007508 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007509 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007510
7511 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
7512
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007513 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007514
7515
7516 /* prepare the WiphyParams Message */
7517 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MULTICAST_FILTER;
7518 strHostIFmsg.drvHandler = hWFIDrv;
7519
7520 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
7521 pstrMulticastFilterParam->u32count = u32count;
7522
Chaehyun Lim79198132015-08-19 15:59:06 +09007523 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007524 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007525 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007526 WILC_CATCH(s32Error)
7527 {
7528 }
7529 return s32Error;
7530}
7531
7532
7533
7534/*Bug4218: Parsing Join Param*/
7535#ifdef WILC_PARSE_SCAN_IN_HOST
7536
7537/*Bug4218: Parsing Join Param*/
7538/**
7539 * @brief host_int_ParseJoinBssParam
7540 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
7541 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7542 * @return
7543 * @author zsalah
7544 * @date
7545 * @version 1.0**/
7546static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
7547{
7548 tstrJoinBssParam *pNewJoinBssParam = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007549 u8 *pu8IEs;
Chaehyun Limd85f5322015-06-11 14:35:54 +09007550 u16 u16IEsLen;
7551 u16 index = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007552 u8 suppRatesNo = 0;
7553 u8 extSuppRatesNo;
Chaehyun Limd85f5322015-06-11 14:35:54 +09007554 u16 jumpOffset;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007555 u8 pcipherCount;
7556 u8 authCount;
7557 u8 pcipherTotalCount = 0;
7558 u8 authTotalCount = 0;
7559 u8 i, j;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007560
7561 pu8IEs = ptstrNetworkInfo->pu8IEs;
7562 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
7563
7564 pNewJoinBssParam = WILC_MALLOC(sizeof(tstrJoinBssParam));
7565 if (pNewJoinBssParam != NULL) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007566 memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007567 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
7568 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
7569 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007570 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007571 /*for(i=0; i<6;i++)
7572 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007573 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007574 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007575 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
7576 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007577 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
7578 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
7579
7580 /* parse supported rates: */
7581 while (index < u16IEsLen) {
7582 /* supportedRates IE */
7583 if (pu8IEs[index] == SUPP_RATES_IE) {
7584 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
7585 suppRatesNo = pu8IEs[index + 1];
7586 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
7587 index += 2; /* skipping ID and length bytes; */
7588
7589 for (i = 0; i < suppRatesNo; i++) {
7590 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
7591 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
7592 }
7593 index += suppRatesNo;
7594 continue;
7595 }
7596 /* Ext SupportedRates IE */
7597 else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
7598 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
7599 /* checking if no of ext. supp and supp rates < max limit */
7600 extSuppRatesNo = pu8IEs[index + 1];
7601 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
7602 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
7603 else
7604 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
7605 index += 2;
7606 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
7607 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
7608 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
7609 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
7610 }
7611 index += extSuppRatesNo;
7612 continue;
7613 }
7614 /* HT Cap. IE */
7615 else if (pu8IEs[index] == HT_CAPABILITY_IE) {
7616 /* if IE found set the flag */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09007617 pNewJoinBssParam->ht_capable = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007618 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7619 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
7620 continue;
7621 } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
7622 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
7623 (pu8IEs[index + 4] == 0xF2) && /* OUI */
7624 (pu8IEs[index + 5] == 0x02) && /* OUI Type */
7625 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
7626 (pu8IEs[index + 7] == 0x01)) {
7627 /* Presence of WMM Info/Param element indicates WMM capability */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09007628 pNewJoinBssParam->wmm_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007629
7630 /* Check if Bit 7 is set indicating U-APSD capability */
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007631 if (pu8IEs[index + 8] & (1 << 7))
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09007632 pNewJoinBssParam->uapsd_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007633 index += pu8IEs[index + 1] + 2;
7634 continue;
7635 }
7636 #ifdef WILC_P2P
7637 else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
7638 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
7639 (pu8IEs[index + 4] == 0x9a) && /* OUI */
7640 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
Chaehyun Limd85f5322015-06-11 14:35:54 +09007641 u16 u16P2P_count;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02007642
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007643 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
7644 pNewJoinBssParam->u8NoaEnbaled = 1;
7645 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
7646
7647 /* Check if Bit 7 is set indicating Opss capability */
7648 if (pu8IEs[index + 10] & (1 << 7)) {
7649 pNewJoinBssParam->u8OppEnable = 1;
7650 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
7651 } else
7652 pNewJoinBssParam->u8OppEnable = 0;
7653 /* HOSTINF_DBG */
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007654 PRINT_D(GENERIC_DBG, "P2P Dump\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007655 for (i = 0; i < pu8IEs[index + 7]; i++)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007656 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007657
7658 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
7659 u16P2P_count = index + 12;
7660
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007661 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007662 u16P2P_count += 4;
7663
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007664 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007665 u16P2P_count += 4;
7666
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007667 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007668
7669 index += pu8IEs[index + 1] + 2;
7670 continue;
7671
7672 }
7673 #endif
7674 else if ((pu8IEs[index] == RSN_IE) ||
7675 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
7676 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
7677 (pu8IEs[index + 5] == 0x01))) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09007678 u16 rsnIndex = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007679 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
7680 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
7681 * {
7682 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
7683 * }*/
7684 if (pu8IEs[rsnIndex] == RSN_IE) {
7685 pNewJoinBssParam->mode_802_11i = 2;
7686 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
7687 } else { /* check if rsn was previously parsed */
7688 if (pNewJoinBssParam->mode_802_11i == 0)
7689 pNewJoinBssParam->mode_802_11i = 1;
7690 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
7691 rsnIndex += 4;
7692 }
7693 rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
7694 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
7695 rsnIndex++;
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007696 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007697 /* initialize policies with invalid values */
7698
7699 jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
7700
7701 /*parsing pairwise cipher*/
7702
7703 /* saving 3 pcipher max. */
7704 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7705 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7706
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007707 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007708 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
7709 /* each count corresponds to 4 bytes, only last byte is saved */
7710 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7711 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
7712 }
7713 pcipherTotalCount += pcipherCount;
7714 rsnIndex += jumpOffset;
7715
7716 jumpOffset = pu8IEs[rsnIndex] * 4;
7717
7718 /*parsing AKM suite (auth_policy)*/
7719 /* saving 3 auth policies max. */
7720 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7721 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7722
7723 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
7724 /* each count corresponds to 4 bytes, only last byte is saved */
7725 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7726 }
7727 authTotalCount += authCount;
7728 rsnIndex += jumpOffset;
7729 /*pasring rsn cap. only if rsn IE*/
7730 if (pu8IEs[index] == RSN_IE) {
7731 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
7732 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
7733 rsnIndex += 2;
7734 }
Abdul Hussainf717c0eb2015-06-16 09:49:49 +00007735 pNewJoinBssParam->rsn_found = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007736 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7737 continue;
7738 } else
7739 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7740
7741 }
7742
7743
7744 }
7745
7746 return (void *)pNewJoinBssParam;
7747
7748}
7749
7750void host_int_freeJoinParams(void *pJoinParams)
7751{
7752 if ((tstrJoinBssParam *)pJoinParams != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09007753 kfree((tstrJoinBssParam *)pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007754 else
7755 PRINT_ER("Unable to FREE null pointer\n");
7756}
7757#endif /*WILC_PARSE_SCAN_IN_HOST*/
7758
7759
7760/**
7761 * @brief host_int_addBASession
7762 * @details Open a block Ack session with the given parameters
7763 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7764 * @return
7765 * @author anoureldin
7766 * @date
7767 * @version 1.0**/
7768
Johnny Kim2b05df52015-08-13 13:41:21 +09007769static int host_int_addBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID, short int BufferSize,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007770 short int SessionTimeout, void *drvHandler)
7771{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007772 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007773 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7774 tstrHostIFmsg strHostIFmsg;
7775 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7776
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007777 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007778 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007779
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007780 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007781
7782 /* prepare the WiphyParams Message */
7783 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BA_SESSION;
7784
7785 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7786 pBASessionInfo->u8Ted = TID;
7787 pBASessionInfo->u16BufferSize = BufferSize;
7788 pBASessionInfo->u16SessionTimeout = SessionTimeout;
7789 strHostIFmsg.drvHandler = hWFIDrv;
7790
Chaehyun Lim79198132015-08-19 15:59:06 +09007791 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007792 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007793 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007794 WILC_CATCH(s32Error)
7795 {
7796
7797 }
7798
7799 return s32Error;
7800}
7801
7802
Johnny Kim218dc402015-08-13 13:41:19 +09007803s32 host_int_delBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007804{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007805 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007806 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7807 tstrHostIFmsg strHostIFmsg;
7808 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7809
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007810 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007811 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007812
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007813 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007814
7815 /* prepare the WiphyParams Message */
7816 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BA_SESSION;
7817
7818 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7819 pBASessionInfo->u8Ted = TID;
7820 strHostIFmsg.drvHandler = hWFIDrv;
7821
Chaehyun Lim79198132015-08-19 15:59:06 +09007822 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007823 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007824 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007825 WILC_CATCH(s32Error)
7826 {
7827
7828 }
7829
7830 /*BugID_5222*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02007831 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007832
7833 return s32Error;
7834}
7835
Johnny Kim218dc402015-08-13 13:41:19 +09007836s32 host_int_del_All_Rx_BASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007837{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007838 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007839 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7840 tstrHostIFmsg strHostIFmsg;
7841 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7842
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007843 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007844 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007845
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007846 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007847
7848 /* prepare the WiphyParams Message */
7849 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
7850
7851 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7852 pBASessionInfo->u8Ted = TID;
7853 strHostIFmsg.drvHandler = hWFIDrv;
7854
Chaehyun Lim79198132015-08-19 15:59:06 +09007855 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007856 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007857 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007858 WILC_CATCH(s32Error)
7859 {
7860
7861 }
7862
7863 /*BugID_5222*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02007864 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007865
7866 return s32Error;
7867}
7868
7869/**
7870 * @brief host_int_setup_ipaddress
7871 * @details setup IP in firmware
7872 * @param[in] Handle to wifi driver
7873 * @return Error code.
7874 * @author Abdelrahman Sobhy
7875 * @date
7876 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09007877s32 host_int_setup_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007878{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007879 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007880 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7881 tstrHostIFmsg strHostIFmsg;
7882
7883 /* TODO: Enable This feature on softap firmware */
7884 return 0;
7885
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007886 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007887 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007888
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007889 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007890
7891 /* prepare the WiphyParams Message */
7892 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_IPADDRESS;
7893
7894 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
7895 strHostIFmsg.drvHandler = hWFIDrv;
7896 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
7897
Chaehyun Lim79198132015-08-19 15:59:06 +09007898 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007899 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007900 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007901 WILC_CATCH(s32Error)
7902 {
7903
7904 }
7905
7906 return s32Error;
7907
7908
7909}
7910
7911/**
7912 * @brief host_int_get_ipaddress
7913 * @details Get IP from firmware
7914 * @param[in] Handle to wifi driver
7915 * @return Error code.
7916 * @author Abdelrahman Sobhy
7917 * @date
7918 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09007919s32 host_int_get_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007920{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007921 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007922 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7923 tstrHostIFmsg strHostIFmsg;
7924
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007925 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007926 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007927
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007928 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007929
7930 /* prepare the WiphyParams Message */
7931 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_IPADDRESS;
7932
7933 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
Sunil Shahubf903c12015-06-22 19:23:01 +05307934 strHostIFmsg.drvHandler = hWFIDrv;
7935 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007936
Chaehyun Lim79198132015-08-19 15:59:06 +09007937 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007938 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007939 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007940 WILC_CATCH(s32Error)
7941 {
7942
7943 }
7944
7945 return s32Error;
7946
7947
7948}