blob: 8ed1aaf3e71ac08eb423d351606dc0e310f27b9c [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
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004extern u8 connecting;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005
6#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -07007extern struct timer_list hDuringIpTimer;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09008#endif
9
Johnny Kimc5c77ba2015-05-11 14:30:56 +090010/*BugID_5137*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090011extern u8 g_wilc_initialized;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090012/*****************************************************************************/
13/* Macros */
14/*****************************************************************************/
15
16/* Message types of the Host IF Message Queue*/
Chaehyun Lim9eac3a12015-06-18 22:08:51 +090017#define HOST_IF_MSG_SCAN 0
18#define HOST_IF_MSG_CONNECT 1
19#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
20#define HOST_IF_MSG_KEY 3
21#define HOST_IF_MSG_RCVD_NTWRK_INFO 4
22#define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
23#define HOST_IF_MSG_CFG_PARAMS 6
24#define HOST_IF_MSG_SET_CHANNEL 7
25#define HOST_IF_MSG_DISCONNECT 8
26#define HOST_IF_MSG_GET_RSSI 9
27#define HOST_IF_MSG_GET_CHNL 10
28#define HOST_IF_MSG_ADD_BEACON 11
29#define HOST_IF_MSG_DEL_BEACON 12
30#define HOST_IF_MSG_ADD_STATION 13
31#define HOST_IF_MSG_DEL_STATION 14
32#define HOST_IF_MSG_EDIT_STATION 15
33#define HOST_IF_MSG_SCAN_TIMER_FIRED 16
34#define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
35#define HOST_IF_MSG_POWER_MGMT 18
36#define HOST_IF_MSG_GET_INACTIVETIME 19
37#define HOST_IF_MSG_REMAIN_ON_CHAN 20
38#define HOST_IF_MSG_REGISTER_FRAME 21
39#define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
40#define HOST_IF_MSG_GET_LINKSPEED 23
41#define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
42#define HOST_IF_MSG_SET_MAC_ADDRESS 25
43#define HOST_IF_MSG_GET_MAC_ADDRESS 26
44#define HOST_IF_MSG_SET_OPERATION_MODE 27
45#define HOST_IF_MSG_SET_IPADDRESS 28
46#define HOST_IF_MSG_GET_IPADDRESS 29
47#define HOST_IF_MSG_FLUSH_CONNECT 30
48#define HOST_IF_MSG_GET_STATISTICS 31
49#define HOST_IF_MSG_SET_MULTICAST_FILTER 32
50#define HOST_IF_MSG_ADD_BA_SESSION 33
51#define HOST_IF_MSG_DEL_BA_SESSION 34
52#define HOST_IF_MSG_Q_IDLE 35
53#define HOST_IF_MSG_DEL_ALL_STA 36
54#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
55#define HOST_IF_MSG_EXIT 100
Johnny Kimc5c77ba2015-05-11 14:30:56 +090056
Chaehyun Lime54d5b72015-06-18 22:08:50 +090057#define HOST_IF_SCAN_TIMEOUT 4000
58#define HOST_IF_CONNECT_TIMEOUT 9500
Johnny Kimc5c77ba2015-05-11 14:30:56 +090059
Chaehyun Lime54d5b72015-06-18 22:08:50 +090060#define BA_SESSION_DEFAULT_BUFFER_SIZE 16
61#define BA_SESSION_DEFAULT_TIMEOUT 1000
62#define BLOCK_ACK_REQ_SIZE 0x14
Johnny Kimc5c77ba2015-05-11 14:30:56 +090063/*****************************************************************************/
64/* Type Definitions */
65/*****************************************************************************/
66
67/*!
68 * @struct tstrHostIFCfgParamAttr
69 * @brief Structure to hold Host IF CFG Params Attributes
70 * @details
71 * @todo
72 * @sa
73 * @author Mai Daftedar
74 * @date 02 April 2012
75 * @version 1.0
76 */
77typedef struct _tstrHostIFCfgParamAttr {
78 tstrCfgParamVal pstrCfgParamVal;
79
80} tstrHostIFCfgParamAttr;
81
82/*!
83 * @struct tstrHostIFwpaAttr
84 * @brief Structure to hold Host IF Scan Attributes
85 * @details
86 * @todo
87 * @sa
88 * @author Mai Daftedar
89 * @date 25 March 2012
90 * @version 1.0
91 */
92typedef struct _tstrHostIFwpaAttr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090093 u8 *pu8key;
94 const u8 *pu8macaddr;
95 u8 *pu8seq;
96 u8 u8seqlen;
97 u8 u8keyidx;
98 u8 u8Keylen;
99 u8 u8Ciphermode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900100} tstrHostIFwpaAttr;
101
102
103/*!
104 * @struct tstrHostIFwepAttr
105 * @brief Structure to hold Host IF Scan Attributes
106 * @details
107 * @todo
108 * @sa
109 * @author Mai Daftedar
110 * @date 25 March 2012
111 * @version 1.0
112 */
113typedef struct _tstrHostIFwepAttr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900114 u8 *pu8WepKey;
115 u8 u8WepKeylen;
116 u8 u8Wepidx;
117 u8 u8mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900118 AUTHTYPE_T tenuAuth_type;
119
120} tstrHostIFwepAttr;
121
122/*!
123 * @struct tuniHostIFkeyAttr
124 * @brief Structure to hold Host IF Scan Attributes
125 * @details
126 * @todo
127 * @sa
128 * @author Mai Daftedar
129 * @date 25 March 2012
130 * @version 1.0
131 */
132typedef union _tuniHostIFkeyAttr {
133 tstrHostIFwepAttr strHostIFwepAttr;
134 tstrHostIFwpaAttr strHostIFwpaAttr;
135 tstrHostIFpmkidAttr strHostIFpmkidAttr;
136} tuniHostIFkeyAttr;
137
138/*!
139 * @struct tstrHostIFkeyAttr
140 * @brief Structure to hold Host IF Scan Attributes
141 * @details
142 * @todo
143 * @sa
144 * @author Mai Daftedar
145 * @date 25 March 2012
146 * @version 1.0
147 */
148typedef struct _tstrHostIFkeyAttr {
149 tenuKeyType enuKeyType;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900150 u8 u8KeyAction;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900151 tuniHostIFkeyAttr uniHostIFkeyAttr;
152} tstrHostIFkeyAttr;
153
154
155
156
157/*!
158 * @struct tstrHostIFscanAttr
159 * @brief Structure to hold Host IF Scan Attributes
160 * @details
161 * @todo
162 * @sa
163 * @author Mostafa Abu Bakr
164 * @date 25 March 2012
165 * @version 1.0
166 */
167typedef struct _tstrHostIFscanAttr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900168 u8 u8ScanSource;
169 u8 u8ScanType;
170 u8 *pu8ChnlFreqList;
171 u8 u8ChnlListLen;
172 u8 *pu8IEs;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900173 size_t IEsLen;
174 tWILCpfScanResult pfScanResult;
175 void *pvUserArg;
176 /*BugID_4189*/
177 tstrHiddenNetwork strHiddenNetwork;
178
179} tstrHostIFscanAttr;
180
181/*!
182 * @struct tstrHostIFconnectAttr
183 * @brief Structure to hold Host IF Connect Attributes
184 * @details
185 * @todo
186 * @sa
187 * @author Mostafa Abu Bakr
188 * @date 25 March 2012
189 * @version 1.0
190 */
191typedef struct _tstrHostIFconnectAttr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900192 u8 *pu8bssid;
193 u8 *pu8ssid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900194 size_t ssidLen;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900195 u8 *pu8IEs;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900196 size_t IEsLen;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900197 u8 u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900198 tWILCpfConnectResult pfConnectResult;
199 void *pvUserArg;
200 AUTHTYPE_T tenuAuth_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900201 u8 u8channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900202 void *pJoinParams;
203} tstrHostIFconnectAttr;
204
205/*!
206 * @struct tstrRcvdGnrlAsyncInfo
207 * @brief Structure to hold Received General Asynchronous info
208 * @details
209 * @todo
210 * @sa
211 * @author Mostafa Abu Bakr
212 * @date 25 March 2012
213 * @version 1.0
214 */
215typedef struct _tstrRcvdGnrlAsyncInfo {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900216 u8 *pu8Buffer;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900217 u32 u32Length;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900218} tstrRcvdGnrlAsyncInfo;
219
220/*!
221 * @struct tstrHostIFSetChan
222 * @brief Set Channel message body
223 * @details
224 * @todo
225 * @sa
226 * @author Mai Daftedar
227 * @date 25 March 2012
228 * @version 1.0
229 */
230typedef struct _tstrHostIFSetChan {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900231 u8 u8SetChan;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900232} tstrHostIFSetChan;
233
234/*!
235 * @struct tstrHostIFSetChan
236 * @brief Get Channel message body
237 * @details
238 * @todo
239 * @sa
240 * @author Mai Daftedar
241 * @date 01 Jule 2012
242 * @version 1.0
243 */
244typedef struct _tstrHostIFGetChan {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900245 u8 u8GetChan;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900246} tstrHostIFGetChan;
247
248/*bug3819: Add Scan acomplete notification to host*/
249/*!
250 * @struct tstrScanComplete
251 * @brief hold received Async. Scan Complete message body
252 * @details
253 * @todo
254 * @sa
255 * @author zsalah
256 * @date 25 March 2012
257 * @version 1.0
258 */
259/*typedef struct _tstrScanComplete
260 * {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900261 * u8* pu8Buffer;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900262 * u32 u32Length;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900263 * } tstrScanComplete;*/
264
265/*!
266 * @struct tstrHostIFSetBeacon
267 * @brief Set Beacon message body
268 * @details
269 * @todo
270 * @sa
271 * @author Adham Abozaeid
272 * @date 10 July 2012
273 * @version 1.0
274 */
275typedef struct _tstrHostIFSetBeacon {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900276 u32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */
277 u32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900278 * (including the current frame) appear before the next DTIM */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900279 u32 u32HeadLen; /*!< Length of the head buffer in bytes */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900280 u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900281 * from the beacon's start till the TIM element, NOT including the TIM */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900282 u32 u32TailLen; /*!< Length of the tail buffer in bytes */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900283 u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900284 * after the TIM inormation element */
285} tstrHostIFSetBeacon;
286
287
288
289/*!
290 * @struct tstrHostIFDelBeacon
291 * @brief Del Beacon message body
292 * @details
293 * @todo
294 * @sa
295 * @author Adham Abozaeid
296 * @date 15 July 2012
297 * @version 1.0
298 */
299typedef struct _tstrHostIFDelBeacon {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900300 u8 u8dummy;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900301} tstrHostIFDelBeacon;
302
303/*!
304 * @struct tstrHostIFSetMulti
305 * @brief set Multicast filter Address
306 * @details
307 * @todo
308 * @sa
309 * @author Abdelrahman Sobhy
310 * @date 30 August 2013
311 * @version 1.0 Description
312 */
313
314typedef struct {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900315 bool bIsEnabled;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900316 u32 u32count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900317} tstrHostIFSetMulti;
318
319/*!
320 * @struct tstrHostIFDelAllSta
321 * @brief Deauth station message body
322 * @details
323 * @todo
324 * @sa
325 * @author Mai Daftedar
326 * @date 09 April 2014
327 * @version 1.0 Description
328 */
329
330typedef struct {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900331 u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN];
332 u8 u8Num_AssocSta;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900333} tstrHostIFDelAllSta;
334
335/*!
336 * @struct tstrHostIFDelSta
337 * @brief Delete station message body
338 * @details
339 * @todo
340 * @sa
341 * @author Adham Abozaeid
342 * @date 15 July 2012
343 * @version 1.0 Description
344 */
345
346typedef struct {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900347 u8 au8MacAddr[ETH_ALEN];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900348} tstrHostIFDelSta;
349
350/*!
351 * @struct tstrTimerCb
352 * @brief Timer callback message body
353 * @details
354 * @todo
355 * @sa
356 * @author Mostafa Abu Bakr
357 * @date 25 March 2012
358 * @version 1.0
359 */
360typedef struct _tstrTimerCb {
361 void *pvUsrArg; /*!< Private data passed at timer start */
362} tstrTimerCb;
363
364/*!
365 * @struct tstrHostIfPowerMgmtParam
366 * @brief Power management message body
367 * @details
368 * @todo
369 * @sa
370 * @author Adham Abozaeid
371 * @date 24 November 2012
372 * @version 1.0
373 */
374typedef struct {
375
Dean Lee72ed4dc2015-06-12 14:11:44 +0900376 bool bIsEnabled;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900377 u32 u32Timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900378} tstrHostIfPowerMgmtParam;
379
380/*!
381 * @struct tstrHostIFSetIPAddr
382 * @brief set IP Address message body
383 * @details
384 * @todo
385 * @sa
386 * @author Abdelrahman Sobhy
387 * @date 30 August 2013
388 * @version 1.0 Description
389 */
390
391typedef struct {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900392 u8 *au8IPAddr;
393 u8 idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900394} tstrHostIFSetIPAddr;
395
396/*!
397 * @struct tstrHostIfStaInactiveT
398 * @brief Get station message body
399 * @details
400 * @todo
401 * @sa
402 * @author Mai Daftedar
403 * @date 16 April 2013
404 * @version 1.0
405 */
406typedef struct {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900407 u8 mac[6];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900408
409} tstrHostIfStaInactiveT;
410/**/
411/*!
412 * @union tuniHostIFmsgBody
413 * @brief Message body for the Host Interface message_q
414 * @details
415 * @todo
416 * @sa
417 * @author Mostafa Abu Bakr
418 * @date 25 March 2012
419 * @version 1.0
420 */
421typedef union _tuniHostIFmsgBody {
422 tstrHostIFscanAttr strHostIFscanAttr; /*!< Host IF Scan Request Attributes message body */
423 tstrHostIFconnectAttr strHostIFconnectAttr; /*!< Host IF Connect Request Attributes message body */
424 tstrRcvdNetworkInfo strRcvdNetworkInfo; /*!< Received Asynchronous Network Info message body */
425 tstrRcvdGnrlAsyncInfo strRcvdGnrlAsyncInfo; /*!< Received General Asynchronous Info message body */
426 tstrHostIFkeyAttr strHostIFkeyAttr; /*!<>*/
427 tstrHostIFCfgParamAttr strHostIFCfgParamAttr; /*! <CFG Parameter message Body> */
428 tstrHostIFSetChan strHostIFSetChan;
429 tstrHostIFGetChan strHostIFGetChan;
430 tstrHostIFSetBeacon strHostIFSetBeacon; /*!< Set beacon message body */
431 tstrHostIFDelBeacon strHostIFDelBeacon; /*!< Del beacon message body */
432 tstrWILC_AddStaParam strAddStaParam; /*!< Add station message body */
433 tstrHostIFDelSta strDelStaParam; /*!< Del Station message body */
434 tstrWILC_AddStaParam strEditStaParam; /*!< Edit station message body */
435 /* tstrScanComplete strScanComplete; / *Received Async. Scan Complete message body* / */
436 tstrTimerCb strTimerCb; /*!< Timer callback message body */
437 tstrHostIfPowerMgmtParam strPowerMgmtparam; /*!< Power Management message body */
438 tstrHostIfStaInactiveT strHostIfStaInactiveT;
439 tstrHostIFSetIPAddr strHostIfSetIP;
440 tstrHostIfSetDrvHandler strHostIfSetDrvHandler;
441 tstrHostIFSetMulti strHostIfSetMulti;
442 tstrHostIfSetOperationMode strHostIfSetOperationMode;
443 tstrHostIfSetMacAddress strHostIfSetMacAddress;
444 tstrHostIfGetMacAddress strHostIfGetMacAddress;
445 tstrHostIfBASessionInfo strHostIfBASessionInfo;
446 #ifdef WILC_P2P
447 tstrHostIfRemainOnChan strHostIfRemainOnChan;
448 tstrHostIfRegisterFrame strHostIfRegisterFrame;
449 #endif
Dean Lee576917a2015-06-15 11:58:57 +0900450 char *pUserData;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900451 tstrHostIFDelAllSta strHostIFDelAllSta;
452} tuniHostIFmsgBody;
453
454/*!
455 * @struct tstrHostIFmsg
456 * @brief Host Interface message
457 * @details
458 * @todo
459 * @sa
460 * @author Mostafa Abu Bakr
461 * @date 25 March 2012
462 * @version 1.0
463 */
464typedef struct _tstrHostIFmsg {
Chaehyun Limd85f5322015-06-11 14:35:54 +0900465 u16 u16MsgId; /*!< Message ID */
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900466 tuniHostIFmsgBody uniHostIFmsgBody; /*!< Message body */
Johnny Kim11f58c82015-08-13 13:41:20 +0900467 tstrWILC_WFIDrv *drvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900468} tstrHostIFmsg;
469
470#ifdef CONNECT_DIRECT
471typedef struct _tstrWidJoinReqExt {
Dean Lee576917a2015-06-15 11:58:57 +0900472 char SSID[MAX_SSID_LEN];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900473 u8 u8channel;
474 u8 BSSID[6];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900475} tstrWidJoinReqExt;
476#endif
477
478/*Bug4218: Parsing Join Param*/
479#ifdef WILC_PARSE_SCAN_IN_HOST
480/*Struct containg joinParam of each AP*/
481typedef struct _tstrJoinBssParam {
482 BSSTYPE_T bss_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900483 u8 dtim_period;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900484 u16 beacon_period;
485 u16 cap_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900486 u8 au8bssid[6];
Dean Lee576917a2015-06-15 11:58:57 +0900487 char ssid[MAX_SSID_LEN];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900488 u8 ssidLen;
489 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
490 u8 ht_capable;
491 u8 wmm_cap;
492 u8 uapsd_cap;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900493 bool rsn_found;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900494 u8 rsn_grp_policy;
495 u8 mode_802_11i;
496 u8 rsn_pcip_policy[3];
497 u8 rsn_auth_policy[3];
498 u8 rsn_cap[2];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900499 struct _tstrJoinParam *nextJoinBss;
500 #ifdef WILC_P2P
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900501 u32 tsf;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900502 u8 u8NoaEnbaled;
503 u8 u8OppEnable;
504 u8 u8CtWindow;
505 u8 u8Count;
506 u8 u8Index;
507 u8 au8Duration[4];
508 u8 au8Interval[4];
509 u8 au8StartTime[4];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900510 #endif
511} tstrJoinBssParam;
512/*Bug4218: Parsing Join Param*/
513/*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
514typedef struct _tstrBssTable {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900515 u8 u8noBssEntries;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900516 tstrJoinBssParam *head;
517 tstrJoinBssParam *tail;
518} tstrBssTable;
519#endif /*WILC_PARSE_SCAN_IN_HOST*/
520
521typedef enum {
522 SCAN_TIMER = 0,
523 CONNECT_TIMER = 1,
524 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
525} tenuScanConnTimer;
526
527/*****************************************************************************/
528/* */
529/* Global Variabls */
530/* */
531/*****************************************************************************/
Johnny Kimd42ab082015-08-20 16:32:52 +0900532/* Zero is not used, because a zero ID means termination */
533static tstrWILC_WFIDrv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
Daniel Machon6fdb3022015-07-06 19:48:04 +0200534tstrWILC_WFIDrv *terminated_handle;
535tstrWILC_WFIDrv *gWFiDrvHandle;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900536#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +0900537bool g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900538#endif
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900539u8 P2P_LISTEN_STATE;
Arnd Bergmann1999bd52015-05-29 22:52:14 +0200540static struct task_struct *HostIFthreadHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900541static WILC_MsgQueueHandle gMsgQHostIF;
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200542static struct semaphore hSemHostIFthrdEnd;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900543
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200544struct semaphore hSemDeinitDrvHandle;
545static struct semaphore hWaitResponse;
546struct semaphore hSemHostIntDeinit;
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -0700547struct timer_list g_hPeriodicRSSI;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900548
549
550
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900551u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900552
553#ifndef CONNECT_DIRECT
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900554static u8 gapu8RcvdSurveyResults[2][MAX_SURVEY_RESULT_FRAG_SIZE];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900555#endif
556
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900557static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900558
Dean Lee72ed4dc2015-06-12 14:11:44 +0900559bool gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900560
Chaehyun Limca356ad2015-06-11 14:35:57 +0900561static s8 gs8Rssi;
562static s8 gs8lnkspd;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900563static u8 gu8Chnl;
564static u8 gs8SetIP[2][4];
565static u8 gs8GetIP[2][4];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900566#ifdef WILC_AP_EXTERNAL_MLME
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900567static u32 gu32InactiveTime;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900568static u8 gu8DelBcn;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900569#endif
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900570static u32 gu32WidConnRstHack;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900571
572/*BugID_5137*/
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900573u8 *gu8FlushedJoinReq;
574u8 *gu8FlushedInfoElemAsoc;
575u8 gu8Flushed11iMode;
576u8 gu8FlushedAuthType;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900577u32 gu32FlushedJoinReqSize;
578u32 gu32FlushedInfoElemAsocSize;
Johnny Kim8a625ca2015-08-20 16:32:50 +0900579tstrWILC_WFIDrv *gu8FlushedJoinReqDrvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900580#define REAL_JOIN_REQ 0
581#define FLUSHED_JOIN_REQ 1
582#define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
583
584/*Bug4218: Parsing Join Param*/
585#ifdef WILC_PARSE_SCAN_IN_HOST
586/*Bug4218: Parsing Join Param*/
587static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
588#endif /*WILC_PARSE_SCAN_IN_HOST*/
589
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900590extern void chip_sleep_manually(u32 u32SleepTime);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900591extern int linux_wlan_get_num_conn_ifcs(void);
592
Johnny Kimd42ab082015-08-20 16:32:52 +0900593static int add_handler_in_list(tstrWILC_WFIDrv *handler)
594{
595 int i;
596
597 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
598 if (!wfidrv_list[i]) {
599 wfidrv_list[i] = handler;
600 return 0;
601 }
602 }
603
604 return -ENOBUFS;
605}
606
607static int remove_handler_in_list(tstrWILC_WFIDrv *handler)
608{
609 int i;
610
611 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
612 if (wfidrv_list[i] == handler) {
613 wfidrv_list[i] = NULL;
614 return 0;
615 }
616 }
617
618 return -EINVAL;
619}
620
621static int get_id_from_handler(tstrWILC_WFIDrv *handler)
622{
623 int i;
624
625 if (!handler)
626 return 0;
627
628 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
629 if (wfidrv_list[i] == handler)
630 return i;
631 }
632
633 return 0;
634}
635
636static tstrWILC_WFIDrv *get_handler_from_id(int id)
637{
Dan Carpenter6ae9ac02015-09-15 09:54:33 +0300638 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
Johnny Kimd42ab082015-08-20 16:32:52 +0900639 return NULL;
640 return wfidrv_list[id];
641}
642
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900643/**
644 * @brief Handle_SetChannel
645 * @details Sending config packet to firmware to set channel
646 * @param[in] tstrHostIFSetChan* pstrHostIFSetChan
647 * @return Error code.
648 * @author
649 * @date
650 * @version 1.0
651 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900652static s32 Handle_SetChannel(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetChan *pstrHostIFSetChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900653{
654
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900655 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900656 tstrWID strWID;
657 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
658
659 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900660 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900661 strWID.enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900662 strWID.ps8WidVal = (char *)&(pstrHostIFSetChan->u8SetChan);
663 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900664
665 PRINT_D(HOSTINF_DBG, "Setting channel\n");
666 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +0900667 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
668 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900669 if (s32Error) {
670 PRINT_ER("Failed to set channel\n");
671 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
672 }
673 WILC_CATCH(s32Error)
674 {
675
676 }
677
678 return s32Error;
679}
680/**
681 * @brief Handle_SetWfiDrvHandler
682 * @details Sending config packet to firmware to set driver handler
683 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
684 * @return Error code.
685 * @author
686 * @date
687 * @version 1.0
688 */
Johnny Kim53a84402015-08-20 16:32:51 +0900689static s32 Handle_SetWfiDrvHandler(tstrWILC_WFIDrv *drvHandler,
690 tstrHostIfSetDrvHandler *pstrHostIfSetDrvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900691{
692
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900693 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900694 tstrWID strWID;
Johnny Kim53a84402015-08-20 16:32:51 +0900695 tstrWILC_WFIDrv *pstrWFIDrv = drvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900696
697
698 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900699 strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900700 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900701 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900702 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900703
704 /*Sending Cfg*/
705
Johnny Kimd42ab082015-08-20 16:32:52 +0900706 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
707 pstrHostIfSetDrvHandler->u32Address);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900708
Johnny Kim53a84402015-08-20 16:32:51 +0900709 if (pstrWFIDrv == NULL)
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200710 up(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900711
712
713 if (s32Error) {
714 PRINT_ER("Failed to set driver handler\n");
715 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
716 }
717 WILC_CATCH(s32Error)
718 {
719
720 }
721
722 return s32Error;
723}
724
725/**
726 * @brief Handle_SetWfiAPDrvHandler
727 * @details Sending config packet to firmware to set driver handler
728 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
729 * @return Error code.
730 * @author
731 * @date
732 * @version 1.0
733 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900734static s32 Handle_SetOperationMode(tstrWILC_WFIDrv *drvHandler, tstrHostIfSetOperationMode *pstrHostIfSetOperationMode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900735{
736
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900737 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900738 tstrWID strWID;
739 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
740
741
742 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900743 strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900744 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900745 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900746 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900747
748 /*Sending Cfg*/
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +0200749 PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900750
Johnny Kimd42ab082015-08-20 16:32:52 +0900751 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
752 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900753
754
Johnny Kimc590b9a2015-09-08 17:07:59 +0900755 if ((pstrHostIfSetOperationMode->u32Mode) == IDLE_MODE)
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200756 up(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900757
758
759 if (s32Error) {
760 PRINT_ER("Failed to set driver handler\n");
761 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
762 }
763 WILC_CATCH(s32Error)
764 {
765
766 }
767
768 return s32Error;
769}
770
771/**
772 * @brief host_int_set_IPAddress
773 * @details Setting IP address params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900774 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900775 * @return Error code.
776 * @author
777 * @date
778 * @version 1.0
779 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900780s32 Handle_set_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900781{
782
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900783 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900784 tstrWID strWID;
785 char firmwareIPAddress[4] = {0};
786 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
787
788 if (pu8IPAddr[0] < 192)
789 pu8IPAddr[0] = 0;
790
Luis de Bethencourtb3a02832015-06-26 17:40:25 +0200791 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900792
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900793 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900794
795 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900796 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900797 strWID.enuWIDtype = WID_STR;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900798 strWID.ps8WidVal = (u8 *)pu8IPAddr;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900799 strWID.s32ValueSize = IP_ALEN;
800
Johnny Kimd42ab082015-08-20 16:32:52 +0900801 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
802 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900803
804
Johnny Kim218dc402015-08-13 13:41:19 +0900805 host_int_get_ipaddress(drvHandler, firmwareIPAddress, idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900806
807 if (s32Error) {
808 PRINT_D(HOSTINF_DBG, "Failed to set IP address\n");
809 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
810 } else {
811 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
812 }
813
814 WILC_CATCH(s32Error)
815 {
816
817 }
818
819 return s32Error;
820}
821
822
823/**
824 * @brief Handle_get_IPAddress
825 * @details Setting IP address params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900826 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900827 * @return Error code.
828 * @author
829 * @date
830 * @version 1.0
831 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900832s32 Handle_get_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900833{
834
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900835 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900836 tstrWID strWID;
837 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
838
839 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900840 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900841 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +0900842 strWID.ps8WidVal = kmalloc(IP_ALEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900843 strWID.s32ValueSize = IP_ALEN;
844
Johnny Kimd42ab082015-08-20 16:32:52 +0900845 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
846 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900847
Luis de Bethencourtb3a02832015-06-26 17:40:25 +0200848 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900849
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900850 memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900851
852 /*get the value by searching the local copy*/
Chaehyun Lim49188af2015-08-11 10:32:41 +0900853 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900854
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900855 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
Johnny Kim218dc402015-08-13 13:41:19 +0900856 host_int_setup_ipaddress(pstrWFIDrv, gs8SetIP[idx], idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900857
858 if (s32Error != WILC_SUCCESS) {
859 PRINT_ER("Failed to get IP address\n");
860 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
861 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +0200862 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
Luis de Bethencourtb3a02832015-06-26 17:40:25 +0200863 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900864 PRINT_INFO(HOSTINF_DBG, "\n");
865 }
866
867 WILC_CATCH(s32Error)
868 {
869
870 }
871
872 return s32Error;
873}
874
875
876/*BugId_5077*/
877/**
878 * @brief Handle_SetMacAddress
879 * @details Setting mac address
880 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
881 * @return Error code.
882 * @author Amr Abdel-Moghny
883 * @date November 2013
884 * @version 7.0
885 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900886static s32 Handle_SetMacAddress(tstrWILC_WFIDrv *drvHandler, tstrHostIfSetMacAddress *pstrHostIfSetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900887{
888
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900889 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900890 tstrWID strWID;
891 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Glen Leef3052582015-09-10 12:03:04 +0900892 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +0200893
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900894 if (mac_buf == NULL) {
895 PRINT_ER("No buffer to send mac address\n");
896 return WILC_FAIL;
897 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900898 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900899
900 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900901 strWID.u16WIDid = (u16)WID_MAC_ADDR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900902 strWID.enuWIDtype = WID_STR;
903 strWID.ps8WidVal = mac_buf;
904 strWID.s32ValueSize = ETH_ALEN;
Alexander Kuleshov310a28f2015-09-04 00:48:14 +0600905 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900906 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +0900907 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
908 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900909 if (s32Error) {
910 PRINT_ER("Failed to set mac address\n");
911 WILC_ERRORREPORT(s32Error, WILC_FAIL);
912 }
913
914 WILC_CATCH(s32Error)
915 {
916
917 }
Chaehyun Lim49188af2015-08-11 10:32:41 +0900918 kfree(mac_buf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900919 return s32Error;
920}
921
922
923/*BugID_5213*/
924/**
925 * @brief Handle_GetMacAddress
926 * @details Getting mac address
927 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
928 * @return Error code.
929 * @author Amr Abdel-Moghny
930 * @date JAN 2013
931 * @version 8.0
932 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900933static s32 Handle_GetMacAddress(tstrWILC_WFIDrv *drvHandler, tstrHostIfGetMacAddress *pstrHostIfGetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900934{
935
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900936 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900937 tstrWID strWID;
938
939 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900940 strWID.u16WIDid = (u16)WID_MAC_ADDR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900941 strWID.enuWIDtype = WID_STR;
942 strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress;
943 strWID.s32ValueSize = ETH_ALEN;
944
945 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +0900946 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, false,
947 get_id_from_handler(drvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900948 if (s32Error) {
949 PRINT_ER("Failed to get mac address\n");
950 WILC_ERRORREPORT(s32Error, WILC_FAIL);
951 }
952 WILC_CATCH(s32Error)
953 {
954
955 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200956 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900957
958 return s32Error;
959}
960
961
962/**
963 * @brief Handle_CfgParam
964 * @details Sending config packet to firmware to set CFG params
965 * @param[in] tstrHostIFCfgParamAttr* strHostIFCfgParamAttr
966 * @return Error code.
967 * @author
968 * @date
969 * @version 1.0
970 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900971static s32 Handle_CfgParam(tstrWILC_WFIDrv *drvHandler, tstrHostIFCfgParamAttr *strHostIFCfgParamAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900972{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900973 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900974 tstrWID strWIDList[32];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900975 u8 u8WidCnt = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900976 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
977
978
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200979 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900980
981
982 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
983
984 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) {
985 /*----------------------------------------------------------*/
986 /*Input Value: INFRASTRUCTURE = 1, */
987 /* INDEPENDENT= 2, */
988 /* ANY_BSS= 3 */
989 /*----------------------------------------------------------*/
990 /* validate input then copy>> need to check value 4 and 5 */
991 if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) {
992 strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900993 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900994 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900995 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900996 pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900997 } else {
998 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
999 }
1000 u8WidCnt++;
1001 }
1002 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) {
1003 /*------------------------------------------------------*/
1004 /*Input Values: OPEN_SYSTEM = 0, */
1005 /* SHARED_KEY = 1, */
1006 /* ANY = 2 */
1007 /*------------------------------------------------------*/
1008 /*validate Possible values*/
1009 if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) {
1010 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001011 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001012 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001013 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001014 pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001015 } else {
1016 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1017 }
1018 u8WidCnt++;
1019 }
1020 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) {
1021 /* range is 1 to 65535. */
1022 if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) {
1023 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001024 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001025 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001026 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001027 pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
1028 } else {
1029 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1030 }
1031 u8WidCnt++;
1032 }
1033 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) {
1034 /*-----------------------------------------------------------*/
1035 /*Input Values: NO_POWERSAVE = 0, */
1036 /* MIN_FAST_PS = 1, */
1037 /* MAX_FAST_PS = 2, */
1038 /* MIN_PSPOLL_PS = 3, */
1039 /* MAX_PSPOLL_PS = 4 */
1040 /*----------------------------------------------------------*/
1041 if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) {
1042 strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001043 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001044 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001045 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001046 pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001047 } else {
1048 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1049 }
1050 u8WidCnt++;
1051 }
1052 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) {
1053 /* range from 1 to 256 */
1054 if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) {
1055 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001056 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001057 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001058 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001059 pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
1060 } else {
1061 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1062 }
1063 u8WidCnt++;
1064 }
1065 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) {
1066 /* range from 1 to 256 */
1067 if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) {
1068 strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001069 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001070
1071 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001072 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001073 pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
1074 } else {
1075 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1076 }
1077 u8WidCnt++;
1078 }
1079 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) {
1080
1081 if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) {
1082 strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001083 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001084 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001085 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001086 pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
1087 } else {
1088 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1089 }
1090 u8WidCnt++;
1091 }
1092 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) {
1093 /* range 256 to 65535 */
1094 if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) {
1095 strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001096 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001097 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001098 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001099 pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1100 } else {
1101 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1102 }
1103 u8WidCnt++;
1104 }
1105 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) {
1106 /*-----------------------------------------------------*/
1107 /*Input Values: Short= 0, */
1108 /* Long= 1, */
1109 /* Auto= 2 */
1110 /*------------------------------------------------------*/
1111 if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) {
1112 strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001113 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001114 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001115 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001116 pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1117 } else {
1118 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1119 }
1120 u8WidCnt++;
1121 }
1122 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) {
1123 if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) {
1124 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001125 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001126 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001127 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001128 pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001129 } else {
1130 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1131 }
1132 u8WidCnt++;
1133 }
1134 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) {
1135 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1136 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1137 /* this information is useful for external supplicant */
1138 /*Input Values: 1 for enable and 0 for disable. */
1139 if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) {
1140 strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001141 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001142 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001143 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001144 pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001145 } else {
1146 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1147 }
1148 u8WidCnt++;
1149 }
1150 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) {
1151 /* range is 1 to 65535. */
1152 if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) {
1153 strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001154 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001155 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001156 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001157 pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1158 } else {
1159 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1160 }
1161 u8WidCnt++;
1162 }
1163 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) {
1164 /* range is 1 to 255. */
1165 if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) {
1166 strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001167 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001168 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001169 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001170 pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1171 } else {
1172 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1173 }
1174 u8WidCnt++;
1175 }
1176 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) {
1177 /*----------------------------------------------------------------------*/
1178 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1179 /* SITE_SURVEY_ALL_CH = 1, */
1180 /* SITE_SURVEY_OFF = 2 */
1181 /*----------------------------------------------------------------------*/
1182 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) {
1183 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001184 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001185 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001186 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001187 pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001188 } else {
1189 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1190 }
1191 u8WidCnt++;
1192 }
1193 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) {
1194 /* range is 1 to 65535. */
1195 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) {
1196 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001197 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001198 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001199 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001200 pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1201 } else {
1202 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1203 }
1204 u8WidCnt++;
1205 }
1206 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) {
1207 /* range is 1 to 65535. */
1208 if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) {
1209 strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001210 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001211 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001212 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001213 pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1214 } else {
1215 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1216 }
1217 u8WidCnt++;
1218 }
1219 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) {
1220 /* range is 1 to 65535. */
1221 if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) {
1222 strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001223 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001224 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001225 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001226 pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1227 } else {
1228 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1229 }
1230 u8WidCnt++;
1231 }
1232 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) {
1233 CURRENT_TX_RATE_T curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate;
1234 /*----------------------------------------------------------------------*/
1235 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1236 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1237 /*----------------------------------------------------------------------*/
1238 /* validate rate */
1239 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
1240 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
1241 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
1242 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
1243 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
1244 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
1245 strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001246 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001247 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001248 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001249 pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001250 } else {
1251 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
1252 }
1253 u8WidCnt++;
1254 }
Johnny Kimd42ab082015-08-20 16:32:52 +09001255 s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, false,
1256 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001257
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001258 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001259 PRINT_ER("Error in setting CFG params\n");
1260
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001261 WILC_CATCH(s32Error)
1262 {
1263 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02001264 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001265 return s32Error;
1266}
1267
1268
1269/**
1270 * @brief Handle_wait_msg_q_empty
1271 * @details this should be the last msg and then the msg Q becomes idle
1272 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1273 * @return Error code.
1274 * @author
1275 * @date
1276 * @version 1.0
1277 */
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001278static s32 Handle_wait_msg_q_empty(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001279{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001280 s32 s32Error = WILC_SUCCESS;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02001281
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001282 g_wilc_initialized = 0;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02001283 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001284 return s32Error;
1285}
1286
1287/**
1288 * @brief Handle_Scan
1289 * @details Sending config packet to firmware to set the scan params
1290 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1291 * @return Error code.
1292 * @author
1293 * @date
1294 * @version 1.0
1295 */
Johnny Kim2b05df52015-08-13 13:41:21 +09001296static s32 Handle_Scan(tstrWILC_WFIDrv *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001297{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001298 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001299 tstrWID strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001300 u32 u32WidsCount = 0;
1301 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001302 u8 *pu8Buffer;
1303 u8 valuesize = 0;
1304 u8 *pu8HdnNtwrksWidVal = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001305 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1306
1307 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001308 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", pstrWFIDrv->enuHostIFstate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001309
1310 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
1311 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
1312
1313 #ifdef WILC_P2P
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001314 #endif
1315
1316 if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) {
1317 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1318 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate);
1319 WILC_ERRORREPORT(s32Error, WILC_BUSY);
1320 }
1321
1322 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
1323 if (g_obtainingIP || connecting) {
1324 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
1325 WILC_ERRORREPORT(s32Error, WILC_BUSY);
1326 }
1327 #endif
1328
1329 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1330
1331
1332 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0;
1333
1334 /*BugID_4189*/
Chaehyun Limd85f5322015-06-11 14:35:54 +09001335 strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001336 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1337
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001338 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001339 valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
Glen Leef3052582015-09-10 12:03:04 +09001340 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001341 strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001342 if (strWIDList[u32WidsCount].ps8WidVal != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001343 pu8Buffer = strWIDList[u32WidsCount].ps8WidVal;
1344
1345 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
1346
1347 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
1348
1349 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1350 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001351 memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001352 pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1353 }
1354
1355
1356
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001357 strWIDList[u32WidsCount].s32ValueSize = (s32)(valuesize + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001358 u32WidsCount++;
1359 }
1360
1361 /*filling cfg param array*/
1362
1363 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1364 {
1365 /* IEs to be inserted in Probe Request */
1366 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE;
1367 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1368 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs;
1369 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen;
1370 u32WidsCount++;
1371 }
1372
1373 /*Scan Type*/
1374 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE;
1375 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001376 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001377 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001378 u32WidsCount++;
1379
1380 /*list of channels to be scanned*/
1381 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST;
1382 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1383
1384 /* Bug 4648: Convert channel numbers to start from 0 not 1. */
1385 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
1386 int i;
1387
1388 for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001389 if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001390 pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001391 }
1392 }
1393
1394 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList;
1395 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen;
1396 u32WidsCount++;
1397
1398 /*Scan Request*/
1399 strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ;
1400 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001401 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001402 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001403 u32WidsCount++;
1404
1405 /*keep the state as is , no need to change it*/
1406 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1407
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301408 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001409 gbScanWhileConnected = true;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301410 else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001411 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001412
Johnny Kimd42ab082015-08-20 16:32:52 +09001413 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false,
1414 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001415
1416 if (s32Error) {
1417 PRINT_ER("Failed to send scan paramters config packet\n");
1418 WILC_ERRORREPORT(s32Error, s32Error);
1419 } else {
1420 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
1421 }
1422
1423 WILC_CATCH(s32Error)
1424 {
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07001425 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001426 /*if there is an ongoing scan request*/
1427 Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED);
1428 }
1429
1430 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1431 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001432 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001433 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1434 }
1435
1436 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1437 if (pstrHostIFscanAttr->pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001438 kfree(pstrHostIFscanAttr->pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001439 pstrHostIFscanAttr->pu8IEs = NULL;
1440 }
1441 if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001442 kfree(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001443 pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
1444 }
1445
1446 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1447 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001448 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001449 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1450 }
1451
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001452 if (pu8HdnNtwrksWidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001453 kfree(pu8HdnNtwrksWidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001454
1455 return s32Error;
1456}
1457
1458/**
1459 * @brief Handle_ScanDone
1460 * @details Call scan notification callback function
1461 * @param[in] NONE
1462 * @return Error code.
1463 * @author
1464 * @date
1465 * @version 1.0
1466 */
Johnny Kim2b05df52015-08-13 13:41:21 +09001467static s32 Handle_ScanDone(tstrWILC_WFIDrv *drvHandler, tenuScanEvent enuEvent)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001468{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001469 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001470
1471 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
1472
1473
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001474 u8 u8abort_running_scan;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001475 tstrWID strWID;
1476
1477
1478 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
1479
1480 /*BugID_4978*/
1481 /*Ask FW to abort the running scan, if any*/
1482 if (enuEvent == SCAN_EVENT_ABORTED) {
1483 PRINT_D(GENERIC_DBG, "Abort running scan\n");
1484 u8abort_running_scan = 1;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001485 strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001486 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001487 strWID.ps8WidVal = (s8 *)&u8abort_running_scan;
Dean Lee576917a2015-06-15 11:58:57 +09001488 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001489
1490 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09001491 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
1492 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001493 if (s32Error != WILC_SUCCESS) {
1494 PRINT_ER("Failed to set abort running scan\n");
1495 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1496 }
1497 WILC_CATCH(s32Error)
1498 {
1499 }
1500 }
1501
1502 if (pstrWFIDrv == NULL) {
1503 PRINT_ER("Driver handler is NULL\n");
1504 return s32Error;
1505 }
1506
1507 /*if there is an ongoing scan request*/
1508 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001509 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001510 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1511 /*delete current scan request*/
1512 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1513 }
1514
1515 return s32Error;
1516}
1517
1518/**
1519 * @brief Handle_Connect
1520 * @details Sending config packet to firmware to starting connection
1521 * @param[in] tstrHostIFconnectAttr* pstrHostIFconnectAttr
1522 * @return Error code.
1523 * @author
1524 * @date
1525 * @version 1.0
1526 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001527u8 u8ConnectedSSID[6] = {0};
Johnny Kim2b05df52015-08-13 13:41:21 +09001528static s32 Handle_Connect(tstrWILC_WFIDrv *drvHandler, tstrHostIFconnectAttr *pstrHostIFconnectAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001529{
1530 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001531 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001532 tstrWID strWIDList[8];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001533 u32 u32WidsCount = 0, dummyval = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001534 /* char passphrase[] = "12345678"; */
1535 #ifndef CONNECT_DIRECT
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001536 s32 s32Err = WILC_SUCCESS;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001537 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001538 u8 u8bssDscListIndex;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001539 wid_site_survey_reslts_s *pstrSurveyResults = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001540 #else
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001541 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001542 /*Bug4218: Parsing Join Param*/
1543 #ifdef WILC_PARSE_SCAN_IN_HOST
1544 tstrJoinBssParam *ptstrJoinBssParam;
1545 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1546
1547 #endif
1548
1549 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1550
1551 #ifndef CONNECT_DIRECT
Hari Prasath Gujulan Elango3a79a7f2015-08-20 09:59:44 +00001552 memset(gapu8RcvdSurveyResults, 0, sizeof(gapu8RcvdSurveyResults));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001553
1554
1555 PRINT_D(HOSTINF_DBG, "Getting site survey results\n");
Johnny Kim218dc402015-08-13 13:41:19 +09001556 s32Err = host_int_get_site_survey_results(pstrWFIDrv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001557 gapu8RcvdSurveyResults,
1558 MAX_SURVEY_RESULT_FRAG_SIZE);
1559 if (s32Err) {
1560 PRINT_ER("Failed to get site survey results\n");
1561 WILC_ERRORREPORT(s32Error, WILC_FAIL);
1562
1563 }
1564 s32Err = ParseSurveyResults(gapu8RcvdSurveyResults, &pstrSurveyResults,
1565 &pstrWFIDrv->u32SurveyResultsCount);
1566
1567
1568 if (s32Err == WILC_SUCCESS) {
1569 /* use the parsed info in pstrSurveyResults, then deallocate it */
1570 PRINT_D(HOSTINF_DBG, "Copying site survey results in global structure, then deallocate\n");
1571 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001572 memcpy(&pstrWFIDrv->astrSurveyResults[i], &pstrSurveyResults[i],
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001573 sizeof(wid_site_survey_reslts_s));
1574 }
1575
1576 DeallocateSurveyResults(pstrSurveyResults);
1577 } else {
1578 WILC_ERRORREPORT(s32Error, WILC_FAIL);
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001579 PRINT_ER("ParseSurveyResults() Error(%d)\n", s32Err);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001580 }
1581
1582
1583 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001584 if (memcmp(pstrWFIDrv->astrSurveyResults[i].SSID,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001585 pstrHostIFconnectAttr->pu8ssid,
1586 pstrHostIFconnectAttr->ssidLen) == 0) {
1587 PRINT_INFO(HOSTINF_DBG, "Network with required SSID is found %s\n", pstrHostIFconnectAttr->pu8ssid);
1588 if (pstrHostIFconnectAttr->pu8bssid == NULL) {
1589 /* BSSID is not passed from the user, so decision of matching
1590 * is done by SSID only */
1591 PRINT_INFO(HOSTINF_DBG, "BSSID is not passed from the user\n");
1592 break;
1593 } else {
1594 /* BSSID is also passed from the user, so decision of matching
1595 * should consider also this passed BSSID */
1596
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001597 if (memcmp(pstrWFIDrv->astrSurveyResults[i].BSSID,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001598 pstrHostIFconnectAttr->pu8bssid,
1599 6) == 0) {
1600 PRINT_INFO(HOSTINF_DBG, "BSSID is passed from the user and matched\n");
1601 break;
1602 }
1603 }
1604 }
1605 }
1606
1607 if (i < pstrWFIDrv->u32SurveyResultsCount) {
1608 u8bssDscListIndex = i;
1609
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001610 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 +09001611 u8bssDscListIndex, pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].SSID,
1612 pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].Channel);
1613
1614 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1615
1616 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001617 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001618 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001619 }
1620
1621 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1622 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001623 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssidLen + 1, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001624 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001625 pstrHostIFconnectAttr->ssidLen);
1626 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1627 }
1628
1629 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1630 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001631 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001632 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001633 pstrHostIFconnectAttr->IEsLen);
1634 }
1635
1636 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1637 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1638 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1639 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1640
1641
1642 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1643 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1644 {
1645 /* IEs to be inserted in Association Request */
1646 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1647 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1648 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1649 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1650 u32WidsCount++;
1651 }
Chaehyun Limd85f5322015-06-11 14:35:54 +09001652 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001653 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001654 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001655 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001656 u32WidsCount++;
1657
1658 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1659
Chaehyun Limd85f5322015-06-11 14:35:54 +09001660 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001661 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001662 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001663 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001664 u32WidsCount++;
1665
1666 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1667 /*
Chaehyun Limd85f5322015-06-11 14:35:54 +09001668 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001669 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1670 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001671 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001672 * u32WidsCount++;
1673 */
1674
Chaehyun Limd85f5322015-06-11 14:35:54 +09001675 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001676 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001677 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001678 strWIDList[u32WidsCount].ps8WidVal = (s8 *)&u8bssDscListIndex;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001679 u32WidsCount++;
1680
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001681 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1682 * firmware at chip reset when processing the WIDs of the Connect Request.
1683 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1684 /* ////////////////////// */
1685 gu32WidConnRstHack = 0;
1686 /* ////////////////////// */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001687
Johnny Kimd42ab082015-08-20 16:32:52 +09001688 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false,
1689 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001690 if (s32Error) {
1691 PRINT_ER("Handle_Connect()] failed to send config packet\n");
1692 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
1693 } else {
1694 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1695 }
1696
1697 } else {
1698 PRINT_ER("Required BSSID not found\n");
1699 WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
1700 }
1701
1702 #else
1703
1704 /* if we try to connect to an already connected AP then discard the request */
1705
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001706 if (memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001707
1708 s32Error = WILC_SUCCESS;
1709 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1710 return s32Error;
1711 }
1712
1713 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1714
1715 /*Bug4218: Parsing Join Param*/
1716 #ifdef WILC_PARSE_SCAN_IN_HOST
1717 ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams;
1718 if (ptstrJoinBssParam == NULL) {
1719 PRINT_ER("Required BSSID not found\n");
1720 WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
1721 }
1722 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1723
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001724 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001725 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001726 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001727 }
1728
1729 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1730 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001731 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssidLen + 1, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001732 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001733 pstrHostIFconnectAttr->ssidLen);
1734 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1735 }
1736
1737 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1738 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001739 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001740 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001741 pstrHostIFconnectAttr->IEsLen);
1742 }
1743
1744 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1745 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1746 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1747 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1748
1749 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
1750 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001751 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001752 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001753 u32WidsCount++;
1754
1755 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
1756 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001757 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001758 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001759 u32WidsCount++;
1760
1761 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
1762 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001763 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001764 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001765 u32WidsCount++;
1766
1767 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1768 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1769 {
1770 /* IEs to be inserted in Association Request */
1771 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1772 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1773 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1774 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1775 u32WidsCount++;
1776
1777 /*BugID_5137*/
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001778 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001779
1780 gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001781 gu8FlushedInfoElemAsoc = kmalloc(gu32FlushedInfoElemAsocSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001782 memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1783 gu32FlushedInfoElemAsocSize);
1784 }
1785 }
Chaehyun Limd85f5322015-06-11 14:35:54 +09001786 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001787 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001788 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001789 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001790 u32WidsCount++;
1791
1792 /*BugID_5137*/
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001793 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001794 gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security;
1795
1796 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1797
1798
Chaehyun Limd85f5322015-06-11 14:35:54 +09001799 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001800 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001801 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001802 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001803 u32WidsCount++;
1804
1805 /*BugID_5137*/
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001806 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001807 gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001808
1809 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1810 /*
Chaehyun Limd85f5322015-06-11 14:35:54 +09001811 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001812 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1813 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001814 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001815 * u32WidsCount++;
1816 */
1817
1818 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1819 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
1820
1821
1822#ifndef WILC_PARSE_SCAN_IN_HOST
Chaehyun Limd85f5322015-06-11 14:35:54 +09001823 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001824 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1825 strWIDList[u32WidsCount].s32ValueSize = MAX_SSID_LEN + 7;
Glen Leef3052582015-09-10 12:03:04 +09001826 strWIDList[u32WidsCount].ps8WidVal = kmalloc(strWIDList[u32WidsCount].s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001827
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001828 if (strWIDList[u32WidsCount].ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001829 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001830
1831 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1832
1833 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001834 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001835 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1836 }
1837 pu8CurrByte += MAX_SSID_LEN;
1838 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1839 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1840 } else {
1841 PRINT_ER("Channel out of range\n");
1842 *(pu8CurrByte++) = 0xFF;
1843 }
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001844 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001845 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001846 pu8CurrByte += 6;
1847
1848 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1849 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1850
1851 #else
1852
Chaehyun Limd85f5322015-06-11 14:35:54 +09001853 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001854 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1855
1856 /*Sending NoA attributes during connection*/
1857 strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */
Glen Leef3052582015-09-10 12:03:04 +09001858 strWIDList[u32WidsCount].ps8WidVal = kmalloc(strWIDList[u32WidsCount].s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001859
1860 /*BugID_5137*/
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001861 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001862 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize;
Glen Leef3052582015-09-10 12:03:04 +09001863 gu8FlushedJoinReq = kmalloc(gu32FlushedJoinReqSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001864 }
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001865 if (strWIDList[u32WidsCount].ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001866 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001867
1868 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1869
1870
1871 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001872 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001873 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1874 }
1875 pu8CurrByte += MAX_SSID_LEN;
1876
1877 /* BSS type*/
1878 *(pu8CurrByte++) = INFRASTRUCTURE;
1879 /* Channel*/
1880 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1881 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1882 } else {
1883 PRINT_ER("Channel out of range\n");
1884 *(pu8CurrByte++) = 0xFF;
1885 }
1886 /* Cap Info*/
1887 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1888 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1889 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1890
1891 /* sa*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001892 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001893 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001894 pu8CurrByte += 6;
1895
1896 /* bssid*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001897 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001898 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001899 pu8CurrByte += 6;
1900
1901 /* Beacon Period*/
1902 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1903 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1904 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1905 /* DTIM Period*/
1906 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1907 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1908 /* Supported rates*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001909 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001910 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1911
1912 /* wmm cap*/
1913 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1914 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1915 /* uapsd cap*/
1916 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1917
1918 /* ht cap*/
1919 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1920 /* copy this information to the user request */
1921 pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1922
1923 /* rsn found*/
1924 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1925 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1926 /* rsn group policy*/
1927 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1928 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1929 /* mode_802_11i*/
1930 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1931 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1932 /* rsn pcip policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001933 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001934 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1935
1936 /* rsn auth policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001937 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001938 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1939
1940 /* rsn auth policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001941 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001942 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1943
1944 /*BugID_5137*/
1945 *(pu8CurrByte++) = REAL_JOIN_REQ;
1946
1947 #ifdef WILC_P2P
1948 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1949 if (ptstrJoinBssParam->u8NoaEnbaled) {
1950 PRINT_D(HOSTINF_DBG, "NOA present\n");
1951
1952 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1953 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1954 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1955 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1956
1957 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1958
1959 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1960
1961 if (ptstrJoinBssParam->u8OppEnable)
1962 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1963
1964 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1965
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001966 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001967
1968 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1969
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001970 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001971
1972 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1973
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001974 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001975
1976 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1977
1978 } else
1979 PRINT_D(HOSTINF_DBG, "NOA not present\n");
1980 #endif
1981
1982
1983 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1984 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1985
1986
1987 #endif /* #ifdef WILC_PARSE_SCAN_IN_HOST*/
1988 u32WidsCount++;
1989
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001990 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1991 * firmware at chip reset when processing the WIDs of the Connect Request.
1992 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1993 /* ////////////////////// */
1994 gu32WidConnRstHack = 0;
1995 /* ////////////////////// */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001996
1997 /*BugID_5137*/
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001998 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001999 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
Johnny Kim8a625ca2015-08-20 16:32:50 +09002000 gu8FlushedJoinReqDrvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002001 }
2002
2003 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
2004
2005 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002006 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002007
Alexander Kuleshov310a28f2015-09-04 00:48:14 +06002008 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->pu8bssid);
2009 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002010 }
2011
Johnny Kimd42ab082015-08-20 16:32:52 +09002012 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false,
2013 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002014 if (s32Error) {
2015 PRINT_ER("Handle_Connect()] failed to send config packet\n");
2016 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
2017 } else {
2018 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
2019 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
2020 }
2021 #endif
2022
2023 WILC_CATCH(s32Error)
2024 {
2025 tstrConnectInfo strConnectInfo;
2026
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002027 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002028
2029 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
2030
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002031 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002032
2033 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002034 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002035 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002036
2037 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
2038 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
Glen Leef3052582015-09-10 12:03:04 +09002039 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002040 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002041 pstrHostIFconnectAttr->pu8IEs,
2042 pstrHostIFconnectAttr->IEsLen);
2043 }
2044
2045 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2046 &strConnectInfo,
2047 MAC_DISCONNECTED,
2048 NULL,
2049 pstrHostIFconnectAttr->pvUserArg);
2050 /*Change state to idle*/
2051 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2052 /* Deallocation */
2053 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002054 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002055 strConnectInfo.pu8ReqIEs = NULL;
2056 }
2057
2058 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002059 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002060 }
2061 }
2062
2063 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
2064 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
2065 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002066 kfree(pstrHostIFconnectAttr->pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002067 pstrHostIFconnectAttr->pu8bssid = NULL;
2068 }
2069
2070 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
2071 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002072 kfree(pstrHostIFconnectAttr->pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002073 pstrHostIFconnectAttr->pu8ssid = NULL;
2074 }
2075
2076 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
2077 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002078 kfree(pstrHostIFconnectAttr->pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002079 pstrHostIFconnectAttr->pu8IEs = NULL;
2080 }
2081
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002082 if (pu8CurrByte != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09002083 kfree(pu8CurrByte);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002084 return s32Error;
2085}
2086
2087/**
2088 * @brief Handle_FlushConnect
2089 * @details Sending config packet to firmware to flush an old connection
2090 * after switching FW from station one to hybrid one
2091 * @param[in] void * drvHandler
2092 * @return Error code.
2093 * @author Amr Abdel-Moghny
2094 * @date 19 DEC 2013
2095 * @version 8.0
2096 */
2097
Johnny Kim2b05df52015-08-13 13:41:21 +09002098static s32 Handle_FlushConnect(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002099{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002100 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002101 tstrWID strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002102 u32 u32WidsCount = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002103 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002104
2105
2106 /* IEs to be inserted in Association Request */
2107 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
2108 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
2109 strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc;
2110 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize;
2111 u32WidsCount++;
2112
Chaehyun Limd85f5322015-06-11 14:35:54 +09002113 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002114 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002115 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002116 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002117 u32WidsCount++;
2118
2119
2120
Chaehyun Limd85f5322015-06-11 14:35:54 +09002121 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002122 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002123 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002124 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002125 u32WidsCount++;
2126
2127
2128 #ifdef WILC_PARSE_SCAN_IN_HOST
Chaehyun Limd85f5322015-06-11 14:35:54 +09002129 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002130 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
2131 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002132 strWIDList[u32WidsCount].ps8WidVal = (s8 *)gu8FlushedJoinReq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002133 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
2134
2135 pu8CurrByte += FLUSHED_BYTE_POS;
2136 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
2137
2138 u32WidsCount++;
2139
2140 #endif
2141
Johnny Kimd42ab082015-08-20 16:32:52 +09002142 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false,
2143 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002144 if (s32Error) {
2145 PRINT_ER("Handle_Flush_Connect()] failed to send config packet\n");
2146 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
2147 }
2148
2149 WILC_CATCH(s32Error)
2150 {
2151
2152 }
2153
2154 return s32Error;
2155}
2156
2157/**
2158 * @brief Handle_ConnectTimeout
2159 * @details Call connect notification callback function indicating connection failure
2160 * @param[in] NONE
2161 * @return Error code.
2162 * @author
2163 * @date
2164 * @version 1.0
2165 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002166static s32 Handle_ConnectTimeout(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002167{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002168 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002169 tstrConnectInfo strConnectInfo;
2170 tstrWID strWID;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002171 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002172 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
2173
2174 if (pstrWFIDrv == NULL) {
2175 PRINT_ER("Driver handler is NULL\n");
2176 return s32Error;
2177 }
2178
2179 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2180
Dean Lee72ed4dc2015-06-12 14:11:44 +09002181 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002182
2183
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002184 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002185
2186
2187 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
2188 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2189 * WID_DISCONNECT} */
2190 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2191 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002192 memcpy(strConnectInfo.au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002193 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2194 }
2195
2196 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2197 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09002198 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002199 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002200 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2201 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2202 }
2203
2204 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2205 &strConnectInfo,
2206 MAC_DISCONNECTED,
2207 NULL,
2208 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2209
2210 /* Deallocation of strConnectInfo.pu8ReqIEs */
2211 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002212 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002213 strConnectInfo.pu8ReqIEs = NULL;
2214 }
2215 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002216 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002217 }
2218
2219 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2220 * WID_DISCONNECT} */
Chaehyun Limd85f5322015-06-11 14:35:54 +09002221 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002222 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002223 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
Dean Lee576917a2015-06-15 11:58:57 +09002224 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002225
2226 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2227
Johnny Kimd42ab082015-08-20 16:32:52 +09002228 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
2229 get_id_from_handler(pstrWFIDrv));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002230 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002231 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002232
2233 /* Deallocation of the Saved Connect Request in the global Handle */
2234 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2235 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002236 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002237 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2238 }
2239
2240 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002241 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002242 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2243 }
2244
2245 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2246 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002247 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002248 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2249 }
2250
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002251 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002252 /*BugID_5213*/
2253 /*Freeing flushed join request params on connect timeout*/
Johnny Kim8a625ca2015-08-20 16:32:50 +09002254 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002255 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002256 gu8FlushedJoinReq = NULL;
2257 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09002258 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002259 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002260 gu8FlushedInfoElemAsoc = NULL;
2261 }
2262
2263 return s32Error;
2264}
2265
2266/**
2267 * @brief Handle_RcvdNtwrkInfo
2268 * @details Handling received network information
2269 * @param[in] tstrRcvdNetworkInfo* pstrRcvdNetworkInfo
2270 * @return Error code.
2271 * @author
2272 * @date
2273 * @version 1.0
2274 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002275static s32 Handle_RcvdNtwrkInfo(tstrWILC_WFIDrv *drvHandler, tstrRcvdNetworkInfo *pstrRcvdNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002276{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002277 u32 i;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002278 bool bNewNtwrkFound;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002279
2280
2281
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002282 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002283 tstrNetworkInfo *pstrNetworkInfo = NULL;
2284 void *pJoinParams = NULL;
2285
2286 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2287
2288
2289
Dean Lee72ed4dc2015-06-12 14:11:44 +09002290 bNewNtwrkFound = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002291 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
2292
2293 /*if there is a an ongoing scan request*/
2294 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2295 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
2296 ParseNetworkInfo(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
2297 if ((pstrNetworkInfo == NULL)
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002298 || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002299 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
2300 }
2301
2302 /* check whether this network is discovered before */
2303 for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
2304
2305 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
2306 (pstrNetworkInfo->au8bssid != NULL)) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002307 if (memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002308 pstrNetworkInfo->au8bssid, 6) == 0) {
2309 if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
2310 /*we have already found this network with better rssi, so keep the old cached one and don't
2311 * send anything to the upper layer */
2312 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
2313 goto done;
2314 } else {
2315 /* here the same already found network is found again but with a better rssi, so just update
2316 * the rssi for this cached network and send this updated network to the upper layer but
2317 * don't add a new record for it */
2318 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002319 bNewNtwrkFound = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002320 break;
2321 }
2322 }
2323 }
2324 }
2325
Dean Lee72ed4dc2015-06-12 14:11:44 +09002326 if (bNewNtwrkFound == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002327 /* here it is confirmed that it is a new discovered network,
2328 * so add its record then call the User CallBack function */
2329
2330 PRINT_D(HOSTINF_DBG, "New network found\n");
2331
2332 if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
2333 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
2334
2335 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
2336 && (pstrNetworkInfo->au8bssid != NULL)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002337 memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002338 pstrNetworkInfo->au8bssid, 6);
2339
2340 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++;
2341
Dean Lee72ed4dc2015-06-12 14:11:44 +09002342 pstrNetworkInfo->bNewNetwork = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002343 /*Bug4218: Parsing Join Param*/
2344 /* add new BSS to JoinBssTable */
2345 #ifdef WILC_PARSE_SCAN_IN_HOST
2346 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
2347 #endif /*WILC_PARSE_SCAN_IN_HOST*/
2348
2349 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2350 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid,
2351 pJoinParams);
2352
2353
2354 }
2355 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002356 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002357 }
2358 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002359 pstrNetworkInfo->bNewNetwork = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002360 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2361 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2362 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2363 }
2364 }
2365
2366
2367 WILC_CATCH(s32Error)
2368 {
2369
2370 }
2371
2372done:
2373 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2374 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002375 kfree(pstrRcvdNetworkInfo->pu8Buffer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002376 pstrRcvdNetworkInfo->pu8Buffer = NULL;
2377 }
2378
2379 /*free structure allocated*/
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002380 if (pstrNetworkInfo != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002381 DeallocateNetworkInfo(pstrNetworkInfo);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002382 pstrNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002383 }
2384
2385 return s32Error;
2386}
2387
2388/**
2389 * @brief Handle_RcvdGnrlAsyncInfo
2390 * @details Handling received asynchrous general network information
2391 * @param[in] tstrRcvdGnrlAsyncInfo* pstrRcvdGnrlAsyncInfo
2392 * @return Error code.
2393 * @author
2394 * @date
2395 * @version 1.0
2396 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002397static s32 Handle_RcvdGnrlAsyncInfo(tstrWILC_WFIDrv *drvHandler, tstrRcvdGnrlAsyncInfo *pstrRcvdGnrlAsyncInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002398{
2399 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2400 /* which carries only 1 WID which have WID ID = WID_STATUS */
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002401 s32 s32Error = WILC_SUCCESS;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002402 u8 u8MsgType = 0;
2403 u8 u8MsgID = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002404 u16 u16MsgLen = 0;
2405 u16 u16WidID = (u16)WID_NIL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002406 u8 u8WidLen = 0;
2407 u8 u8MacStatus;
2408 u8 u8MacStatusReasonCode;
2409 u8 u8MacStatusAdditionalInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002410 tstrConnectInfo strConnectInfo;
2411 tstrDisconnectNotifInfo strDisconnectNotifInfo;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002412 s32 s32Err = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002413 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002414
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002415 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002416 PRINT_ER("Driver handler is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002417 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
2418 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
2419
2420 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
2421 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) ||
2422 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2423 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002424 (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002425 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
2426 }
2427
2428 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
2429
2430 /* Check whether the received message type is 'I' */
2431 if ('I' != u8MsgType) {
2432 PRINT_ER("Received Message format incorrect.\n");
2433 WILC_ERRORREPORT(s32Error, WILC_FAIL);
2434 }
2435
2436 /* Extract message ID */
2437 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
2438
2439 /* Extract message Length */
2440 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
2441
2442 /* Extract WID ID [expected to be = WID_STATUS] */
2443 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
2444
2445 /* Extract WID Length [expected to be = 1] */
2446 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
2447
2448 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2449 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
2450 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
2451 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
2452 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2453 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2454 /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002455 u32 u32RcvdAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002456 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
2457
2458 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2459
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002460 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002461
2462 if (u8MacStatus == MAC_CONNECTED) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002463 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002464
Johnny Kim218dc402015-08-13 13:41:19 +09002465 host_int_get_assoc_res_info(pstrWFIDrv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002466 gapu8RcvdAssocResp,
2467 MAX_ASSOC_RESP_FRAME_SIZE,
2468 &u32RcvdAssocRespInfoLen);
2469
2470 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
2471
2472 if (u32RcvdAssocRespInfoLen != 0) {
2473
2474 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
2475 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
2476 &pstrConnectRespInfo);
2477 if (s32Err) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002478 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002479 } else {
2480 /* use the necessary parsed Info from the Received Association Response */
2481 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
2482
2483 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
2484 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
2485 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
2486 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
2487
2488
Glen Leef3052582015-09-10 12:03:04 +09002489 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002490 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002491 pstrConnectRespInfo->u16RespIEsLen);
2492 }
2493 }
2494
2495 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2496 if (pstrConnectRespInfo != NULL) {
2497 DeallocateAssocRespInfo(pstrConnectRespInfo);
2498 pstrConnectRespInfo = NULL;
2499 }
2500 }
2501 }
2502 }
2503
2504 /* The station has just received mac status and it also received assoc. response which
2505 * it was waiting for.
2506 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2507 if ((u8MacStatus == MAC_CONNECTED) &&
2508 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002509 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 +09002510 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002511
2512 } else if (u8MacStatus == MAC_DISCONNECTED) {
2513 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002514 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002515 }
2516
2517 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2518 /* through a structure of type tstrConnectRespInfo */
2519 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2520 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002521 memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002522
2523 if ((u8MacStatus == MAC_CONNECTED) &&
2524 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002525 memcpy(pstrWFIDrv->au8AssociatedBSSID,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002526 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
2527 }
2528 }
2529
2530
2531 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2532 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09002533 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002534 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002535 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2536 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2537 }
2538
2539
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002540 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002541 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2542 &strConnectInfo,
2543 u8MacStatus,
2544 NULL,
2545 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2546
2547
2548 /* if received mac status is MAC_CONNECTED and
2549 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2550 * else change state to IDLE */
2551 if ((u8MacStatus == MAC_CONNECTED) &&
2552 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2553 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2554
Johnny Kim218dc402015-08-13 13:41:19 +09002555 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002556 #endif
2557
2558 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
2559 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED;
2560
2561 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2562 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +09002563 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002564 mod_timer(&hDuringIpTimer,
2565 jiffies + msecs_to_jiffies(10000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002566 #endif
2567
2568 #ifdef WILC_PARSE_SCAN_IN_HOST
2569 /* open a BA session if possible */
2570 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
2571
2572 #endif
2573
2574 /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
2575 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2576 } else {
2577 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
2578 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002579 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002580 }
2581
2582 /* Deallocation */
2583 if (strConnectInfo.pu8RespIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002584 kfree(strConnectInfo.pu8RespIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002585 strConnectInfo.pu8RespIEs = NULL;
2586 }
2587
2588 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002589 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002590 strConnectInfo.pu8ReqIEs = NULL;
2591 }
2592
2593
2594 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2595 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002596 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002597 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2598 }
2599
2600 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002601 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002602 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2603 }
2604
2605 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2606 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002607 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002608 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2609 }
2610
2611 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2612 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) {
2613 /* Disassociation or Deauthentication frame has been received */
2614 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
2615
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002616 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002617
2618 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002619 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002620 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002621 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2622 }
2623
2624 strDisconnectNotifInfo.u16reason = 0;
2625 strDisconnectNotifInfo.ie = NULL;
2626 strDisconnectNotifInfo.ie_len = 0;
2627
2628 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2629 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2630
Dean Lee72ed4dc2015-06-12 14:11:44 +09002631 g_obtainingIP = false;
Johnny Kim218dc402015-08-13 13:41:19 +09002632 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002633 #endif
2634
2635 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2636 NULL,
2637 0,
2638 &strDisconnectNotifInfo,
2639 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2640
2641 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002642 PRINT_ER("Connect result callback function is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002643 }
2644
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002645 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002646
2647
2648 /* Deallocation */
2649
2650 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2651 * should be deallocated here */
2652 /*
2653 * if(strDisconnectNotifInfo.ie != NULL)
2654 * {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002655 * kfree(strDisconnectNotifInfo.ie);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002656 * strDisconnectNotifInfo.ie = NULL;
2657 * }
2658 */
2659
2660 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2661 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002662 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002663 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2664 }
2665
2666 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002667 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002668 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2669 }
2670
2671 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2672 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002673 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002674 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2675 }
2676
2677 /*BugID_5213*/
2678 /*Freeing flushed join request params on receiving*/
2679 /*MAC_DISCONNECTED while connected*/
Johnny Kim8a625ca2015-08-20 16:32:50 +09002680 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002681 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002682 gu8FlushedJoinReq = NULL;
2683 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09002684 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002685 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002686 gu8FlushedInfoElemAsoc = NULL;
2687 }
2688
2689 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002690 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002691
2692 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2693 (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
2694 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002695 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002696 /*Abort the running scan*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002697 del_timer(&pstrWFIDrv->hScanTimer);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002698 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult)
Johnny Kim2b05df52015-08-13 13:41:21 +09002699 Handle_ScanDone(pstrWFIDrv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002700
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002701 }
2702
2703 }
2704
2705 WILC_CATCH(s32Error)
2706 {
2707
2708 }
2709
2710 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2711 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002712 kfree(pstrRcvdGnrlAsyncInfo->pu8Buffer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002713 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
2714 }
2715
2716 return s32Error;
2717}
2718
2719/**
2720 * @brief Handle_Key
2721 * @details Sending config packet to firmware to set key
2722 * @param[in] tstrHostIFkeyAttr* pstrHostIFkeyAttr
2723 * @return Error code.
2724 * @author
2725 * @date
2726 * @version 1.0
2727 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002728static int Handle_Key(tstrWILC_WFIDrv *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002729{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09002730 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002731 tstrWID strWID;
2732 #ifdef WILC_AP_EXTERNAL_MLME
2733 tstrWID strWIDList[5];
2734 #endif
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002735 u8 i;
2736 u8 *pu8keybuf;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002737 s8 s8idxarray[1];
2738 s8 ret = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002739 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2740
2741
2742 switch (pstrHostIFkeyAttr->enuKeyType) {
2743
2744
2745 case WEP:
2746
2747#ifdef WILC_AP_EXTERNAL_MLME
2748 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2749
2750 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2751 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Chaehyun Limd85f5322015-06-11 14:35:54 +09002752 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002753 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002754 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002755 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002756
2757 strWIDList[1].u16WIDid = WID_AUTH_TYPE;
2758 strWIDList[1].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002759 strWIDList[1].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002760 strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002761
Chaehyun Limd85f5322015-06-11 14:35:54 +09002762 strWIDList[2].u16WIDid = (u16)WID_KEY_ID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002763 strWIDList[2].enuWIDtype = WID_CHAR;
2764
Chaehyun Limca356ad2015-06-11 14:35:57 +09002765 strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Dean Lee576917a2015-06-15 11:58:57 +09002766 strWIDList[2].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002767
2768
Glen Leef3052582015-09-10 12:03:04 +09002769 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002770
2771
2772 if (pu8keybuf == NULL) {
2773 PRINT_ER("No buffer to send Key\n");
2774 return -1;
2775 }
2776
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002777 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002778 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2779
2780
Chaehyun Lim49188af2015-08-11 10:32:41 +09002781 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002782
Chaehyun Limd85f5322015-06-11 14:35:54 +09002783 strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002784 strWIDList[3].enuWIDtype = WID_STR;
2785 strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002786 strWIDList[3].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002787
2788
Johnny Kimd42ab082015-08-20 16:32:52 +09002789 s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, true,
2790 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002791 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002792
2793
2794 }
2795#endif
2796
2797 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2798 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Glen Leef3052582015-09-10 12:03:04 +09002799 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002800 if (pu8keybuf == NULL) {
2801 PRINT_ER("No buffer to send Key\n");
2802 return -1;
2803 }
2804 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2805
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002806 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002807
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002808 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002809 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2810
Chaehyun Lim49188af2015-08-11 10:32:41 +09002811 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002812
Chaehyun Limd85f5322015-06-11 14:35:54 +09002813 strWID.u16WIDid = (u16)WID_ADD_WEP_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002814 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002815 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002816 strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2;
2817
Johnny Kimd42ab082015-08-20 16:32:52 +09002818 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2819 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002820 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002821 } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) {
2822
2823 PRINT_D(HOSTINF_DBG, "Removing key\n");
Chaehyun Limd85f5322015-06-11 14:35:54 +09002824 strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002825 strWID.enuWIDtype = WID_STR;
2826
Chaehyun Limca356ad2015-06-11 14:35:57 +09002827 s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002828 strWID.ps8WidVal = s8idxarray;
2829 strWID.s32ValueSize = 1;
2830
Johnny Kimd42ab082015-08-20 16:32:52 +09002831 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2832 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002833 } else {
Chaehyun Limd85f5322015-06-11 14:35:54 +09002834 strWID.u16WIDid = (u16)WID_KEY_ID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002835 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002836 strWID.ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Dean Lee576917a2015-06-15 11:58:57 +09002837 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002838
2839 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
2840
Johnny Kimd42ab082015-08-20 16:32:52 +09002841 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2842 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002843 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002844 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002845 break;
2846
2847 case WPARxGtk:
2848 #ifdef WILC_AP_EXTERNAL_MLME
2849 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
Glen Leef3052582015-09-10 12:03:04 +09002850 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002851 if (pu8keybuf == NULL) {
2852 PRINT_ER("No buffer to send RxGTK Key\n");
2853 ret = -1;
2854 goto _WPARxGtk_end_case_;
2855 }
2856
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002857 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002858
2859
2860 /*|----------------------------------------------------------------------------|
2861 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2862 * |------------|---------|-------|------------|---------------|----------------|
2863 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2864
2865
2866
2867 if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002868 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002869
2870
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002871 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002872
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002873 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002874
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002875 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002876 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2877 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
Chaehyun Limd85f5322015-06-11 14:35:54 +09002878 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002879 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002880 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002881 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002882
Chaehyun Limd85f5322015-06-11 14:35:54 +09002883 strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002884 strWIDList[1].enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002885 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002886 strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN;
2887
Johnny Kimd42ab082015-08-20 16:32:52 +09002888 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true,
2889 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002890
Chaehyun Lim49188af2015-08-11 10:32:41 +09002891 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002892
2893 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002894 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002895 /* ///////////////////////// */
2896 }
2897
2898 #endif
2899 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2900 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
2901
Glen Leef3052582015-09-10 12:03:04 +09002902 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002903 if (pu8keybuf == NULL) {
2904 PRINT_ER("No buffer to send RxGTK Key\n");
2905 ret = -1;
2906 goto _WPARxGtk_end_case_;
2907 }
2908
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002909 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002910
2911
2912 /*|----------------------------------------------------------------------------|
2913 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2914 * |------------|---------|-------|------------|---------------|----------------|
2915 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2916
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302917 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002918 memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302919 else
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002920 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002921
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002922 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002923
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002924 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002925
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002926 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2927 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002928 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2929
Chaehyun Limd85f5322015-06-11 14:35:54 +09002930 strWID.u16WIDid = (u16)WID_ADD_RX_GTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002931 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002932 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002933 strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN;
2934
Johnny Kimd42ab082015-08-20 16:32:52 +09002935 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2936 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002937
Chaehyun Lim49188af2015-08-11 10:32:41 +09002938 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002939
2940 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002941 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002942 /* ///////////////////////// */
2943 }
2944_WPARxGtk_end_case_:
Chaehyun Lim49188af2015-08-11 10:32:41 +09002945 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2946 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002947 if (ret == -1)
2948 return ret;
2949
2950 break;
2951
2952 case WPAPtk:
2953 #ifdef WILC_AP_EXTERNAL_MLME
2954 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2955
2956
Glen Leef3052582015-09-10 12:03:04 +09002957 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002958
2959
2960
2961 if (pu8keybuf == NULL) {
2962 PRINT_ER("No buffer to send PTK Key\n");
2963 ret = -1;
2964 goto _WPAPtk_end_case_;
2965
2966 }
2967
2968 /*|-----------------------------------------------------------------------------|
2969 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2970 * |----------------|------------ |--------------|----------------|---------------|
2971 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2972 |-----------------------------------------------------------------------------|*/
2973
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002974 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002975
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002976 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2977 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002978 /*16 byte TK*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002979 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002980 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2981
2982
Chaehyun Limd85f5322015-06-11 14:35:54 +09002983 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002984 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002985 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002986 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002987
Chaehyun Limd85f5322015-06-11 14:35:54 +09002988 strWIDList[1].u16WIDid = (u16)WID_ADD_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002989 strWIDList[1].enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002990 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002991 strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1;
2992
Johnny Kimd42ab082015-08-20 16:32:52 +09002993 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true,
2994 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002995 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002996
2997 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002998 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002999 /* ///////////////////////// */
3000 }
3001 #endif
3002 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
3003
3004
Glen Leef3052582015-09-10 12:03:04 +09003005 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003006
3007
3008
3009 if (pu8keybuf == NULL) {
3010 PRINT_ER("No buffer to send PTK Key\n");
3011 ret = -1;
3012 goto _WPAPtk_end_case_;
3013
3014 }
3015
3016 /*|-----------------------------------------------------------------------------|
3017 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
3018 * |----------------|------------|--------------|----------------|---------------|
3019 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
3020 |-----------------------------------------------------------------------------|*/
3021
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003022 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003023
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003024 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003025 /*16 byte TK*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003026 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003027 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
3028
3029
Chaehyun Limd85f5322015-06-11 14:35:54 +09003030 strWID.u16WIDid = (u16)WID_ADD_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003031 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003032 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003033 strWID.s32ValueSize = PTK_KEY_MSG_LEN;
3034
Johnny Kimd42ab082015-08-20 16:32:52 +09003035 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3036 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09003037 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003038
3039 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003040 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003041 /* ///////////////////////// */
3042 }
3043
3044_WPAPtk_end_case_:
Chaehyun Lim49188af2015-08-11 10:32:41 +09003045 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003046 if (ret == -1)
3047 return ret;
3048
3049 break;
3050
3051
3052 case PMKSA:
3053
3054 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
3055
Glen Leef3052582015-09-10 12:03:04 +09003056 pu8keybuf = kmalloc((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003057 if (pu8keybuf == NULL) {
3058 PRINT_ER("No buffer to send PMKSA Key\n");
3059 return -1;
3060 }
3061
3062 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
3063
3064 for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
3065
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003066 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
3067 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003068 }
3069
Chaehyun Limd85f5322015-06-11 14:35:54 +09003070 strWID.u16WIDid = (u16)WID_PMKID_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003071 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003072 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003073 strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1;
3074
Johnny Kimd42ab082015-08-20 16:32:52 +09003075 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3076 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003077
Chaehyun Lim49188af2015-08-11 10:32:41 +09003078 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003079 break;
3080 }
3081
3082 if (s32Error)
3083 PRINT_ER("Failed to send key config packet\n");
3084
3085
3086 return s32Error;
3087}
3088
3089
3090/**
3091 * @brief Handle_Disconnect
3092 * @details Sending config packet to firmware to disconnect
3093 * @param[in] NONE
3094 * @return NONE
3095 * @author
3096 * @date
3097 * @version 1.0
3098 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003099static void Handle_Disconnect(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003100{
3101 tstrWID strWID;
3102
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003103 s32 s32Error = WILC_SUCCESS;
Chaehyun Limd85f5322015-06-11 14:35:54 +09003104 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003105 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3106
3107
Chaehyun Limd85f5322015-06-11 14:35:54 +09003108 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003109 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003110 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
Dean Lee576917a2015-06-15 11:58:57 +09003111 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003112
3113
3114
3115 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
3116
3117 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3118
Dean Lee72ed4dc2015-06-12 14:11:44 +09003119 g_obtainingIP = false;
Johnny Kim218dc402015-08-13 13:41:19 +09003120 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003121 #endif
3122
Chaehyun Lim2cc46832015-08-07 09:02:01 +09003123 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003124
Johnny Kimd42ab082015-08-20 16:32:52 +09003125 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3126 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003127
3128 if (s32Error) {
3129 PRINT_ER("Failed to send dissconect config packet\n");
3130 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3131 } else {
3132 tstrDisconnectNotifInfo strDisconnectNotifInfo;
3133
Chaehyun Lim2cc46832015-08-07 09:02:01 +09003134 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003135
3136 strDisconnectNotifInfo.u16reason = 0;
3137 strDisconnectNotifInfo.ie = NULL;
3138 strDisconnectNotifInfo.ie_len = 0;
3139
3140 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07003141 del_timer(&pstrWFIDrv->hScanTimer);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003142 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003143 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
3144
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003145 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003146 }
3147
3148 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
3149
3150 /*BugID_5193*/
3151 /*Stop connect timer, if connection in progress*/
3152 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3153 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07003154 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003155 }
3156
3157 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
3158 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
3159 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003160 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003161 }
3162
Dean Lee72ed4dc2015-06-12 14:11:44 +09003163 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003164
3165 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
3166
Chaehyun Lim2cc46832015-08-07 09:02:01 +09003167 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003168
3169
3170 /* Deallocation */
3171 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
3172 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003173 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003174 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
3175 }
3176
3177 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003178 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003179 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
3180 }
3181
3182 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
3183 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003184 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003185 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
3186 }
3187
3188
3189 /*BugID_5137*/
Johnny Kim8a625ca2015-08-20 16:32:50 +09003190 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003191 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003192 gu8FlushedJoinReq = NULL;
3193 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09003194 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003195 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003196 gu8FlushedInfoElemAsoc = NULL;
3197 }
3198
3199 }
3200
3201 WILC_CATCH(s32Error)
3202 {
3203
3204 }
3205
3206 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003207 up(&(pstrWFIDrv->hSemTestDisconnectBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003208 /* ///////////////////////// */
3209
3210}
3211
3212
Johnny Kim2b05df52015-08-13 13:41:21 +09003213void resolve_disconnect_aberration(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003214{
3215 tstrWILC_WFIDrv *pstrWFIDrv;
3216
3217 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003218 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003219 return;
3220 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
3221 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
Johnny Kim218dc402015-08-13 13:41:19 +09003222 host_int_disconnect(pstrWFIDrv, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003223 }
3224}
Johnny Kim2b05df52015-08-13 13:41:21 +09003225static s32 Switch_Log_Terminal(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003226{
3227
3228
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003229 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003230 tstrWID strWID;
3231 static char dummy = 9;
3232 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3233
Chaehyun Limd85f5322015-06-11 14:35:54 +09003234 strWID.u16WIDid = (u16)WID_LOGTerminal_Switch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003235 strWID.enuWIDtype = WID_CHAR;
3236 strWID.ps8WidVal = &dummy;
Dean Lee576917a2015-06-15 11:58:57 +09003237 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003238
Johnny Kimd42ab082015-08-20 16:32:52 +09003239 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3240 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003241
3242
3243 if (s32Error) {
3244 PRINT_D(HOSTINF_DBG, "Failed to switch log terminal\n");
3245 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
3246 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003247 PRINT_INFO(HOSTINF_DBG, "MAC address set ::\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003248
3249
3250 }
3251
3252 WILC_CATCH(s32Error)
3253 {
3254
3255 }
3256
3257 return s32Error;
3258}
3259
3260/**
3261 * @brief Handle_GetChnl
3262 * @details Sending config packet to get channel
3263 * @param[in] NONE
3264 * @return NONE
3265 *
3266 * @author
3267 * @date
3268 * @version 1.0
3269 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003270static s32 Handle_GetChnl(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003271{
3272
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003273 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003274 tstrWID strWID;
3275 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
3276 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003277
Chaehyun Limd85f5322015-06-11 14:35:54 +09003278 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003279 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003280 strWID.ps8WidVal = (s8 *)&gu8Chnl;
Dean Lee576917a2015-06-15 11:58:57 +09003281 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003282
3283 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
3284
Johnny Kimd42ab082015-08-20 16:32:52 +09003285 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
3286 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003287 /*get the value by searching the local copy*/
3288 if (s32Error) {
3289 PRINT_ER("Failed to get channel number\n");
3290 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3291 }
3292
3293
3294 WILC_CATCH(s32Error)
3295 {
3296
3297 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003298 up(&(pstrWFIDrv->hSemGetCHNL));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003299
3300 return s32Error;
3301
3302
3303
3304}
3305
3306
3307/**
3308 * @brief Handle_GetRssi
3309 * @details Sending config packet to get RSSI
3310 * @param[in] NONE
3311 * @return NONE
3312 * @author
3313 * @date
3314 * @version 1.0
3315 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003316static void Handle_GetRssi(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003317{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003318 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003319 tstrWID strWID;
3320 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3321
Chaehyun Limd85f5322015-06-11 14:35:54 +09003322 strWID.u16WIDid = (u16)WID_RSSI;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003323 strWID.enuWIDtype = WID_CHAR;
3324 strWID.ps8WidVal = &gs8Rssi;
Dean Lee576917a2015-06-15 11:58:57 +09003325 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003326
3327 /*Sending Cfg*/
3328 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
3329
Johnny Kimd42ab082015-08-20 16:32:52 +09003330 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
3331 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003332 if (s32Error) {
3333 PRINT_ER("Failed to get RSSI value\n");
3334 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3335 }
3336
3337 WILC_CATCH(s32Error)
3338 {
3339
3340 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003341 up(&(pstrWFIDrv->hSemGetRSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003342
3343
3344}
3345
3346
Johnny Kim2b05df52015-08-13 13:41:21 +09003347static void Handle_GetLinkspeed(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003348{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003349 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003350 tstrWID strWID;
3351 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3352
3353 gs8lnkspd = 0;
3354
Chaehyun Limd85f5322015-06-11 14:35:54 +09003355 strWID.u16WIDid = (u16)WID_LINKSPEED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003356 strWID.enuWIDtype = WID_CHAR;
3357 strWID.ps8WidVal = &gs8lnkspd;
Dean Lee576917a2015-06-15 11:58:57 +09003358 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003359 /*Sending Cfg*/
3360 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
3361
Johnny Kimd42ab082015-08-20 16:32:52 +09003362 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
3363 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003364 if (s32Error) {
3365 PRINT_ER("Failed to get LINKSPEED value\n");
3366 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3367 }
3368
3369 WILC_CATCH(s32Error)
3370 {
3371
3372 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003373 up(&(pstrWFIDrv->hSemGetLINKSPEED));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003374
3375
3376}
3377
Johnny Kim2b05df52015-08-13 13:41:21 +09003378s32 Handle_GetStatistics(tstrWILC_WFIDrv *drvHandler, tstrStatistics *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003379{
3380 tstrWID strWIDList[5];
Chaehyun Limfbc2fe12015-09-15 14:06:16 +09003381 u32 u32WidsCount = 0, s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003382
3383 strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED;
3384 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003385 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003386 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003387 u32WidsCount++;
3388
3389 strWIDList[u32WidsCount].u16WIDid = WID_RSSI;
3390 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003391 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003392 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->s8RSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003393 u32WidsCount++;
3394
3395 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
3396 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003397 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003398 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003399 u32WidsCount++;
3400
3401 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
3402 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003403 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003404 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32RxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003405 u32WidsCount++;
3406
3407 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
3408 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003409 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003410 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxFailureCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003411 u32WidsCount++;
3412
Johnny Kimd42ab082015-08-20 16:32:52 +09003413 s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, false,
3414 get_id_from_handler(drvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003415
3416 if (s32Error) {
3417 PRINT_ER("Failed to send scan paramters config packet\n");
3418 /* WILC_ERRORREPORT(s32Error, s32Error); */
3419 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003420 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003421 return 0;
3422
3423}
3424
3425
3426#ifdef WILC_AP_EXTERNAL_MLME
3427
3428
3429/**
3430 * @brief Handle_Get_InActiveTime
3431 * @details Sending config packet to set mac adddress for station and
3432 * get inactive time
3433 * @param[in] NONE
3434 * @return NONE
3435 *
3436 * @author
3437 * @date
3438 * @version 1.0
3439 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003440static s32 Handle_Get_InActiveTime(tstrWILC_WFIDrv *drvHandler, tstrHostIfStaInactiveT *strHostIfStaInactiveT)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003441{
3442
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003443 s32 s32Error = WILC_SUCCESS;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003444 u8 *stamac;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003445 tstrWID strWID;
3446 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3447
3448
Chaehyun Limd85f5322015-06-11 14:35:54 +09003449 strWID.u16WIDid = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003450 strWID.enuWIDtype = WID_STR;
3451 strWID.s32ValueSize = ETH_ALEN;
Glen Leef3052582015-09-10 12:03:04 +09003452 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003453
3454
3455 stamac = strWID.ps8WidVal;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003456 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003457
3458
3459 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
3460
3461
Johnny Kimd42ab082015-08-20 16:32:52 +09003462 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3463 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003464 /*get the value by searching the local copy*/
3465 if (s32Error) {
3466 PRINT_ER("Failed to SET incative time\n");
3467 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3468 }
3469
3470
Chaehyun Limd85f5322015-06-11 14:35:54 +09003471 strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003472 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003473 strWID.ps8WidVal = (s8 *)&gu32InactiveTime;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003474 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003475
3476
Johnny Kimd42ab082015-08-20 16:32:52 +09003477 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
3478 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003479 /*get the value by searching the local copy*/
3480 if (s32Error) {
3481 PRINT_ER("Failed to get incative time\n");
3482 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3483 }
3484
3485
3486 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
3487
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003488 up(&(pstrWFIDrv->hSemInactiveTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003489 WILC_CATCH(s32Error)
3490 {
3491
3492 }
3493
3494
3495 return s32Error;
3496
3497
3498
3499}
3500
3501
3502/**
3503 * @brief Handle_AddBeacon
3504 * @details Sending config packet to add beacon
3505 * @param[in] tstrHostIFSetBeacon* pstrSetBeaconParam
3506 * @return NONE
3507 * @author
3508 * @date
3509 * @version 1.0
3510 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003511static void Handle_AddBeacon(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetBeacon *pstrSetBeaconParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003512{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003513 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003514 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003515 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003516 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003517
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003518 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
3519
Chaehyun Limd85f5322015-06-11 14:35:54 +09003520 strWID.u16WIDid = (u16)WID_ADD_BEACON;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003521 strWID.enuWIDtype = WID_BIN;
3522 strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
Glen Leef3052582015-09-10 12:03:04 +09003523 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003524 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003525 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003526
3527 pu8CurrByte = strWID.ps8WidVal;
3528 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
3529 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
3530 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
3531 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
3532
3533 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
3534 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
3535 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
3536 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
3537
3538 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
3539 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
3540 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
3541 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
3542
3543 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
3544 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
3545
3546 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
3547 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
3548 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
3549 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
3550
3551 /* Bug 4599 : if tail length = 0 skip copying */
3552 if (pstrSetBeaconParam->pu8Tail > 0)
3553 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
3554 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
3555
3556
3557
3558 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003559 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3560 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003561 if (s32Error) {
3562 PRINT_ER("Failed to send add beacon config packet\n");
3563 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3564 }
3565
3566 WILC_CATCH(s32Error)
3567 {
3568 }
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003569 kfree(strWID.ps8WidVal);
3570 kfree(pstrSetBeaconParam->pu8Head);
3571 kfree(pstrSetBeaconParam->pu8Tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003572}
3573
3574
3575/**
3576 * @brief Handle_AddBeacon
3577 * @details Sending config packet to delete beacon
3578 * @param[in] tstrHostIFDelBeacon* pstrDelBeacon
3579 * @return NONE
3580 * @author
3581 * @date
3582 * @version 1.0
3583 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003584static void Handle_DelBeacon(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelBeacon *pstrDelBeacon)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003585{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003586 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003587 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003588 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003589 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003590
Chaehyun Limd85f5322015-06-11 14:35:54 +09003591 strWID.u16WIDid = (u16)WID_DEL_BEACON;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003592 strWID.enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003593 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003594 strWID.ps8WidVal = &gu8DelBcn;
3595
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003596 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003597 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003598
3599 pu8CurrByte = strWID.ps8WidVal;
3600
3601 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
3602 /* TODO: build del beacon message*/
3603
3604 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003605 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3606 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003607 if (s32Error) {
3608
3609 PRINT_ER("Failed to send delete beacon config packet\n");
3610 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3611 }
3612
3613 WILC_CATCH(s32Error)
3614 {
3615 }
3616}
3617
3618
3619/**
3620 * @brief WILC_HostIf_PackStaParam
3621 * @details Handling packing of the station params in a buffer
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003622 * @param[in] u8* pu8Buffer, tstrWILC_AddStaParam* pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003623 * @return NONE
3624 * @author
3625 * @date
3626 * @version 1.0
3627 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003628static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, tstrWILC_AddStaParam *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003629{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003630 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003631
3632 pu8CurrByte = pu8Buffer;
3633
3634 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003635 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003636 pu8CurrByte += ETH_ALEN;
3637
3638 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
3639 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
3640
3641 *pu8CurrByte++ = pstrStationParam->u8NumRates;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003642 if (pstrStationParam->u8NumRates > 0)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003643 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003644 pu8CurrByte += pstrStationParam->u8NumRates;
3645
3646 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
3647 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
3648 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
3649
3650 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003651 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003652 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
3653
3654 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
3655 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
3656
3657 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
3658 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
3659 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
3660 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
3661
3662 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
3663
3664 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
3665 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
3666
3667 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
3668 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
3669
3670 return pu8CurrByte - pu8Buffer;
3671}
3672
3673/**
3674 * @brief Handle_AddStation
3675 * @details Sending config packet to add station
3676 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3677 * @return NONE
3678 * @author
3679 * @date
3680 * @version 1.0
3681 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003682static void Handle_AddStation(tstrWILC_WFIDrv *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003683{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003684 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003685 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003686 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003687 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003688
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003689 PRINT_D(HOSTINF_DBG, "Handling add station\n");
Chaehyun Limd85f5322015-06-11 14:35:54 +09003690 strWID.u16WIDid = (u16)WID_ADD_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003691 strWID.enuWIDtype = WID_BIN;
3692 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3693
Glen Leef3052582015-09-10 12:03:04 +09003694 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003695 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003696 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003697
3698 pu8CurrByte = strWID.ps8WidVal;
3699 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3700
3701 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003702 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3703 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003704 if (s32Error != WILC_SUCCESS) {
3705
3706 PRINT_ER("Failed to send add station config packet\n");
3707 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3708 }
3709
3710 WILC_CATCH(s32Error)
3711 {
3712 }
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003713 kfree(pstrStationParam->pu8Rates);
3714 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003715}
3716
3717/**
3718 * @brief Handle_DelAllSta
3719 * @details Sending config packet to delete station
3720 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3721 * @return NONE
3722 * @author
3723 * @date
3724 * @version 1.0
3725 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003726static void Handle_DelAllSta(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelAllSta *pstrDelAllStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003727{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003728 s32 s32Error = WILC_SUCCESS;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003729
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003730 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003731 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003732 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003733 u8 i;
Chaehyun Lim37034802015-06-11 14:34:32 +09003734 u8 au8Zero_Buff[6] = {0};
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003735
Chaehyun Limd85f5322015-06-11 14:35:54 +09003736 strWID.u16WIDid = (u16)WID_DEL_ALL_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003737 strWID.enuWIDtype = WID_STR;
3738 strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
3739
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003740 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003741
Glen Leef3052582015-09-10 12:03:04 +09003742 strWID.ps8WidVal = kmalloc((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003743 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003744 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003745
3746 pu8CurrByte = strWID.ps8WidVal;
3747
3748 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
3749
3750 for (i = 0; i < MAX_NUM_STA; i++) {
3751 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003752 memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003753 else
3754 continue;
3755
3756 pu8CurrByte += ETH_ALEN;
3757 }
3758
3759 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003760 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3761 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003762 if (s32Error) {
3763
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02003764 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003765 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3766 }
3767
3768 WILC_CATCH(s32Error)
3769 {
3770 }
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003771 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003772
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003773 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003774}
3775
3776
3777/**
3778 * @brief Handle_DelStation
3779 * @details Sending config packet to delete station
3780 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3781 * @return NONE
3782 * @author
3783 * @date
3784 * @version 1.0
3785 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003786static void Handle_DelStation(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelSta *pstrDelStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003787{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003788 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003789 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003790 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003791 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3792
Chaehyun Limd85f5322015-06-11 14:35:54 +09003793 strWID.u16WIDid = (u16)WID_REMOVE_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003794 strWID.enuWIDtype = WID_BIN;
3795 strWID.s32ValueSize = ETH_ALEN;
3796
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003797 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003798
Glen Leef3052582015-09-10 12:03:04 +09003799 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003800 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003801 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003802
3803 pu8CurrByte = strWID.ps8WidVal;
3804
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003805 memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003806
3807 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003808 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3809 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003810 if (s32Error) {
3811
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02003812 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003813 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3814 }
3815
3816 WILC_CATCH(s32Error)
3817 {
3818 }
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003819 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003820}
3821
3822
3823/**
3824 * @brief Handle_EditStation
3825 * @details Sending config packet to edit station
3826 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3827 * @return NONE
3828 * @author
3829 * @date
3830 * @version 1.0
3831 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003832static void Handle_EditStation(tstrWILC_WFIDrv *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003833{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003834 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003835 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003836 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003837 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3838
Chaehyun Limd85f5322015-06-11 14:35:54 +09003839 strWID.u16WIDid = (u16)WID_EDIT_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003840 strWID.enuWIDtype = WID_BIN;
3841 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3842
3843 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
Glen Leef3052582015-09-10 12:03:04 +09003844 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003845 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003846 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003847
3848 pu8CurrByte = strWID.ps8WidVal;
3849 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3850
3851 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003852 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3853 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003854 if (s32Error) {
3855
3856 PRINT_ER("Failed to send edit station config packet\n");
3857 WILC_ERRORREPORT(s32Error, WILC_FAIL);
3858 }
3859
3860 WILC_CATCH(s32Error)
3861 {
3862 }
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003863 kfree(pstrStationParam->pu8Rates);
3864 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003865}
3866#endif /*WILC_AP_EXTERNAL_MLME*/
3867
3868#ifdef WILC_P2P
3869/**
3870 * @brief Handle_RemainOnChan
3871 * @details Sending config packet to edit station
3872 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3873 * @return NONE
3874 * @author
3875 * @date
3876 * @version 1.0
3877 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003878static int Handle_RemainOnChan(tstrWILC_WFIDrv *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003879{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003880 s32 s32Error = WILC_SUCCESS;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003881 u8 u8remain_on_chan_flag;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003882 tstrWID strWID;
3883 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3884
3885 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3886 if (!pstrWFIDrv->u8RemainOnChan_pendingreq) {
3887 pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
3888 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
3889 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
3890 pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
3891 pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
3892 } else {
3893 /*Set the channel to use it as a wid val*/
3894 pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel;
3895 }
3896
3897 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3898 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
3899 pstrWFIDrv->u8RemainOnChan_pendingreq = 1;
3900 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3901 }
3902 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3903 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
3904 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3905 }
3906
3907 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3908 if (g_obtainingIP || connecting) {
3909 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
3910 WILC_ERRORREPORT(s32Error, WILC_BUSY);
3911 }
3912 #endif
3913
3914 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
3915
Dean Lee72ed4dc2015-06-12 14:11:44 +09003916 u8remain_on_chan_flag = true;
Chaehyun Limd85f5322015-06-11 14:35:54 +09003917 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003918 strWID.enuWIDtype = WID_STR;
3919 strWID.s32ValueSize = 2;
Glen Leef3052582015-09-10 12:03:04 +09003920 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003921
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003922 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003923 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003924
3925 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003926 strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003927
3928 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003929 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3930 get_id_from_handler(pstrWFIDrv));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003931 if (s32Error != WILC_SUCCESS)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003932 PRINT_ER("Failed to set remain on channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003933
3934 WILC_CATCH(-1)
3935 {
3936 P2P_LISTEN_STATE = 1;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003937 pstrWFIDrv->hRemainOnChannel.data = (unsigned long)pstrWFIDrv;
3938 mod_timer(&pstrWFIDrv->hRemainOnChannel,
3939 jiffies +
3940 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003941
3942 /*Calling CFG ready_on_channel*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003943 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003944 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003945
3946 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3947 pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
3948 }
3949 return s32Error;
3950}
3951
3952/**
3953 * @brief Handle_RegisterFrame
3954 * @details
3955 * @param[in]
3956 * @return NONE
3957 * @author
3958 * @date
3959 * @version 1.0
3960 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003961static int Handle_RegisterFrame(tstrWILC_WFIDrv *drvHandler, tstrHostIfRegisterFrame *pstrHostIfRegisterFrame)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003962{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09003963 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003964 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003965 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003966 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3967
3968 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
3969
3970 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +09003971 strWID.u16WIDid = (u16)WID_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003972 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09003973 strWID.ps8WidVal = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003974 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003975 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003976
3977 pu8CurrByte = strWID.ps8WidVal;
3978
3979 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
3980 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003981 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003982
3983
Chaehyun Limd85f5322015-06-11 14:35:54 +09003984 strWID.s32ValueSize = sizeof(u16) + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003985
3986
3987 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003988 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3989 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003990 if (s32Error) {
3991 PRINT_ER("Failed to frame register config packet\n");
3992 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
3993 }
3994
3995
3996 WILC_CATCH(s32Error)
3997 {
3998 }
3999
4000 return s32Error;
4001
4002}
4003
4004/**
4005 * @brief Handle_ListenStateExpired
4006 * @details Handle of listen state expiration
4007 * @param[in] NONE
4008 * @return Error code.
4009 * @author
4010 * @date
4011 * @version 1.0
4012 */
4013#define FALSE_FRMWR_CHANNEL 100
Johnny Kim2b05df52015-08-13 13:41:21 +09004014static u32 Handle_ListenStateExpired(tstrWILC_WFIDrv *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004015{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004016 u8 u8remain_on_chan_flag;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004017 tstrWID strWID;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004018 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004019 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
4020
4021 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
4022
4023 /*BugID_5477*/
4024 /*Make sure we are already in listen state*/
4025 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
4026 if (P2P_LISTEN_STATE) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09004027 u8remain_on_chan_flag = false;
Chaehyun Limd85f5322015-06-11 14:35:54 +09004028 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004029 strWID.enuWIDtype = WID_STR;
4030 strWID.s32ValueSize = 2;
Glen Leef3052582015-09-10 12:03:04 +09004031 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004032
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004033 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004034 PRINT_ER("Failed to allocate memory\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004035
4036 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
4037 strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL;
4038
4039 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09004040 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4041 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004042 if (s32Error != WILC_SUCCESS) {
4043 PRINT_ER("Failed to set remain on channel\n");
4044 goto _done_;
4045 }
4046
4047 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) {
4048 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid
4049 , pstrHostIfRemainOnChan->u32ListenSessionID);
4050 }
4051 P2P_LISTEN_STATE = 0;
4052 } else {
4053 PRINT_D(GENERIC_DBG, "Not in listen state\n");
4054 s32Error = WILC_FAIL;
4055 }
4056
4057_done_:
4058 return s32Error;
4059}
4060
4061
4062/**
4063 * @brief ListenTimerCB
4064 * @details Callback function of remain-on-channel timer
4065 * @param[in] NONE
4066 * @return Error code.
4067 * @author
4068 * @date
4069 * @version 1.0
4070 */
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004071static void ListenTimerCB(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004072{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004073 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004074 tstrHostIFmsg strHostIFmsg;
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004075 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004076 /*Stopping remain-on-channel timer*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07004077 del_timer(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004078
4079 /* prepare the Timer Callback message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004080 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004081 strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
4082 strHostIFmsg.drvHandler = pstrWFIDrv;
4083 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID;
4084
4085 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09004086 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004087 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004088 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004089 WILC_CATCH(s32Error)
4090 {
4091
4092 }
4093}
4094#endif
4095
4096
4097/**
4098 * @brief Handle_EditStation
4099 * @details Sending config packet to edit station
4100 * @param[in] tstrWILC_AddStaParam* pstrStationParam
4101 * @return NONE
4102 * @author
4103 * @date
4104 * @version 1.0
4105 */
Johnny Kim2b05df52015-08-13 13:41:21 +09004106static void Handle_PowerManagement(tstrWILC_WFIDrv *drvHandler, tstrHostIfPowerMgmtParam *strPowerMgmtParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004107{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004108 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004109 tstrWID strWID;
Chaehyun Limca356ad2015-06-11 14:35:57 +09004110 s8 s8PowerMode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004111 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004112
Chaehyun Limd85f5322015-06-11 14:35:54 +09004113 strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004114
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05304115 if (strPowerMgmtParam->bIsEnabled == true)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004116 s8PowerMode = MIN_FAST_PS;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05304117 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004118 s8PowerMode = NO_POWERSAVE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004119 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
4120 strWID.ps8WidVal = &s8PowerMode;
Dean Lee576917a2015-06-15 11:58:57 +09004121 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004122
4123 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
4124
4125 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09004126 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4127 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004128 if (s32Error) {
4129 PRINT_ER("Failed to send power management config packet\n");
4130 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
4131 }
4132
4133 WILC_CATCH(s32Error)
4134 {
4135
4136 }
4137}
4138
4139/**
4140 * @brief Handle_SetMulticastFilter
4141 * @details Set Multicast filter in firmware
4142 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4143 * @return NONE
4144 * @author asobhy
4145 * @date
4146 * @version 1.0
4147 */
Johnny Kim2b05df52015-08-13 13:41:21 +09004148static void Handle_SetMulticastFilter(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetMulti *strHostIfSetMulti)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004149{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004150 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004151 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004152 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004153
4154 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
4155
Chaehyun Limd85f5322015-06-11 14:35:54 +09004156 strWID.u16WIDid = (u16)WID_SETUP_MULTICAST_FILTER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004157 strWID.enuWIDtype = WID_BIN;
4158 strWID.s32ValueSize = sizeof(tstrHostIFSetMulti) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
Glen Leef3052582015-09-10 12:03:04 +09004159 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004160 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004161 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004162
4163 pu8CurrByte = strWID.ps8WidVal;
4164 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
4165 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
4166 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
4167 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
4168
4169 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
4170 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
4171 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
4172 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
4173
4174 if ((strHostIfSetMulti->u32count) > 0)
4175 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
4176
4177 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09004178 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
4179 get_id_from_handler(drvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004180 if (s32Error) {
4181 PRINT_ER("Failed to send setup multicast config packet\n");
4182 WILC_ERRORREPORT(s32Error, WILC_FAIL);
4183 }
4184
4185 WILC_CATCH(s32Error)
4186 {
4187 }
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07004188 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004189
4190}
4191
4192
4193/*BugID_5222*/
4194/**
4195 * @brief Handle_AddBASession
4196 * @details Add block ack session
4197 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4198 * @return NONE
4199 * @author Amr Abdel-Moghny
4200 * @date Feb. 2014
4201 * @version 9.0
4202 */
Johnny Kim2b05df52015-08-13 13:41:21 +09004203static s32 Handle_AddBASession(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004204{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004205 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004206 tstrWID strWID;
4207 int AddbaTimeout = 100;
4208 char *ptr = NULL;
4209 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4210
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004211 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 +09004212 strHostIfBASessionInfo->au8Bssid[0],
4213 strHostIfBASessionInfo->au8Bssid[1],
4214 strHostIfBASessionInfo->au8Bssid[2],
4215 strHostIfBASessionInfo->u16BufferSize,
4216 strHostIfBASessionInfo->u16SessionTimeout,
4217 strHostIfBASessionInfo->u8Ted);
4218
Chaehyun Limd85f5322015-06-11 14:35:54 +09004219 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004220 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09004221 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004222 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4223 ptr = strWID.ps8WidVal;
4224 /* *ptr++ = 0x14; */
4225 *ptr++ = 0x14;
4226 *ptr++ = 0x3;
4227 *ptr++ = 0x0;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004228 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004229 ptr += ETH_ALEN;
4230 *ptr++ = strHostIfBASessionInfo->u8Ted;
4231 /* BA Policy*/
4232 *ptr++ = 1;
4233 /* Buffer size*/
4234 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4235 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
4236 /* BA timeout*/
4237 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
4238 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4239 /* ADDBA timeout*/
4240 *ptr++ = (AddbaTimeout & 0xFF);
4241 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
4242 /* Group Buffer Max Frames*/
4243 *ptr++ = 8;
4244 /* Group Buffer Timeout */
4245 *ptr++ = 0;
4246
Johnny Kimd42ab082015-08-20 16:32:52 +09004247 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4248 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004249 if (s32Error)
4250 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
4251
4252
Chaehyun Limd85f5322015-06-11 14:35:54 +09004253 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004254 strWID.enuWIDtype = WID_STR;
4255 strWID.s32ValueSize = 15;
4256 ptr = strWID.ps8WidVal;
4257 /* *ptr++ = 0x14; */
4258 *ptr++ = 15;
4259 *ptr++ = 7;
4260 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004261 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004262 ptr += ETH_ALEN;
4263 /* TID*/
4264 *ptr++ = strHostIfBASessionInfo->u8Ted;
4265 /* Max Num MSDU */
4266 *ptr++ = 8;
4267 /* BA timeout*/
4268 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4269 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4270 /*Ack-Policy */
4271 *ptr++ = 3;
Johnny Kimd42ab082015-08-20 16:32:52 +09004272 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4273 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004274
4275 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09004276 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004277
4278 return s32Error;
4279
4280}
4281
4282
4283/*BugID_5222*/
4284/**
4285 * @brief Handle_DelBASession
4286 * @details Delete block ack session
4287 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4288 * @return NONE
4289 * @author Amr Abdel-Moghny
4290 * @date Feb. 2013
4291 * @version 9.0
4292 */
Johnny Kim2b05df52015-08-13 13:41:21 +09004293static s32 Handle_DelBASession(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004294{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004295 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004296 tstrWID strWID;
4297 char *ptr = NULL;
4298 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4299
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004300 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004301 strHostIfBASessionInfo->au8Bssid[0],
4302 strHostIfBASessionInfo->au8Bssid[1],
4303 strHostIfBASessionInfo->au8Bssid[2],
4304 strHostIfBASessionInfo->u8Ted);
4305
Chaehyun Limd85f5322015-06-11 14:35:54 +09004306 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004307 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09004308 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004309 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4310 ptr = strWID.ps8WidVal;
4311 /* *ptr++ = 0x14; */
4312 *ptr++ = 0x14;
4313 *ptr++ = 0x3;
4314 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004315 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004316 ptr += ETH_ALEN;
4317 *ptr++ = strHostIfBASessionInfo->u8Ted;
4318 /* BA direction = recipent*/
4319 *ptr++ = 0;
4320 /* Delba Reason */
4321 *ptr++ = 32; /* Unspecific QOS reason */
4322
Johnny Kimd42ab082015-08-20 16:32:52 +09004323 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4324 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004325 if (s32Error)
4326 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4327
4328
Chaehyun Limd85f5322015-06-11 14:35:54 +09004329 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004330 strWID.enuWIDtype = WID_STR;
4331 strWID.s32ValueSize = 15;
4332 ptr = strWID.ps8WidVal;
4333 /* *ptr++ = 0x14; */
4334 *ptr++ = 15;
4335 *ptr++ = 7;
4336 *ptr++ = 0x3;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004337 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004338 ptr += ETH_ALEN;
4339 /* TID*/
4340 *ptr++ = strHostIfBASessionInfo->u8Ted;
4341
Johnny Kimd42ab082015-08-20 16:32:52 +09004342 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4343 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004344
4345 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09004346 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004347
4348 /*BugID_5222*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004349 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004350
4351 return s32Error;
4352
4353}
4354
4355
4356/**
4357 * @brief Handle_DelAllRxBASessions
4358 * @details Delete all Rx BA sessions
4359 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4360 * @return NONE
4361 * @author Abdelrahman Sobhy
4362 * @date Feb. 2013
4363 * @version 9.0
4364 */
Johnny Kim2b05df52015-08-13 13:41:21 +09004365static s32 Handle_DelAllRxBASessions(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004366{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004367 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004368 tstrWID strWID;
4369 char *ptr = NULL;
4370 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4371
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004372 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004373 strHostIfBASessionInfo->au8Bssid[0],
4374 strHostIfBASessionInfo->au8Bssid[1],
4375 strHostIfBASessionInfo->au8Bssid[2],
4376 strHostIfBASessionInfo->u8Ted);
4377
Chaehyun Limd85f5322015-06-11 14:35:54 +09004378 strWID.u16WIDid = (u16)WID_DEL_ALL_RX_BA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004379 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09004380 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004381 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4382 ptr = strWID.ps8WidVal;
4383 *ptr++ = 0x14;
4384 *ptr++ = 0x3;
4385 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004386 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004387 ptr += ETH_ALEN;
4388 *ptr++ = strHostIfBASessionInfo->u8Ted;
4389 /* BA direction = recipent*/
4390 *ptr++ = 0;
4391 /* Delba Reason */
4392 *ptr++ = 32; /* Unspecific QOS reason */
4393
Johnny Kimd42ab082015-08-20 16:32:52 +09004394 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4395 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004396 if (s32Error)
4397 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4398
4399
4400 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09004401 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004402
4403 /*BugID_5222*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004404 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004405
4406 return s32Error;
4407
4408}
4409
4410/**
4411 * @brief hostIFthread
4412 * @details Main thread to handle message queue requests
4413 * @param[in] void* pvArg
4414 * @return NONE
4415 * @author
4416 * @date
4417 * @version 1.0
4418 */
Arnd Bergmann1999bd52015-05-29 22:52:14 +02004419static int hostIFthread(void *pvArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004420{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004421 u32 u32Ret;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004422 tstrHostIFmsg strHostIFmsg;
4423 tstrWILC_WFIDrv *pstrWFIDrv;
4424
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004425 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004426
4427 while (1) {
Chaehyun Limb986e332015-08-19 15:59:07 +09004428 wilc_mq_recv(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), &u32Ret);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004429 pstrWFIDrv = (tstrWILC_WFIDrv *)strHostIFmsg.drvHandler;
4430 if (strHostIFmsg.u16MsgId == HOST_IF_MSG_EXIT) {
4431 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
4432 break;
4433 }
4434
4435
4436 /*Re-Queue HIF message*/
4437 if ((!g_wilc_initialized)) {
4438 PRINT_D(GENERIC_DBG, "--WAIT--");
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07004439 usleep_range(200 * 1000, 200 * 1000);
Chaehyun Lim79198132015-08-19 15:59:06 +09004440 wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004441 continue;
4442 }
4443
4444 if (strHostIFmsg.u16MsgId == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
4445 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
Chaehyun Lim79198132015-08-19 15:59:06 +09004446 wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07004447 usleep_range(2 * 1000, 2 * 1000);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004448 continue;
4449 }
4450
4451 switch (strHostIFmsg.u16MsgId) {
4452 case HOST_IF_MSG_Q_IDLE:
4453 Handle_wait_msg_q_empty();
4454 break;
4455
4456 case HOST_IF_MSG_SCAN:
4457 Handle_Scan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr);
4458 break;
4459
4460 case HOST_IF_MSG_CONNECT:
4461 Handle_Connect(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr);
4462 break;
4463
4464 /*BugID_5137*/
4465 case HOST_IF_MSG_FLUSH_CONNECT:
4466 Handle_FlushConnect(strHostIFmsg.drvHandler);
4467 break;
4468
4469 case HOST_IF_MSG_RCVD_NTWRK_INFO:
4470 Handle_RcvdNtwrkInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo);
4471 break;
4472
4473 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
4474 Handle_RcvdGnrlAsyncInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo);
4475 break;
4476
4477 case HOST_IF_MSG_KEY:
4478 Handle_Key(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr);
4479 break;
4480
4481 case HOST_IF_MSG_CFG_PARAMS:
4482
4483 Handle_CfgParam(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr);
4484 break;
4485
4486 case HOST_IF_MSG_SET_CHANNEL:
4487 Handle_SetChannel(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan);
4488 break;
4489
4490 case HOST_IF_MSG_DISCONNECT:
4491 Handle_Disconnect(strHostIFmsg.drvHandler);
4492 break;
4493
4494 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07004495 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004496 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
4497
4498 /*BugID_5213*/
4499 /*Allow chip sleep, only if both interfaces are not connected*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004500 if (!linux_wlan_get_num_conn_ifcs())
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004501 chip_sleep_manually(INFINITE_SLEEP_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004502
4503 Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_DONE);
4504
4505 #ifdef WILC_P2P
4506 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
4507 Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4508 #endif
4509
4510 break;
4511
4512 case HOST_IF_MSG_GET_RSSI:
4513 Handle_GetRssi(strHostIFmsg.drvHandler);
4514 break;
4515
4516 case HOST_IF_MSG_GET_LINKSPEED:
4517 Handle_GetLinkspeed(strHostIFmsg.drvHandler);
4518 break;
4519
4520 case HOST_IF_MSG_GET_STATISTICS:
4521 Handle_GetStatistics(strHostIFmsg.drvHandler, (tstrStatistics *)strHostIFmsg.uniHostIFmsgBody.pUserData);
4522 break;
4523
4524 case HOST_IF_MSG_GET_CHNL:
4525 Handle_GetChnl(strHostIFmsg.drvHandler);
4526 break;
4527
4528#ifdef WILC_AP_EXTERNAL_MLME
4529 case HOST_IF_MSG_ADD_BEACON:
4530 Handle_AddBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon);
4531 break;
4532
4533 case HOST_IF_MSG_DEL_BEACON:
4534 Handle_DelBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelBeacon);
4535 break;
4536
4537 case HOST_IF_MSG_ADD_STATION:
4538 Handle_AddStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strAddStaParam);
4539 break;
4540
4541 case HOST_IF_MSG_DEL_STATION:
4542 Handle_DelStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strDelStaParam);
4543 break;
4544
4545 case HOST_IF_MSG_EDIT_STATION:
4546 Handle_EditStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strEditStaParam);
4547 break;
4548
4549 case HOST_IF_MSG_GET_INACTIVETIME:
4550 Handle_Get_InActiveTime(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT);
4551 break;
4552
4553#endif /*WILC_AP_EXTERNAL_MLME*/
4554 case HOST_IF_MSG_SCAN_TIMER_FIRED:
4555 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
4556
4557 Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_ABORTED);
4558 break;
4559
4560 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004561 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004562 Handle_ConnectTimeout(strHostIFmsg.drvHandler);
4563 break;
4564
4565 case HOST_IF_MSG_POWER_MGMT:
4566 Handle_PowerManagement(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam);
4567 break;
4568
4569 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
Johnny Kim53a84402015-08-20 16:32:51 +09004570 Handle_SetWfiDrvHandler(strHostIFmsg.drvHandler,
4571 &strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004572 break;
4573
4574 case HOST_IF_MSG_SET_OPERATION_MODE:
4575 Handle_SetOperationMode(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode);
4576 break;
4577
4578 case HOST_IF_MSG_SET_IPADDRESS:
4579 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4580 Handle_set_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
4581 break;
4582
4583 case HOST_IF_MSG_GET_IPADDRESS:
4584 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
4585 Handle_get_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
4586 break;
4587
4588 /*BugID_5077*/
4589 case HOST_IF_MSG_SET_MAC_ADDRESS:
4590 Handle_SetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress);
4591 break;
4592
4593 /*BugID_5213*/
4594 case HOST_IF_MSG_GET_MAC_ADDRESS:
4595 Handle_GetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress);
4596 break;
4597
4598#ifdef WILC_P2P
4599 case HOST_IF_MSG_REMAIN_ON_CHAN:
4600 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
4601 Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4602 break;
4603
4604 case HOST_IF_MSG_REGISTER_FRAME:
4605 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
4606 Handle_RegisterFrame(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame);
4607 break;
4608
4609 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
4610 Handle_ListenStateExpired(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
4611 break;
4612
4613 #endif
4614 case HOST_IF_MSG_SET_MULTICAST_FILTER:
4615 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
4616 Handle_SetMulticastFilter(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti);
4617 break;
4618
4619 /*BugID_5222*/
4620 case HOST_IF_MSG_ADD_BA_SESSION:
4621 Handle_AddBASession(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
4622 break;
4623
4624 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
4625 Handle_DelAllRxBASessions(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
4626 break;
4627
4628 case HOST_IF_MSG_DEL_ALL_STA:
4629 Handle_DelAllSta(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta);
4630 break;
4631
4632 default:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004633 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004634 break;
4635 }
4636 }
4637
4638 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004639 up(&hSemHostIFthrdEnd);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02004640 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004641}
4642
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004643static void TimerCB_Scan(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004644{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004645 void *pvArg = (void *)arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004646 tstrHostIFmsg strHostIFmsg;
4647
4648 /* prepare the Timer Callback message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004649 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004650 strHostIFmsg.drvHandler = pvArg;
4651 strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN_TIMER_FIRED;
4652
4653 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09004654 wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004655}
4656
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004657static void TimerCB_Connect(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004658{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004659 void *pvArg = (void *)arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004660 tstrHostIFmsg strHostIFmsg;
4661
4662 /* prepare the Timer Callback message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004663 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004664 strHostIFmsg.drvHandler = pvArg;
4665 strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT_TIMER_FIRED;
4666
4667 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09004668 wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004669}
4670
4671
4672/**
4673 * @brief removes wpa/wpa2 keys
4674 * @details only in BSS STA mode if External Supplicant support is enabled.
4675 * removes all WPA/WPA2 station key entries from MAC hardware.
4676 * @param[in,out] handle to the wifi driver
4677 * @param[in] 6 bytes of Station Adress in the station entry table
4678 * @return Error code indicating success/failure
4679 * @note
4680 * @author zsalah
4681 * @date 8 March 2012
4682 * @version 1.0
4683 */
4684/* Check implementation in core adding 9 bytes to the input! */
Johnny Kim218dc402015-08-13 13:41:19 +09004685s32 host_int_remove_key(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8StaAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004686{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004687 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004688 tstrWID strWID;
4689 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4690
Chaehyun Limd85f5322015-06-11 14:35:54 +09004691 strWID.u16WIDid = (u16)WID_REMOVE_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004692 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09004693 strWID.ps8WidVal = (s8 *)pu8StaAddress;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004694 strWID.s32ValueSize = 6;
4695
4696 return s32Error;
4697
4698}
4699
4700/**
4701 * @brief removes WEP key
4702 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4703 * remove a WEP key entry from MAC HW.
4704 * The BSS Station automatically finds the index of the entry using its
4705 * BSS ID and removes that entry from the MAC hardware.
4706 * @param[in,out] handle to the wifi driver
4707 * @param[in] 6 bytes of Station Adress in the station entry table
4708 * @return Error code indicating success/failure
4709 * @note NO need for the STA add since it is not used for processing
4710 * @author zsalah
4711 * @date 8 March 2012
4712 * @version 1.0
4713 */
Johnny Kim218dc402015-08-13 13:41:19 +09004714s32 host_int_remove_wep_key(tstrWILC_WFIDrv *hWFIDrv, u8 u8keyIdx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004715{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004716 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004717 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4718 tstrHostIFmsg strHostIFmsg;
4719
4720
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004721 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004722 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004723
4724 /* prepare the Remove Wep Key Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004725 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004726
4727
4728 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4729 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4730 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = REMOVEKEY;
4731 strHostIFmsg.drvHandler = hWFIDrv;
4732
4733
4734
4735 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4736 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8keyIdx;
4737
4738 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09004739 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004740 if (s32Error)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004741 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004742 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004743
4744 WILC_CATCH(s32Error)
4745 {
4746
4747 }
4748 return s32Error;
4749}
4750
4751/**
4752 * @brief sets WEP default key
4753 * @details Sets the index of the WEP encryption key in use,
4754 * in the key table
4755 * @param[in,out] handle to the wifi driver
4756 * @param[in] key index ( 0, 1, 2, 3)
4757 * @return Error code indicating success/failure
4758 * @note
4759 * @author zsalah
4760 * @date 8 March 2012
4761 * @version 1.0
4762 */
Johnny Kim218dc402015-08-13 13:41:19 +09004763s32 host_int_set_WEPDefaultKeyID(tstrWILC_WFIDrv *hWFIDrv, u8 u8Index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004764{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004765 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004766 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4767 tstrHostIFmsg strHostIFmsg;
4768
4769
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004770 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004771 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004772
4773 /* prepare the Key Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004774 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004775
4776
4777 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4778 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4779 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = DEFAULTKEY;
4780 strHostIFmsg.drvHandler = hWFIDrv;
4781
4782
4783 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4784 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
4785
4786 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09004787 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004788 if (s32Error)
4789 PRINT_ER("Error in sending message queue : Default key index\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004790 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004791
4792 WILC_CATCH(s32Error)
4793 {
4794
4795 }
4796
4797 return s32Error;
4798}
4799
4800/**
4801 * @brief sets WEP deafault key
4802 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4803 * sets WEP key entry into MAC hardware when it receives the
4804 * corresponding request from NDIS.
4805 * @param[in,out] handle to the wifi driver
4806 * @param[in] message containing WEP Key in the following format
4807 *|---------------------------------------|
4808 *|Key ID Value | Key Length | Key |
4809 *|-------------|------------|------------|
4810 | 1byte | 1byte | Key Length |
4811 ||---------------------------------------|
4812 |
4813 * @return Error code indicating success/failure
4814 * @note
4815 * @author zsalah
4816 * @date 8 March 2012
4817 * @version 1.0
4818 */
Johnny Kim218dc402015-08-13 13:41:19 +09004819s32 host_int_add_wep_key_bss_sta(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004820{
4821
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004822 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004823 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4824 tstrHostIFmsg strHostIFmsg;
4825
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004826 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004827 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4828
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004829
4830 /* prepare the Key Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004831 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004832
4833
4834 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4835 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4836 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
4837 strHostIFmsg.drvHandler = hWFIDrv;
4838
4839
4840 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
Glen Leef3052582015-09-10 12:03:04 +09004841 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004842
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004843 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004844 pu8WepKey, u8WepKeylen);
4845
4846
4847 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4848 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4849
4850 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4851 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4852
4853 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09004854 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004855 if (s32Error)
4856 PRINT_ER("Error in sending message queue :WEP Key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004857 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004858
4859 WILC_CATCH(s32Error)
4860 {
4861
4862 }
4863 return s32Error;
4864
4865}
4866
4867#ifdef WILC_AP_EXTERNAL_MLME
4868/**
4869 *
4870 * @brief host_int_add_wep_key_bss_ap
4871 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4872 * sets WEP key entry into MAC hardware when it receives the
4873 *
4874 * corresponding request from NDIS.
4875 * @param[in,out] handle to the wifi driver
4876 *
4877 *
4878 * @return Error code indicating success/failure
4879 * @note
4880 * @author mdaftedar
4881 * @date 28 FEB 2013
4882 * @version 1.0
4883 */
Johnny Kim218dc402015-08-13 13:41:19 +09004884s32 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 +09004885{
4886
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004887 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004888 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4889 tstrHostIFmsg strHostIFmsg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004890 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004891
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004892 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004893 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
4894
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004895
4896 /* prepare the Key Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004897 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004898
4899 if (INFO) {
4900 for (i = 0; i < u8WepKeylen; i++)
4901 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4902 }
4903 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4904 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
4905 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4906 strHostIFmsg.drvHandler = hWFIDrv;
4907
4908
4909 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
Glen Leef3052582015-09-10 12:03:04 +09004910 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004911
4912
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004913 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004914 pu8WepKey, (u8WepKeylen));
4915
4916
4917 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4918 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4919
4920 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4921 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4922
4923 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4924 uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
4925
4926 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4927 uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
4928 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09004929 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004930
4931 if (s32Error)
4932 PRINT_ER("Error in sending message queue :WEP Key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004933 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004934
4935 WILC_CATCH(s32Error)
4936 {
4937
4938 }
4939 return s32Error;
4940
4941}
4942#endif
4943/**
4944 * @brief adds ptk Key
4945 * @details
4946 * @param[in,out] handle to the wifi driver
4947 * @param[in] message containing PTK Key in the following format
4948 *|-----------------------------------------------------------------------------|
4949 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4950 *|----------------|------------|--------------|----------------|---------------|
4951 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4952 ||-----------------------------------------------------------------------------|
4953 * @return Error code indicating success/failure
4954 * @note
4955 * @author zsalah
4956 * @date 8 March 2012
4957 * @version 1.0
4958 */
Johnny Kim218dc402015-08-13 13:41:19 +09004959s32 host_int_add_ptk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004960 const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004961{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09004962 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004963 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
4964 tstrHostIFmsg strHostIFmsg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004965 u8 u8KeyLen = u8PtkKeylen;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004966 u32 i;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004967
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004968 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004969 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004970 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004971 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004972 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004973 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004974
4975 /* prepare the Key Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004976 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004977
4978
4979 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
4980 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPAPtk;
4981 #ifdef WILC_AP_EXTERNAL_MLME
4982 if (mode == AP_MODE) {
4983 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4984 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
4985 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
4986 }
4987 #endif
4988 if (mode == STATION_MODE)
4989 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
4990
4991
4992 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
Glen Leef3052582015-09-10 12:03:04 +09004993 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8PtkKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004994
4995
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004996 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004997 pu8Ptk, u8PtkKeylen);
4998
4999 if (pu8RxMic != NULL) {
5000
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005001 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005002 pu8RxMic, RX_MIC_KEY_LEN);
5003 if (INFO) {
5004 for (i = 0; i < RX_MIC_KEY_LEN; i++)
5005 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
5006 }
5007 }
5008 if (pu8TxMic != NULL) {
5009
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005010 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005011 pu8TxMic, TX_MIC_KEY_LEN);
5012 if (INFO) {
5013 for (i = 0; i < TX_MIC_KEY_LEN; i++)
5014 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
5015 }
5016 }
5017
5018 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5019 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
5020
5021 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5022 uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
5023 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5024 uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
5025 strHostIFmsg.drvHandler = hWFIDrv;
5026
5027 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09005028 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005029
5030 if (s32Error)
5031 PRINT_ER("Error in sending message queue: PTK Key\n");
5032
5033 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005034 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005035 /* /////// */
5036
5037 WILC_CATCH(s32Error)
5038 {
5039
5040 }
5041
5042 return s32Error;
5043}
5044
5045/**
5046 * @brief adds Rx GTk Key
5047 * @details
5048 * @param[in,out] handle to the wifi driver
5049 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
5050 * u8GtkKeylen :The total key length
5051 *
5052 * @return Error code indicating success/failure
5053 * @note
5054 * @author zsalah
5055 * @date 8 March 2012
5056 * @version 1.0
5057 */
Johnny Kim218dc402015-08-13 13:41:19 +09005058s32 host_int_add_rx_gtk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005059 u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005060 const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005061{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005062 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005063 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5064 tstrHostIFmsg strHostIFmsg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005065 u8 u8KeyLen = u8GtkKeylen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005066
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005067 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005068 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005069 /* prepare the Key Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005070 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005071
5072
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005073 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005074 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005075 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005076 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005077 if (KeyRSC != NULL) {
5078 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
Glen Leef3052582015-09-10 12:03:04 +09005079 uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005080
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005081 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005082 KeyRSC, u32KeyRSClen);
5083 }
5084
5085
5086 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
5087 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPARxGtk;
5088 strHostIFmsg.drvHandler = hWFIDrv;
5089
5090 #ifdef WILC_AP_EXTERNAL_MLME
5091 if (mode == AP_MODE) {
5092 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
5093 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
5094 }
5095 #endif
5096 if (mode == STATION_MODE)
5097 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
5098
5099
5100 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
Glen Leef3052582015-09-10 12:03:04 +09005101 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8KeyLen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005102
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005103 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005104 pu8RxGtk, u8GtkKeylen);
5105
5106 if (pu8RxMic != NULL) {
5107
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005108 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005109 pu8RxMic, RX_MIC_KEY_LEN);
5110
5111 }
5112 if (pu8TxMic != NULL) {
5113
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005114 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005115 pu8TxMic, TX_MIC_KEY_LEN);
5116
5117 }
5118
5119 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5120 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
5121 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5122 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
5123
5124 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
5125 uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
5126
5127
5128
5129 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09005130 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005131 if (s32Error)
5132 PRINT_ER("Error in sending message queue: RX GTK\n");
5133 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005134 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005135 /* /////// */
5136
5137 WILC_CATCH(s32Error)
5138 {
5139
5140 }
5141 return s32Error;
5142}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005143
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005144/**
5145 * @brief host_int_set_pmkid_info
5146 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
5147 * support is enabled. This Function sets the PMKID in firmware
5148 * when host drivr receives the corresponding request from NDIS.
5149 * The firmware then includes theset PMKID in the appropriate
5150 * management frames
5151 * @param[in,out] handle to the wifi driver
5152 * @param[in] message containing PMKID Info in the following format
5153 *|-----------------------------------------------------------------|
5154 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5155 *|-----------|------------|----------|-------|----------|----------|
5156 | 1 | 6 | 16 | ... | 6 | 16 |
5157 ||-----------------------------------------------------------------|
5158 * @return Error code indicating success/failure
5159 * @note
5160 * @author zsalah
5161 * @date 8 March 2012
5162 * @version 1.0
5163 */
Johnny Kim218dc402015-08-13 13:41:19 +09005164s32 host_int_set_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005165{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005166 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005167 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5168 tstrHostIFmsg strHostIFmsg;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005169 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005170
5171
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005172 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005173 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005174
5175 /* prepare the Key Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005176 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005177
5178 strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
5179 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = PMKSA;
5180 strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
5181 strHostIFmsg.drvHandler = hWFIDrv;
5182
5183 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
5184
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005185 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005186 ETH_ALEN);
5187
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005188 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005189 PMKID_LEN);
5190 }
5191
5192 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09005193 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005194 if (s32Error)
5195 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
5196
5197 WILC_CATCH(s32Error)
5198 {
5199
5200 }
5201
5202 return s32Error;
5203}
5204
5205/**
5206 * @brief gets the cached the pmkid info
5207 * @details valid only in BSS STA mode if External Supplicant
5208 * support is enabled. This Function sets the PMKID in firmware
5209 * when host drivr receives the corresponding request from NDIS.
5210 * The firmware then includes theset PMKID in the appropriate
5211 * management frames
5212 * @param[in,out] handle to the wifi driver,
5213 * message containing PMKID Info in the following format
5214 *|-----------------------------------------------------------------|
5215 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5216 *|-----------|------------|----------|-------|----------|----------|
5217 | 1 | 6 | 16 | ... | 6 | 16 |
5218 ||-----------------------------------------------------------------|
5219 * @param[in]
5220 * @return Error code indicating success/failure
5221 * @note
5222 * @author zsalah
5223 * @date 8 March 2012
5224 * @version 1.0
5225 */
Johnny Kim218dc402015-08-13 13:41:19 +09005226s32 host_int_get_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PmkidInfoArray,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005227 u32 u32PmkidInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005228{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005229 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005230 tstrWID strWID;
5231 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5232
Chaehyun Limd85f5322015-06-11 14:35:54 +09005233 strWID.u16WIDid = (u16)WID_PMKID_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005234 strWID.enuWIDtype = WID_STR;
5235 strWID.s32ValueSize = u32PmkidInfoLen;
5236 strWID.ps8WidVal = pu8PmkidInfoArray;
5237
5238 return s32Error;
5239}
5240
5241/**
5242 * @brief sets the pass phrase
5243 * @details AP/STA mode. This function gives the pass phrase used to
5244 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5245 * The length of the field can vary from 8 to 64 bytes,
5246 * the lower layer should get the
5247 * @param[in,out] handle to the wifi driver,
5248 * @param[in] String containing PSK
5249 * @return Error code indicating success/failure
5250 * @note
5251 * @author zsalah
5252 * @date 8 March 2012
5253 * @version 1.0
5254 */
Johnny Kim218dc402015-08-13 13:41:19 +09005255s32 host_int_set_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PassPhrase,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005256 u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005257{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005258 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005259 tstrWID strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005260
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005261 /*validating psk length*/
5262 if ((u8Psklength > 7) && (u8Psklength < 65)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09005263 strWID.u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005264 strWID.enuWIDtype = WID_STR;
5265 strWID.ps8WidVal = pu8PassPhrase;
5266 strWID.s32ValueSize = u8Psklength;
5267 }
5268
5269 return s32Error;
5270}
5271/**
5272 * @brief host_int_get_MacAddress
5273 * @details gets mac address
5274 * @param[in,out] handle to the wifi driver,
5275 *
5276 * @return Error code indicating success/failure
5277 * @note
5278 * @author mdaftedar
5279 * @date 19 April 2012
5280 * @version 1.0
5281 */
Johnny Kim218dc402015-08-13 13:41:19 +09005282s32 host_int_get_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005283{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005284 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005285 tstrHostIFmsg strHostIFmsg;
5286
5287
5288 /* prepare the Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005289 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005290
5291 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_MAC_ADDRESS;
5292 strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress.u8MacAddress = pu8MacAddress;
5293 strHostIFmsg.drvHandler = hWFIDrv;
5294 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09005295 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005296 if (s32Error) {
5297 PRINT_ER("Failed to send get mac address\n");
5298 return WILC_FAIL;
5299 }
5300
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005301 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005302 return s32Error;
5303}
5304
5305/**
5306 * @brief host_int_set_MacAddress
5307 * @details sets mac address
5308 * @param[in,out] handle to the wifi driver,
5309 *
5310 * @return Error code indicating success/failure
5311 * @note
5312 * @author mabubakr
5313 * @date 16 July 2012
5314 * @version 1.0
5315 */
Johnny Kim218dc402015-08-13 13:41:19 +09005316s32 host_int_set_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005317{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005318 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005319 tstrHostIFmsg strHostIFmsg;
5320
5321 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
5322
5323 /* prepare setting mac address message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005324 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005325 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MAC_ADDRESS;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005326 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress.u8MacAddress, pu8MacAddress, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005327 strHostIFmsg.drvHandler = hWFIDrv;
5328
Chaehyun Lim79198132015-08-19 15:59:06 +09005329 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005330 if (s32Error) {
5331 PRINT_ER("Failed to send message queue: Set mac address\n");
5332 WILC_ERRORREPORT(s32Error, s32Error);
5333 }
5334 WILC_CATCH(s32Error)
5335 {
5336
5337 }
5338
5339 return s32Error;
5340
5341}
5342
5343/**
5344 * @brief host_int_get_RSNAConfigPSKPassPhrase
5345 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
5346 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5347 * The length of the field can vary from 8 to 64 bytes,
5348 * the lower layer should get the
5349 * @param[in,out] handle to the wifi driver,
5350 * String containing PSK
5351 * @return Error code indicating success/failure
5352 * @note
5353 * @author zsalah
5354 * @date 8 March 2012
5355 * @version 1.0
5356 */
Johnny Kim218dc402015-08-13 13:41:19 +09005357s32 host_int_get_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005358 u8 *pu8PassPhrase, u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005359{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005360 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005361 tstrWID strWID;
5362 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5363
Chaehyun Limd85f5322015-06-11 14:35:54 +09005364 strWID.u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005365 strWID.enuWIDtype = WID_STR;
5366 strWID.s32ValueSize = u8Psklength;
5367 strWID.ps8WidVal = pu8PassPhrase;
5368
5369 return s32Error;
5370}
5371
5372/**
5373 * @brief host_int_get_site_survey_results
5374 * @details gets the site survey results
5375 * @param[in,out] handle to the wifi driver,
5376 * Message containing site survey results in the
5377 * following format
5378 *|---------------------------------------------------|
5379 | MsgLength | fragNo. | MsgBodyLength | MsgBody |
5380 ||-----------|-----------|---------------|-----------|
5381 | 1 | 1 | 1 | 1 |
5382 | ----------------------------------------- | ----------------
5383 |
5384 ||---------------------------------------|
5385 | Network1 | Netweork2 | ... | Network5 |
5386 ||---------------------------------------|
5387 | 44 | 44 | ... | 44 |
5388 | -------------------------- | ---------------------------------------
5389 |
5390 ||---------------------------------------------------------------------|
5391 | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved |
5392 |
5393 |
5394 ||------|----------|---------|----------------|-------|------|---------|
5395 | 33 | 1 | 1 | 1 | 6 | 1 | 1 |
5396 ||---------------------------------------------------------------------|
5397 * @return Error code indicating success/failure
5398 * @note
5399 * @author zsalah
5400 * @date 8 March 2012
5401 * @version 1.0
5402 */
5403#ifndef CONNECT_DIRECT
Johnny Kim218dc402015-08-13 13:41:19 +09005404s32 host_int_get_site_survey_results(tstrWILC_WFIDrv *hWFIDrv,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005405 u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE],
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005406 u32 u32MaxSiteSrvyFragLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005407{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005408 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005409 tstrWID astrWIDList[2];
5410 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5411
Chaehyun Limd85f5322015-06-11 14:35:54 +09005412 astrWIDList[0].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005413 astrWIDList[0].enuWIDtype = WID_STR;
5414 astrWIDList[0].ps8WidVal = ppu8RcvdSiteSurveyResults[0];
5415 astrWIDList[0].s32ValueSize = u32MaxSiteSrvyFragLen;
5416
Chaehyun Limd85f5322015-06-11 14:35:54 +09005417 astrWIDList[1].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005418 astrWIDList[1].enuWIDtype = WID_STR;
5419 astrWIDList[1].ps8WidVal = ppu8RcvdSiteSurveyResults[1];
5420 astrWIDList[1].s32ValueSize = u32MaxSiteSrvyFragLen;
5421
Johnny Kimd42ab082015-08-20 16:32:52 +09005422 s32Error = SendConfigPkt(GET_CFG, astrWIDList, 2, true,
5423 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005424
5425 /*get the value by searching the local copy*/
5426 if (s32Error) {
5427 PRINT_ER("Failed to send config packet to get survey results\n");
5428 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5429 }
5430
5431 WILC_CATCH(s32Error)
5432 {
5433
5434 }
5435
5436 return s32Error;
5437}
5438#endif
5439
5440/**
5441 * @brief sets a start scan request
5442 * @details
5443 * @param[in,out] handle to the wifi driver,
5444 * @param[in] Scan Source one of the following values
5445 * DEFAULT_SCAN 0
5446 * USER_SCAN BIT0
5447 * OBSS_PERIODIC_SCAN BIT1
5448 * OBSS_ONETIME_SCAN BIT2
5449 * @return Error code indicating success/failure
5450 * @note
5451 * @author zsalah
5452 * @date 8 March 2012
5453 * @version 1.0
5454 */
Johnny Kim218dc402015-08-13 13:41:19 +09005455s32 host_int_set_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 scanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005456{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005457 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005458 tstrWID strWID;
5459 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5460
Chaehyun Limd85f5322015-06-11 14:35:54 +09005461 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005462 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005463 strWID.ps8WidVal = (s8 *)&scanSource;
Dean Lee576917a2015-06-15 11:58:57 +09005464 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005465
5466 return s32Error;
5467}
5468
5469/**
5470 * @brief host_int_get_start_scan_req
5471 * @details gets a start scan request
5472 * @param[in,out] handle to the wifi driver,
5473 * @param[in] Scan Source one of the following values
5474 * DEFAULT_SCAN 0
5475 * USER_SCAN BIT0
5476 * OBSS_PERIODIC_SCAN BIT1
5477 * OBSS_ONETIME_SCAN BIT2
5478 * @return Error code indicating success/failure
5479 * @note
5480 * @author zsalah
5481 * @date 8 March 2012
5482 * @version 1.0
5483 */
5484
Johnny Kim218dc402015-08-13 13:41:19 +09005485s32 host_int_get_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ScanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005486{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005487 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005488 tstrWID strWID;
5489 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5490
Chaehyun Limd85f5322015-06-11 14:35:54 +09005491 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005492 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005493 strWID.ps8WidVal = (s8 *)pu8ScanSource;
Dean Lee576917a2015-06-15 11:58:57 +09005494 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005495
5496 return s32Error;
5497}
5498
5499/**
5500 * @brief host_int_set_join_req
5501 * @details sets a join request
5502 * @param[in,out] handle to the wifi driver,
5503 * @param[in] Index of the bss descriptor
5504 * @return Error code indicating success/failure
5505 * @note
5506 * @author zsalah
5507 * @date 8 March 2012
5508 * @version 1.0
5509 */
Johnny Kim218dc402015-08-13 13:41:19 +09005510s32 host_int_set_join_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8bssid,
Arnd Bergmann057d1e92015-06-01 21:06:44 +02005511 const u8 *pu8ssid, size_t ssidLen,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005512 const u8 *pu8IEs, size_t IEsLen,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005513 tWILCpfConnectResult pfConnectResult, void *pvUserArg,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005514 u8 u8security, AUTHTYPE_T tenuAuth_type,
5515 u8 u8channel,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005516 void *pJoinParams)
5517{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005518 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005519 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5520 tstrHostIFmsg strHostIFmsg;
5521 tenuScanConnTimer enuScanConnTimer;
5522
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005523 if (pstrWFIDrv == NULL || pfConnectResult == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005524 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005525
5526 if (hWFIDrv == NULL) {
5527 PRINT_ER("Driver not initialized: gWFiDrvHandle = NULL\n");
5528 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5529 }
5530
5531 if (pJoinParams == NULL) {
5532 PRINT_ER("Unable to Join - JoinParams is NULL\n");
5533 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5534
5535 }
5536/*
5537 * if(gWFiDrvHandle->strWILC_UsrScanReq.u32RcvdChCount == 0)
5538 * {
5539 * PRINT_ER("No scan results exist: Scanning should be done\n");
5540 * WILC_ERRORREPORT(s32Error, WILC_FAIL);
5541 * }
5542 */
5543 /* prepare the Connect Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005544 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005545
5546 strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT;
5547
5548 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8security = u8security;
5549 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.tenuAuth_type = tenuAuth_type;
5550 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8channel = u8channel;
5551 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pfConnectResult = pfConnectResult;
5552 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pvUserArg = pvUserArg;
5553 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pJoinParams = pJoinParams;
5554 strHostIFmsg.drvHandler = hWFIDrv;
5555
5556 if (pu8bssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09005557 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid = kmalloc(6, GFP_KERNEL); /* will be deallocated by the receiving thread */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005558 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005559 pu8bssid, 6);
5560 }
5561
5562 if (pu8ssid != NULL) {
5563 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.ssidLen = ssidLen;
Glen Leef3052582015-09-10 12:03:04 +09005564 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid = kmalloc(ssidLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005565 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005566
5567 pu8ssid, ssidLen);
5568 }
5569
5570 if (pu8IEs != NULL) {
5571 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.IEsLen = IEsLen;
Glen Leef3052582015-09-10 12:03:04 +09005572 strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005573 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005574 pu8IEs, IEsLen);
5575 }
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05305576 if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005577 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05305578 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005579 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate);
5580
5581 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09005582 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005583 if (s32Error) {
5584 PRINT_ER("Failed to send message queue: Set join request\n");
5585 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5586 }
5587
5588 enuScanConnTimer = CONNECT_TIMER;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005589 pstrWFIDrv->hConnectTimer.data = (unsigned long)hWFIDrv;
5590 mod_timer(&pstrWFIDrv->hConnectTimer,
5591 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005592
5593 WILC_CATCH(s32Error)
5594 {
5595
5596 }
5597
5598 return s32Error;
5599}
5600
5601/**
5602 * @brief Flush a join request parameters to FW, but actual connection
5603 * @details The function is called in situation where WILC is connected to AP and
5604 * required to switch to hybrid FW for P2P connection
5605 * @param[in] handle to the wifi driver,
5606 * @return Error code indicating success/failure
5607 * @note
5608 * @author Amr Abdel-Moghny
5609 * @date 19 DEC 2013
5610 * @version 8.0
5611 */
5612
Johnny Kim218dc402015-08-13 13:41:19 +09005613s32 host_int_flush_join_req(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005614{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005615 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005616 tstrHostIFmsg strHostIFmsg;
5617
5618 if (!gu8FlushedJoinReq) {
5619 s32Error = WILC_FAIL;
5620 return s32Error;
5621 }
5622
5623
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005624 if (hWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005625 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005626
5627
5628 strHostIFmsg.u16MsgId = HOST_IF_MSG_FLUSH_CONNECT;
5629 strHostIFmsg.drvHandler = hWFIDrv;
5630
5631 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09005632 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005633 if (s32Error) {
5634 PRINT_ER("Failed to send message queue: Flush join request\n");
5635 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5636 }
5637
5638 WILC_CATCH(s32Error)
5639 {
5640
5641 }
5642 return s32Error;
5643}
5644
5645/**
5646 * @brief host_int_disconnect
5647 * @details disconnects from the currently associated network
5648 * @param[in,out] handle to the wifi driver,
5649 * @param[in] Reason Code of the Disconnection
5650 * @return Error code indicating success/failure
5651 * @note
5652 * @author zsalah
5653 * @date 8 March 2012
5654 * @version 1.0
5655 */
Johnny Kim218dc402015-08-13 13:41:19 +09005656s32 host_int_disconnect(tstrWILC_WFIDrv *hWFIDrv, u16 u16ReasonCode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005657{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005658 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005659 tstrHostIFmsg strHostIFmsg;
5660 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5661
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005662 if (pstrWFIDrv == NULL) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005663 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005664 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5665 }
5666
5667 if (pstrWFIDrv == NULL) {
5668 PRINT_ER("gWFiDrvHandle = NULL\n");
5669 WILC_ERRORREPORT(s32Error, WILC_FAIL);
5670 }
5671
5672 /* prepare the Disconnect Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005673 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005674
5675 strHostIFmsg.u16MsgId = HOST_IF_MSG_DISCONNECT;
5676 strHostIFmsg.drvHandler = hWFIDrv;
5677
5678 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09005679 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005680 if (s32Error)
5681 PRINT_ER("Failed to send message queue: disconnect\n");
5682 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005683 down(&(pstrWFIDrv->hSemTestDisconnectBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005684 /* /////// */
5685
5686 WILC_CATCH(s32Error)
5687 {
5688
5689 }
5690
5691 return s32Error;
5692}
5693
5694/**
5695 * @brief host_int_disconnect_station
5696 * @details disconnects a sta
5697 * @param[in,out] handle to the wifi driver,
5698 * @param[in] Association Id of the station to be disconnected
5699 * @return Error code indicating success/failure
5700 * @note
5701 * @author zsalah
5702 * @date 8 March 2012
5703 * @version 1.0
5704 */
Johnny Kim218dc402015-08-13 13:41:19 +09005705s32 host_int_disconnect_station(tstrWILC_WFIDrv *hWFIDrv, u8 assoc_id)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005706{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005707 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005708 tstrWID strWID;
5709 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5710
Chaehyun Limd85f5322015-06-11 14:35:54 +09005711 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005712 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005713 strWID.ps8WidVal = (s8 *)&assoc_id;
Dean Lee576917a2015-06-15 11:58:57 +09005714 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005715
5716 return s32Error;
5717}
5718
5719/**
5720 * @brief host_int_get_assoc_req_info
5721 * @details gets a Association request info
5722 * @param[in,out] handle to the wifi driver,
5723 * Message containg assoc. req info in the following format
5724 * ------------------------------------------------------------------------
5725 | Management Frame Format |
5726 ||-------------------------------------------------------------------|
5727 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5728 ||-------------|--------|--|--|-----|----------------|----------|----|
5729 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5730 ||-------------------------------------------------------------------|
5731 | |
5732 | Association Request Frame - Frame Body |
5733 ||-------------------------------------------------------------------|
5734 | Capability Information | Listen Interval | SSID | Supported Rates |
5735 ||------------------------|-----------------|------|-----------------|
5736 | 2 | 2 | 2-34 | 3-10 |
5737 | ---------------------------------------------------------------------
5738 * @return Error code indicating success/failure
5739 * @note
5740 * @author zsalah
5741 * @date 8 March 2012
5742 * @version 1.0
5743 */
5744
Johnny Kim218dc402015-08-13 13:41:19 +09005745s32 host_int_get_assoc_req_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocReqInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005746 u32 u32AssocReqInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005747{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005748 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005749 tstrWID strWID;
5750 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5751
Chaehyun Limd85f5322015-06-11 14:35:54 +09005752 strWID.u16WIDid = (u16)WID_ASSOC_REQ_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005753 strWID.enuWIDtype = WID_STR;
5754 strWID.ps8WidVal = pu8AssocReqInfo;
5755 strWID.s32ValueSize = u32AssocReqInfoLen;
5756
5757
5758 return s32Error;
5759}
5760
5761/**
5762 * @brief gets a Association Response info
5763 * @details
5764 * @param[in,out] handle to the wifi driver,
5765 * Message containg assoc. resp info
5766 * @return Error code indicating success/failure
5767 * @note
5768 * @author zsalah
5769 * @date 8 March 2012
5770 * @version 1.0
5771 */
Johnny Kim218dc402015-08-13 13:41:19 +09005772s32 host_int_get_assoc_res_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocRespInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005773 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005774{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005775 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005776 tstrWID strWID;
5777 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5778
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005779 if (pstrWFIDrv == NULL) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005780 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005781 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5782 }
5783
Chaehyun Limd85f5322015-06-11 14:35:54 +09005784 strWID.u16WIDid = (u16)WID_ASSOC_RES_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005785 strWID.enuWIDtype = WID_STR;
5786 strWID.ps8WidVal = pu8AssocRespInfo;
5787 strWID.s32ValueSize = u32MaxAssocRespInfoLen;
5788
5789
5790 /* Sending Configuration packet */
Johnny Kimd42ab082015-08-20 16:32:52 +09005791 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
5792 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005793 if (s32Error) {
5794 PRINT_ER("Failed to send association response config packet\n");
5795 *pu32RcvdAssocRespInfoLen = 0;
5796 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
5797 } else {
5798 *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize;
5799 }
5800
5801 WILC_CATCH(s32Error)
5802 {
5803
5804 }
5805 return s32Error;
5806}
5807
5808/**
5809 * @brief gets a Association Response info
5810 * @details Valid only in STA mode. This function gives the RSSI
5811 * values observed in all the channels at the time of scanning.
5812 * The length of the field is 1 greater that the total number of
5813 * channels supported. Byte 0 contains the number of channels while
5814 * each of Byte N contains the observed RSSI value for the channel index N.
5815 * @param[in,out] handle to the wifi driver,
5816 * array of scanned channels' RSSI
5817 * @return Error code indicating success/failure
5818 * @note
5819 * @author zsalah
5820 * @date 8 March 2012
5821 * @version 1.0
5822 */
Johnny Kim218dc402015-08-13 13:41:19 +09005823s32 host_int_get_rx_power_level(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8RxPowerLevel,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005824 u32 u32RxPowerLevelLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005825{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005826 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005827 tstrWID strWID;
5828 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5829
Chaehyun Limd85f5322015-06-11 14:35:54 +09005830 strWID.u16WIDid = (u16)WID_RX_POWER_LEVEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005831 strWID.enuWIDtype = WID_STR;
5832 strWID.ps8WidVal = pu8RxPowerLevel;
5833 strWID.s32ValueSize = u32RxPowerLevelLen;
5834
5835
5836 return s32Error;
5837}
5838
5839/**
5840 * @brief sets a channel
5841 * @details
5842 * @param[in,out] handle to the wifi driver,
5843 * @param[in] Index of the channel to be set
5844 *|-------------------------------------------------------------------|
5845 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5846 | Input: 1 2 14 |
5847 ||-------------------------------------------------------------------|
5848 * @return Error code indicating success/failure
5849 * @note
5850 * @author zsalah
5851 * @date 8 March 2012
5852 * @version 1.0
5853 */
Johnny Kim218dc402015-08-13 13:41:19 +09005854s32 host_int_set_mac_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 u8ChNum)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005855{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005856 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005857 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5858 tstrHostIFmsg strHostIFmsg;
5859
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005860 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005861 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005862
5863 /* prepare the set channel message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005864 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005865 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_CHANNEL;
5866 strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan.u8SetChan = u8ChNum;
5867 strHostIFmsg.drvHandler = hWFIDrv;
5868
Chaehyun Lim79198132015-08-19 15:59:06 +09005869 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005870 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005871 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005872 WILC_CATCH(s32Error)
5873 {
5874
5875 }
5876
5877 return s32Error;
5878}
5879
5880
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005881s32 host_int_wait_msg_queue_idle(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005882{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005883 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005884
5885 tstrHostIFmsg strHostIFmsg;
5886
5887 /* prepare the set driver handler message */
5888
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005889 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005890 strHostIFmsg.u16MsgId = HOST_IF_MSG_Q_IDLE;
Chaehyun Lim79198132015-08-19 15:59:06 +09005891 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005892 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005893 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005894 WILC_CATCH(s32Error)
5895 {
5896
5897 }
5898
5899 /* wait untill MSG Q is empty */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005900 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005901
5902 return s32Error;
5903
5904}
5905
Johnny Kim218dc402015-08-13 13:41:19 +09005906s32 host_int_set_wfi_drv_handler(tstrWILC_WFIDrv *u32address)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005907{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005908 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005909
5910 tstrHostIFmsg strHostIFmsg;
5911
5912
5913 /* prepare the set driver handler message */
5914
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005915 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005916 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_WFIDRV_HANDLER;
Johnny Kimd42ab082015-08-20 16:32:52 +09005917 strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler.u32Address = get_id_from_handler(u32address);
Johnny Kim53a84402015-08-20 16:32:51 +09005918 strHostIFmsg.drvHandler = u32address;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005919
Chaehyun Lim79198132015-08-19 15:59:06 +09005920 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005921 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005922 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005923 WILC_CATCH(s32Error)
5924 {
5925
5926 }
5927
5928 return s32Error;
5929}
5930
5931
5932
Johnny Kim218dc402015-08-13 13:41:19 +09005933s32 host_int_set_operation_mode(tstrWILC_WFIDrv *hWFIDrv, u32 u32mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005934{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005935 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005936
5937 tstrHostIFmsg strHostIFmsg;
5938
5939
5940 /* prepare the set driver handler message */
5941
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005942 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005943 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_OPERATION_MODE;
5944 strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode.u32Mode = u32mode;
5945 strHostIFmsg.drvHandler = hWFIDrv;
5946
Chaehyun Lim79198132015-08-19 15:59:06 +09005947 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005948 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005949 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005950 WILC_CATCH(s32Error)
5951 {
5952
5953 }
5954
5955 return s32Error;
5956}
5957
5958/**
5959 * @brief gets the current channel index
5960 * @details
5961 * @param[in,out] handle to the wifi driver,
5962 * current channel index
5963 *|-----------------------------------------------------------------------|
5964 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5965 | Input: 1 2 14 |
5966 ||-----------------------------------------------------------------------|
5967 * @return Error code indicating success/failure
5968 * @note
5969 * @author zsalah
5970 * @date 8 March 2012
5971 * @version 1.0
5972 */
Johnny Kim218dc402015-08-13 13:41:19 +09005973s32 host_int_get_host_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ChNo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005974{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005975 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005976 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5977 tstrHostIFmsg strHostIFmsg;
5978
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005979 if (pstrWFIDrv == NULL) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005980 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005981 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
5982 }
5983
5984 /* prepare the Get Channel Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09005985 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005986
5987 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_CHNL;
5988 strHostIFmsg.drvHandler = hWFIDrv;
5989
5990 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09005991 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005992 if (s32Error)
5993 PRINT_ER("Failed to send get host channel param's message queue ");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005994 down(&(pstrWFIDrv->hSemGetCHNL));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005995 /* gu8Chnl = 11; */
5996
5997 *pu8ChNo = gu8Chnl;
5998
5999 WILC_CATCH(s32Error)
6000 {
6001 }
6002
6003 return s32Error;
6004
6005
6006}
6007
6008
6009/**
6010 * @brief host_int_test_set_int_wid
6011 * @details Test function for setting wids
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006012 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006013 * @return Error code indicating success/failure
6014 * @note
6015 * @author zsalah
6016 * @date 8 March 2012
6017 * @version 1.0
6018 */
Johnny Kim218dc402015-08-13 13:41:19 +09006019s32 host_int_test_set_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 u32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006020{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006021 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006022 tstrWID strWID;
6023 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6024
6025
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006026 if (pstrWFIDrv == NULL) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006027 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006028 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6029 }
6030
6031 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +09006032 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006033 strWID.enuWIDtype = WID_INT;
Dean Lee576917a2015-06-15 11:58:57 +09006034 strWID.ps8WidVal = (char *)&u32TestMemAddr;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006035 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006036
6037 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09006038 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
6039 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006040 if (s32Error) {
6041 PRINT_ER("Test Function: Failed to set wid value\n");
6042 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
6043 } else {
6044 PRINT_D(HOSTINF_DBG, "Successfully set wid value\n");
6045
6046 }
6047
6048 WILC_CATCH(s32Error)
6049 {
6050
6051 }
6052 return s32Error;
6053}
6054
6055#ifdef WILC_AP_EXTERNAL_MLME
6056/**
6057 * @brief host_int_get_inactive_time
6058 * @details
6059 * @param[in,out] handle to the wifi driver,
6060 * current sta macaddress, inactive_time
6061 * @return
6062 * @note
6063 * @author
6064 * @date
6065 * @version 1.0
6066 */
Johnny Kim218dc402015-08-13 13:41:19 +09006067s32 host_int_get_inactive_time(tstrWILC_WFIDrv *hWFIDrv, const u8 *mac, u32 *pu32InactiveTime)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006068{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006069 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006070 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6071 tstrHostIFmsg strHostIFmsg;
6072
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006073 if (pstrWFIDrv == NULL) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006074 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006075 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6076 }
6077
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006078 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006079
6080
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006081 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT.mac,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006082 mac, ETH_ALEN);
6083
6084 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_INACTIVETIME;
6085 strHostIFmsg.drvHandler = hWFIDrv;
6086
6087 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09006088 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006089 if (s32Error)
6090 PRINT_ER("Failed to send get host channel param's message queue ");
6091
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006092 down(&(pstrWFIDrv->hSemInactiveTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006093
6094 *pu32InactiveTime = gu32InactiveTime;
6095
6096 WILC_CATCH(s32Error)
6097 {
6098 }
6099
6100 return s32Error;
6101}
6102#endif
6103/**
6104 * @brief host_int_test_get_int_wid
6105 * @details Test function for getting wids
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006106 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006107 * @return Error code indicating success/failure
6108 * @note
6109 * @author zsalah
6110 * @date 8 March 2012
6111 * @version 1.0
6112 */
Johnny Kim218dc402015-08-13 13:41:19 +09006113s32 host_int_test_get_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 *pu32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006114{
6115
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006116 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006117 tstrWID strWID;
6118 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6119
6120
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006121 if (pstrWFIDrv == NULL) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006122 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006123 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6124 }
6125
Chaehyun Limd85f5322015-06-11 14:35:54 +09006126 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006127 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09006128 strWID.ps8WidVal = (s8 *)pu32TestMemAddr;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006129 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006130
Johnny Kimd42ab082015-08-20 16:32:52 +09006131 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
6132 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006133 /*get the value by searching the local copy*/
6134 if (s32Error) {
6135 PRINT_ER("Test Function: Failed to get wid value\n");
6136 WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
6137 } else {
6138 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
6139
6140 }
6141
6142 WILC_CATCH(s32Error)
6143 {
6144
6145 }
6146 return s32Error;
6147}
6148
6149
6150/**
6151 * @brief host_int_get_rssi
6152 * @details gets the currently maintained RSSI value for the station.
6153 * The received signal strength value in dB.
6154 * The range of valid values is -128 to 0.
6155 * @param[in,out] handle to the wifi driver,
6156 * rssi value in dB
6157 * @return Error code indicating success/failure
6158 * @note
6159 * @author zsalah
6160 * @date 8 March 2012
6161 * @version 1.0
6162 */
Johnny Kim218dc402015-08-13 13:41:19 +09006163s32 host_int_get_rssi(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006164{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006165 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006166 tstrHostIFmsg strHostIFmsg;
6167 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6168
6169
6170 /* prepare the Get RSSI Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006171 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006172
6173 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
6174 strHostIFmsg.drvHandler = hWFIDrv;
6175
6176 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09006177 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006178 if (s32Error) {
6179 PRINT_ER("Failed to send get host channel param's message queue ");
6180 return WILC_FAIL;
6181 }
6182
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006183 down(&(pstrWFIDrv->hSemGetRSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006184
6185
6186 if (ps8Rssi == NULL) {
6187 PRINT_ER("RSS pointer value is null");
6188 return WILC_FAIL;
6189 }
6190
6191
6192 *ps8Rssi = gs8Rssi;
6193
6194
6195 return s32Error;
6196}
6197
Johnny Kim218dc402015-08-13 13:41:19 +09006198s32 host_int_get_link_speed(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8lnkspd)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006199{
6200 tstrHostIFmsg strHostIFmsg;
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006201 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006202
6203 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6204
6205
6206
6207 /* prepare the Get LINKSPEED Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006208 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006209
6210 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_LINKSPEED;
6211 strHostIFmsg.drvHandler = hWFIDrv;
6212
6213 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09006214 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006215 if (s32Error) {
6216 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
6217 return WILC_FAIL;
6218 }
6219
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006220 down(&(pstrWFIDrv->hSemGetLINKSPEED));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006221
6222
6223 if (ps8lnkspd == NULL) {
6224 PRINT_ER("LINKSPEED pointer value is null");
6225 return WILC_FAIL;
6226 }
6227
6228
6229 *ps8lnkspd = gs8lnkspd;
6230
6231
6232 return s32Error;
6233}
6234
Johnny Kim218dc402015-08-13 13:41:19 +09006235s32 host_int_get_statistics(tstrWILC_WFIDrv *hWFIDrv, tstrStatistics *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006236{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006237 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006238 tstrHostIFmsg strHostIFmsg;
6239
6240
6241 /* prepare the Get RSSI Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006242 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006243
6244 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_STATISTICS;
Dean Lee576917a2015-06-15 11:58:57 +09006245 strHostIFmsg.uniHostIFmsgBody.pUserData = (char *)pstrStatistics;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006246 strHostIFmsg.drvHandler = hWFIDrv;
6247 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09006248 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006249 if (s32Error) {
6250 PRINT_ER("Failed to send get host channel param's message queue ");
6251 return WILC_FAIL;
6252 }
6253
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006254 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006255 return s32Error;
6256}
6257
6258
6259/**
6260 * @brief host_int_scan
6261 * @details scans a set of channels
6262 * @param[in,out] handle to the wifi driver,
6263 * @param[in] Scan source
6264 * Scan Type PASSIVE_SCAN = 0,
6265 * ACTIVE_SCAN = 1
6266 * Channels Array
6267 * Channels Array length
6268 * Scan Callback function
6269 * @return Error code indicating success/failure
6270 * @note
6271 * @author zsalah
6272 * @date 8 March 2012
6273 * @version 1.0
6274 */
Johnny Kim218dc402015-08-13 13:41:19 +09006275s32 host_int_scan(tstrWILC_WFIDrv *hWFIDrv, u8 u8ScanSource,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006276 u8 u8ScanType, u8 *pu8ChnlFreqList,
6277 u8 u8ChnlListLen, const u8 *pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006278 size_t IEsLen, tWILCpfScanResult ScanResult,
6279 void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork)
6280{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006281 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006282 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6283 tstrHostIFmsg strHostIFmsg;
6284 tenuScanConnTimer enuScanConnTimer;
6285
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006286 if (pstrWFIDrv == NULL || ScanResult == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006287 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006288
6289
6290 /* prepare the Scan Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006291 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006292
6293 strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN;
6294
6295 if (pstrHiddenNetwork != NULL) {
6296 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
6297 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
6298
6299 } else
6300 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
6301
6302 strHostIFmsg.drvHandler = hWFIDrv;
6303 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanSource = u8ScanSource;
6304 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanType = u8ScanType;
6305 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pfScanResult = ScanResult;
6306 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pvUserArg = pvUserArg;
6307
6308 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ChnlListLen = u8ChnlListLen;
Glen Leef3052582015-09-10 12:03:04 +09006309 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList = kmalloc(u8ChnlListLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006310 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006311 pu8ChnlFreqList, u8ChnlListLen);
6312
6313 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.IEsLen = IEsLen;
Glen Leef3052582015-09-10 12:03:04 +09006314 strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006315 memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006316 pu8IEs, IEsLen);
6317
6318 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09006319 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006320 if (s32Error) {
6321 PRINT_ER("Error in sending message queue scanning parameters: Error(%d)\n", s32Error);
6322 WILC_ERRORREPORT(s32Error, WILC_FAIL);
6323 }
6324
6325 enuScanConnTimer = SCAN_TIMER;
6326 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07006327 pstrWFIDrv->hScanTimer.data = (unsigned long)hWFIDrv;
6328 mod_timer(&pstrWFIDrv->hScanTimer,
6329 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006330
6331 WILC_CATCH(s32Error)
6332 {
6333
6334 }
6335 return s32Error;
6336
6337}
6338/**
6339 * @brief hif_set_cfg
6340 * @details sets configuration wids values
6341 * @param[in,out] handle to the wifi driver,
6342 * @param[in] WID, WID value
6343 * @return Error code indicating success/failure
6344 * @note
6345 * @author zsalah
6346 * @date 8 March 2012
6347 * @version 1.0
6348 */
Johnny Kim218dc402015-08-13 13:41:19 +09006349s32 hif_set_cfg(tstrWILC_WFIDrv *hWFIDrv, tstrCfgParamVal *pstrCfgParamVal)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006350{
6351
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006352 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006353 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6354
6355 tstrHostIFmsg strHostIFmsg;
6356
6357
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006358 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006359 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006360 /* prepare the WiphyParams Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006361 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006362 strHostIFmsg.u16MsgId = HOST_IF_MSG_CFG_PARAMS;
6363 strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr.pstrCfgParamVal = *pstrCfgParamVal;
6364 strHostIFmsg.drvHandler = hWFIDrv;
6365
Chaehyun Lim79198132015-08-19 15:59:06 +09006366 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006367
6368 WILC_CATCH(s32Error)
6369 {
6370 }
6371
6372 return s32Error;
6373
6374}
6375
6376
6377/**
6378 * @brief hif_get_cfg
6379 * @details gets configuration wids values
6380 * @param[in,out] handle to the wifi driver,
6381 * WID value
6382 * @param[in] WID,
6383 * @return Error code indicating success/failure
6384 * @note
6385 * @author zsalah
6386 *
6387 * @date 8 March 2012
6388 * @version 1.0
6389 */
Johnny Kim218dc402015-08-13 13:41:19 +09006390s32 hif_get_cfg(tstrWILC_WFIDrv *hWFIDrv, u16 u16WID, u16 *pu16WID_Value)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006391{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006392 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006393 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6394
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006395 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006396
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006397 if (pstrWFIDrv == NULL) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006398 PRINT_ER("Driver not initialized: pstrWFIDrv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006399 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
6400 }
6401 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
6402 switch (u16WID) {
6403
6404 case WID_BSS_TYPE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006405 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006406 break;
6407
6408 case WID_AUTH_TYPE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006409 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006410 break;
6411
6412 case WID_AUTH_TIMEOUT:
6413 *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout;
6414 break;
6415
6416 case WID_POWER_MANAGEMENT:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006417 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006418 break;
6419
6420 case WID_SHORT_RETRY_LIMIT:
6421 *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit;
6422 break;
6423
6424 case WID_LONG_RETRY_LIMIT:
6425 *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit;
6426 break;
6427
6428 case WID_FRAG_THRESHOLD:
6429 *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold;
6430 break;
6431
6432 case WID_RTS_THRESHOLD:
6433 *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold;
6434 break;
6435
6436 case WID_PREAMBLE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006437 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006438 break;
6439
6440 case WID_SHORT_SLOT_ALLOWED:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006441 *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006442 break;
6443
6444 case WID_11N_TXOP_PROT_DISABLE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006445 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006446 break;
6447
6448 case WID_BEACON_INTERVAL:
6449 *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval;
6450 break;
6451
6452 case WID_DTIM_PERIOD:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006453 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006454 break;
6455
6456 case WID_SITE_SURVEY:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006457 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006458 break;
6459
6460 case WID_SITE_SURVEY_SCAN_TIME:
6461 *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time;
6462 break;
6463
6464 case WID_ACTIVE_SCAN_TIME:
6465 *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time;
6466 break;
6467
6468 case WID_PASSIVE_SCAN_TIME:
6469 *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time;
6470 break;
6471
6472 case WID_CURRENT_TX_RATE:
6473 *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate;
6474 break;
6475
6476 default:
6477 break;
6478 }
6479
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006480 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006481
6482 WILC_CATCH(s32Error)
6483 {
6484 }
6485 return s32Error;
6486
6487}
6488
6489/*****************************************************************************/
6490/* Notification Functions */
6491/*****************************************************************************/
6492/**
6493 * @brief notifies host with join and leave requests
6494 * @details This function prepares an Information frame having the
6495 * information about a joining/leaving station.
6496 * @param[in,out] handle to the wifi driver,
6497 * @param[in] 6 byte Sta Adress
6498 * Join or leave flag:
6499 * Join = 1,
6500 * Leave =0
6501 * @return Error code indicating success/failure
6502 * @note
6503 * @author zsalah
6504 * @date 8 March 2012
6505 * @version 1.0
6506 */
6507void host_int_send_join_leave_info_to_host
Dean Lee72ed4dc2015-06-12 14:11:44 +09006508 (u16 assocId, u8 *stationAddr, bool joining)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006509{
6510}
6511/**
6512 * @brief notifies host with stations found in scan
6513 * @details sends the beacon/probe response from scan
6514 * @param[in,out] handle to the wifi driver,
6515 * @param[in] Sta Address,
6516 * Frame length,
6517 * Rssi of the Station found
6518 * @return Error code indicating success/failure
6519 * @note
6520 * @author zsalah
6521 * @date 8 March 2012
6522 * @version 1.0
6523 */
6524
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006525static void GetPeriodicRSSI(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006526{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006527 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006528
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006529 if (pstrWFIDrv == NULL) {
6530 PRINT_ER("Driver handler is NULL\n");
6531 return;
6532 }
6533
6534 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006535 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006536 tstrHostIFmsg strHostIFmsg;
6537
6538 /* prepare the Get RSSI Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006539 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006540
6541 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
6542 strHostIFmsg.drvHandler = pstrWFIDrv;
6543
6544 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09006545 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006546 if (s32Error) {
6547 PRINT_ER("Failed to send get host channel param's message queue ");
6548 return;
6549 }
6550 }
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07006551 g_hPeriodicRSSI.data = (unsigned long)pstrWFIDrv;
6552 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006553}
6554
6555
6556void host_int_send_network_info_to_host
Chaehyun Limca356ad2015-06-11 14:35:57 +09006557 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006558{
6559}
6560/**
6561 * @brief host_int_init
6562 * @details host interface initialization function
6563 * @param[in,out] handle to the wifi driver,
6564 * @note
6565 * @author zsalah
6566 * @date 8 March 2012
6567 * @version 1.0
6568 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006569static u32 u32Intialized;
6570static u32 msgQ_created;
6571static u32 clients_count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006572
Johnny Kim218dc402015-08-13 13:41:19 +09006573s32 host_int_init(tstrWILC_WFIDrv **phWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006574{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006575 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006576 tstrWILC_WFIDrv *pstrWFIDrv;
Johnny Kimd42ab082015-08-20 16:32:52 +09006577 int err;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006578
6579 /*if(u32Intialized == 1)
6580 * {
6581 * PRINT_D(HOSTINF_DBG,"Host interface is previously initialized\n");
6582 * *phWFIDrv = (WILC_WFIDrvHandle)gWFiDrvHandle; //Will be adjusted later for P2P
6583 * return 0;
6584 * } */
6585 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
6586
Dean Lee72ed4dc2015-06-12 14:11:44 +09006587 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006588
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006589 sema_init(&hWaitResponse, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006590
6591
6592
6593 /*Allocate host interface private structure*/
Glen Leef3052582015-09-10 12:03:04 +09006594 pstrWFIDrv = kmalloc(sizeof(tstrWILC_WFIDrv), GFP_KERNEL);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006595 if (pstrWFIDrv == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006596 /* WILC_ERRORREPORT(s32Error,WILC_NO_MEM); */
6597 s32Error = WILC_NO_MEM;
6598 PRINT_ER("Failed to allocate memory\n");
6599 goto _fail_timer_2;
6600 }
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006601 memset(pstrWFIDrv, 0, sizeof(tstrWILC_WFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006602 /*return driver handle to user*/
Johnny Kim218dc402015-08-13 13:41:19 +09006603 *phWFIDrv = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006604 /*save into globl handle*/
Johnny Kimd42ab082015-08-20 16:32:52 +09006605 err = add_handler_in_list(pstrWFIDrv);
6606 if (err) {
6607 s32Error = WILC_FAIL;
6608 goto _fail_timer_2;
6609 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006610
6611 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
6612
Dean Lee72ed4dc2015-06-12 14:11:44 +09006613 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006614 #endif
6615
Johnny Kim8a143302015-06-10 17:06:46 +09006616 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006617 /* /////////////////////////////////////// */
6618 if (clients_count == 0) {
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006619 sema_init(&hSemHostIFthrdEnd, 0);
6620 sema_init(&hSemDeinitDrvHandle, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006621 /*BugID_5348*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006622 sema_init(&hSemHostIntDeinit, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006623 }
6624
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006625 sema_init(&(pstrWFIDrv->hSemTestKeyBlock), 0);
6626 sema_init(&(pstrWFIDrv->hSemTestDisconnectBlock), 0);
6627 sema_init(&(pstrWFIDrv->hSemGetRSSI), 0);
6628 sema_init(&(pstrWFIDrv->hSemGetLINKSPEED), 0);
6629 sema_init(&(pstrWFIDrv->hSemGetCHNL), 0);
6630 sema_init(&(pstrWFIDrv->hSemInactiveTime), 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006631
6632 /* /////////////////////////////////////// */
6633
6634
6635
6636 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
6637
6638 if (clients_count == 0) {
Chaehyun Limcd08fc72015-08-19 15:59:05 +09006639 s32Error = wilc_mq_create(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006640
6641 if (s32Error < 0) {
6642 PRINT_ER("Failed to creat MQ\n");
6643 goto _fail_;
6644 }
6645 msgQ_created = 1;
Arnd Bergmann1999bd52015-05-29 22:52:14 +02006646 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
6647 if (IS_ERR(HostIFthreadHandler)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006648 PRINT_ER("Failed to creat Thread\n");
Arnd Bergmann1999bd52015-05-29 22:52:14 +02006649 s32Error = WILC_FAIL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006650 goto _fail_mq_;
6651 }
Greg Kroah-Hartman507d7fc2015-08-17 12:59:42 -07006652 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
6653 (unsigned long)pstrWFIDrv);
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07006654 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006655 }
6656
6657
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006658 setup_timer(&pstrWFIDrv->hScanTimer, TimerCB_Scan, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006659
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006660 setup_timer(&pstrWFIDrv->hConnectTimer, TimerCB_Connect, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006661
6662 #ifdef WILC_P2P
6663 /*Remain on channel timer*/
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006664 setup_timer(&pstrWFIDrv->hRemainOnChannel, ListenTimerCB, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006665 #endif
6666
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006667 sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1);
6668 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006669
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006670 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09006671 /* gWFiDrvHandle->bPendingConnRequest = false; */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006672
6673 /*Initialize CFG WIDS Defualt Values*/
6674
6675 pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
6676 pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN;
6677 pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
6678 pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
6679 pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE;
6680
6681
6682 #ifdef WILC_P2P
6683
6684 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
6685
6686 #endif
6687
6688 PRINT_INFO(HOSTINF_DBG, "Initialization values, Site survey value: %d\n Scan source: %d\n Active scan time: %d\n Passive scan time: %d\nCurrent tx Rate = %d\n",
6689
6690 pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source,
6691 pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time,
6692 pstrWFIDrv->strCfgValues.curr_tx_rate);
6693
6694
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006695 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006696
6697 /*TODO Code to setup simulation to be removed later*/
6698 /*Intialize configurator module*/
6699 s32Error = CoreConfiguratorInit();
6700 if (s32Error < 0) {
6701 PRINT_ER("Failed to initialize core configurator\n");
6702 goto _fail_mem_;
6703 }
6704
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006705 u32Intialized = 1;
6706 clients_count++; /* increase number of created entities */
6707
6708 return s32Error;
6709
6710
6711_fail_mem_:
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006712 if (pstrWFIDrv != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006713 kfree(pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006714#ifdef WILC_P2P
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006715 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006716#endif
6717_fail_timer_2:
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006718 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006719 del_timer_sync(&pstrWFIDrv->hConnectTimer);
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006720 del_timer_sync(&pstrWFIDrv->hScanTimer);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02006721 kthread_stop(HostIFthreadHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006722_fail_mq_:
Chaehyun Lim1b128f62015-08-19 15:59:08 +09006723 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006724_fail_:
6725 return s32Error;
6726
6727
6728}
6729/**
6730 * @brief host_int_deinit
6731 * @details host interface initialization function
6732 * @param[in,out] handle to the wifi driver,
6733 * @note
6734 * @author zsalah
6735 * @date 8 March 2012
6736 * @version 1.0
6737 */
6738
Johnny Kim218dc402015-08-13 13:41:19 +09006739s32 host_int_deinit(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006740{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006741 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006742 tstrHostIFmsg strHostIFmsg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006743 int ret;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006744
6745 /*obtain driver handle*/
6746 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6747 /*if(u32Intialized == 0)
6748 * {
6749 * PRINT_ER("Host Interface is not initialized\n");
6750 * return 0;
6751 * }*/
6752
6753 /*BugID_5348*/
6754
6755 if (pstrWFIDrv == NULL) {
6756 PRINT_ER("pstrWFIDrv = NULL\n");
6757 return 0;
6758 }
6759
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006760 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006761
6762 terminated_handle = pstrWFIDrv;
6763 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
6764
6765 /*BugID_5348*/
6766 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
6767 /*to guarantee handling all messages befor proceeding*/
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006768 if (del_timer_sync(&pstrWFIDrv->hScanTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006769 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006770 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
6771 }
6772
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006773 if (del_timer_sync(&pstrWFIDrv->hConnectTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006774 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006775 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6776 }
6777
6778
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006779 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006780 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006781 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6782 }
6783
6784 #ifdef WILC_P2P
6785 /*Destroy Remain-onchannel Timer*/
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006786 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006787 #endif
6788
Johnny Kim218dc402015-08-13 13:41:19 +09006789 host_int_set_wfi_drv_handler(NULL);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006790 down(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006791
6792
6793 /*Calling the CFG80211 scan done function with the abort flag set to true*/
6794 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006795 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006796 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
6797
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006798 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006799 }
6800 /*deinit configurator and simulator*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006801 CoreConfiguratorDeInit();
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006802
6803 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6804
Dean Lee72ed4dc2015-06-12 14:11:44 +09006805 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006806
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006807 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006808
6809 if (clients_count == 1) {
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006810 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006811 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006812 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6813 }
6814 strHostIFmsg.u16MsgId = HOST_IF_MSG_EXIT;
6815 strHostIFmsg.drvHandler = hWFIDrv;
6816
6817
Chaehyun Lim79198132015-08-19 15:59:06 +09006818 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006819 if (s32Error != WILC_SUCCESS)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006820 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006821
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006822 down(&hSemHostIFthrdEnd);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006823
Chaehyun Lim1b128f62015-08-19 15:59:08 +09006824 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006825 msgQ_created = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006826 }
6827
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006828 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006829
6830 /*Setting the gloabl driver handler with NULL*/
6831 u32Intialized = 0;
6832 /* gWFiDrvHandle = NULL; */
Johnny Kimd42ab082015-08-20 16:32:52 +09006833 ret = remove_handler_in_list(pstrWFIDrv);
6834 if (ret)
6835 s32Error = WILC_NOT_FOUND;
6836
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006837 if (pstrWFIDrv != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09006838 kfree(pstrWFIDrv);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006839 /* pstrWFIDrv=NULL; */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006840
6841 }
6842
6843 clients_count--; /* Decrease number of created entities */
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006844 terminated_handle = NULL;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006845 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006846 return s32Error;
6847}
6848
6849
6850/**
6851 * @brief NetworkInfoReceived
6852 * @details function to to be called when network info packet is received
6853 * @param[in] pu8Buffer the received packet
6854 * @param[in] u32Length length of the received packet
6855 * @return none
6856 * @note
6857 * @author
6858 * @date 1 Mar 2012
6859 * @version 1.0
6860 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006861void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006862{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006863 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006864 tstrHostIFmsg strHostIFmsg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006865 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006866 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006867
Johnny Kimd42ab082015-08-20 16:32:52 +09006868 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6869 pstrWFIDrv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006870
6871
6872
6873
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006874 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
Johnny Kim8a143302015-06-10 17:06:46 +09006875 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006876 return;
6877 }
6878
6879 /* prepare the Asynchronous Network Info message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006880 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006881
6882 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_NTWRK_INFO;
6883 strHostIFmsg.drvHandler = pstrWFIDrv;
6884
6885 strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.u32Length = u32Length;
Glen Leef3052582015-09-10 12:03:04 +09006886 strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006887 memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006888 pu8Buffer, u32Length);
6889
6890 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09006891 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006892 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006893 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006894}
6895
6896/**
6897 * @brief GnrlAsyncInfoReceived
6898 * @details function to be called when general Asynchronous info packet is received
6899 * @param[in] pu8Buffer the received packet
6900 * @param[in] u32Length length of the received packet
6901 * @return none
6902 * @note
6903 * @author
6904 * @date 15 Mar 2012
6905 * @version 1.0
6906 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006907void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006908{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006909 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006910 tstrHostIFmsg strHostIFmsg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006911 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006912 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006913
6914 /*BugID_5348*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006915 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006916
Johnny Kimd42ab082015-08-20 16:32:52 +09006917 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6918 pstrWFIDrv = get_handler_from_id(id);
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006919 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006920
6921
6922 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6923 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
6924 /*BugID_5348*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006925 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006926 return;
6927 }
6928
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006929 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006930 /* received mac status is not needed when there is no current Connect Request */
6931 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
6932 /*BugID_5348*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006933 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006934 return;
6935 }
6936
6937 /* prepare the General Asynchronous Info message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006938 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006939
6940
6941 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
6942 strHostIFmsg.drvHandler = pstrWFIDrv;
6943
6944
6945 strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.u32Length = u32Length;
Glen Leef3052582015-09-10 12:03:04 +09006946 strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006947 memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006948 pu8Buffer, u32Length);
6949
6950 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09006951 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006952 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006953 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006954
6955 /*BugID_5348*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006956 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006957}
6958
6959/**
6960 * @brief host_int_ScanCompleteReceived
6961 * @details Setting scan complete received notifcation in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006962 * @param[in] u8* pu8Buffer, u32 u32Length
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006963 * @return Error code.
6964 * @author
6965 * @date
6966 * @version 1.0
6967 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006968void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006969{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09006970 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006971 tstrHostIFmsg strHostIFmsg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006972 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006973 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006974
Johnny Kimd42ab082015-08-20 16:32:52 +09006975 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6976 pstrWFIDrv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006977
6978
Johnny Kim8a143302015-06-10 17:06:46 +09006979 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006980
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006981 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006982 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006983
6984 /*if there is an ongoing scan request*/
6985 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6986 /* prepare theScan Done message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006987 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006988
6989 strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
6990 strHostIFmsg.drvHandler = pstrWFIDrv;
6991
6992
6993 /* will be deallocated by the receiving thread */
6994 /*no need to send message body*/
6995
6996 /*strHostIFmsg.uniHostIFmsgBody.strScanComplete.u32Length = u32Length;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006997 * strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006998 * memcpy(strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006999 * pu8Buffer, u32Length); */
7000
7001 /* send the message */
Chaehyun Lim79198132015-08-19 15:59:06 +09007002 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007003 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007004 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007005 }
7006
7007
7008 return;
7009
7010}
7011
7012#ifdef WILC_P2P
7013/**
7014 * @brief host_int_remain_on_channel
7015 * @details
7016 * @param[in] Handle to wifi driver
7017 * Duration to remain on channel
7018 * Channel to remain on
7019 * Pointer to fn to be called on receive frames in listen state
7020 * Pointer to remain-on-channel expired fn
7021 * Priv
7022 * @return Error code.
7023 * @author
7024 * @date
7025 * @version 1.0
7026 */
Johnny Kim218dc402015-08-13 13:41:19 +09007027s32 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 +09007028{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007029 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007030 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7031 tstrHostIFmsg strHostIFmsg;
7032
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007033 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007034 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007035
7036 /* prepare the remainonchan Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007037 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007038
7039 /* prepare the WiphyParams Message */
7040 strHostIFmsg.u16MsgId = HOST_IF_MSG_REMAIN_ON_CHAN;
7041 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u16Channel = chan;
7042 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanExpired = RemainOnChanExpired;
7043 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanReady = RemainOnChanReady;
7044 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pVoid = pvUserArg;
7045 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32duration = u32duration;
7046 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
7047 strHostIFmsg.drvHandler = hWFIDrv;
7048
Chaehyun Lim79198132015-08-19 15:59:06 +09007049 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007050 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007051 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007052 WILC_CATCH(s32Error)
7053 {
7054
7055 }
7056
7057 return s32Error;
7058}
7059
7060/**
7061 * @brief host_int_ListenStateExpired
7062 * @details
7063 * @param[in] Handle to wifi driver
7064 * Duration to remain on channel
7065 * Channel to remain on
7066 * Pointer to fn to be called on receive frames in listen state
7067 * Pointer to remain-on-channel expired fn
7068 * Priv
7069 * @return Error code.
7070 * @author
7071 * @date
7072 * @version 1.0
7073 */
Johnny Kim218dc402015-08-13 13:41:19 +09007074s32 host_int_ListenStateExpired(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007075{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007076 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007077 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7078 tstrHostIFmsg strHostIFmsg;
7079
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007080 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007081 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007082
7083 /*Stopping remain-on-channel timer*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07007084 del_timer(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007085
7086 /* prepare the timer fire Message */
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007087 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007088 strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
7089 strHostIFmsg.drvHandler = hWFIDrv;
7090 strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
7091
Chaehyun Lim79198132015-08-19 15:59:06 +09007092 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007093 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007094 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007095 WILC_CATCH(s32Error)
7096 {
7097
7098 }
7099 return s32Error;
7100}
7101
7102/**
7103 * @brief host_int_frame_register
7104 * @details
7105 * @param[in] Handle to wifi driver
7106 * @return Error code.
7107 * @author
7108 * @date
7109 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09007110s32 host_int_frame_register(tstrWILC_WFIDrv *hWFIDrv, u16 u16FrameType, bool bReg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007111{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007112 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007113 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7114 tstrHostIFmsg strHostIFmsg;
7115
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007116 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007117 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007118
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007119 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007120
7121 /* prepare the WiphyParams Message */
7122 strHostIFmsg.u16MsgId = HOST_IF_MSG_REGISTER_FRAME;
7123 switch (u16FrameType) {
7124 case ACTION:
7125 PRINT_D(HOSTINF_DBG, "ACTION\n");
7126 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = ACTION_FRM_IDX;
7127 break;
7128
7129 case PROBE_REQ:
7130 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
7131 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = PROBE_REQ_IDX;
7132 break;
7133
7134 default:
7135 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
7136 break;
7137 }
7138 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u16FrameType = u16FrameType;
7139 strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.bReg = bReg;
7140 strHostIFmsg.drvHandler = hWFIDrv;
7141
Chaehyun Lim79198132015-08-19 15:59:06 +09007142 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007143 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007144 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007145 WILC_CATCH(s32Error)
7146 {
7147
7148 }
7149
7150 return s32Error;
7151
7152
7153}
7154#endif
7155
7156#ifdef WILC_AP_EXTERNAL_MLME
7157/**
7158 * @brief host_int_add_beacon
7159 * @details Setting add beacon params in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09007160 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
7161 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
7162 * u32 u32TailLen, u8* pu8Tail
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007163 * @return Error code.
7164 * @author
7165 * @date
7166 * @version 1.0
7167 */
Johnny Kim218dc402015-08-13 13:41:19 +09007168s32 host_int_add_beacon(tstrWILC_WFIDrv *hWFIDrv, u32 u32Interval,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09007169 u32 u32DTIMPeriod,
7170 u32 u32HeadLen, u8 *pu8Head,
7171 u32 u32TailLen, u8 *pu8Tail)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007172{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007173 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007174 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7175 tstrHostIFmsg strHostIFmsg;
7176 tstrHostIFSetBeacon *pstrSetBeaconParam = &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon;
7177
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007178 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007179 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007180
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007181 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007182
7183 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
7184
7185
7186 /* prepare the WiphyParams Message */
7187 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BEACON;
7188 strHostIFmsg.drvHandler = hWFIDrv;
7189 pstrSetBeaconParam->u32Interval = u32Interval;
7190 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
7191 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
Glen Leef3052582015-09-10 12:03:04 +09007192 pstrSetBeaconParam->pu8Head = kmalloc(u32HeadLen, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007193 if (pstrSetBeaconParam->pu8Head == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007194 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007195 memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007196 pstrSetBeaconParam->u32TailLen = u32TailLen;
7197
7198 /* Bug 4599 : if tail length = 0 skip allocating & copying */
7199 if (u32TailLen > 0) {
Glen Leef3052582015-09-10 12:03:04 +09007200 pstrSetBeaconParam->pu8Tail = kmalloc(u32TailLen, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007201 if (pstrSetBeaconParam->pu8Tail == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007202 WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007203 memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007204 } else {
7205 pstrSetBeaconParam->pu8Tail = NULL;
7206 }
7207
Chaehyun Lim79198132015-08-19 15:59:06 +09007208 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007209 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007210 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007211
7212 WILC_CATCH(s32Error)
7213 {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007214 if (pstrSetBeaconParam->pu8Head != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09007215 kfree(pstrSetBeaconParam->pu8Head);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007216
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007217 if (pstrSetBeaconParam->pu8Tail != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09007218 kfree(pstrSetBeaconParam->pu8Tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007219 }
7220
7221 return s32Error;
7222
7223}
7224
7225
7226/**
7227 * @brief host_int_del_beacon
7228 * @details Setting add beacon params in message queue
7229 * @param[in] WILC_WFIDrvHandle hWFIDrv
7230 * @return Error code.
7231 * @author
7232 * @date
7233 * @version 1.0
7234 */
Johnny Kim218dc402015-08-13 13:41:19 +09007235s32 host_int_del_beacon(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007236{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007237 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007238 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7239 tstrHostIFmsg strHostIFmsg;
7240
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007241 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007242 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007243
7244 /* prepare the WiphyParams Message */
7245 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BEACON;
7246 strHostIFmsg.drvHandler = hWFIDrv;
7247 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
7248
Chaehyun Lim79198132015-08-19 15:59:06 +09007249 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Leo Kim7dc1d0c2015-09-16 18:36:00 +09007250 if (s32Error)
7251 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007252
7253 WILC_CATCH(s32Error)
7254 {
7255 }
7256 return s32Error;
7257}
7258
7259
7260/**
7261 * @brief host_int_add_station
7262 * @details Setting add station params in message queue
7263 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7264 * @return Error code.
7265 * @author
7266 * @date
7267 * @version 1.0
7268 */
Johnny Kim218dc402015-08-13 13:41:19 +09007269s32 host_int_add_station(tstrWILC_WFIDrv *hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007270{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007271 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007272 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7273 tstrHostIFmsg strHostIFmsg;
7274 tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
7275
7276
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007277 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007278 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007279
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007280 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007281
7282 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
7283
7284
7285 /* prepare the WiphyParams Message */
7286 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_STATION;
7287 strHostIFmsg.drvHandler = hWFIDrv;
7288
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007289 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007290 if (pstrAddStationMsg->u8NumRates > 0) {
Glen Leef3052582015-09-10 12:03:04 +09007291 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02007292
Leo Kim7ae43362015-09-16 18:35:59 +09007293 if (!rates)
7294 return -ENOMEM;
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) {
Glen Leef3052582015-09-10 12:03:04 +09007447 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02007448
Leo Kim7ae43362015-09-16 18:35:59 +09007449 if (!rates)
7450 return -ENOMEM;
7451
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007452 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02007453 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007454 }
7455
Chaehyun Lim79198132015-08-19 15:59:06 +09007456 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007457 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007458 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007459 WILC_CATCH(s32Error)
7460 {
7461 }
7462 return s32Error;
7463}
7464#endif /*WILC_AP_EXTERNAL_MLME*/
Chaehyun Limfbc2fe12015-09-15 14:06:16 +09007465u32 wilc_get_chipid(u8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007466
Johnny Kim218dc402015-08-13 13:41:19 +09007467s32 host_int_set_power_mgmt(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32Timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007468{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007469 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007470 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7471 tstrHostIFmsg strHostIFmsg;
7472 tstrHostIfPowerMgmtParam *pstrPowerMgmtParam = &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam;
7473
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007474 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007475
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007476 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007477 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007478
7479 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
7480
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007481 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007482
7483
7484 /* prepare the WiphyParams Message */
7485 strHostIFmsg.u16MsgId = HOST_IF_MSG_POWER_MGMT;
7486 strHostIFmsg.drvHandler = hWFIDrv;
7487
7488 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
7489 pstrPowerMgmtParam->u32Timeout = u32Timeout;
7490
7491
Chaehyun Lim79198132015-08-19 15:59:06 +09007492 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007493 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007494 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007495 WILC_CATCH(s32Error)
7496 {
7497 }
7498 return s32Error;
7499}
7500
Johnny Kim218dc402015-08-13 13:41:19 +09007501s32 host_int_setup_multicast_filter(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32count)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007502{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007503 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007504
7505 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7506 tstrHostIFmsg strHostIFmsg;
7507 tstrHostIFSetMulti *pstrMulticastFilterParam = &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti;
7508
7509
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007510 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007511 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007512
7513 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
7514
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007515 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007516
7517
7518 /* prepare the WiphyParams Message */
7519 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MULTICAST_FILTER;
7520 strHostIFmsg.drvHandler = hWFIDrv;
7521
7522 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
7523 pstrMulticastFilterParam->u32count = u32count;
7524
Chaehyun Lim79198132015-08-19 15:59:06 +09007525 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007526 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007527 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007528 WILC_CATCH(s32Error)
7529 {
7530 }
7531 return s32Error;
7532}
7533
7534
7535
7536/*Bug4218: Parsing Join Param*/
7537#ifdef WILC_PARSE_SCAN_IN_HOST
7538
7539/*Bug4218: Parsing Join Param*/
7540/**
7541 * @brief host_int_ParseJoinBssParam
7542 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
7543 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7544 * @return
7545 * @author zsalah
7546 * @date
7547 * @version 1.0**/
7548static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
7549{
7550 tstrJoinBssParam *pNewJoinBssParam = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007551 u8 *pu8IEs;
Chaehyun Limd85f5322015-06-11 14:35:54 +09007552 u16 u16IEsLen;
7553 u16 index = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007554 u8 suppRatesNo = 0;
7555 u8 extSuppRatesNo;
Chaehyun Limd85f5322015-06-11 14:35:54 +09007556 u16 jumpOffset;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007557 u8 pcipherCount;
7558 u8 authCount;
7559 u8 pcipherTotalCount = 0;
7560 u8 authTotalCount = 0;
7561 u8 i, j;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007562
7563 pu8IEs = ptstrNetworkInfo->pu8IEs;
7564 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
7565
Glen Leef3052582015-09-10 12:03:04 +09007566 pNewJoinBssParam = kmalloc(sizeof(tstrJoinBssParam), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007567 if (pNewJoinBssParam != NULL) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007568 memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007569 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
7570 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
7571 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007572 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007573 /*for(i=0; i<6;i++)
7574 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007575 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007576 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007577 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
7578 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007579 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
7580 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
7581
7582 /* parse supported rates: */
7583 while (index < u16IEsLen) {
7584 /* supportedRates IE */
7585 if (pu8IEs[index] == SUPP_RATES_IE) {
7586 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
7587 suppRatesNo = pu8IEs[index + 1];
7588 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
7589 index += 2; /* skipping ID and length bytes; */
7590
7591 for (i = 0; i < suppRatesNo; i++) {
7592 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
7593 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
7594 }
7595 index += suppRatesNo;
7596 continue;
7597 }
7598 /* Ext SupportedRates IE */
7599 else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
7600 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
7601 /* checking if no of ext. supp and supp rates < max limit */
7602 extSuppRatesNo = pu8IEs[index + 1];
7603 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
7604 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
7605 else
7606 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
7607 index += 2;
7608 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
7609 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
7610 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
7611 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
7612 }
7613 index += extSuppRatesNo;
7614 continue;
7615 }
7616 /* HT Cap. IE */
7617 else if (pu8IEs[index] == HT_CAPABILITY_IE) {
7618 /* if IE found set the flag */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09007619 pNewJoinBssParam->ht_capable = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007620 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7621 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
7622 continue;
7623 } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
7624 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
7625 (pu8IEs[index + 4] == 0xF2) && /* OUI */
7626 (pu8IEs[index + 5] == 0x02) && /* OUI Type */
7627 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
7628 (pu8IEs[index + 7] == 0x01)) {
7629 /* Presence of WMM Info/Param element indicates WMM capability */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09007630 pNewJoinBssParam->wmm_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007631
7632 /* Check if Bit 7 is set indicating U-APSD capability */
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007633 if (pu8IEs[index + 8] & (1 << 7))
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09007634 pNewJoinBssParam->uapsd_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007635 index += pu8IEs[index + 1] + 2;
7636 continue;
7637 }
7638 #ifdef WILC_P2P
7639 else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
7640 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
7641 (pu8IEs[index + 4] == 0x9a) && /* OUI */
7642 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
Chaehyun Limd85f5322015-06-11 14:35:54 +09007643 u16 u16P2P_count;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02007644
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007645 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
7646 pNewJoinBssParam->u8NoaEnbaled = 1;
7647 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
7648
7649 /* Check if Bit 7 is set indicating Opss capability */
7650 if (pu8IEs[index + 10] & (1 << 7)) {
7651 pNewJoinBssParam->u8OppEnable = 1;
7652 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
7653 } else
7654 pNewJoinBssParam->u8OppEnable = 0;
7655 /* HOSTINF_DBG */
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007656 PRINT_D(GENERIC_DBG, "P2P Dump\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007657 for (i = 0; i < pu8IEs[index + 7]; i++)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007658 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007659
7660 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
7661 u16P2P_count = index + 12;
7662
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007663 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007664 u16P2P_count += 4;
7665
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007666 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007667 u16P2P_count += 4;
7668
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007669 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007670
7671 index += pu8IEs[index + 1] + 2;
7672 continue;
7673
7674 }
7675 #endif
7676 else if ((pu8IEs[index] == RSN_IE) ||
7677 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
7678 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
7679 (pu8IEs[index + 5] == 0x01))) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09007680 u16 rsnIndex = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007681 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
7682 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
7683 * {
7684 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
7685 * }*/
7686 if (pu8IEs[rsnIndex] == RSN_IE) {
7687 pNewJoinBssParam->mode_802_11i = 2;
7688 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
7689 } else { /* check if rsn was previously parsed */
7690 if (pNewJoinBssParam->mode_802_11i == 0)
7691 pNewJoinBssParam->mode_802_11i = 1;
7692 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
7693 rsnIndex += 4;
7694 }
7695 rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
7696 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
7697 rsnIndex++;
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007698 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007699 /* initialize policies with invalid values */
7700
7701 jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
7702
7703 /*parsing pairwise cipher*/
7704
7705 /* saving 3 pcipher max. */
7706 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7707 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7708
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007709 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007710 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
7711 /* each count corresponds to 4 bytes, only last byte is saved */
7712 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7713 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
7714 }
7715 pcipherTotalCount += pcipherCount;
7716 rsnIndex += jumpOffset;
7717
7718 jumpOffset = pu8IEs[rsnIndex] * 4;
7719
7720 /*parsing AKM suite (auth_policy)*/
7721 /* saving 3 auth policies max. */
7722 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7723 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7724
7725 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
7726 /* each count corresponds to 4 bytes, only last byte is saved */
7727 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7728 }
7729 authTotalCount += authCount;
7730 rsnIndex += jumpOffset;
7731 /*pasring rsn cap. only if rsn IE*/
7732 if (pu8IEs[index] == RSN_IE) {
7733 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
7734 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
7735 rsnIndex += 2;
7736 }
Abdul Hussainf717c0eb2015-06-16 09:49:49 +00007737 pNewJoinBssParam->rsn_found = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007738 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7739 continue;
7740 } else
7741 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7742
7743 }
7744
7745
7746 }
7747
7748 return (void *)pNewJoinBssParam;
7749
7750}
7751
7752void host_int_freeJoinParams(void *pJoinParams)
7753{
7754 if ((tstrJoinBssParam *)pJoinParams != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09007755 kfree((tstrJoinBssParam *)pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007756 else
7757 PRINT_ER("Unable to FREE null pointer\n");
7758}
7759#endif /*WILC_PARSE_SCAN_IN_HOST*/
7760
7761
7762/**
7763 * @brief host_int_addBASession
7764 * @details Open a block Ack session with the given parameters
7765 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7766 * @return
7767 * @author anoureldin
7768 * @date
7769 * @version 1.0**/
7770
Johnny Kim2b05df52015-08-13 13:41:21 +09007771static int host_int_addBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID, short int BufferSize,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007772 short int SessionTimeout, void *drvHandler)
7773{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007774 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007775 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7776 tstrHostIFmsg strHostIFmsg;
7777 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7778
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007779 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007780 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007781
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007782 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007783
7784 /* prepare the WiphyParams Message */
7785 strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BA_SESSION;
7786
7787 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7788 pBASessionInfo->u8Ted = TID;
7789 pBASessionInfo->u16BufferSize = BufferSize;
7790 pBASessionInfo->u16SessionTimeout = SessionTimeout;
7791 strHostIFmsg.drvHandler = hWFIDrv;
7792
Chaehyun Lim79198132015-08-19 15:59:06 +09007793 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007794 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007795 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007796 WILC_CATCH(s32Error)
7797 {
7798
7799 }
7800
7801 return s32Error;
7802}
7803
7804
Johnny Kim218dc402015-08-13 13:41:19 +09007805s32 host_int_delBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007806{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007807 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007808 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7809 tstrHostIFmsg strHostIFmsg;
7810 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7811
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007812 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007813 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007814
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007815 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007816
7817 /* prepare the WiphyParams Message */
7818 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BA_SESSION;
7819
7820 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7821 pBASessionInfo->u8Ted = TID;
7822 strHostIFmsg.drvHandler = hWFIDrv;
7823
Chaehyun Lim79198132015-08-19 15:59:06 +09007824 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007825 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007826 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007827 WILC_CATCH(s32Error)
7828 {
7829
7830 }
7831
7832 /*BugID_5222*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02007833 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007834
7835 return s32Error;
7836}
7837
Johnny Kim218dc402015-08-13 13:41:19 +09007838s32 host_int_del_All_Rx_BASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007839{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007840 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007841 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7842 tstrHostIFmsg strHostIFmsg;
7843 tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
7844
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007845 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007846 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007847
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007848 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007849
7850 /* prepare the WiphyParams Message */
7851 strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
7852
7853 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7854 pBASessionInfo->u8Ted = TID;
7855 strHostIFmsg.drvHandler = hWFIDrv;
7856
Chaehyun Lim79198132015-08-19 15:59:06 +09007857 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007858 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007859 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007860 WILC_CATCH(s32Error)
7861 {
7862
7863 }
7864
7865 /*BugID_5222*/
Arnd Bergmann83383ea2015-06-01 21:06:43 +02007866 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007867
7868 return s32Error;
7869}
7870
7871/**
7872 * @brief host_int_setup_ipaddress
7873 * @details setup IP in firmware
7874 * @param[in] Handle to wifi driver
7875 * @return Error code.
7876 * @author Abdelrahman Sobhy
7877 * @date
7878 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09007879s32 host_int_setup_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007880{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007881 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007882 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7883 tstrHostIFmsg strHostIFmsg;
7884
7885 /* TODO: Enable This feature on softap firmware */
7886 return 0;
7887
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007888 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007889 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007890
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007891 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007892
7893 /* prepare the WiphyParams Message */
7894 strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_IPADDRESS;
7895
7896 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
7897 strHostIFmsg.drvHandler = hWFIDrv;
7898 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
7899
Chaehyun Lim79198132015-08-19 15:59:06 +09007900 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007901 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007902 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007903 WILC_CATCH(s32Error)
7904 {
7905
7906 }
7907
7908 return s32Error;
7909
7910
7911}
7912
7913/**
7914 * @brief host_int_get_ipaddress
7915 * @details Get IP from firmware
7916 * @param[in] Handle to wifi driver
7917 * @return Error code.
7918 * @author Abdelrahman Sobhy
7919 * @date
7920 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09007921s32 host_int_get_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007922{
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09007923 s32 s32Error = WILC_SUCCESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007924 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
7925 tstrHostIFmsg strHostIFmsg;
7926
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007927 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007928 WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007929
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007930 memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007931
7932 /* prepare the WiphyParams Message */
7933 strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_IPADDRESS;
7934
7935 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
Sunil Shahubf903c12015-06-22 19:23:01 +05307936 strHostIFmsg.drvHandler = hWFIDrv;
7937 strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007938
Chaehyun Lim79198132015-08-19 15:59:06 +09007939 s32Error = wilc_mq_send(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007940 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007941 WILC_ERRORREPORT(s32Error, s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007942 WILC_CATCH(s32Error)
7943 {
7944
7945 }
7946
7947 return s32Error;
7948
7949
7950}