blob: 12fd43dfeeef0f39be42d90d3cdd608cbda1f6f2 [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"
Chaehyun Lim53660122015-09-17 16:48:49 +09003#include "wilc_wlan_if.h"
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005extern u8 connecting;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006
7#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -07008extern struct timer_list hDuringIpTimer;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09009#endif
10
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/*!
Tony Choc98387a2015-09-21 12:16:40 +0900139 * @struct key_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900140 * @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 */
Tony Choc98387a2015-09-21 12:16:40 +0900148struct key_attr {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900149 tenuKeyType enuKeyType;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900150 u8 u8KeyAction;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900151 tuniHostIFkeyAttr uniHostIFkeyAttr;
Tony Choc98387a2015-09-21 12:16:40 +0900152};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900153
154
155
156
157/*!
Tony Choc476feb2015-09-21 12:16:36 +0900158 * @struct scan_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900159 * @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 */
Tony Choc476feb2015-09-21 12:16:36 +0900167struct scan_attr {
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;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900176 tstrHiddenNetwork strHiddenNetwork;
Tony Choc476feb2015-09-21 12:16:36 +0900177};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900178
179/*!
Tony Cho120ae592015-09-21 12:16:37 +0900180 * @struct connect_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900181 * @brief Structure to hold Host IF Connect Attributes
182 * @details
183 * @todo
184 * @sa
185 * @author Mostafa Abu Bakr
186 * @date 25 March 2012
187 * @version 1.0
188 */
Tony Cho120ae592015-09-21 12:16:37 +0900189struct connect_attr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900190 u8 *pu8bssid;
191 u8 *pu8ssid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900192 size_t ssidLen;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900193 u8 *pu8IEs;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900194 size_t IEsLen;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900195 u8 u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900196 tWILCpfConnectResult pfConnectResult;
197 void *pvUserArg;
198 AUTHTYPE_T tenuAuth_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900199 u8 u8channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900200 void *pJoinParams;
Tony Cho120ae592015-09-21 12:16:37 +0900201};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900202
203/*!
Tony Chof23a9ea2015-09-21 12:16:39 +0900204 * @struct rcvd_async_info
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900205 * @brief Structure to hold Received General Asynchronous info
206 * @details
207 * @todo
208 * @sa
209 * @author Mostafa Abu Bakr
210 * @date 25 March 2012
211 * @version 1.0
212 */
Tony Chof23a9ea2015-09-21 12:16:39 +0900213struct rcvd_async_info {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900214 u8 *pu8Buffer;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900215 u32 u32Length;
Tony Chof23a9ea2015-09-21 12:16:39 +0900216};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900217
218/*!
219 * @struct tstrHostIFSetChan
220 * @brief Set Channel message body
221 * @details
222 * @todo
223 * @sa
224 * @author Mai Daftedar
225 * @date 25 March 2012
226 * @version 1.0
227 */
228typedef struct _tstrHostIFSetChan {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900229 u8 u8SetChan;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900230} tstrHostIFSetChan;
231
232/*!
233 * @struct tstrHostIFSetChan
234 * @brief Get Channel message body
235 * @details
236 * @todo
237 * @sa
238 * @author Mai Daftedar
239 * @date 01 Jule 2012
240 * @version 1.0
241 */
242typedef struct _tstrHostIFGetChan {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900243 u8 u8GetChan;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900244} tstrHostIFGetChan;
245
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900246/*!
247 * @struct tstrScanComplete
248 * @brief hold received Async. Scan Complete message body
249 * @details
250 * @todo
251 * @sa
252 * @author zsalah
253 * @date 25 March 2012
254 * @version 1.0
255 */
256/*typedef struct _tstrScanComplete
257 * {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900258 * u8* pu8Buffer;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900259 * u32 u32Length;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900260 * } tstrScanComplete;*/
261
262/*!
263 * @struct tstrHostIFSetBeacon
264 * @brief Set Beacon message body
265 * @details
266 * @todo
267 * @sa
268 * @author Adham Abozaeid
269 * @date 10 July 2012
270 * @version 1.0
271 */
272typedef struct _tstrHostIFSetBeacon {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900273 u32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */
274 u32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900275 * (including the current frame) appear before the next DTIM */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900276 u32 u32HeadLen; /*!< Length of the head buffer in bytes */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900277 u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900278 * from the beacon's start till the TIM element, NOT including the TIM */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900279 u32 u32TailLen; /*!< Length of the tail buffer in bytes */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900280 u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900281 * after the TIM inormation element */
282} tstrHostIFSetBeacon;
283
284
285
286/*!
287 * @struct tstrHostIFDelBeacon
288 * @brief Del Beacon message body
289 * @details
290 * @todo
291 * @sa
292 * @author Adham Abozaeid
293 * @date 15 July 2012
294 * @version 1.0
295 */
296typedef struct _tstrHostIFDelBeacon {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900297 u8 u8dummy;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900298} tstrHostIFDelBeacon;
299
300/*!
301 * @struct tstrHostIFSetMulti
302 * @brief set Multicast filter Address
303 * @details
304 * @todo
305 * @sa
306 * @author Abdelrahman Sobhy
307 * @date 30 August 2013
308 * @version 1.0 Description
309 */
310
311typedef struct {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900312 bool bIsEnabled;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900313 u32 u32count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900314} tstrHostIFSetMulti;
315
316/*!
317 * @struct tstrHostIFDelAllSta
318 * @brief Deauth station message body
319 * @details
320 * @todo
321 * @sa
322 * @author Mai Daftedar
323 * @date 09 April 2014
324 * @version 1.0 Description
325 */
326
327typedef struct {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900328 u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN];
329 u8 u8Num_AssocSta;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900330} tstrHostIFDelAllSta;
331
332/*!
333 * @struct tstrHostIFDelSta
334 * @brief Delete station message body
335 * @details
336 * @todo
337 * @sa
338 * @author Adham Abozaeid
339 * @date 15 July 2012
340 * @version 1.0 Description
341 */
342
343typedef struct {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900344 u8 au8MacAddr[ETH_ALEN];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900345} tstrHostIFDelSta;
346
347/*!
348 * @struct tstrTimerCb
349 * @brief Timer callback message body
350 * @details
351 * @todo
352 * @sa
353 * @author Mostafa Abu Bakr
354 * @date 25 March 2012
355 * @version 1.0
356 */
357typedef struct _tstrTimerCb {
358 void *pvUsrArg; /*!< Private data passed at timer start */
359} tstrTimerCb;
360
361/*!
362 * @struct tstrHostIfPowerMgmtParam
363 * @brief Power management message body
364 * @details
365 * @todo
366 * @sa
367 * @author Adham Abozaeid
368 * @date 24 November 2012
369 * @version 1.0
370 */
371typedef struct {
372
Dean Lee72ed4dc2015-06-12 14:11:44 +0900373 bool bIsEnabled;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900374 u32 u32Timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900375} tstrHostIfPowerMgmtParam;
376
377/*!
378 * @struct tstrHostIFSetIPAddr
379 * @brief set IP Address message body
380 * @details
381 * @todo
382 * @sa
383 * @author Abdelrahman Sobhy
384 * @date 30 August 2013
385 * @version 1.0 Description
386 */
387
388typedef struct {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900389 u8 *au8IPAddr;
390 u8 idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900391} tstrHostIFSetIPAddr;
392
393/*!
394 * @struct tstrHostIfStaInactiveT
395 * @brief Get station message body
396 * @details
397 * @todo
398 * @sa
399 * @author Mai Daftedar
400 * @date 16 April 2013
401 * @version 1.0
402 */
403typedef struct {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900404 u8 mac[6];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900405
406} tstrHostIfStaInactiveT;
407/**/
408/*!
Tony Chodfc76632015-09-21 12:16:34 +0900409 * @union message_body
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900410 * @brief Message body for the Host Interface message_q
411 * @details
412 * @todo
413 * @sa
414 * @author Mostafa Abu Bakr
415 * @date 25 March 2012
416 * @version 1.0
417 */
Tony Chodfc76632015-09-21 12:16:34 +0900418union message_body {
Tony Choc476feb2015-09-21 12:16:36 +0900419 struct scan_attr strHostIFscanAttr; /*!< Host IF Scan Request Attributes message body */
Tony Cho120ae592015-09-21 12:16:37 +0900420 struct connect_attr strHostIFconnectAttr; /*!< Host IF Connect Request Attributes message body */
Tony Cho3bbd59f2015-09-21 12:16:38 +0900421 struct rcvd_net_info strRcvdNetworkInfo; /*!< Received Asynchronous Network Info message body */
Tony Chof23a9ea2015-09-21 12:16:39 +0900422 struct rcvd_async_info strRcvdGnrlAsyncInfo; /*!< Received General Asynchronous Info message body */
Tony Choc98387a2015-09-21 12:16:40 +0900423 struct key_attr strHostIFkeyAttr; /*!<>*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900424 tstrHostIFCfgParamAttr strHostIFCfgParamAttr; /*! <CFG Parameter message Body> */
425 tstrHostIFSetChan strHostIFSetChan;
426 tstrHostIFGetChan strHostIFGetChan;
427 tstrHostIFSetBeacon strHostIFSetBeacon; /*!< Set beacon message body */
428 tstrHostIFDelBeacon strHostIFDelBeacon; /*!< Del beacon message body */
429 tstrWILC_AddStaParam strAddStaParam; /*!< Add station message body */
430 tstrHostIFDelSta strDelStaParam; /*!< Del Station message body */
431 tstrWILC_AddStaParam strEditStaParam; /*!< Edit station message body */
432 /* tstrScanComplete strScanComplete; / *Received Async. Scan Complete message body* / */
433 tstrTimerCb strTimerCb; /*!< Timer callback message body */
434 tstrHostIfPowerMgmtParam strPowerMgmtparam; /*!< Power Management message body */
435 tstrHostIfStaInactiveT strHostIfStaInactiveT;
436 tstrHostIFSetIPAddr strHostIfSetIP;
437 tstrHostIfSetDrvHandler strHostIfSetDrvHandler;
438 tstrHostIFSetMulti strHostIfSetMulti;
439 tstrHostIfSetOperationMode strHostIfSetOperationMode;
440 tstrHostIfSetMacAddress strHostIfSetMacAddress;
441 tstrHostIfGetMacAddress strHostIfGetMacAddress;
442 tstrHostIfBASessionInfo strHostIfBASessionInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900443 tstrHostIfRemainOnChan strHostIfRemainOnChan;
444 tstrHostIfRegisterFrame strHostIfRegisterFrame;
Dean Lee576917a2015-06-15 11:58:57 +0900445 char *pUserData;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900446 tstrHostIFDelAllSta strHostIFDelAllSta;
Tony Chodfc76632015-09-21 12:16:34 +0900447};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900448
449/*!
Tony Cho3a8c41b2015-09-18 18:11:04 +0900450 * @struct struct host_if_msg
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900451 * @brief Host Interface message
452 * @details
453 * @todo
454 * @sa
455 * @author Mostafa Abu Bakr
456 * @date 25 March 2012
457 * @version 1.0
458 */
Tony Cho3a8c41b2015-09-18 18:11:04 +0900459struct host_if_msg {
Tony Choa9f812a2015-09-21 12:16:33 +0900460 u16 id; /*!< Message ID */
Tony Cho410c2482015-09-21 12:16:35 +0900461 union message_body body; /*!< Message body */
Johnny Kim11f58c82015-08-13 13:41:20 +0900462 tstrWILC_WFIDrv *drvHandler;
Tony Cho3a8c41b2015-09-18 18:11:04 +0900463};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900464
465#ifdef CONNECT_DIRECT
466typedef struct _tstrWidJoinReqExt {
Dean Lee576917a2015-06-15 11:58:57 +0900467 char SSID[MAX_SSID_LEN];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900468 u8 u8channel;
469 u8 BSSID[6];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900470} tstrWidJoinReqExt;
471#endif
472
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900473#ifdef WILC_PARSE_SCAN_IN_HOST
474/*Struct containg joinParam of each AP*/
475typedef struct _tstrJoinBssParam {
476 BSSTYPE_T bss_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900477 u8 dtim_period;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900478 u16 beacon_period;
479 u16 cap_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900480 u8 au8bssid[6];
Dean Lee576917a2015-06-15 11:58:57 +0900481 char ssid[MAX_SSID_LEN];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900482 u8 ssidLen;
483 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
484 u8 ht_capable;
485 u8 wmm_cap;
486 u8 uapsd_cap;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900487 bool rsn_found;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900488 u8 rsn_grp_policy;
489 u8 mode_802_11i;
490 u8 rsn_pcip_policy[3];
491 u8 rsn_auth_policy[3];
492 u8 rsn_cap[2];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900493 struct _tstrJoinParam *nextJoinBss;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900494 u32 tsf;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900495 u8 u8NoaEnbaled;
496 u8 u8OppEnable;
497 u8 u8CtWindow;
498 u8 u8Count;
499 u8 u8Index;
500 u8 au8Duration[4];
501 u8 au8Interval[4];
502 u8 au8StartTime[4];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900503} tstrJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900504/*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
505typedef struct _tstrBssTable {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900506 u8 u8noBssEntries;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900507 tstrJoinBssParam *head;
508 tstrJoinBssParam *tail;
509} tstrBssTable;
510#endif /*WILC_PARSE_SCAN_IN_HOST*/
511
512typedef enum {
513 SCAN_TIMER = 0,
514 CONNECT_TIMER = 1,
515 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
516} tenuScanConnTimer;
517
518/*****************************************************************************/
519/* */
520/* Global Variabls */
521/* */
522/*****************************************************************************/
Johnny Kimd42ab082015-08-20 16:32:52 +0900523/* Zero is not used, because a zero ID means termination */
524static tstrWILC_WFIDrv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
Daniel Machon6fdb3022015-07-06 19:48:04 +0200525tstrWILC_WFIDrv *terminated_handle;
526tstrWILC_WFIDrv *gWFiDrvHandle;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900527#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +0900528bool g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900529#endif
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900530u8 P2P_LISTEN_STATE;
Arnd Bergmann1999bd52015-05-29 22:52:14 +0200531static struct task_struct *HostIFthreadHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900532static WILC_MsgQueueHandle gMsgQHostIF;
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200533static struct semaphore hSemHostIFthrdEnd;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900534
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200535struct semaphore hSemDeinitDrvHandle;
536static struct semaphore hWaitResponse;
537struct semaphore hSemHostIntDeinit;
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -0700538struct timer_list g_hPeriodicRSSI;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900539
540
541
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900542u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900543
544#ifndef CONNECT_DIRECT
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900545static u8 gapu8RcvdSurveyResults[2][MAX_SURVEY_RESULT_FRAG_SIZE];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900546#endif
547
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900548static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900549
Dean Lee72ed4dc2015-06-12 14:11:44 +0900550bool gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900551
Chaehyun Limca356ad2015-06-11 14:35:57 +0900552static s8 gs8Rssi;
553static s8 gs8lnkspd;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900554static u8 gu8Chnl;
555static u8 gs8SetIP[2][4];
556static u8 gs8GetIP[2][4];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900557static u32 gu32InactiveTime;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900558static u8 gu8DelBcn;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900559static u32 gu32WidConnRstHack;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900560
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900561u8 *gu8FlushedJoinReq;
562u8 *gu8FlushedInfoElemAsoc;
563u8 gu8Flushed11iMode;
564u8 gu8FlushedAuthType;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900565u32 gu32FlushedJoinReqSize;
566u32 gu32FlushedInfoElemAsocSize;
Johnny Kim8a625ca2015-08-20 16:32:50 +0900567tstrWILC_WFIDrv *gu8FlushedJoinReqDrvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900568#define REAL_JOIN_REQ 0
569#define FLUSHED_JOIN_REQ 1
570#define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
571
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900572#ifdef WILC_PARSE_SCAN_IN_HOST
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900573static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
574#endif /*WILC_PARSE_SCAN_IN_HOST*/
575
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900576extern void chip_sleep_manually(u32 u32SleepTime);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900577extern int linux_wlan_get_num_conn_ifcs(void);
578
Johnny Kimd42ab082015-08-20 16:32:52 +0900579static int add_handler_in_list(tstrWILC_WFIDrv *handler)
580{
581 int i;
582
583 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
584 if (!wfidrv_list[i]) {
585 wfidrv_list[i] = handler;
586 return 0;
587 }
588 }
589
590 return -ENOBUFS;
591}
592
593static int remove_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] == handler) {
599 wfidrv_list[i] = NULL;
600 return 0;
601 }
602 }
603
604 return -EINVAL;
605}
606
607static int get_id_from_handler(tstrWILC_WFIDrv *handler)
608{
609 int i;
610
611 if (!handler)
612 return 0;
613
614 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
615 if (wfidrv_list[i] == handler)
616 return i;
617 }
618
619 return 0;
620}
621
622static tstrWILC_WFIDrv *get_handler_from_id(int id)
623{
Dan Carpenter6ae9ac02015-09-15 09:54:33 +0300624 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
Johnny Kimd42ab082015-08-20 16:32:52 +0900625 return NULL;
626 return wfidrv_list[id];
627}
628
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900629/**
630 * @brief Handle_SetChannel
631 * @details Sending config packet to firmware to set channel
632 * @param[in] tstrHostIFSetChan* pstrHostIFSetChan
633 * @return Error code.
634 * @author
635 * @date
636 * @version 1.0
637 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900638static s32 Handle_SetChannel(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetChan *pstrHostIFSetChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900639{
640
Leo Kime6e12662015-09-16 18:36:03 +0900641 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900642 tstrWID strWID;
643 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
644
645 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900646 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900647 strWID.enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900648 strWID.ps8WidVal = (char *)&(pstrHostIFSetChan->u8SetChan);
649 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900650
651 PRINT_D(HOSTINF_DBG, "Setting channel\n");
652 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +0900653 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
654 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900655 if (s32Error) {
656 PRINT_ER("Failed to set channel\n");
Leo Kim24db7132015-09-16 18:36:01 +0900657 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900658 }
659
660 return s32Error;
661}
662/**
663 * @brief Handle_SetWfiDrvHandler
664 * @details Sending config packet to firmware to set driver handler
665 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
666 * @return Error code.
667 * @author
668 * @date
669 * @version 1.0
670 */
Johnny Kim53a84402015-08-20 16:32:51 +0900671static s32 Handle_SetWfiDrvHandler(tstrWILC_WFIDrv *drvHandler,
672 tstrHostIfSetDrvHandler *pstrHostIfSetDrvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900673{
674
Leo Kime6e12662015-09-16 18:36:03 +0900675 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900676 tstrWID strWID;
Johnny Kim53a84402015-08-20 16:32:51 +0900677 tstrWILC_WFIDrv *pstrWFIDrv = drvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900678
679
680 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900681 strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900682 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900683 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900684 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900685
686 /*Sending Cfg*/
687
Johnny Kimd42ab082015-08-20 16:32:52 +0900688 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
689 pstrHostIfSetDrvHandler->u32Address);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900690
Johnny Kim53a84402015-08-20 16:32:51 +0900691 if (pstrWFIDrv == NULL)
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200692 up(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900693
694
695 if (s32Error) {
696 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900697 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900698 }
699
700 return s32Error;
701}
702
703/**
704 * @brief Handle_SetWfiAPDrvHandler
705 * @details Sending config packet to firmware to set driver handler
706 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
707 * @return Error code.
708 * @author
709 * @date
710 * @version 1.0
711 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900712static s32 Handle_SetOperationMode(tstrWILC_WFIDrv *drvHandler, tstrHostIfSetOperationMode *pstrHostIfSetOperationMode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900713{
714
Leo Kime6e12662015-09-16 18:36:03 +0900715 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900716 tstrWID strWID;
717 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
718
719
720 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900721 strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900722 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900723 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900724 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900725
726 /*Sending Cfg*/
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +0200727 PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900728
Johnny Kimd42ab082015-08-20 16:32:52 +0900729 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
730 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900731
732
Johnny Kimc590b9a2015-09-08 17:07:59 +0900733 if ((pstrHostIfSetOperationMode->u32Mode) == IDLE_MODE)
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200734 up(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900735
736
737 if (s32Error) {
738 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900739 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900740 }
741
742 return s32Error;
743}
744
745/**
746 * @brief host_int_set_IPAddress
747 * @details Setting IP address params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900748 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900749 * @return Error code.
750 * @author
751 * @date
752 * @version 1.0
753 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900754s32 Handle_set_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900755{
756
Leo Kime6e12662015-09-16 18:36:03 +0900757 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900758 tstrWID strWID;
759 char firmwareIPAddress[4] = {0};
760 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
761
762 if (pu8IPAddr[0] < 192)
763 pu8IPAddr[0] = 0;
764
Luis de Bethencourtb3a02832015-06-26 17:40:25 +0200765 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900766
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900767 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900768
769 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900770 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900771 strWID.enuWIDtype = WID_STR;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900772 strWID.ps8WidVal = (u8 *)pu8IPAddr;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900773 strWID.s32ValueSize = IP_ALEN;
774
Johnny Kimd42ab082015-08-20 16:32:52 +0900775 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
776 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900777
778
Johnny Kim218dc402015-08-13 13:41:19 +0900779 host_int_get_ipaddress(drvHandler, firmwareIPAddress, idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900780
781 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +0900782 PRINT_ER("Failed to set IP address\n");
783 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900784 }
785
Leo Kim24db7132015-09-16 18:36:01 +0900786 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900787
788 return s32Error;
789}
790
791
792/**
793 * @brief Handle_get_IPAddress
794 * @details Setting IP address params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900795 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900796 * @return Error code.
797 * @author
798 * @date
799 * @version 1.0
800 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900801s32 Handle_get_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900802{
803
Leo Kime6e12662015-09-16 18:36:03 +0900804 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900805 tstrWID strWID;
806 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
807
808 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900809 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900810 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +0900811 strWID.ps8WidVal = kmalloc(IP_ALEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900812 strWID.s32ValueSize = IP_ALEN;
813
Johnny Kimd42ab082015-08-20 16:32:52 +0900814 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
815 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900816
Luis de Bethencourtb3a02832015-06-26 17:40:25 +0200817 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900818
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900819 memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900820
821 /*get the value by searching the local copy*/
Chaehyun Lim49188af2015-08-11 10:32:41 +0900822 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900823
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900824 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
Johnny Kim218dc402015-08-13 13:41:19 +0900825 host_int_setup_ipaddress(pstrWFIDrv, gs8SetIP[idx], idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900826
Leo Kime6e12662015-09-16 18:36:03 +0900827 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900828 PRINT_ER("Failed to get IP address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900829 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900830 }
831
Leo Kim24db7132015-09-16 18:36:01 +0900832 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
833 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
834 PRINT_INFO(HOSTINF_DBG, "\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900835
836 return s32Error;
837}
838
839
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900840/**
841 * @brief Handle_SetMacAddress
842 * @details Setting mac address
843 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
844 * @return Error code.
845 * @author Amr Abdel-Moghny
846 * @date November 2013
847 * @version 7.0
848 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900849static s32 Handle_SetMacAddress(tstrWILC_WFIDrv *drvHandler, tstrHostIfSetMacAddress *pstrHostIfSetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900850{
851
Leo Kime6e12662015-09-16 18:36:03 +0900852 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900853 tstrWID strWID;
854 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Glen Leef3052582015-09-10 12:03:04 +0900855 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +0200856
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900857 if (mac_buf == NULL) {
858 PRINT_ER("No buffer to send mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +0900859 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900860 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900861 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900862
863 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900864 strWID.u16WIDid = (u16)WID_MAC_ADDR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900865 strWID.enuWIDtype = WID_STR;
866 strWID.ps8WidVal = mac_buf;
867 strWID.s32ValueSize = ETH_ALEN;
Alexander Kuleshov310a28f2015-09-04 00:48:14 +0600868 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900869 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +0900870 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
871 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900872 if (s32Error) {
873 PRINT_ER("Failed to set mac address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900874 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900875 }
876
Chaehyun Lim49188af2015-08-11 10:32:41 +0900877 kfree(mac_buf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900878 return s32Error;
879}
880
881
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900882/**
883 * @brief Handle_GetMacAddress
884 * @details Getting mac address
885 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
886 * @return Error code.
887 * @author Amr Abdel-Moghny
888 * @date JAN 2013
889 * @version 8.0
890 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900891static s32 Handle_GetMacAddress(tstrWILC_WFIDrv *drvHandler, tstrHostIfGetMacAddress *pstrHostIfGetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900892{
893
Leo Kime6e12662015-09-16 18:36:03 +0900894 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900895 tstrWID strWID;
896
897 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900898 strWID.u16WIDid = (u16)WID_MAC_ADDR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900899 strWID.enuWIDtype = WID_STR;
900 strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress;
901 strWID.s32ValueSize = ETH_ALEN;
902
903 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +0900904 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, false,
905 get_id_from_handler(drvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900906 if (s32Error) {
907 PRINT_ER("Failed to get mac address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900908 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900909 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200910 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900911
912 return s32Error;
913}
914
915
916/**
917 * @brief Handle_CfgParam
918 * @details Sending config packet to firmware to set CFG params
919 * @param[in] tstrHostIFCfgParamAttr* strHostIFCfgParamAttr
920 * @return Error code.
921 * @author
922 * @date
923 * @version 1.0
924 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900925static s32 Handle_CfgParam(tstrWILC_WFIDrv *drvHandler, tstrHostIFCfgParamAttr *strHostIFCfgParamAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900926{
Leo Kime6e12662015-09-16 18:36:03 +0900927 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900928 tstrWID strWIDList[32];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900929 u8 u8WidCnt = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900930 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
931
932
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200933 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900934
935
936 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
937
938 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) {
939 /*----------------------------------------------------------*/
940 /*Input Value: INFRASTRUCTURE = 1, */
941 /* INDEPENDENT= 2, */
942 /* ANY_BSS= 3 */
943 /*----------------------------------------------------------*/
944 /* validate input then copy>> need to check value 4 and 5 */
945 if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) {
946 strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900947 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900948 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900949 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900950 pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900951 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900952 PRINT_ER("check value 6 over\n");
953 s32Error = -EINVAL;
954 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900955 }
956 u8WidCnt++;
957 }
958 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) {
959 /*------------------------------------------------------*/
960 /*Input Values: OPEN_SYSTEM = 0, */
961 /* SHARED_KEY = 1, */
962 /* ANY = 2 */
963 /*------------------------------------------------------*/
964 /*validate Possible values*/
965 if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) {
966 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900967 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900968 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900969 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900970 pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900971 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900972 PRINT_ER("Impossible value \n");
973 s32Error = -EINVAL;
974 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900975 }
976 u8WidCnt++;
977 }
978 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) {
979 /* range is 1 to 65535. */
980 if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) {
981 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900982 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900983 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900984 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900985 pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
986 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900987 PRINT_ER("Range(1 ~ 65535) over\n");
988 s32Error = -EINVAL;
989 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900990 }
991 u8WidCnt++;
992 }
993 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) {
994 /*-----------------------------------------------------------*/
995 /*Input Values: NO_POWERSAVE = 0, */
996 /* MIN_FAST_PS = 1, */
997 /* MAX_FAST_PS = 2, */
998 /* MIN_PSPOLL_PS = 3, */
999 /* MAX_PSPOLL_PS = 4 */
1000 /*----------------------------------------------------------*/
1001 if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) {
1002 strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001003 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001004 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001005 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001006 pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001007 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001008 PRINT_ER("Invalide power mode\n");
1009 s32Error = -EINVAL;
1010 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001011 }
1012 u8WidCnt++;
1013 }
1014 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) {
1015 /* range from 1 to 256 */
1016 if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) {
1017 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001018 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001019 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001020 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001021 pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
1022 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001023 PRINT_ER("Range(1~256) over\n");
1024 s32Error = -EINVAL;
1025 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001026 }
1027 u8WidCnt++;
1028 }
1029 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) {
1030 /* range from 1 to 256 */
1031 if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) {
1032 strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001033 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001034
1035 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001036 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001037 pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
1038 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001039 PRINT_ER("Range(1~256) over\n");
1040 s32Error = -EINVAL;
1041 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001042 }
1043 u8WidCnt++;
1044 }
1045 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) {
1046
1047 if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) {
1048 strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001049 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001050 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001051 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001052 pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
1053 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001054 PRINT_ER("Threshold Range fail\n");
1055 s32Error = -EINVAL;
1056 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001057 }
1058 u8WidCnt++;
1059 }
1060 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) {
1061 /* range 256 to 65535 */
1062 if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) {
1063 strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001064 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001065 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001066 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001067 pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1068 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001069 PRINT_ER("Threshold Range fail\n");
1070 s32Error = -EINVAL;
1071 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001072 }
1073 u8WidCnt++;
1074 }
1075 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) {
1076 /*-----------------------------------------------------*/
1077 /*Input Values: Short= 0, */
1078 /* Long= 1, */
1079 /* Auto= 2 */
1080 /*------------------------------------------------------*/
1081 if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) {
1082 strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001083 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001084 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001085 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001086 pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1087 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001088 PRINT_ER("Preamle Range(0~2) over\n");
1089 s32Error = -EINVAL;
1090 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001091 }
1092 u8WidCnt++;
1093 }
1094 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) {
1095 if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) {
1096 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001097 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001098 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001099 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001100 pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001101 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001102 PRINT_ER("Short slot(2) over\n");
1103 s32Error = -EINVAL;
1104 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001105 }
1106 u8WidCnt++;
1107 }
1108 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) {
1109 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1110 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1111 /* this information is useful for external supplicant */
1112 /*Input Values: 1 for enable and 0 for disable. */
1113 if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) {
1114 strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001115 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001116 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001117 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001118 pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001119 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001120 PRINT_ER("TXOP prot disable\n");
1121 s32Error = -EINVAL;
1122 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001123 }
1124 u8WidCnt++;
1125 }
1126 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) {
1127 /* range is 1 to 65535. */
1128 if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) {
1129 strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001130 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001131 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001132 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001133 pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1134 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001135 PRINT_ER("Beacon interval(1~65535) fail\n");
1136 s32Error = -EINVAL;
1137 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001138 }
1139 u8WidCnt++;
1140 }
1141 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) {
1142 /* range is 1 to 255. */
1143 if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) {
1144 strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001145 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001146 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001147 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001148 pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1149 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001150 PRINT_ER("DTIM range(1~255) fail\n");
1151 s32Error = -EINVAL;
1152 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001153 }
1154 u8WidCnt++;
1155 }
1156 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) {
1157 /*----------------------------------------------------------------------*/
1158 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1159 /* SITE_SURVEY_ALL_CH = 1, */
1160 /* SITE_SURVEY_OFF = 2 */
1161 /*----------------------------------------------------------------------*/
1162 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) {
1163 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001164 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001165 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001166 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001167 pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001168 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001169 PRINT_ER("Site survey disable\n");
1170 s32Error = -EINVAL;
1171 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001172 }
1173 u8WidCnt++;
1174 }
1175 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) {
1176 /* range is 1 to 65535. */
1177 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) {
1178 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001179 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001180 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001181 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001182 pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1183 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001184 PRINT_ER("Site survey scan time(1~65535) over\n");
1185 s32Error = -EINVAL;
1186 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001187 }
1188 u8WidCnt++;
1189 }
1190 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) {
1191 /* range is 1 to 65535. */
1192 if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) {
1193 strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001194 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001195 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001196 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001197 pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1198 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001199 PRINT_ER("Active scan time(1~65535) over\n");
1200 s32Error = -EINVAL;
1201 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001202 }
1203 u8WidCnt++;
1204 }
1205 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) {
1206 /* range is 1 to 65535. */
1207 if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) {
1208 strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001209 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001210 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001211 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001212 pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1213 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001214 PRINT_ER("Passive scan time(1~65535) over\n");
1215 s32Error = -EINVAL;
1216 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001217 }
1218 u8WidCnt++;
1219 }
1220 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) {
1221 CURRENT_TX_RATE_T curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate;
1222 /*----------------------------------------------------------------------*/
1223 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1224 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1225 /*----------------------------------------------------------------------*/
1226 /* validate rate */
1227 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
1228 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
1229 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
1230 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
1231 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
1232 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
1233 strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001234 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001235 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001236 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001237 pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001238 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001239 PRINT_ER("out of TX rate\n");
1240 s32Error = -EINVAL;
1241 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001242 }
1243 u8WidCnt++;
1244 }
Johnny Kimd42ab082015-08-20 16:32:52 +09001245 s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, false,
1246 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001247
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001248 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001249 PRINT_ER("Error in setting CFG params\n");
1250
Leo Kim24db7132015-09-16 18:36:01 +09001251ERRORHANDLER:
Arnd Bergmann83383ea2015-06-01 21:06:43 +02001252 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001253 return s32Error;
1254}
1255
1256
1257/**
1258 * @brief Handle_wait_msg_q_empty
1259 * @details this should be the last msg and then the msg Q becomes idle
1260 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1261 * @return Error code.
1262 * @author
1263 * @date
1264 * @version 1.0
1265 */
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001266static s32 Handle_wait_msg_q_empty(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001267{
Leo Kime6e12662015-09-16 18:36:03 +09001268 s32 s32Error = 0;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02001269
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001270 g_wilc_initialized = 0;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02001271 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001272 return s32Error;
1273}
1274
1275/**
1276 * @brief Handle_Scan
1277 * @details Sending config packet to firmware to set the scan params
Tony Choc476feb2015-09-21 12:16:36 +09001278 * @param[in] struct scan_attr *pstrHostIFscanAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001279 * @return Error code.
1280 * @author
1281 * @date
1282 * @version 1.0
1283 */
Tony Choc476feb2015-09-21 12:16:36 +09001284static s32 Handle_Scan(tstrWILC_WFIDrv *drvHandler,
1285 struct scan_attr *pstrHostIFscanAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001286{
Leo Kime6e12662015-09-16 18:36:03 +09001287 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001288 tstrWID strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001289 u32 u32WidsCount = 0;
1290 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001291 u8 *pu8Buffer;
1292 u8 valuesize = 0;
1293 u8 *pu8HdnNtwrksWidVal = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001294 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1295
1296 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001297 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", pstrWFIDrv->enuHostIFstate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001298
1299 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
1300 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
1301
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001302 if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) {
1303 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1304 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate);
Leo Kim24db7132015-09-16 18:36:01 +09001305 PRINT_ER("Already scan\n");
1306 s32Error = -EBUSY;
1307 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001308 }
1309
1310 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
1311 if (g_obtainingIP || connecting) {
1312 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +09001313 PRINT_ER("Don't do obss scan\n");
1314 s32Error = -EBUSY;
1315 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001316 }
1317 #endif
1318
1319 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1320
1321
1322 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0;
1323
Chaehyun Limd85f5322015-06-11 14:35:54 +09001324 strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001325 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1326
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001327 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001328 valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
Glen Leef3052582015-09-10 12:03:04 +09001329 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001330 strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001331 if (strWIDList[u32WidsCount].ps8WidVal != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001332 pu8Buffer = strWIDList[u32WidsCount].ps8WidVal;
1333
1334 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
1335
1336 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
1337
1338 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1339 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001340 memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001341 pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1342 }
1343
1344
1345
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001346 strWIDList[u32WidsCount].s32ValueSize = (s32)(valuesize + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001347 u32WidsCount++;
1348 }
1349
1350 /*filling cfg param array*/
1351
1352 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1353 {
1354 /* IEs to be inserted in Probe Request */
1355 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE;
1356 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1357 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs;
1358 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen;
1359 u32WidsCount++;
1360 }
1361
1362 /*Scan Type*/
1363 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE;
1364 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001365 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001366 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001367 u32WidsCount++;
1368
1369 /*list of channels to be scanned*/
1370 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST;
1371 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1372
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001373 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
1374 int i;
1375
1376 for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001377 if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001378 pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001379 }
1380 }
1381
1382 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList;
1383 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen;
1384 u32WidsCount++;
1385
1386 /*Scan Request*/
1387 strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ;
1388 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001389 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001390 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001391 u32WidsCount++;
1392
1393 /*keep the state as is , no need to change it*/
1394 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1395
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301396 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001397 gbScanWhileConnected = true;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301398 else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001399 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001400
Johnny Kimd42ab082015-08-20 16:32:52 +09001401 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false,
1402 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001403
Leo Kim24db7132015-09-16 18:36:01 +09001404 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001405 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09001406 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001407 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001408
Leo Kim24db7132015-09-16 18:36:01 +09001409ERRORHANDLER:
1410 if (s32Error) {
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07001411 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001412 /*if there is an ongoing scan request*/
1413 Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED);
1414 }
1415
1416 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1417 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001418 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001419 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1420 }
1421
1422 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1423 if (pstrHostIFscanAttr->pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001424 kfree(pstrHostIFscanAttr->pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001425 pstrHostIFscanAttr->pu8IEs = NULL;
1426 }
1427 if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001428 kfree(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001429 pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
1430 }
1431
1432 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1433 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001434 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001435 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1436 }
1437
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001438 if (pu8HdnNtwrksWidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001439 kfree(pu8HdnNtwrksWidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001440
1441 return s32Error;
1442}
1443
1444/**
1445 * @brief Handle_ScanDone
1446 * @details Call scan notification callback function
1447 * @param[in] NONE
1448 * @return Error code.
1449 * @author
1450 * @date
1451 * @version 1.0
1452 */
Johnny Kim2b05df52015-08-13 13:41:21 +09001453static s32 Handle_ScanDone(tstrWILC_WFIDrv *drvHandler, tenuScanEvent enuEvent)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001454{
Leo Kime6e12662015-09-16 18:36:03 +09001455 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001456
1457 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
1458
1459
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001460 u8 u8abort_running_scan;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001461 tstrWID strWID;
1462
1463
1464 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
1465
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001466 /*Ask FW to abort the running scan, if any*/
1467 if (enuEvent == SCAN_EVENT_ABORTED) {
1468 PRINT_D(GENERIC_DBG, "Abort running scan\n");
1469 u8abort_running_scan = 1;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001470 strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001471 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001472 strWID.ps8WidVal = (s8 *)&u8abort_running_scan;
Dean Lee576917a2015-06-15 11:58:57 +09001473 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001474
1475 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09001476 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
1477 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09001478 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001479 PRINT_ER("Failed to set abort running scan\n");
Leo Kim24db7132015-09-16 18:36:01 +09001480 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001481 }
1482 }
1483
1484 if (pstrWFIDrv == NULL) {
1485 PRINT_ER("Driver handler is NULL\n");
1486 return s32Error;
1487 }
1488
1489 /*if there is an ongoing scan request*/
1490 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001491 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001492 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1493 /*delete current scan request*/
1494 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1495 }
1496
1497 return s32Error;
1498}
1499
1500/**
1501 * @brief Handle_Connect
1502 * @details Sending config packet to firmware to starting connection
Tony Cho120ae592015-09-21 12:16:37 +09001503 * @param[in] struct connect_attr *pstrHostIFconnectAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001504 * @return Error code.
1505 * @author
1506 * @date
1507 * @version 1.0
1508 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001509u8 u8ConnectedSSID[6] = {0};
Tony Cho120ae592015-09-21 12:16:37 +09001510static s32 Handle_Connect(tstrWILC_WFIDrv *drvHandler,
1511 struct connect_attr *pstrHostIFconnectAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001512{
1513 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
Leo Kime6e12662015-09-16 18:36:03 +09001514 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001515 tstrWID strWIDList[8];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001516 u32 u32WidsCount = 0, dummyval = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001517 /* char passphrase[] = "12345678"; */
1518 #ifndef CONNECT_DIRECT
Leo Kime6e12662015-09-16 18:36:03 +09001519 s32 s32Err = 0;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001520 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001521 u8 u8bssDscListIndex;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001522 wid_site_survey_reslts_s *pstrSurveyResults = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001523 #else
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001524 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001525 #ifdef WILC_PARSE_SCAN_IN_HOST
1526 tstrJoinBssParam *ptstrJoinBssParam;
1527 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1528
1529 #endif
1530
1531 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1532
1533 #ifndef CONNECT_DIRECT
Hari Prasath Gujulan Elango3a79a7f2015-08-20 09:59:44 +00001534 memset(gapu8RcvdSurveyResults, 0, sizeof(gapu8RcvdSurveyResults));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001535
1536
1537 PRINT_D(HOSTINF_DBG, "Getting site survey results\n");
Johnny Kim218dc402015-08-13 13:41:19 +09001538 s32Err = host_int_get_site_survey_results(pstrWFIDrv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001539 gapu8RcvdSurveyResults,
1540 MAX_SURVEY_RESULT_FRAG_SIZE);
1541 if (s32Err) {
1542 PRINT_ER("Failed to get site survey results\n");
Leo Kim24db7132015-09-16 18:36:01 +09001543 s32Error = -EFAULT;
1544 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001545 }
1546 s32Err = ParseSurveyResults(gapu8RcvdSurveyResults, &pstrSurveyResults,
1547 &pstrWFIDrv->u32SurveyResultsCount);
1548
1549
Leo Kime6e12662015-09-16 18:36:03 +09001550 if (s32Err == 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001551 /* use the parsed info in pstrSurveyResults, then deallocate it */
1552 PRINT_D(HOSTINF_DBG, "Copying site survey results in global structure, then deallocate\n");
1553 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001554 memcpy(&pstrWFIDrv->astrSurveyResults[i], &pstrSurveyResults[i],
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001555 sizeof(wid_site_survey_reslts_s));
1556 }
1557
1558 DeallocateSurveyResults(pstrSurveyResults);
1559 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001560 PRINT_ER("ParseSurveyResults() Error\n");
1561 s32Error = -EFAULT;
1562 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001563 }
1564
1565
1566 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001567 if (memcmp(pstrWFIDrv->astrSurveyResults[i].SSID,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001568 pstrHostIFconnectAttr->pu8ssid,
1569 pstrHostIFconnectAttr->ssidLen) == 0) {
1570 PRINT_INFO(HOSTINF_DBG, "Network with required SSID is found %s\n", pstrHostIFconnectAttr->pu8ssid);
1571 if (pstrHostIFconnectAttr->pu8bssid == NULL) {
1572 /* BSSID is not passed from the user, so decision of matching
1573 * is done by SSID only */
1574 PRINT_INFO(HOSTINF_DBG, "BSSID is not passed from the user\n");
1575 break;
1576 } else {
1577 /* BSSID is also passed from the user, so decision of matching
1578 * should consider also this passed BSSID */
1579
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001580 if (memcmp(pstrWFIDrv->astrSurveyResults[i].BSSID,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001581 pstrHostIFconnectAttr->pu8bssid,
1582 6) == 0) {
1583 PRINT_INFO(HOSTINF_DBG, "BSSID is passed from the user and matched\n");
1584 break;
1585 }
1586 }
1587 }
1588 }
1589
1590 if (i < pstrWFIDrv->u32SurveyResultsCount) {
1591 u8bssDscListIndex = i;
1592
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001593 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 +09001594 u8bssDscListIndex, pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].SSID,
1595 pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].Channel);
1596
1597 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1598
1599 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001600 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001601 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001602 }
1603
1604 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1605 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001606 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssidLen + 1, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001607 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001608 pstrHostIFconnectAttr->ssidLen);
1609 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1610 }
1611
1612 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1613 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001614 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001615 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001616 pstrHostIFconnectAttr->IEsLen);
1617 }
1618
1619 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1620 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1621 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1622 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1623
1624
1625 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1626 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1627 {
1628 /* IEs to be inserted in Association Request */
1629 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1630 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1631 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1632 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1633 u32WidsCount++;
1634 }
Chaehyun Limd85f5322015-06-11 14:35:54 +09001635 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001636 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001637 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001638 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001639 u32WidsCount++;
1640
1641 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1642
Chaehyun Limd85f5322015-06-11 14:35:54 +09001643 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001644 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001645 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001646 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001647 u32WidsCount++;
1648
1649 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1650 /*
Chaehyun Limd85f5322015-06-11 14:35:54 +09001651 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001652 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1653 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001654 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001655 * u32WidsCount++;
1656 */
1657
Chaehyun Limd85f5322015-06-11 14:35:54 +09001658 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001659 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001660 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001661 strWIDList[u32WidsCount].ps8WidVal = (s8 *)&u8bssDscListIndex;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001662 u32WidsCount++;
1663
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001664 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1665 * firmware at chip reset when processing the WIDs of the Connect Request.
1666 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1667 /* ////////////////////// */
1668 gu32WidConnRstHack = 0;
1669 /* ////////////////////// */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001670
Johnny Kimd42ab082015-08-20 16:32:52 +09001671 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false,
1672 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001673 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09001674 PRINT_ER("failed to send config packet\n");
1675 s32Error = -EINVAL;
1676 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001677 } else {
1678 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1679 }
1680
1681 } else {
1682 PRINT_ER("Required BSSID not found\n");
Leo Kim24db7132015-09-16 18:36:01 +09001683 s32Error = -ENOENT;
1684 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001685 }
1686
1687 #else
1688
1689 /* if we try to connect to an already connected AP then discard the request */
1690
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001691 if (memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001692
Leo Kime6e12662015-09-16 18:36:03 +09001693 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001694 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1695 return s32Error;
1696 }
1697
1698 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1699
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001700 #ifdef WILC_PARSE_SCAN_IN_HOST
1701 ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams;
1702 if (ptstrJoinBssParam == NULL) {
1703 PRINT_ER("Required BSSID not found\n");
Leo Kim24db7132015-09-16 18:36:01 +09001704 s32Error = -ENOENT;
1705 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001706 }
1707 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1708
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001709 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001710 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001711 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001712 }
1713
1714 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1715 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001716 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssidLen + 1, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001717 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001718 pstrHostIFconnectAttr->ssidLen);
1719 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1720 }
1721
1722 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1723 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001724 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001725 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001726 pstrHostIFconnectAttr->IEsLen);
1727 }
1728
1729 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1730 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1731 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1732 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1733
1734 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
1735 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001736 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001737 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001738 u32WidsCount++;
1739
1740 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
1741 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001742 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001743 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001744 u32WidsCount++;
1745
1746 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
1747 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001748 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001749 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001750 u32WidsCount++;
1751
1752 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1753 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1754 {
1755 /* IEs to be inserted in Association Request */
1756 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1757 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1758 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1759 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1760 u32WidsCount++;
1761
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001762 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001763
1764 gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001765 gu8FlushedInfoElemAsoc = kmalloc(gu32FlushedInfoElemAsocSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001766 memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1767 gu32FlushedInfoElemAsocSize);
1768 }
1769 }
Chaehyun Limd85f5322015-06-11 14:35:54 +09001770 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001771 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001772 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001773 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001774 u32WidsCount++;
1775
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001776 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001777 gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security;
1778
1779 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1780
1781
Chaehyun Limd85f5322015-06-11 14:35:54 +09001782 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001783 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001784 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001785 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001786 u32WidsCount++;
1787
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001788 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001789 gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001790
1791 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1792 /*
Chaehyun Limd85f5322015-06-11 14:35:54 +09001793 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001794 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1795 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001796 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001797 * u32WidsCount++;
1798 */
1799
1800 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1801 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
1802
1803
1804#ifndef WILC_PARSE_SCAN_IN_HOST
Chaehyun Limd85f5322015-06-11 14:35:54 +09001805 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001806 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1807 strWIDList[u32WidsCount].s32ValueSize = MAX_SSID_LEN + 7;
Glen Leef3052582015-09-10 12:03:04 +09001808 strWIDList[u32WidsCount].ps8WidVal = kmalloc(strWIDList[u32WidsCount].s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001809
Leo Kim24db7132015-09-16 18:36:01 +09001810 if (strWIDList[u32WidsCount].ps8WidVal == NULL) {
1811 s32Error = -EFAULT;
1812 goto ERRORHANDLER;
1813 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001814
1815 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1816
1817 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001818 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001819 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1820 }
1821 pu8CurrByte += MAX_SSID_LEN;
1822 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1823 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1824 } else {
1825 PRINT_ER("Channel out of range\n");
1826 *(pu8CurrByte++) = 0xFF;
1827 }
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001828 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001829 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001830 pu8CurrByte += 6;
1831
1832 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1833 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1834
1835 #else
1836
Chaehyun Limd85f5322015-06-11 14:35:54 +09001837 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001838 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1839
1840 /*Sending NoA attributes during connection*/
1841 strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */
Glen Leef3052582015-09-10 12:03:04 +09001842 strWIDList[u32WidsCount].ps8WidVal = kmalloc(strWIDList[u32WidsCount].s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001843
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001844 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001845 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize;
Glen Leef3052582015-09-10 12:03:04 +09001846 gu8FlushedJoinReq = kmalloc(gu32FlushedJoinReqSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001847 }
Leo Kim24db7132015-09-16 18:36:01 +09001848 if (strWIDList[u32WidsCount].ps8WidVal == NULL) {
1849 s32Error = -EFAULT;
1850 goto ERRORHANDLER;
1851 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001852
1853 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1854
1855
1856 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001857 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001858 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1859 }
1860 pu8CurrByte += MAX_SSID_LEN;
1861
1862 /* BSS type*/
1863 *(pu8CurrByte++) = INFRASTRUCTURE;
1864 /* Channel*/
1865 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1866 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1867 } else {
1868 PRINT_ER("Channel out of range\n");
1869 *(pu8CurrByte++) = 0xFF;
1870 }
1871 /* Cap Info*/
1872 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1873 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1874 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1875
1876 /* sa*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001877 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001878 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001879 pu8CurrByte += 6;
1880
1881 /* bssid*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001882 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001883 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001884 pu8CurrByte += 6;
1885
1886 /* Beacon Period*/
1887 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1888 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1889 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1890 /* DTIM Period*/
1891 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1892 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1893 /* Supported rates*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001894 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001895 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1896
1897 /* wmm cap*/
1898 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1899 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1900 /* uapsd cap*/
1901 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1902
1903 /* ht cap*/
1904 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1905 /* copy this information to the user request */
1906 pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1907
1908 /* rsn found*/
1909 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1910 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1911 /* rsn group policy*/
1912 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1913 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1914 /* mode_802_11i*/
1915 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1916 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1917 /* rsn pcip policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001918 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001919 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1920
1921 /* rsn auth policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001922 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001923 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1924
1925 /* rsn auth policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001926 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001927 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1928
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001929 *(pu8CurrByte++) = REAL_JOIN_REQ;
1930
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001931 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1932 if (ptstrJoinBssParam->u8NoaEnbaled) {
1933 PRINT_D(HOSTINF_DBG, "NOA present\n");
1934
1935 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1936 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1937 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1938 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1939
1940 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1941
1942 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1943
1944 if (ptstrJoinBssParam->u8OppEnable)
1945 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1946
1947 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1948
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001949 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001950
1951 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1952
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001953 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001954
1955 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1956
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001957 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001958
1959 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1960
1961 } else
1962 PRINT_D(HOSTINF_DBG, "NOA not present\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001963
1964 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1965 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1966
1967
1968 #endif /* #ifdef WILC_PARSE_SCAN_IN_HOST*/
1969 u32WidsCount++;
1970
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001971 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1972 * firmware at chip reset when processing the WIDs of the Connect Request.
1973 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1974 /* ////////////////////// */
1975 gu32WidConnRstHack = 0;
1976 /* ////////////////////// */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001977
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001978 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001979 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
Johnny Kim8a625ca2015-08-20 16:32:50 +09001980 gu8FlushedJoinReqDrvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001981 }
1982
1983 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1984
1985 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001986 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001987
Alexander Kuleshov310a28f2015-09-04 00:48:14 +06001988 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->pu8bssid);
1989 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001990 }
1991
Johnny Kimd42ab082015-08-20 16:32:52 +09001992 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false,
1993 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001994 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09001995 PRINT_ER("failed to send config packet\n");
1996 s32Error = -EFAULT;
1997 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001998 } else {
1999 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
2000 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
2001 }
2002 #endif
2003
Leo Kim24db7132015-09-16 18:36:01 +09002004ERRORHANDLER:
2005 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002006 tstrConnectInfo strConnectInfo;
2007
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002008 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002009
2010 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
2011
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002012 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002013
2014 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002015 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002016 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002017
2018 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
2019 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
Glen Leef3052582015-09-10 12:03:04 +09002020 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002021 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002022 pstrHostIFconnectAttr->pu8IEs,
2023 pstrHostIFconnectAttr->IEsLen);
2024 }
2025
2026 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2027 &strConnectInfo,
2028 MAC_DISCONNECTED,
2029 NULL,
2030 pstrHostIFconnectAttr->pvUserArg);
2031 /*Change state to idle*/
2032 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2033 /* Deallocation */
2034 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002035 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002036 strConnectInfo.pu8ReqIEs = NULL;
2037 }
2038
2039 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002040 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002041 }
2042 }
2043
2044 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
2045 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
2046 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002047 kfree(pstrHostIFconnectAttr->pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002048 pstrHostIFconnectAttr->pu8bssid = NULL;
2049 }
2050
2051 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
2052 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002053 kfree(pstrHostIFconnectAttr->pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002054 pstrHostIFconnectAttr->pu8ssid = NULL;
2055 }
2056
2057 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
2058 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002059 kfree(pstrHostIFconnectAttr->pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002060 pstrHostIFconnectAttr->pu8IEs = NULL;
2061 }
2062
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002063 if (pu8CurrByte != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09002064 kfree(pu8CurrByte);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002065 return s32Error;
2066}
2067
2068/**
2069 * @brief Handle_FlushConnect
2070 * @details Sending config packet to firmware to flush an old connection
2071 * after switching FW from station one to hybrid one
2072 * @param[in] void * drvHandler
2073 * @return Error code.
2074 * @author Amr Abdel-Moghny
2075 * @date 19 DEC 2013
2076 * @version 8.0
2077 */
2078
Johnny Kim2b05df52015-08-13 13:41:21 +09002079static s32 Handle_FlushConnect(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002080{
Leo Kime6e12662015-09-16 18:36:03 +09002081 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002082 tstrWID strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002083 u32 u32WidsCount = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002084 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002085
2086
2087 /* IEs to be inserted in Association Request */
2088 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
2089 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
2090 strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc;
2091 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize;
2092 u32WidsCount++;
2093
Chaehyun Limd85f5322015-06-11 14:35:54 +09002094 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002095 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002096 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002097 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002098 u32WidsCount++;
2099
2100
2101
Chaehyun Limd85f5322015-06-11 14:35:54 +09002102 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002103 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002104 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002105 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002106 u32WidsCount++;
2107
2108
2109 #ifdef WILC_PARSE_SCAN_IN_HOST
Chaehyun Limd85f5322015-06-11 14:35:54 +09002110 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002111 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
2112 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002113 strWIDList[u32WidsCount].ps8WidVal = (s8 *)gu8FlushedJoinReq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002114 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
2115
2116 pu8CurrByte += FLUSHED_BYTE_POS;
2117 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
2118
2119 u32WidsCount++;
2120
2121 #endif
2122
Johnny Kimd42ab082015-08-20 16:32:52 +09002123 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false,
2124 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002125 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09002126 PRINT_ER("failed to send config packet\n");
2127 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002128 }
2129
2130 return s32Error;
2131}
2132
2133/**
2134 * @brief Handle_ConnectTimeout
2135 * @details Call connect notification callback function indicating connection failure
2136 * @param[in] NONE
2137 * @return Error code.
2138 * @author
2139 * @date
2140 * @version 1.0
2141 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002142static s32 Handle_ConnectTimeout(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002143{
Leo Kime6e12662015-09-16 18:36:03 +09002144 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002145 tstrConnectInfo strConnectInfo;
2146 tstrWID strWID;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002147 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002148 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
2149
2150 if (pstrWFIDrv == NULL) {
2151 PRINT_ER("Driver handler is NULL\n");
2152 return s32Error;
2153 }
2154
2155 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2156
Dean Lee72ed4dc2015-06-12 14:11:44 +09002157 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002158
2159
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002160 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002161
2162
2163 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
2164 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2165 * WID_DISCONNECT} */
2166 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2167 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002168 memcpy(strConnectInfo.au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002169 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2170 }
2171
2172 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2173 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09002174 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002175 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002176 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2177 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2178 }
2179
2180 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2181 &strConnectInfo,
2182 MAC_DISCONNECTED,
2183 NULL,
2184 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2185
2186 /* Deallocation of strConnectInfo.pu8ReqIEs */
2187 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002188 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002189 strConnectInfo.pu8ReqIEs = NULL;
2190 }
2191 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002192 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002193 }
2194
2195 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2196 * WID_DISCONNECT} */
Chaehyun Limd85f5322015-06-11 14:35:54 +09002197 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002198 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002199 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
Dean Lee576917a2015-06-15 11:58:57 +09002200 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002201
2202 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2203
Johnny Kimd42ab082015-08-20 16:32:52 +09002204 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
2205 get_id_from_handler(pstrWFIDrv));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002206 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002207 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002208
2209 /* Deallocation of the Saved Connect Request in the global Handle */
2210 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2211 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002212 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002213 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2214 }
2215
2216 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002217 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002218 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2219 }
2220
2221 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2222 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002223 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002224 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2225 }
2226
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002227 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002228 /*Freeing flushed join request params on connect timeout*/
Johnny Kim8a625ca2015-08-20 16:32:50 +09002229 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002230 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002231 gu8FlushedJoinReq = NULL;
2232 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09002233 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002234 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002235 gu8FlushedInfoElemAsoc = NULL;
2236 }
2237
2238 return s32Error;
2239}
2240
2241/**
2242 * @brief Handle_RcvdNtwrkInfo
2243 * @details Handling received network information
Tony Cho3bbd59f2015-09-21 12:16:38 +09002244 * @param[in] struct rcvd_net_info *pstrRcvdNetworkInfo
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002245 * @return Error code.
2246 * @author
2247 * @date
2248 * @version 1.0
2249 */
Tony Cho3bbd59f2015-09-21 12:16:38 +09002250static s32 Handle_RcvdNtwrkInfo(tstrWILC_WFIDrv *drvHandler,
2251 struct rcvd_net_info *pstrRcvdNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002252{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002253 u32 i;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002254 bool bNewNtwrkFound;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002255
2256
2257
Leo Kime6e12662015-09-16 18:36:03 +09002258 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002259 tstrNetworkInfo *pstrNetworkInfo = NULL;
2260 void *pJoinParams = NULL;
2261
2262 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2263
2264
2265
Dean Lee72ed4dc2015-06-12 14:11:44 +09002266 bNewNtwrkFound = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002267 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
2268
2269 /*if there is a an ongoing scan request*/
2270 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2271 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
2272 ParseNetworkInfo(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
2273 if ((pstrNetworkInfo == NULL)
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002274 || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
Leo Kim24db7132015-09-16 18:36:01 +09002275 PRINT_ER("driver is null\n");
2276 s32Error = -EINVAL;
2277 goto done;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002278 }
2279
2280 /* check whether this network is discovered before */
2281 for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
2282
2283 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
2284 (pstrNetworkInfo->au8bssid != NULL)) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002285 if (memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002286 pstrNetworkInfo->au8bssid, 6) == 0) {
2287 if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
2288 /*we have already found this network with better rssi, so keep the old cached one and don't
2289 * send anything to the upper layer */
2290 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
2291 goto done;
2292 } else {
2293 /* here the same already found network is found again but with a better rssi, so just update
2294 * the rssi for this cached network and send this updated network to the upper layer but
2295 * don't add a new record for it */
2296 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002297 bNewNtwrkFound = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002298 break;
2299 }
2300 }
2301 }
2302 }
2303
Dean Lee72ed4dc2015-06-12 14:11:44 +09002304 if (bNewNtwrkFound == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002305 /* here it is confirmed that it is a new discovered network,
2306 * so add its record then call the User CallBack function */
2307
2308 PRINT_D(HOSTINF_DBG, "New network found\n");
2309
2310 if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
2311 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
2312
2313 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
2314 && (pstrNetworkInfo->au8bssid != NULL)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002315 memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002316 pstrNetworkInfo->au8bssid, 6);
2317
2318 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++;
2319
Dean Lee72ed4dc2015-06-12 14:11:44 +09002320 pstrNetworkInfo->bNewNetwork = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002321 /* add new BSS to JoinBssTable */
2322 #ifdef WILC_PARSE_SCAN_IN_HOST
2323 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
2324 #endif /*WILC_PARSE_SCAN_IN_HOST*/
2325
2326 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2327 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid,
2328 pJoinParams);
2329
2330
2331 }
2332 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002333 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002334 }
2335 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002336 pstrNetworkInfo->bNewNetwork = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002337 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2338 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2339 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2340 }
2341 }
2342
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002343done:
2344 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2345 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002346 kfree(pstrRcvdNetworkInfo->pu8Buffer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002347 pstrRcvdNetworkInfo->pu8Buffer = NULL;
2348 }
2349
2350 /*free structure allocated*/
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002351 if (pstrNetworkInfo != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002352 DeallocateNetworkInfo(pstrNetworkInfo);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002353 pstrNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002354 }
2355
2356 return s32Error;
2357}
2358
2359/**
2360 * @brief Handle_RcvdGnrlAsyncInfo
2361 * @details Handling received asynchrous general network information
Tony Chof23a9ea2015-09-21 12:16:39 +09002362 * @param[in] struct rcvd_async_info *pstrRcvdGnrlAsyncInfo
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002363 * @return Error code.
2364 * @author
2365 * @date
2366 * @version 1.0
2367 */
Tony Chof23a9ea2015-09-21 12:16:39 +09002368static s32 Handle_RcvdGnrlAsyncInfo(tstrWILC_WFIDrv *drvHandler,
2369 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002370{
2371 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2372 /* which carries only 1 WID which have WID ID = WID_STATUS */
Leo Kime6e12662015-09-16 18:36:03 +09002373 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002374 u8 u8MsgType = 0;
2375 u8 u8MsgID = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002376 u16 u16MsgLen = 0;
2377 u16 u16WidID = (u16)WID_NIL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002378 u8 u8WidLen = 0;
2379 u8 u8MacStatus;
2380 u8 u8MacStatusReasonCode;
2381 u8 u8MacStatusAdditionalInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002382 tstrConnectInfo strConnectInfo;
2383 tstrDisconnectNotifInfo strDisconnectNotifInfo;
Leo Kime6e12662015-09-16 18:36:03 +09002384 s32 s32Err = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002385 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002386
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002387 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002388 PRINT_ER("Driver handler is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002389 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
2390 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
2391
2392 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
2393 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) ||
2394 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2395 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002396 (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
Leo Kim24db7132015-09-16 18:36:01 +09002397 PRINT_ER("driver is null\n");
2398 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002399 }
2400
2401 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
2402
2403 /* Check whether the received message type is 'I' */
2404 if ('I' != u8MsgType) {
2405 PRINT_ER("Received Message format incorrect.\n");
Leo Kim24db7132015-09-16 18:36:01 +09002406 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002407 }
2408
2409 /* Extract message ID */
2410 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
2411
2412 /* Extract message Length */
2413 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
2414
2415 /* Extract WID ID [expected to be = WID_STATUS] */
2416 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
2417
2418 /* Extract WID Length [expected to be = 1] */
2419 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
2420
2421 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2422 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
2423 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
2424 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
2425 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2426 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2427 /* 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 +09002428 u32 u32RcvdAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002429 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
2430
2431 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2432
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002433 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002434
2435 if (u8MacStatus == MAC_CONNECTED) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002436 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002437
Johnny Kim218dc402015-08-13 13:41:19 +09002438 host_int_get_assoc_res_info(pstrWFIDrv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002439 gapu8RcvdAssocResp,
2440 MAX_ASSOC_RESP_FRAME_SIZE,
2441 &u32RcvdAssocRespInfoLen);
2442
2443 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
2444
2445 if (u32RcvdAssocRespInfoLen != 0) {
2446
2447 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
2448 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
2449 &pstrConnectRespInfo);
2450 if (s32Err) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002451 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002452 } else {
2453 /* use the necessary parsed Info from the Received Association Response */
2454 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
2455
2456 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
2457 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
2458 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
2459 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
2460
2461
Glen Leef3052582015-09-10 12:03:04 +09002462 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002463 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002464 pstrConnectRespInfo->u16RespIEsLen);
2465 }
2466 }
2467
2468 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2469 if (pstrConnectRespInfo != NULL) {
2470 DeallocateAssocRespInfo(pstrConnectRespInfo);
2471 pstrConnectRespInfo = NULL;
2472 }
2473 }
2474 }
2475 }
2476
2477 /* The station has just received mac status and it also received assoc. response which
2478 * it was waiting for.
2479 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2480 if ((u8MacStatus == MAC_CONNECTED) &&
2481 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002482 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 +09002483 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002484
2485 } else if (u8MacStatus == MAC_DISCONNECTED) {
2486 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002487 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002488 }
2489
2490 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2491 /* through a structure of type tstrConnectRespInfo */
2492 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2493 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002494 memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002495
2496 if ((u8MacStatus == MAC_CONNECTED) &&
2497 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002498 memcpy(pstrWFIDrv->au8AssociatedBSSID,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002499 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
2500 }
2501 }
2502
2503
2504 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2505 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09002506 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002507 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002508 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2509 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2510 }
2511
2512
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002513 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002514 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2515 &strConnectInfo,
2516 u8MacStatus,
2517 NULL,
2518 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2519
2520
2521 /* if received mac status is MAC_CONNECTED and
2522 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2523 * else change state to IDLE */
2524 if ((u8MacStatus == MAC_CONNECTED) &&
2525 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2526 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2527
Johnny Kim218dc402015-08-13 13:41:19 +09002528 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002529 #endif
2530
2531 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
2532 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED;
2533
2534 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2535 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +09002536 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002537 mod_timer(&hDuringIpTimer,
2538 jiffies + msecs_to_jiffies(10000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002539 #endif
2540
2541 #ifdef WILC_PARSE_SCAN_IN_HOST
2542 /* open a BA session if possible */
2543 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
2544
2545 #endif
2546
2547 /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
2548 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2549 } else {
2550 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
2551 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002552 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002553 }
2554
2555 /* Deallocation */
2556 if (strConnectInfo.pu8RespIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002557 kfree(strConnectInfo.pu8RespIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002558 strConnectInfo.pu8RespIEs = NULL;
2559 }
2560
2561 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002562 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002563 strConnectInfo.pu8ReqIEs = NULL;
2564 }
2565
2566
2567 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2568 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002569 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002570 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2571 }
2572
2573 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002574 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002575 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2576 }
2577
2578 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2579 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002580 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002581 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2582 }
2583
2584 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2585 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) {
2586 /* Disassociation or Deauthentication frame has been received */
2587 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
2588
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002589 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002590
2591 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002592 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002593 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002594 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2595 }
2596
2597 strDisconnectNotifInfo.u16reason = 0;
2598 strDisconnectNotifInfo.ie = NULL;
2599 strDisconnectNotifInfo.ie_len = 0;
2600
2601 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2602 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2603
Dean Lee72ed4dc2015-06-12 14:11:44 +09002604 g_obtainingIP = false;
Johnny Kim218dc402015-08-13 13:41:19 +09002605 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002606 #endif
2607
2608 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2609 NULL,
2610 0,
2611 &strDisconnectNotifInfo,
2612 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2613
2614 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002615 PRINT_ER("Connect result callback function is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002616 }
2617
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002618 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002619
2620
2621 /* Deallocation */
2622
2623 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2624 * should be deallocated here */
2625 /*
2626 * if(strDisconnectNotifInfo.ie != NULL)
2627 * {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002628 * kfree(strDisconnectNotifInfo.ie);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002629 * strDisconnectNotifInfo.ie = NULL;
2630 * }
2631 */
2632
2633 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2634 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002635 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002636 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2637 }
2638
2639 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002640 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002641 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2642 }
2643
2644 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2645 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002646 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002647 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2648 }
2649
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002650 /*Freeing flushed join request params on receiving*/
2651 /*MAC_DISCONNECTED while connected*/
Johnny Kim8a625ca2015-08-20 16:32:50 +09002652 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002653 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002654 gu8FlushedJoinReq = NULL;
2655 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09002656 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002657 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002658 gu8FlushedInfoElemAsoc = NULL;
2659 }
2660
2661 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002662 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002663
2664 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2665 (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
2666 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002667 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002668 /*Abort the running scan*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002669 del_timer(&pstrWFIDrv->hScanTimer);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002670 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult)
Johnny Kim2b05df52015-08-13 13:41:21 +09002671 Handle_ScanDone(pstrWFIDrv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002672
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002673 }
2674
2675 }
2676
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002677 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2678 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002679 kfree(pstrRcvdGnrlAsyncInfo->pu8Buffer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002680 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
2681 }
2682
2683 return s32Error;
2684}
2685
2686/**
2687 * @brief Handle_Key
2688 * @details Sending config packet to firmware to set key
Tony Choc98387a2015-09-21 12:16:40 +09002689 * @param[in] struct key_attr *pstrHostIFkeyAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002690 * @return Error code.
2691 * @author
2692 * @date
2693 * @version 1.0
2694 */
Tony Choc98387a2015-09-21 12:16:40 +09002695static int Handle_Key(tstrWILC_WFIDrv *drvHandler,
2696 struct key_attr *pstrHostIFkeyAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002697{
Leo Kime6e12662015-09-16 18:36:03 +09002698 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002699 tstrWID strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002700 tstrWID strWIDList[5];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002701 u8 i;
2702 u8 *pu8keybuf;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002703 s8 s8idxarray[1];
2704 s8 ret = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002705 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2706
2707
2708 switch (pstrHostIFkeyAttr->enuKeyType) {
2709
2710
2711 case WEP:
2712
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002713 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2714
2715 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2716 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Chaehyun Limd85f5322015-06-11 14:35:54 +09002717 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002718 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002719 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002720 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002721
2722 strWIDList[1].u16WIDid = WID_AUTH_TYPE;
2723 strWIDList[1].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002724 strWIDList[1].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002725 strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002726
Chaehyun Limd85f5322015-06-11 14:35:54 +09002727 strWIDList[2].u16WIDid = (u16)WID_KEY_ID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002728 strWIDList[2].enuWIDtype = WID_CHAR;
2729
Chaehyun Limca356ad2015-06-11 14:35:57 +09002730 strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Dean Lee576917a2015-06-15 11:58:57 +09002731 strWIDList[2].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002732
2733
Glen Leef3052582015-09-10 12:03:04 +09002734 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002735
2736
2737 if (pu8keybuf == NULL) {
2738 PRINT_ER("No buffer to send Key\n");
2739 return -1;
2740 }
2741
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002742 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002743 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2744
2745
Chaehyun Lim49188af2015-08-11 10:32:41 +09002746 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002747
Chaehyun Limd85f5322015-06-11 14:35:54 +09002748 strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002749 strWIDList[3].enuWIDtype = WID_STR;
2750 strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002751 strWIDList[3].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002752
2753
Johnny Kimd42ab082015-08-20 16:32:52 +09002754 s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, true,
2755 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002756 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002757
2758
2759 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002760
2761 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2762 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Glen Leef3052582015-09-10 12:03:04 +09002763 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002764 if (pu8keybuf == NULL) {
2765 PRINT_ER("No buffer to send Key\n");
2766 return -1;
2767 }
2768 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2769
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002770 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002771
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002772 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002773 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2774
Chaehyun Lim49188af2015-08-11 10:32:41 +09002775 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002776
Chaehyun Limd85f5322015-06-11 14:35:54 +09002777 strWID.u16WIDid = (u16)WID_ADD_WEP_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002778 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002779 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002780 strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2;
2781
Johnny Kimd42ab082015-08-20 16:32:52 +09002782 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2783 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002784 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002785 } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) {
2786
2787 PRINT_D(HOSTINF_DBG, "Removing key\n");
Chaehyun Limd85f5322015-06-11 14:35:54 +09002788 strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002789 strWID.enuWIDtype = WID_STR;
2790
Chaehyun Limca356ad2015-06-11 14:35:57 +09002791 s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002792 strWID.ps8WidVal = s8idxarray;
2793 strWID.s32ValueSize = 1;
2794
Johnny Kimd42ab082015-08-20 16:32:52 +09002795 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2796 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002797 } else {
Chaehyun Limd85f5322015-06-11 14:35:54 +09002798 strWID.u16WIDid = (u16)WID_KEY_ID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002799 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002800 strWID.ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Dean Lee576917a2015-06-15 11:58:57 +09002801 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002802
2803 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
2804
Johnny Kimd42ab082015-08-20 16:32:52 +09002805 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2806 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002807 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002808 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002809 break;
2810
2811 case WPARxGtk:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002812 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
Glen Leef3052582015-09-10 12:03:04 +09002813 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002814 if (pu8keybuf == NULL) {
2815 PRINT_ER("No buffer to send RxGTK Key\n");
2816 ret = -1;
2817 goto _WPARxGtk_end_case_;
2818 }
2819
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002820 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002821
2822
2823 /*|----------------------------------------------------------------------------|
2824 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2825 * |------------|---------|-------|------------|---------------|----------------|
2826 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2827
2828
2829
2830 if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002831 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002832
2833
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002834 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002835
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002836 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002837
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002838 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002839 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2840 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
Chaehyun Limd85f5322015-06-11 14:35:54 +09002841 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002842 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002843 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002844 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002845
Chaehyun Limd85f5322015-06-11 14:35:54 +09002846 strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002847 strWIDList[1].enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002848 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002849 strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN;
2850
Johnny Kimd42ab082015-08-20 16:32:52 +09002851 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true,
2852 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002853
Chaehyun Lim49188af2015-08-11 10:32:41 +09002854 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002855
2856 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002857 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002858 /* ///////////////////////// */
2859 }
2860
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002861 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2862 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
2863
Glen Leef3052582015-09-10 12:03:04 +09002864 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002865 if (pu8keybuf == NULL) {
2866 PRINT_ER("No buffer to send RxGTK Key\n");
2867 ret = -1;
2868 goto _WPARxGtk_end_case_;
2869 }
2870
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002871 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002872
2873
2874 /*|----------------------------------------------------------------------------|
2875 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2876 * |------------|---------|-------|------------|---------------|----------------|
2877 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2878
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302879 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002880 memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302881 else
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002882 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002883
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002884 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002885
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002886 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002887
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002888 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2889 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002890 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2891
Chaehyun Limd85f5322015-06-11 14:35:54 +09002892 strWID.u16WIDid = (u16)WID_ADD_RX_GTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002893 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002894 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002895 strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN;
2896
Johnny Kimd42ab082015-08-20 16:32:52 +09002897 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2898 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002899
Chaehyun Lim49188af2015-08-11 10:32:41 +09002900 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002901
2902 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002903 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002904 /* ///////////////////////// */
2905 }
2906_WPARxGtk_end_case_:
Chaehyun Lim49188af2015-08-11 10:32:41 +09002907 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2908 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002909 if (ret == -1)
2910 return ret;
2911
2912 break;
2913
2914 case WPAPtk:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002915 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2916
2917
Glen Leef3052582015-09-10 12:03:04 +09002918 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002919
2920
2921
2922 if (pu8keybuf == NULL) {
2923 PRINT_ER("No buffer to send PTK Key\n");
2924 ret = -1;
2925 goto _WPAPtk_end_case_;
2926
2927 }
2928
2929 /*|-----------------------------------------------------------------------------|
2930 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2931 * |----------------|------------ |--------------|----------------|---------------|
2932 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2933 |-----------------------------------------------------------------------------|*/
2934
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002935 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002936
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002937 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2938 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002939 /*16 byte TK*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002940 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002941 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2942
2943
Chaehyun Limd85f5322015-06-11 14:35:54 +09002944 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002945 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002946 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002947 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002948
Chaehyun Limd85f5322015-06-11 14:35:54 +09002949 strWIDList[1].u16WIDid = (u16)WID_ADD_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002950 strWIDList[1].enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002951 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002952 strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1;
2953
Johnny Kimd42ab082015-08-20 16:32:52 +09002954 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true,
2955 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002956 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002957
2958 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002959 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002960 /* ///////////////////////// */
2961 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002962 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2963
2964
Glen Leef3052582015-09-10 12:03:04 +09002965 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002966
2967
2968
2969 if (pu8keybuf == NULL) {
2970 PRINT_ER("No buffer to send PTK Key\n");
2971 ret = -1;
2972 goto _WPAPtk_end_case_;
2973
2974 }
2975
2976 /*|-----------------------------------------------------------------------------|
2977 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
2978 * |----------------|------------|--------------|----------------|---------------|
2979 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
2980 |-----------------------------------------------------------------------------|*/
2981
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002982 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002983
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002984 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002985 /*16 byte TK*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002986 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002987 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2988
2989
Chaehyun Limd85f5322015-06-11 14:35:54 +09002990 strWID.u16WIDid = (u16)WID_ADD_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002991 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002992 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002993 strWID.s32ValueSize = PTK_KEY_MSG_LEN;
2994
Johnny Kimd42ab082015-08-20 16:32:52 +09002995 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2996 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002997 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002998
2999 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003000 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003001 /* ///////////////////////// */
3002 }
3003
3004_WPAPtk_end_case_:
Chaehyun Lim49188af2015-08-11 10:32:41 +09003005 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003006 if (ret == -1)
3007 return ret;
3008
3009 break;
3010
3011
3012 case PMKSA:
3013
3014 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
3015
Glen Leef3052582015-09-10 12:03:04 +09003016 pu8keybuf = kmalloc((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003017 if (pu8keybuf == NULL) {
3018 PRINT_ER("No buffer to send PMKSA Key\n");
3019 return -1;
3020 }
3021
3022 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
3023
3024 for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
3025
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003026 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
3027 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003028 }
3029
Chaehyun Limd85f5322015-06-11 14:35:54 +09003030 strWID.u16WIDid = (u16)WID_PMKID_INFO;
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 = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1;
3034
Johnny Kimd42ab082015-08-20 16:32:52 +09003035 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3036 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003037
Chaehyun Lim49188af2015-08-11 10:32:41 +09003038 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003039 break;
3040 }
3041
3042 if (s32Error)
3043 PRINT_ER("Failed to send key config packet\n");
3044
3045
3046 return s32Error;
3047}
3048
3049
3050/**
3051 * @brief Handle_Disconnect
3052 * @details Sending config packet to firmware to disconnect
3053 * @param[in] NONE
3054 * @return NONE
3055 * @author
3056 * @date
3057 * @version 1.0
3058 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003059static void Handle_Disconnect(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003060{
3061 tstrWID strWID;
3062
Leo Kime6e12662015-09-16 18:36:03 +09003063 s32 s32Error = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09003064 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003065 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3066
3067
Chaehyun Limd85f5322015-06-11 14:35:54 +09003068 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003069 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003070 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
Dean Lee576917a2015-06-15 11:58:57 +09003071 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003072
3073
3074
3075 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
3076
3077 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3078
Dean Lee72ed4dc2015-06-12 14:11:44 +09003079 g_obtainingIP = false;
Johnny Kim218dc402015-08-13 13:41:19 +09003080 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003081 #endif
3082
Chaehyun Lim2cc46832015-08-07 09:02:01 +09003083 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003084
Johnny Kimd42ab082015-08-20 16:32:52 +09003085 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3086 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003087
3088 if (s32Error) {
3089 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003090 } else {
3091 tstrDisconnectNotifInfo strDisconnectNotifInfo;
3092
Chaehyun Lim2cc46832015-08-07 09:02:01 +09003093 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003094
3095 strDisconnectNotifInfo.u16reason = 0;
3096 strDisconnectNotifInfo.ie = NULL;
3097 strDisconnectNotifInfo.ie_len = 0;
3098
3099 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07003100 del_timer(&pstrWFIDrv->hScanTimer);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003101 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003102 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
3103
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003104 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003105 }
3106
3107 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
3108
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003109 /*Stop connect timer, if connection in progress*/
3110 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3111 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07003112 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003113 }
3114
3115 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
3116 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
3117 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003118 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003119 }
3120
Dean Lee72ed4dc2015-06-12 14:11:44 +09003121 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003122
3123 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
3124
Chaehyun Lim2cc46832015-08-07 09:02:01 +09003125 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003126
3127
3128 /* Deallocation */
3129 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
3130 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003131 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003132 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
3133 }
3134
3135 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003136 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003137 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
3138 }
3139
3140 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
3141 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003142 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003143 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
3144 }
3145
3146
Johnny Kim8a625ca2015-08-20 16:32:50 +09003147 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003148 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003149 gu8FlushedJoinReq = NULL;
3150 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09003151 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003152 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003153 gu8FlushedInfoElemAsoc = NULL;
3154 }
3155
3156 }
3157
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003158 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003159 up(&(pstrWFIDrv->hSemTestDisconnectBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003160 /* ///////////////////////// */
3161
3162}
3163
3164
Johnny Kim2b05df52015-08-13 13:41:21 +09003165void resolve_disconnect_aberration(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003166{
3167 tstrWILC_WFIDrv *pstrWFIDrv;
3168
3169 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003170 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003171 return;
3172 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
3173 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
Johnny Kim218dc402015-08-13 13:41:19 +09003174 host_int_disconnect(pstrWFIDrv, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003175 }
3176}
Johnny Kim2b05df52015-08-13 13:41:21 +09003177static s32 Switch_Log_Terminal(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003178{
3179
3180
Leo Kime6e12662015-09-16 18:36:03 +09003181 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003182 tstrWID strWID;
3183 static char dummy = 9;
3184 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3185
Chaehyun Limd85f5322015-06-11 14:35:54 +09003186 strWID.u16WIDid = (u16)WID_LOGTerminal_Switch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003187 strWID.enuWIDtype = WID_CHAR;
3188 strWID.ps8WidVal = &dummy;
Dean Lee576917a2015-06-15 11:58:57 +09003189 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003190
Johnny Kimd42ab082015-08-20 16:32:52 +09003191 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3192 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003193
3194
3195 if (s32Error) {
3196 PRINT_D(HOSTINF_DBG, "Failed to switch log terminal\n");
Leo Kim24db7132015-09-16 18:36:01 +09003197 PRINT_ER("Failed to switch log terminal\n");
3198 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003199 }
3200
Leo Kim24db7132015-09-16 18:36:01 +09003201 PRINT_INFO(HOSTINF_DBG, "MAC address set ::\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003202
3203 return s32Error;
3204}
3205
3206/**
3207 * @brief Handle_GetChnl
3208 * @details Sending config packet to get channel
3209 * @param[in] NONE
3210 * @return NONE
3211 *
3212 * @author
3213 * @date
3214 * @version 1.0
3215 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003216static s32 Handle_GetChnl(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003217{
3218
Leo Kime6e12662015-09-16 18:36:03 +09003219 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003220 tstrWID strWID;
3221 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
3222 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003223
Chaehyun Limd85f5322015-06-11 14:35:54 +09003224 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003225 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003226 strWID.ps8WidVal = (s8 *)&gu8Chnl;
Dean Lee576917a2015-06-15 11:58:57 +09003227 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003228
3229 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
3230
Johnny Kimd42ab082015-08-20 16:32:52 +09003231 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
3232 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003233 /*get the value by searching the local copy*/
3234 if (s32Error) {
3235 PRINT_ER("Failed to get channel number\n");
Leo Kim24db7132015-09-16 18:36:01 +09003236 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003237 }
3238
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003239 up(&(pstrWFIDrv->hSemGetCHNL));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003240
3241 return s32Error;
3242
3243
3244
3245}
3246
3247
3248/**
3249 * @brief Handle_GetRssi
3250 * @details Sending config packet to get RSSI
3251 * @param[in] NONE
3252 * @return NONE
3253 * @author
3254 * @date
3255 * @version 1.0
3256 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003257static void Handle_GetRssi(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003258{
Leo Kime6e12662015-09-16 18:36:03 +09003259 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003260 tstrWID strWID;
3261 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3262
Chaehyun Limd85f5322015-06-11 14:35:54 +09003263 strWID.u16WIDid = (u16)WID_RSSI;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003264 strWID.enuWIDtype = WID_CHAR;
3265 strWID.ps8WidVal = &gs8Rssi;
Dean Lee576917a2015-06-15 11:58:57 +09003266 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003267
3268 /*Sending Cfg*/
3269 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
3270
Johnny Kimd42ab082015-08-20 16:32:52 +09003271 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
3272 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003273 if (s32Error) {
3274 PRINT_ER("Failed to get RSSI value\n");
Leo Kim24db7132015-09-16 18:36:01 +09003275 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003276 }
3277
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003278 up(&(pstrWFIDrv->hSemGetRSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003279
3280
3281}
3282
3283
Johnny Kim2b05df52015-08-13 13:41:21 +09003284static void Handle_GetLinkspeed(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003285{
Leo Kime6e12662015-09-16 18:36:03 +09003286 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003287 tstrWID strWID;
3288 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3289
3290 gs8lnkspd = 0;
3291
Chaehyun Limd85f5322015-06-11 14:35:54 +09003292 strWID.u16WIDid = (u16)WID_LINKSPEED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003293 strWID.enuWIDtype = WID_CHAR;
3294 strWID.ps8WidVal = &gs8lnkspd;
Dean Lee576917a2015-06-15 11:58:57 +09003295 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003296 /*Sending Cfg*/
3297 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
3298
Johnny Kimd42ab082015-08-20 16:32:52 +09003299 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
3300 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003301 if (s32Error) {
3302 PRINT_ER("Failed to get LINKSPEED value\n");
Leo Kim24db7132015-09-16 18:36:01 +09003303 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003304 }
3305
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003306 up(&(pstrWFIDrv->hSemGetLINKSPEED));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003307
3308
3309}
3310
Johnny Kim2b05df52015-08-13 13:41:21 +09003311s32 Handle_GetStatistics(tstrWILC_WFIDrv *drvHandler, tstrStatistics *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003312{
3313 tstrWID strWIDList[5];
Chaehyun Limfbc2fe12015-09-15 14:06:16 +09003314 u32 u32WidsCount = 0, s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003315
3316 strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED;
3317 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003318 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003319 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003320 u32WidsCount++;
3321
3322 strWIDList[u32WidsCount].u16WIDid = WID_RSSI;
3323 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003324 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003325 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->s8RSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003326 u32WidsCount++;
3327
3328 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
3329 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003330 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003331 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003332 u32WidsCount++;
3333
3334 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
3335 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003336 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003337 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32RxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003338 u32WidsCount++;
3339
3340 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
3341 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003342 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003343 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxFailureCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003344 u32WidsCount++;
3345
Johnny Kimd42ab082015-08-20 16:32:52 +09003346 s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, false,
3347 get_id_from_handler(drvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003348
Leo Kim24db7132015-09-16 18:36:01 +09003349 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003350 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09003351
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003352 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003353 return 0;
3354
3355}
3356
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003357/**
3358 * @brief Handle_Get_InActiveTime
3359 * @details Sending config packet to set mac adddress for station and
3360 * get inactive time
3361 * @param[in] NONE
3362 * @return NONE
3363 *
3364 * @author
3365 * @date
3366 * @version 1.0
3367 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003368static s32 Handle_Get_InActiveTime(tstrWILC_WFIDrv *drvHandler, tstrHostIfStaInactiveT *strHostIfStaInactiveT)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003369{
3370
Leo Kime6e12662015-09-16 18:36:03 +09003371 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003372 u8 *stamac;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003373 tstrWID strWID;
3374 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3375
3376
Chaehyun Limd85f5322015-06-11 14:35:54 +09003377 strWID.u16WIDid = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003378 strWID.enuWIDtype = WID_STR;
3379 strWID.s32ValueSize = ETH_ALEN;
Glen Leef3052582015-09-10 12:03:04 +09003380 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003381
3382
3383 stamac = strWID.ps8WidVal;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003384 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003385
3386
3387 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
3388
3389
Johnny Kimd42ab082015-08-20 16:32:52 +09003390 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3391 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003392 /*get the value by searching the local copy*/
3393 if (s32Error) {
3394 PRINT_ER("Failed to SET incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09003395 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003396 }
3397
3398
Chaehyun Limd85f5322015-06-11 14:35:54 +09003399 strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003400 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003401 strWID.ps8WidVal = (s8 *)&gu32InactiveTime;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003402 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003403
3404
Johnny Kimd42ab082015-08-20 16:32:52 +09003405 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
3406 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003407 /*get the value by searching the local copy*/
3408 if (s32Error) {
3409 PRINT_ER("Failed to get incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09003410 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003411 }
3412
3413
3414 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
3415
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003416 up(&(pstrWFIDrv->hSemInactiveTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003417
3418 return s32Error;
3419
3420
3421
3422}
3423
3424
3425/**
3426 * @brief Handle_AddBeacon
3427 * @details Sending config packet to add beacon
3428 * @param[in] tstrHostIFSetBeacon* pstrSetBeaconParam
3429 * @return NONE
3430 * @author
3431 * @date
3432 * @version 1.0
3433 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003434static void Handle_AddBeacon(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetBeacon *pstrSetBeaconParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003435{
Leo Kime6e12662015-09-16 18:36:03 +09003436 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003437 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003438 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003439 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003440
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003441 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
3442
Chaehyun Limd85f5322015-06-11 14:35:54 +09003443 strWID.u16WIDid = (u16)WID_ADD_BEACON;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003444 strWID.enuWIDtype = WID_BIN;
3445 strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
Glen Leef3052582015-09-10 12:03:04 +09003446 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003447 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003448 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003449
3450 pu8CurrByte = strWID.ps8WidVal;
3451 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
3452 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
3453 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
3454 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
3455
3456 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
3457 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
3458 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
3459 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
3460
3461 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
3462 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
3463 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
3464 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
3465
3466 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
3467 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
3468
3469 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
3470 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
3471 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
3472 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
3473
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003474 if (pstrSetBeaconParam->pu8Tail > 0)
3475 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
3476 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
3477
3478
3479
3480 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003481 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3482 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003483 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003484 PRINT_ER("Failed to send add beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003485
Leo Kim24db7132015-09-16 18:36:01 +09003486ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003487 kfree(strWID.ps8WidVal);
3488 kfree(pstrSetBeaconParam->pu8Head);
3489 kfree(pstrSetBeaconParam->pu8Tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003490}
3491
3492
3493/**
3494 * @brief Handle_AddBeacon
3495 * @details Sending config packet to delete beacon
3496 * @param[in] tstrHostIFDelBeacon* pstrDelBeacon
3497 * @return NONE
3498 * @author
3499 * @date
3500 * @version 1.0
3501 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003502static void Handle_DelBeacon(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelBeacon *pstrDelBeacon)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003503{
Leo Kime6e12662015-09-16 18:36:03 +09003504 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003505 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003506 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003507 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003508
Chaehyun Limd85f5322015-06-11 14:35:54 +09003509 strWID.u16WIDid = (u16)WID_DEL_BEACON;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003510 strWID.enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003511 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003512 strWID.ps8WidVal = &gu8DelBcn;
3513
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003514 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003515 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003516
3517 pu8CurrByte = strWID.ps8WidVal;
3518
3519 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
3520 /* TODO: build del beacon message*/
3521
3522 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003523 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3524 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003525 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003526 PRINT_ER("Failed to send delete beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003527}
3528
3529
3530/**
3531 * @brief WILC_HostIf_PackStaParam
3532 * @details Handling packing of the station params in a buffer
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003533 * @param[in] u8* pu8Buffer, tstrWILC_AddStaParam* pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003534 * @return NONE
3535 * @author
3536 * @date
3537 * @version 1.0
3538 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003539static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, tstrWILC_AddStaParam *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003540{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003541 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003542
3543 pu8CurrByte = pu8Buffer;
3544
3545 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003546 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003547 pu8CurrByte += ETH_ALEN;
3548
3549 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
3550 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
3551
3552 *pu8CurrByte++ = pstrStationParam->u8NumRates;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003553 if (pstrStationParam->u8NumRates > 0)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003554 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003555 pu8CurrByte += pstrStationParam->u8NumRates;
3556
3557 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
3558 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
3559 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
3560
3561 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003562 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003563 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
3564
3565 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
3566 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
3567
3568 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
3569 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
3570 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
3571 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
3572
3573 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
3574
3575 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
3576 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
3577
3578 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
3579 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
3580
3581 return pu8CurrByte - pu8Buffer;
3582}
3583
3584/**
3585 * @brief Handle_AddStation
3586 * @details Sending config packet to add station
3587 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3588 * @return NONE
3589 * @author
3590 * @date
3591 * @version 1.0
3592 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003593static void Handle_AddStation(tstrWILC_WFIDrv *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003594{
Leo Kime6e12662015-09-16 18:36:03 +09003595 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003596 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003597 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003598 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003599
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003600 PRINT_D(HOSTINF_DBG, "Handling add station\n");
Chaehyun Limd85f5322015-06-11 14:35:54 +09003601 strWID.u16WIDid = (u16)WID_ADD_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003602 strWID.enuWIDtype = WID_BIN;
3603 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3604
Glen Leef3052582015-09-10 12:03:04 +09003605 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003606 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003607 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003608
3609 pu8CurrByte = strWID.ps8WidVal;
3610 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3611
3612 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003613 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3614 get_id_from_handler(pstrWFIDrv));
Leo Kime6e12662015-09-16 18:36:03 +09003615 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003616 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003617
Leo Kim24db7132015-09-16 18:36:01 +09003618ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003619 kfree(pstrStationParam->pu8Rates);
3620 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003621}
3622
3623/**
3624 * @brief Handle_DelAllSta
3625 * @details Sending config packet to delete station
3626 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3627 * @return NONE
3628 * @author
3629 * @date
3630 * @version 1.0
3631 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003632static void Handle_DelAllSta(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelAllSta *pstrDelAllStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003633{
Leo Kime6e12662015-09-16 18:36:03 +09003634 s32 s32Error = 0;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003635
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003636 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003637 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003638 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003639 u8 i;
Chaehyun Lim37034802015-06-11 14:34:32 +09003640 u8 au8Zero_Buff[6] = {0};
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003641
Chaehyun Limd85f5322015-06-11 14:35:54 +09003642 strWID.u16WIDid = (u16)WID_DEL_ALL_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003643 strWID.enuWIDtype = WID_STR;
3644 strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
3645
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003646 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003647
Glen Leef3052582015-09-10 12:03:04 +09003648 strWID.ps8WidVal = kmalloc((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003649 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003650 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003651
3652 pu8CurrByte = strWID.ps8WidVal;
3653
3654 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
3655
3656 for (i = 0; i < MAX_NUM_STA; i++) {
3657 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003658 memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003659 else
3660 continue;
3661
3662 pu8CurrByte += ETH_ALEN;
3663 }
3664
3665 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003666 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3667 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003668 if (s32Error)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02003669 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003670
Leo Kim24db7132015-09-16 18:36:01 +09003671ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003672 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003673
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003674 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003675}
3676
3677
3678/**
3679 * @brief Handle_DelStation
3680 * @details Sending config packet to delete station
3681 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3682 * @return NONE
3683 * @author
3684 * @date
3685 * @version 1.0
3686 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003687static void Handle_DelStation(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelSta *pstrDelStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003688{
Leo Kime6e12662015-09-16 18:36:03 +09003689 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003690 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003691 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003692 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3693
Chaehyun Limd85f5322015-06-11 14:35:54 +09003694 strWID.u16WIDid = (u16)WID_REMOVE_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003695 strWID.enuWIDtype = WID_BIN;
3696 strWID.s32ValueSize = ETH_ALEN;
3697
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003698 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003699
Glen Leef3052582015-09-10 12:03:04 +09003700 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003701 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003702 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003703
3704 pu8CurrByte = strWID.ps8WidVal;
3705
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003706 memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003707
3708 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003709 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3710 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003711 if (s32Error)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02003712 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003713
Leo Kim24db7132015-09-16 18:36:01 +09003714ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003715 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003716}
3717
3718
3719/**
3720 * @brief Handle_EditStation
3721 * @details Sending config packet to edit station
3722 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3723 * @return NONE
3724 * @author
3725 * @date
3726 * @version 1.0
3727 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003728static void Handle_EditStation(tstrWILC_WFIDrv *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003729{
Leo Kime6e12662015-09-16 18:36:03 +09003730 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003731 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003732 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003733 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3734
Chaehyun Limd85f5322015-06-11 14:35:54 +09003735 strWID.u16WIDid = (u16)WID_EDIT_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003736 strWID.enuWIDtype = WID_BIN;
3737 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3738
3739 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
Glen Leef3052582015-09-10 12:03:04 +09003740 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003741 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003742 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003743
3744 pu8CurrByte = strWID.ps8WidVal;
3745 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3746
3747 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003748 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3749 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003750 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003751 PRINT_ER("Failed to send edit station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003752
Leo Kim24db7132015-09-16 18:36:01 +09003753ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003754 kfree(pstrStationParam->pu8Rates);
3755 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003756}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003757
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003758/**
3759 * @brief Handle_RemainOnChan
3760 * @details Sending config packet to edit station
3761 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3762 * @return NONE
3763 * @author
3764 * @date
3765 * @version 1.0
3766 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003767static int Handle_RemainOnChan(tstrWILC_WFIDrv *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003768{
Leo Kime6e12662015-09-16 18:36:03 +09003769 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003770 u8 u8remain_on_chan_flag;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003771 tstrWID strWID;
3772 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3773
3774 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3775 if (!pstrWFIDrv->u8RemainOnChan_pendingreq) {
3776 pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
3777 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
3778 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
3779 pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
3780 pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
3781 } else {
3782 /*Set the channel to use it as a wid val*/
3783 pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel;
3784 }
3785
3786 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3787 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
3788 pstrWFIDrv->u8RemainOnChan_pendingreq = 1;
Leo Kim24db7132015-09-16 18:36:01 +09003789 s32Error = -EBUSY;
3790 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003791 }
3792 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3793 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
Leo Kim24db7132015-09-16 18:36:01 +09003794 s32Error = -EBUSY;
3795 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003796 }
3797
3798 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3799 if (g_obtainingIP || connecting) {
3800 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +09003801 s32Error = -EBUSY;
3802 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003803 }
3804 #endif
3805
3806 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
3807
Dean Lee72ed4dc2015-06-12 14:11:44 +09003808 u8remain_on_chan_flag = true;
Chaehyun Limd85f5322015-06-11 14:35:54 +09003809 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003810 strWID.enuWIDtype = WID_STR;
3811 strWID.s32ValueSize = 2;
Glen Leef3052582015-09-10 12:03:04 +09003812 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003813
Leo Kim24db7132015-09-16 18:36:01 +09003814 if (strWID.ps8WidVal == NULL) {
3815 s32Error = -ENOMEM;
3816 goto ERRORHANDLER;
3817 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003818
3819 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003820 strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003821
3822 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003823 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3824 get_id_from_handler(pstrWFIDrv));
Leo Kime6e12662015-09-16 18:36:03 +09003825 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003826 PRINT_ER("Failed to set remain on channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003827
Leo Kim24db7132015-09-16 18:36:01 +09003828ERRORHANDLER:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003829 {
3830 P2P_LISTEN_STATE = 1;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003831 pstrWFIDrv->hRemainOnChannel.data = (unsigned long)pstrWFIDrv;
3832 mod_timer(&pstrWFIDrv->hRemainOnChannel,
3833 jiffies +
3834 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003835
3836 /*Calling CFG ready_on_channel*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003837 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003838 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003839
3840 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3841 pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
3842 }
3843 return s32Error;
3844}
3845
3846/**
3847 * @brief Handle_RegisterFrame
3848 * @details
3849 * @param[in]
3850 * @return NONE
3851 * @author
3852 * @date
3853 * @version 1.0
3854 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003855static int Handle_RegisterFrame(tstrWILC_WFIDrv *drvHandler, tstrHostIfRegisterFrame *pstrHostIfRegisterFrame)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003856{
Leo Kime6e12662015-09-16 18:36:03 +09003857 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003858 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003859 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003860 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3861
3862 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
3863
3864 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +09003865 strWID.u16WIDid = (u16)WID_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003866 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09003867 strWID.ps8WidVal = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003868 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003869 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003870
3871 pu8CurrByte = strWID.ps8WidVal;
3872
3873 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
3874 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003875 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003876
3877
Chaehyun Limd85f5322015-06-11 14:35:54 +09003878 strWID.s32ValueSize = sizeof(u16) + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003879
3880
3881 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003882 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3883 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003884 if (s32Error) {
3885 PRINT_ER("Failed to frame register config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09003886 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003887 }
3888
3889 return s32Error;
3890
3891}
3892
3893/**
3894 * @brief Handle_ListenStateExpired
3895 * @details Handle of listen state expiration
3896 * @param[in] NONE
3897 * @return Error code.
3898 * @author
3899 * @date
3900 * @version 1.0
3901 */
3902#define FALSE_FRMWR_CHANNEL 100
Johnny Kim2b05df52015-08-13 13:41:21 +09003903static u32 Handle_ListenStateExpired(tstrWILC_WFIDrv *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003904{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003905 u8 u8remain_on_chan_flag;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003906 tstrWID strWID;
Leo Kime6e12662015-09-16 18:36:03 +09003907 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003908 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3909
3910 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
3911
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003912 /*Make sure we are already in listen state*/
3913 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
3914 if (P2P_LISTEN_STATE) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003915 u8remain_on_chan_flag = false;
Chaehyun Limd85f5322015-06-11 14:35:54 +09003916 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003917 strWID.enuWIDtype = WID_STR;
3918 strWID.s32ValueSize = 2;
Glen Leef3052582015-09-10 12:03:04 +09003919 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003920
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003921 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003922 PRINT_ER("Failed to allocate memory\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003923
3924 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3925 strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL;
3926
3927 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003928 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3929 get_id_from_handler(pstrWFIDrv));
Leo Kime6e12662015-09-16 18:36:03 +09003930 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003931 PRINT_ER("Failed to set remain on channel\n");
3932 goto _done_;
3933 }
3934
3935 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) {
3936 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid
3937 , pstrHostIfRemainOnChan->u32ListenSessionID);
3938 }
3939 P2P_LISTEN_STATE = 0;
3940 } else {
3941 PRINT_D(GENERIC_DBG, "Not in listen state\n");
Leo Kime6e12662015-09-16 18:36:03 +09003942 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003943 }
3944
3945_done_:
3946 return s32Error;
3947}
3948
3949
3950/**
3951 * @brief ListenTimerCB
3952 * @details Callback function of remain-on-channel timer
3953 * @param[in] NONE
3954 * @return Error code.
3955 * @author
3956 * @date
3957 * @version 1.0
3958 */
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003959static void ListenTimerCB(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003960{
Leo Kime6e12662015-09-16 18:36:03 +09003961 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003962 struct host_if_msg msg;
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003963 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003964 /*Stopping remain-on-channel timer*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07003965 del_timer(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003966
3967 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09003968 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003969 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Cho143eb952015-09-21 12:16:32 +09003970 msg.drvHandler = pstrWFIDrv;
Tony Cho410c2482015-09-21 12:16:35 +09003971 msg.body.strHostIfRemainOnChan.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003972
3973 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09003974 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003975 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09003976 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003977}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003978
3979/**
3980 * @brief Handle_EditStation
3981 * @details Sending config packet to edit station
3982 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3983 * @return NONE
3984 * @author
3985 * @date
3986 * @version 1.0
3987 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003988static void Handle_PowerManagement(tstrWILC_WFIDrv *drvHandler, tstrHostIfPowerMgmtParam *strPowerMgmtParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003989{
Leo Kime6e12662015-09-16 18:36:03 +09003990 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003991 tstrWID strWID;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003992 s8 s8PowerMode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003993 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003994
Chaehyun Limd85f5322015-06-11 14:35:54 +09003995 strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003996
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05303997 if (strPowerMgmtParam->bIsEnabled == true)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003998 s8PowerMode = MIN_FAST_PS;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05303999 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004000 s8PowerMode = NO_POWERSAVE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004001 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
4002 strWID.ps8WidVal = &s8PowerMode;
Dean Lee576917a2015-06-15 11:58:57 +09004003 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004004
4005 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
4006
4007 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09004008 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4009 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09004010 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004011 PRINT_ER("Failed to send power management config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004012}
4013
4014/**
4015 * @brief Handle_SetMulticastFilter
4016 * @details Set Multicast filter in firmware
4017 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4018 * @return NONE
4019 * @author asobhy
4020 * @date
4021 * @version 1.0
4022 */
Johnny Kim2b05df52015-08-13 13:41:21 +09004023static void Handle_SetMulticastFilter(tstrWILC_WFIDrv *drvHandler, tstrHostIFSetMulti *strHostIfSetMulti)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004024{
Leo Kime6e12662015-09-16 18:36:03 +09004025 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004026 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004027 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004028
4029 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
4030
Chaehyun Limd85f5322015-06-11 14:35:54 +09004031 strWID.u16WIDid = (u16)WID_SETUP_MULTICAST_FILTER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004032 strWID.enuWIDtype = WID_BIN;
4033 strWID.s32ValueSize = sizeof(tstrHostIFSetMulti) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
Glen Leef3052582015-09-10 12:03:04 +09004034 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004035 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09004036 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004037
4038 pu8CurrByte = strWID.ps8WidVal;
4039 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
4040 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
4041 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
4042 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
4043
4044 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
4045 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
4046 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
4047 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
4048
4049 if ((strHostIfSetMulti->u32count) > 0)
4050 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
4051
4052 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09004053 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
4054 get_id_from_handler(drvHandler));
Leo Kim24db7132015-09-16 18:36:01 +09004055 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004056 PRINT_ER("Failed to send setup multicast config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004057
Leo Kim24db7132015-09-16 18:36:01 +09004058ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07004059 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004060
4061}
4062
4063
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004064/**
4065 * @brief Handle_AddBASession
4066 * @details Add block ack session
4067 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4068 * @return NONE
4069 * @author Amr Abdel-Moghny
4070 * @date Feb. 2014
4071 * @version 9.0
4072 */
Johnny Kim2b05df52015-08-13 13:41:21 +09004073static s32 Handle_AddBASession(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004074{
Leo Kime6e12662015-09-16 18:36:03 +09004075 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004076 tstrWID strWID;
4077 int AddbaTimeout = 100;
4078 char *ptr = NULL;
4079 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4080
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004081 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 +09004082 strHostIfBASessionInfo->au8Bssid[0],
4083 strHostIfBASessionInfo->au8Bssid[1],
4084 strHostIfBASessionInfo->au8Bssid[2],
4085 strHostIfBASessionInfo->u16BufferSize,
4086 strHostIfBASessionInfo->u16SessionTimeout,
4087 strHostIfBASessionInfo->u8Ted);
4088
Chaehyun Limd85f5322015-06-11 14:35:54 +09004089 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004090 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09004091 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004092 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4093 ptr = strWID.ps8WidVal;
4094 /* *ptr++ = 0x14; */
4095 *ptr++ = 0x14;
4096 *ptr++ = 0x3;
4097 *ptr++ = 0x0;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004098 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004099 ptr += ETH_ALEN;
4100 *ptr++ = strHostIfBASessionInfo->u8Ted;
4101 /* BA Policy*/
4102 *ptr++ = 1;
4103 /* Buffer size*/
4104 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4105 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
4106 /* BA timeout*/
4107 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
4108 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4109 /* ADDBA timeout*/
4110 *ptr++ = (AddbaTimeout & 0xFF);
4111 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
4112 /* Group Buffer Max Frames*/
4113 *ptr++ = 8;
4114 /* Group Buffer Timeout */
4115 *ptr++ = 0;
4116
Johnny Kimd42ab082015-08-20 16:32:52 +09004117 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4118 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004119 if (s32Error)
4120 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
4121
4122
Chaehyun Limd85f5322015-06-11 14:35:54 +09004123 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004124 strWID.enuWIDtype = WID_STR;
4125 strWID.s32ValueSize = 15;
4126 ptr = strWID.ps8WidVal;
4127 /* *ptr++ = 0x14; */
4128 *ptr++ = 15;
4129 *ptr++ = 7;
4130 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004131 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004132 ptr += ETH_ALEN;
4133 /* TID*/
4134 *ptr++ = strHostIfBASessionInfo->u8Ted;
4135 /* Max Num MSDU */
4136 *ptr++ = 8;
4137 /* BA timeout*/
4138 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4139 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4140 /*Ack-Policy */
4141 *ptr++ = 3;
Johnny Kimd42ab082015-08-20 16:32:52 +09004142 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4143 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004144
4145 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09004146 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004147
4148 return s32Error;
4149
4150}
4151
4152
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004153/**
4154 * @brief Handle_DelBASession
4155 * @details Delete block ack session
4156 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4157 * @return NONE
4158 * @author Amr Abdel-Moghny
4159 * @date Feb. 2013
4160 * @version 9.0
4161 */
Johnny Kim2b05df52015-08-13 13:41:21 +09004162static s32 Handle_DelBASession(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004163{
Leo Kime6e12662015-09-16 18:36:03 +09004164 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004165 tstrWID strWID;
4166 char *ptr = NULL;
4167 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4168
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004169 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004170 strHostIfBASessionInfo->au8Bssid[0],
4171 strHostIfBASessionInfo->au8Bssid[1],
4172 strHostIfBASessionInfo->au8Bssid[2],
4173 strHostIfBASessionInfo->u8Ted);
4174
Chaehyun Limd85f5322015-06-11 14:35:54 +09004175 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004176 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09004177 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004178 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4179 ptr = strWID.ps8WidVal;
4180 /* *ptr++ = 0x14; */
4181 *ptr++ = 0x14;
4182 *ptr++ = 0x3;
4183 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004184 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004185 ptr += ETH_ALEN;
4186 *ptr++ = strHostIfBASessionInfo->u8Ted;
4187 /* BA direction = recipent*/
4188 *ptr++ = 0;
4189 /* Delba Reason */
4190 *ptr++ = 32; /* Unspecific QOS reason */
4191
Johnny Kimd42ab082015-08-20 16:32:52 +09004192 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4193 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004194 if (s32Error)
4195 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4196
4197
Chaehyun Limd85f5322015-06-11 14:35:54 +09004198 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004199 strWID.enuWIDtype = WID_STR;
4200 strWID.s32ValueSize = 15;
4201 ptr = strWID.ps8WidVal;
4202 /* *ptr++ = 0x14; */
4203 *ptr++ = 15;
4204 *ptr++ = 7;
4205 *ptr++ = 0x3;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004206 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004207 ptr += ETH_ALEN;
4208 /* TID*/
4209 *ptr++ = strHostIfBASessionInfo->u8Ted;
4210
Johnny Kimd42ab082015-08-20 16:32:52 +09004211 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4212 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004213
4214 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09004215 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004216
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004217 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004218
4219 return s32Error;
4220
4221}
4222
4223
4224/**
4225 * @brief Handle_DelAllRxBASessions
4226 * @details Delete all Rx BA sessions
4227 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4228 * @return NONE
4229 * @author Abdelrahman Sobhy
4230 * @date Feb. 2013
4231 * @version 9.0
4232 */
Johnny Kim2b05df52015-08-13 13:41:21 +09004233static s32 Handle_DelAllRxBASessions(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004234{
Leo Kime6e12662015-09-16 18:36:03 +09004235 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004236 tstrWID strWID;
4237 char *ptr = NULL;
4238 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4239
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004240 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004241 strHostIfBASessionInfo->au8Bssid[0],
4242 strHostIfBASessionInfo->au8Bssid[1],
4243 strHostIfBASessionInfo->au8Bssid[2],
4244 strHostIfBASessionInfo->u8Ted);
4245
Chaehyun Limd85f5322015-06-11 14:35:54 +09004246 strWID.u16WIDid = (u16)WID_DEL_ALL_RX_BA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004247 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09004248 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004249 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4250 ptr = strWID.ps8WidVal;
4251 *ptr++ = 0x14;
4252 *ptr++ = 0x3;
4253 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004254 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004255 ptr += ETH_ALEN;
4256 *ptr++ = strHostIfBASessionInfo->u8Ted;
4257 /* BA direction = recipent*/
4258 *ptr++ = 0;
4259 /* Delba Reason */
4260 *ptr++ = 32; /* Unspecific QOS reason */
4261
Johnny Kimd42ab082015-08-20 16:32:52 +09004262 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4263 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004264 if (s32Error)
4265 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4266
4267
4268 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09004269 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004270
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004271 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004272
4273 return s32Error;
4274
4275}
4276
4277/**
4278 * @brief hostIFthread
4279 * @details Main thread to handle message queue requests
4280 * @param[in] void* pvArg
4281 * @return NONE
4282 * @author
4283 * @date
4284 * @version 1.0
4285 */
Arnd Bergmann1999bd52015-05-29 22:52:14 +02004286static int hostIFthread(void *pvArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004287{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004288 u32 u32Ret;
Tony Cho143eb952015-09-21 12:16:32 +09004289 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004290 tstrWILC_WFIDrv *pstrWFIDrv;
4291
Tony Cho143eb952015-09-21 12:16:32 +09004292 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004293
4294 while (1) {
Tony Cho143eb952015-09-21 12:16:32 +09004295 wilc_mq_recv(&gMsgQHostIF, &msg, sizeof(struct host_if_msg), &u32Ret);
4296 pstrWFIDrv = (tstrWILC_WFIDrv *)msg.drvHandler;
Tony Choa9f812a2015-09-21 12:16:33 +09004297 if (msg.id == HOST_IF_MSG_EXIT) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004298 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
4299 break;
4300 }
4301
4302
4303 /*Re-Queue HIF message*/
4304 if ((!g_wilc_initialized)) {
4305 PRINT_D(GENERIC_DBG, "--WAIT--");
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07004306 usleep_range(200 * 1000, 200 * 1000);
Tony Cho143eb952015-09-21 12:16:32 +09004307 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004308 continue;
4309 }
4310
Tony Choa9f812a2015-09-21 12:16:33 +09004311 if (msg.id == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004312 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
Tony Cho143eb952015-09-21 12:16:32 +09004313 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07004314 usleep_range(2 * 1000, 2 * 1000);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004315 continue;
4316 }
4317
Tony Choa9f812a2015-09-21 12:16:33 +09004318 switch (msg.id) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004319 case HOST_IF_MSG_Q_IDLE:
4320 Handle_wait_msg_q_empty();
4321 break;
4322
4323 case HOST_IF_MSG_SCAN:
Tony Cho410c2482015-09-21 12:16:35 +09004324 Handle_Scan(msg.drvHandler, &msg.body.strHostIFscanAttr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004325 break;
4326
4327 case HOST_IF_MSG_CONNECT:
Tony Cho410c2482015-09-21 12:16:35 +09004328 Handle_Connect(msg.drvHandler, &msg.body.strHostIFconnectAttr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004329 break;
4330
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004331 case HOST_IF_MSG_FLUSH_CONNECT:
Tony Cho143eb952015-09-21 12:16:32 +09004332 Handle_FlushConnect(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004333 break;
4334
4335 case HOST_IF_MSG_RCVD_NTWRK_INFO:
Tony Cho410c2482015-09-21 12:16:35 +09004336 Handle_RcvdNtwrkInfo(msg.drvHandler, &msg.body.strRcvdNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004337 break;
4338
4339 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
Tony Cho410c2482015-09-21 12:16:35 +09004340 Handle_RcvdGnrlAsyncInfo(msg.drvHandler, &msg.body.strRcvdGnrlAsyncInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004341 break;
4342
4343 case HOST_IF_MSG_KEY:
Tony Cho410c2482015-09-21 12:16:35 +09004344 Handle_Key(msg.drvHandler, &msg.body.strHostIFkeyAttr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004345 break;
4346
4347 case HOST_IF_MSG_CFG_PARAMS:
4348
Tony Cho410c2482015-09-21 12:16:35 +09004349 Handle_CfgParam(msg.drvHandler, &msg.body.strHostIFCfgParamAttr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004350 break;
4351
4352 case HOST_IF_MSG_SET_CHANNEL:
Tony Cho410c2482015-09-21 12:16:35 +09004353 Handle_SetChannel(msg.drvHandler, &msg.body.strHostIFSetChan);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004354 break;
4355
4356 case HOST_IF_MSG_DISCONNECT:
Tony Cho143eb952015-09-21 12:16:32 +09004357 Handle_Disconnect(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004358 break;
4359
4360 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07004361 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004362 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
4363
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004364 /*Allow chip sleep, only if both interfaces are not connected*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004365 if (!linux_wlan_get_num_conn_ifcs())
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004366 chip_sleep_manually(INFINITE_SLEEP_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004367
Tony Cho143eb952015-09-21 12:16:32 +09004368 Handle_ScanDone(msg.drvHandler, SCAN_EVENT_DONE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004369
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004370 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
Tony Cho410c2482015-09-21 12:16:35 +09004371 Handle_RemainOnChan(msg.drvHandler, &msg.body.strHostIfRemainOnChan);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004372
4373 break;
4374
4375 case HOST_IF_MSG_GET_RSSI:
Tony Cho143eb952015-09-21 12:16:32 +09004376 Handle_GetRssi(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004377 break;
4378
4379 case HOST_IF_MSG_GET_LINKSPEED:
Tony Cho143eb952015-09-21 12:16:32 +09004380 Handle_GetLinkspeed(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004381 break;
4382
4383 case HOST_IF_MSG_GET_STATISTICS:
Tony Cho410c2482015-09-21 12:16:35 +09004384 Handle_GetStatistics(msg.drvHandler, (tstrStatistics *)msg.body.pUserData);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004385 break;
4386
4387 case HOST_IF_MSG_GET_CHNL:
Tony Cho143eb952015-09-21 12:16:32 +09004388 Handle_GetChnl(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004389 break;
4390
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004391 case HOST_IF_MSG_ADD_BEACON:
Tony Cho410c2482015-09-21 12:16:35 +09004392 Handle_AddBeacon(msg.drvHandler, &msg.body.strHostIFSetBeacon);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004393 break;
4394
4395 case HOST_IF_MSG_DEL_BEACON:
Tony Cho410c2482015-09-21 12:16:35 +09004396 Handle_DelBeacon(msg.drvHandler, &msg.body.strHostIFDelBeacon);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004397 break;
4398
4399 case HOST_IF_MSG_ADD_STATION:
Tony Cho410c2482015-09-21 12:16:35 +09004400 Handle_AddStation(msg.drvHandler, &msg.body.strAddStaParam);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004401 break;
4402
4403 case HOST_IF_MSG_DEL_STATION:
Tony Cho410c2482015-09-21 12:16:35 +09004404 Handle_DelStation(msg.drvHandler, &msg.body.strDelStaParam);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004405 break;
4406
4407 case HOST_IF_MSG_EDIT_STATION:
Tony Cho410c2482015-09-21 12:16:35 +09004408 Handle_EditStation(msg.drvHandler, &msg.body.strEditStaParam);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004409 break;
4410
4411 case HOST_IF_MSG_GET_INACTIVETIME:
Tony Cho410c2482015-09-21 12:16:35 +09004412 Handle_Get_InActiveTime(msg.drvHandler, &msg.body.strHostIfStaInactiveT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004413 break;
4414
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004415 case HOST_IF_MSG_SCAN_TIMER_FIRED:
4416 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
4417
Tony Cho143eb952015-09-21 12:16:32 +09004418 Handle_ScanDone(msg.drvHandler, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004419 break;
4420
4421 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004422 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
Tony Cho143eb952015-09-21 12:16:32 +09004423 Handle_ConnectTimeout(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004424 break;
4425
4426 case HOST_IF_MSG_POWER_MGMT:
Tony Cho410c2482015-09-21 12:16:35 +09004427 Handle_PowerManagement(msg.drvHandler, &msg.body.strPowerMgmtparam);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004428 break;
4429
4430 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
Tony Cho143eb952015-09-21 12:16:32 +09004431 Handle_SetWfiDrvHandler(msg.drvHandler,
Tony Cho410c2482015-09-21 12:16:35 +09004432 &msg.body.strHostIfSetDrvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004433 break;
4434
4435 case HOST_IF_MSG_SET_OPERATION_MODE:
Tony Cho410c2482015-09-21 12:16:35 +09004436 Handle_SetOperationMode(msg.drvHandler, &msg.body.strHostIfSetOperationMode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004437 break;
4438
4439 case HOST_IF_MSG_SET_IPADDRESS:
4440 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Tony Cho410c2482015-09-21 12:16:35 +09004441 Handle_set_IPAddress(msg.drvHandler, msg.body.strHostIfSetIP.au8IPAddr, msg.body.strHostIfSetIP.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004442 break;
4443
4444 case HOST_IF_MSG_GET_IPADDRESS:
4445 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Tony Cho410c2482015-09-21 12:16:35 +09004446 Handle_get_IPAddress(msg.drvHandler, msg.body.strHostIfSetIP.au8IPAddr, msg.body.strHostIfSetIP.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004447 break;
4448
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004449 case HOST_IF_MSG_SET_MAC_ADDRESS:
Tony Cho410c2482015-09-21 12:16:35 +09004450 Handle_SetMacAddress(msg.drvHandler, &msg.body.strHostIfSetMacAddress);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004451 break;
4452
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004453 case HOST_IF_MSG_GET_MAC_ADDRESS:
Tony Cho410c2482015-09-21 12:16:35 +09004454 Handle_GetMacAddress(msg.drvHandler, &msg.body.strHostIfGetMacAddress);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004455 break;
4456
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004457 case HOST_IF_MSG_REMAIN_ON_CHAN:
4458 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
Tony Cho410c2482015-09-21 12:16:35 +09004459 Handle_RemainOnChan(msg.drvHandler, &msg.body.strHostIfRemainOnChan);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004460 break;
4461
4462 case HOST_IF_MSG_REGISTER_FRAME:
4463 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
Tony Cho410c2482015-09-21 12:16:35 +09004464 Handle_RegisterFrame(msg.drvHandler, &msg.body.strHostIfRegisterFrame);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004465 break;
4466
4467 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
Tony Cho410c2482015-09-21 12:16:35 +09004468 Handle_ListenStateExpired(msg.drvHandler, &msg.body.strHostIfRemainOnChan);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004469 break;
4470
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004471 case HOST_IF_MSG_SET_MULTICAST_FILTER:
4472 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
Tony Cho410c2482015-09-21 12:16:35 +09004473 Handle_SetMulticastFilter(msg.drvHandler, &msg.body.strHostIfSetMulti);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004474 break;
4475
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004476 case HOST_IF_MSG_ADD_BA_SESSION:
Tony Cho410c2482015-09-21 12:16:35 +09004477 Handle_AddBASession(msg.drvHandler, &msg.body.strHostIfBASessionInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004478 break;
4479
4480 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
Tony Cho410c2482015-09-21 12:16:35 +09004481 Handle_DelAllRxBASessions(msg.drvHandler, &msg.body.strHostIfBASessionInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004482 break;
4483
4484 case HOST_IF_MSG_DEL_ALL_STA:
Tony Cho410c2482015-09-21 12:16:35 +09004485 Handle_DelAllSta(msg.drvHandler, &msg.body.strHostIFDelAllSta);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004486 break;
4487
4488 default:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004489 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004490 break;
4491 }
4492 }
4493
4494 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004495 up(&hSemHostIFthrdEnd);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02004496 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004497}
4498
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004499static void TimerCB_Scan(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004500{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004501 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09004502 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004503
4504 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09004505 memset(&msg, 0, sizeof(struct host_if_msg));
4506 msg.drvHandler = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09004507 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004508
4509 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004510 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004511}
4512
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004513static void TimerCB_Connect(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004514{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004515 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09004516 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004517
4518 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09004519 memset(&msg, 0, sizeof(struct host_if_msg));
4520 msg.drvHandler = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09004521 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004522
4523 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004524 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004525}
4526
4527
4528/**
4529 * @brief removes wpa/wpa2 keys
4530 * @details only in BSS STA mode if External Supplicant support is enabled.
4531 * removes all WPA/WPA2 station key entries from MAC hardware.
4532 * @param[in,out] handle to the wifi driver
4533 * @param[in] 6 bytes of Station Adress in the station entry table
4534 * @return Error code indicating success/failure
4535 * @note
4536 * @author zsalah
4537 * @date 8 March 2012
4538 * @version 1.0
4539 */
4540/* Check implementation in core adding 9 bytes to the input! */
Johnny Kim218dc402015-08-13 13:41:19 +09004541s32 host_int_remove_key(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8StaAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004542{
Leo Kime6e12662015-09-16 18:36:03 +09004543 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004544 tstrWID strWID;
4545 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4546
Chaehyun Limd85f5322015-06-11 14:35:54 +09004547 strWID.u16WIDid = (u16)WID_REMOVE_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004548 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09004549 strWID.ps8WidVal = (s8 *)pu8StaAddress;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004550 strWID.s32ValueSize = 6;
4551
4552 return s32Error;
4553
4554}
4555
4556/**
4557 * @brief removes WEP key
4558 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4559 * remove a WEP key entry from MAC HW.
4560 * The BSS Station automatically finds the index of the entry using its
4561 * BSS ID and removes that entry from the MAC hardware.
4562 * @param[in,out] handle to the wifi driver
4563 * @param[in] 6 bytes of Station Adress in the station entry table
4564 * @return Error code indicating success/failure
4565 * @note NO need for the STA add since it is not used for processing
4566 * @author zsalah
4567 * @date 8 March 2012
4568 * @version 1.0
4569 */
Johnny Kim218dc402015-08-13 13:41:19 +09004570s32 host_int_remove_wep_key(tstrWILC_WFIDrv *hWFIDrv, u8 u8keyIdx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004571{
Leo Kime6e12662015-09-16 18:36:03 +09004572 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004573 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004574 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004575
4576
Leo Kim24db7132015-09-16 18:36:01 +09004577 if (pstrWFIDrv == NULL) {
4578 s32Error = -EFAULT;
4579 PRINT_ER("Failed to send setup multicast config packet\n");
4580 return s32Error;
4581 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004582
4583 /* prepare the Remove Wep Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004584 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004585
4586
Tony Choa9f812a2015-09-21 12:16:33 +09004587 msg.id = HOST_IF_MSG_KEY;
Tony Cho410c2482015-09-21 12:16:35 +09004588 msg.body.strHostIFkeyAttr.enuKeyType = WEP;
4589 msg.body.strHostIFkeyAttr.u8KeyAction = REMOVEKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004590 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004591
4592
4593
Tony Cho410c2482015-09-21 12:16:35 +09004594 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004595 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8keyIdx;
4596
4597 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004598 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004599 if (s32Error)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004600 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004601 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004602
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004603 return s32Error;
4604}
4605
4606/**
4607 * @brief sets WEP default key
4608 * @details Sets the index of the WEP encryption key in use,
4609 * in the key table
4610 * @param[in,out] handle to the wifi driver
4611 * @param[in] key index ( 0, 1, 2, 3)
4612 * @return Error code indicating success/failure
4613 * @note
4614 * @author zsalah
4615 * @date 8 March 2012
4616 * @version 1.0
4617 */
Johnny Kim218dc402015-08-13 13:41:19 +09004618s32 host_int_set_WEPDefaultKeyID(tstrWILC_WFIDrv *hWFIDrv, u8 u8Index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004619{
Leo Kime6e12662015-09-16 18:36:03 +09004620 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004621 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004622 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004623
4624
Leo Kim24db7132015-09-16 18:36:01 +09004625 if (pstrWFIDrv == NULL) {
4626 s32Error = -EFAULT;
4627 PRINT_ER("driver is null\n");
4628 return s32Error;
4629 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004630
4631 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004632 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004633
4634
Tony Choa9f812a2015-09-21 12:16:33 +09004635 msg.id = HOST_IF_MSG_KEY;
Tony Cho410c2482015-09-21 12:16:35 +09004636 msg.body.strHostIFkeyAttr.enuKeyType = WEP;
4637 msg.body.strHostIFkeyAttr.u8KeyAction = DEFAULTKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004638 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004639
4640
Tony Cho410c2482015-09-21 12:16:35 +09004641 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004642 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
4643
4644 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004645 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004646 if (s32Error)
4647 PRINT_ER("Error in sending message queue : Default key index\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004648 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004649
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004650 return s32Error;
4651}
4652
4653/**
4654 * @brief sets WEP deafault key
4655 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4656 * sets WEP key entry into MAC hardware when it receives the
4657 * corresponding request from NDIS.
4658 * @param[in,out] handle to the wifi driver
4659 * @param[in] message containing WEP Key in the following format
4660 *|---------------------------------------|
4661 *|Key ID Value | Key Length | Key |
4662 *|-------------|------------|------------|
4663 | 1byte | 1byte | Key Length |
4664 ||---------------------------------------|
4665 |
4666 * @return Error code indicating success/failure
4667 * @note
4668 * @author zsalah
4669 * @date 8 March 2012
4670 * @version 1.0
4671 */
Johnny Kim218dc402015-08-13 13:41:19 +09004672s32 host_int_add_wep_key_bss_sta(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004673{
4674
Leo Kime6e12662015-09-16 18:36:03 +09004675 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004676 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004677 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004678
Leo Kim24db7132015-09-16 18:36:01 +09004679 if (pstrWFIDrv == NULL) {
4680 s32Error = -EFAULT;
4681 PRINT_ER("driver is null\n");
4682 return s32Error;
4683 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004684
4685 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004686 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004687
4688
Tony Choa9f812a2015-09-21 12:16:33 +09004689 msg.id = HOST_IF_MSG_KEY;
Tony Cho410c2482015-09-21 12:16:35 +09004690 msg.body.strHostIFkeyAttr.enuKeyType = WEP;
4691 msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004692 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004693
4694
Tony Cho410c2482015-09-21 12:16:35 +09004695 msg.body.strHostIFkeyAttr.
Glen Leef3052582015-09-10 12:03:04 +09004696 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004697
Tony Cho410c2482015-09-21 12:16:35 +09004698 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004699 pu8WepKey, u8WepKeylen);
4700
4701
Tony Cho410c2482015-09-21 12:16:35 +09004702 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004703 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4704
Tony Cho410c2482015-09-21 12:16:35 +09004705 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004706 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4707
4708 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004709 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004710 if (s32Error)
4711 PRINT_ER("Error in sending message queue :WEP Key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004712 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004713
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004714 return s32Error;
4715
4716}
4717
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004718/**
4719 *
4720 * @brief host_int_add_wep_key_bss_ap
4721 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4722 * sets WEP key entry into MAC hardware when it receives the
4723 *
4724 * corresponding request from NDIS.
4725 * @param[in,out] handle to the wifi driver
4726 *
4727 *
4728 * @return Error code indicating success/failure
4729 * @note
4730 * @author mdaftedar
4731 * @date 28 FEB 2013
4732 * @version 1.0
4733 */
Johnny Kim218dc402015-08-13 13:41:19 +09004734s32 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 +09004735{
4736
Leo Kime6e12662015-09-16 18:36:03 +09004737 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004738 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004739 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004740 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004741
Leo Kim24db7132015-09-16 18:36:01 +09004742 if (pstrWFIDrv == NULL) {
4743 s32Error = -EFAULT;
4744 PRINT_ER("driver is null\n");
4745 return s32Error;
4746 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004747
4748 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004749 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004750
4751 if (INFO) {
4752 for (i = 0; i < u8WepKeylen; i++)
4753 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4754 }
Tony Choa9f812a2015-09-21 12:16:33 +09004755 msg.id = HOST_IF_MSG_KEY;
Tony Cho410c2482015-09-21 12:16:35 +09004756 msg.body.strHostIFkeyAttr.enuKeyType = WEP;
4757 msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
Tony Cho143eb952015-09-21 12:16:32 +09004758 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004759
4760
Tony Cho410c2482015-09-21 12:16:35 +09004761 msg.body.strHostIFkeyAttr.
Glen Leef3052582015-09-10 12:03:04 +09004762 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004763
4764
Tony Cho410c2482015-09-21 12:16:35 +09004765 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004766 pu8WepKey, (u8WepKeylen));
4767
4768
Tony Cho410c2482015-09-21 12:16:35 +09004769 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004770 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4771
Tony Cho410c2482015-09-21 12:16:35 +09004772 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004773 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4774
Tony Cho410c2482015-09-21 12:16:35 +09004775 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004776 uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
4777
Tony Cho410c2482015-09-21 12:16:35 +09004778 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004779 uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
4780 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004781 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004782
4783 if (s32Error)
4784 PRINT_ER("Error in sending message queue :WEP Key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004785 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004786
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004787 return s32Error;
4788
4789}
Glen Lee108b3432015-09-16 18:53:20 +09004790
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004791/**
4792 * @brief adds ptk Key
4793 * @details
4794 * @param[in,out] handle to the wifi driver
4795 * @param[in] message containing PTK Key in the following format
4796 *|-----------------------------------------------------------------------------|
4797 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4798 *|----------------|------------|--------------|----------------|---------------|
4799 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4800 ||-----------------------------------------------------------------------------|
4801 * @return Error code indicating success/failure
4802 * @note
4803 * @author zsalah
4804 * @date 8 March 2012
4805 * @version 1.0
4806 */
Johnny Kim218dc402015-08-13 13:41:19 +09004807s32 host_int_add_ptk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004808 const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004809{
Leo Kime6e12662015-09-16 18:36:03 +09004810 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004811 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004812 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004813 u8 u8KeyLen = u8PtkKeylen;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004814 u32 i;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004815
Leo Kim24db7132015-09-16 18:36:01 +09004816 if (pstrWFIDrv == NULL) {
4817 s32Error = -EFAULT;
4818 PRINT_ER("driver is null\n");
4819 return s32Error;
4820 }
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004821 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004822 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004823 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004824 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004825
4826 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004827 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004828
4829
Tony Choa9f812a2015-09-21 12:16:33 +09004830 msg.id = HOST_IF_MSG_KEY;
Tony Cho410c2482015-09-21 12:16:35 +09004831 msg.body.strHostIFkeyAttr.enuKeyType = WPAPtk;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004832 if (mode == AP_MODE) {
Tony Cho410c2482015-09-21 12:16:35 +09004833 msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4834 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004835 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
4836 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004837 if (mode == STATION_MODE)
Tony Cho410c2482015-09-21 12:16:35 +09004838 msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004839
4840
Tony Cho410c2482015-09-21 12:16:35 +09004841 msg.body.strHostIFkeyAttr.
Glen Leef3052582015-09-10 12:03:04 +09004842 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8PtkKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004843
4844
Tony Cho410c2482015-09-21 12:16:35 +09004845 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004846 pu8Ptk, u8PtkKeylen);
4847
4848 if (pu8RxMic != NULL) {
4849
Tony Cho410c2482015-09-21 12:16:35 +09004850 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004851 pu8RxMic, RX_MIC_KEY_LEN);
4852 if (INFO) {
4853 for (i = 0; i < RX_MIC_KEY_LEN; i++)
4854 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
4855 }
4856 }
4857 if (pu8TxMic != NULL) {
4858
Tony Cho410c2482015-09-21 12:16:35 +09004859 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004860 pu8TxMic, TX_MIC_KEY_LEN);
4861 if (INFO) {
4862 for (i = 0; i < TX_MIC_KEY_LEN; i++)
4863 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
4864 }
4865 }
4866
Tony Cho410c2482015-09-21 12:16:35 +09004867 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004868 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4869
Tony Cho410c2482015-09-21 12:16:35 +09004870 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004871 uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
Tony Cho410c2482015-09-21 12:16:35 +09004872 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004873 uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
Tony Cho143eb952015-09-21 12:16:32 +09004874 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004875
4876 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004877 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004878
4879 if (s32Error)
4880 PRINT_ER("Error in sending message queue: PTK Key\n");
4881
4882 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004883 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004884 /* /////// */
4885
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004886 return s32Error;
4887}
4888
4889/**
4890 * @brief adds Rx GTk Key
4891 * @details
4892 * @param[in,out] handle to the wifi driver
4893 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
4894 * u8GtkKeylen :The total key length
4895 *
4896 * @return Error code indicating success/failure
4897 * @note
4898 * @author zsalah
4899 * @date 8 March 2012
4900 * @version 1.0
4901 */
Johnny Kim218dc402015-08-13 13:41:19 +09004902s32 host_int_add_rx_gtk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004903 u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004904 const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004905{
Leo Kime6e12662015-09-16 18:36:03 +09004906 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004907 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004908 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004909 u8 u8KeyLen = u8GtkKeylen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004910
Leo Kim24db7132015-09-16 18:36:01 +09004911 if (pstrWFIDrv == NULL) {
4912 s32Error = -EFAULT;
4913 PRINT_ER("driver is null\n");
4914 return s32Error;
4915 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004916 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004917 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004918
4919
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004920 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004921 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004922 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004923 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004924 if (KeyRSC != NULL) {
Tony Cho410c2482015-09-21 12:16:35 +09004925 msg.body.strHostIFkeyAttr.
Glen Leef3052582015-09-10 12:03:04 +09004926 uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004927
Tony Cho410c2482015-09-21 12:16:35 +09004928 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004929 KeyRSC, u32KeyRSClen);
4930 }
4931
4932
Tony Choa9f812a2015-09-21 12:16:33 +09004933 msg.id = HOST_IF_MSG_KEY;
Tony Cho410c2482015-09-21 12:16:35 +09004934 msg.body.strHostIFkeyAttr.enuKeyType = WPARxGtk;
Tony Cho143eb952015-09-21 12:16:32 +09004935 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004936
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004937 if (mode == AP_MODE) {
Tony Cho410c2482015-09-21 12:16:35 +09004938 msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4939 msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004940 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004941 if (mode == STATION_MODE)
Tony Cho410c2482015-09-21 12:16:35 +09004942 msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004943
4944
Tony Cho410c2482015-09-21 12:16:35 +09004945 msg.body.strHostIFkeyAttr.
Glen Leef3052582015-09-10 12:03:04 +09004946 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8KeyLen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004947
Tony Cho410c2482015-09-21 12:16:35 +09004948 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004949 pu8RxGtk, u8GtkKeylen);
4950
4951 if (pu8RxMic != NULL) {
4952
Tony Cho410c2482015-09-21 12:16:35 +09004953 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004954 pu8RxMic, RX_MIC_KEY_LEN);
4955
4956 }
4957 if (pu8TxMic != NULL) {
4958
Tony Cho410c2482015-09-21 12:16:35 +09004959 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004960 pu8TxMic, TX_MIC_KEY_LEN);
4961
4962 }
4963
Tony Cho410c2482015-09-21 12:16:35 +09004964 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004965 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
Tony Cho410c2482015-09-21 12:16:35 +09004966 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004967 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4968
Tony Cho410c2482015-09-21 12:16:35 +09004969 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004970 uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
4971
4972
4973
4974 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004975 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004976 if (s32Error)
4977 PRINT_ER("Error in sending message queue: RX GTK\n");
4978 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004979 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004980 /* /////// */
4981
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004982 return s32Error;
4983}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004984
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004985/**
4986 * @brief host_int_set_pmkid_info
4987 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
4988 * support is enabled. This Function sets the PMKID in firmware
4989 * when host drivr receives the corresponding request from NDIS.
4990 * The firmware then includes theset PMKID in the appropriate
4991 * management frames
4992 * @param[in,out] handle to the wifi driver
4993 * @param[in] message containing PMKID Info in the following format
4994 *|-----------------------------------------------------------------|
4995 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
4996 *|-----------|------------|----------|-------|----------|----------|
4997 | 1 | 6 | 16 | ... | 6 | 16 |
4998 ||-----------------------------------------------------------------|
4999 * @return Error code indicating success/failure
5000 * @note
5001 * @author zsalah
5002 * @date 8 March 2012
5003 * @version 1.0
5004 */
Johnny Kim218dc402015-08-13 13:41:19 +09005005s32 host_int_set_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005006{
Leo Kime6e12662015-09-16 18:36:03 +09005007 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005008 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005009 struct host_if_msg msg;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005010 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005011
5012
Leo Kim24db7132015-09-16 18:36:01 +09005013 if (pstrWFIDrv == NULL) {
5014 s32Error = -EFAULT;
5015 PRINT_ER("driver is null\n");
5016 return s32Error;
5017 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005018
5019 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09005020 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005021
Tony Choa9f812a2015-09-21 12:16:33 +09005022 msg.id = HOST_IF_MSG_KEY;
Tony Cho410c2482015-09-21 12:16:35 +09005023 msg.body.strHostIFkeyAttr.enuKeyType = PMKSA;
5024 msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY;
Tony Cho143eb952015-09-21 12:16:32 +09005025 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005026
5027 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
5028
Tony Cho410c2482015-09-21 12:16:35 +09005029 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005030 ETH_ALEN);
5031
Tony Cho410c2482015-09-21 12:16:35 +09005032 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005033 PMKID_LEN);
5034 }
5035
5036 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005037 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005038 if (s32Error)
5039 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
5040
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005041 return s32Error;
5042}
5043
5044/**
5045 * @brief gets the cached the pmkid info
5046 * @details valid only in BSS STA mode if External Supplicant
5047 * support is enabled. This Function sets the PMKID in firmware
5048 * when host drivr receives the corresponding request from NDIS.
5049 * The firmware then includes theset PMKID in the appropriate
5050 * management frames
5051 * @param[in,out] handle to the wifi driver,
5052 * message containing PMKID Info in the following format
5053 *|-----------------------------------------------------------------|
5054 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5055 *|-----------|------------|----------|-------|----------|----------|
5056 | 1 | 6 | 16 | ... | 6 | 16 |
5057 ||-----------------------------------------------------------------|
5058 * @param[in]
5059 * @return Error code indicating success/failure
5060 * @note
5061 * @author zsalah
5062 * @date 8 March 2012
5063 * @version 1.0
5064 */
Johnny Kim218dc402015-08-13 13:41:19 +09005065s32 host_int_get_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PmkidInfoArray,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005066 u32 u32PmkidInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005067{
Leo Kime6e12662015-09-16 18:36:03 +09005068 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005069 tstrWID strWID;
5070 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5071
Chaehyun Limd85f5322015-06-11 14:35:54 +09005072 strWID.u16WIDid = (u16)WID_PMKID_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005073 strWID.enuWIDtype = WID_STR;
5074 strWID.s32ValueSize = u32PmkidInfoLen;
5075 strWID.ps8WidVal = pu8PmkidInfoArray;
5076
5077 return s32Error;
5078}
5079
5080/**
5081 * @brief sets the pass phrase
5082 * @details AP/STA mode. This function gives the pass phrase used to
5083 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5084 * The length of the field can vary from 8 to 64 bytes,
5085 * the lower layer should get the
5086 * @param[in,out] handle to the wifi driver,
5087 * @param[in] String containing PSK
5088 * @return Error code indicating success/failure
5089 * @note
5090 * @author zsalah
5091 * @date 8 March 2012
5092 * @version 1.0
5093 */
Johnny Kim218dc402015-08-13 13:41:19 +09005094s32 host_int_set_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PassPhrase,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005095 u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005096{
Leo Kime6e12662015-09-16 18:36:03 +09005097 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005098 tstrWID strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005099
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005100 /*validating psk length*/
5101 if ((u8Psklength > 7) && (u8Psklength < 65)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09005102 strWID.u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005103 strWID.enuWIDtype = WID_STR;
5104 strWID.ps8WidVal = pu8PassPhrase;
5105 strWID.s32ValueSize = u8Psklength;
5106 }
5107
5108 return s32Error;
5109}
5110/**
5111 * @brief host_int_get_MacAddress
5112 * @details gets mac address
5113 * @param[in,out] handle to the wifi driver,
5114 *
5115 * @return Error code indicating success/failure
5116 * @note
5117 * @author mdaftedar
5118 * @date 19 April 2012
5119 * @version 1.0
5120 */
Johnny Kim218dc402015-08-13 13:41:19 +09005121s32 host_int_get_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005122{
Leo Kime6e12662015-09-16 18:36:03 +09005123 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005124 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005125
5126
5127 /* prepare the Message */
Tony Cho143eb952015-09-21 12:16:32 +09005128 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005129
Tony Choa9f812a2015-09-21 12:16:33 +09005130 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
Tony Cho410c2482015-09-21 12:16:35 +09005131 msg.body.strHostIfGetMacAddress.u8MacAddress = pu8MacAddress;
Tony Cho143eb952015-09-21 12:16:32 +09005132 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005133 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005134 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005135 if (s32Error) {
5136 PRINT_ER("Failed to send get mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +09005137 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005138 }
5139
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005140 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005141 return s32Error;
5142}
5143
5144/**
5145 * @brief host_int_set_MacAddress
5146 * @details sets mac address
5147 * @param[in,out] handle to the wifi driver,
5148 *
5149 * @return Error code indicating success/failure
5150 * @note
5151 * @author mabubakr
5152 * @date 16 July 2012
5153 * @version 1.0
5154 */
Johnny Kim218dc402015-08-13 13:41:19 +09005155s32 host_int_set_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005156{
Leo Kime6e12662015-09-16 18:36:03 +09005157 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005158 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005159
5160 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
5161
5162 /* prepare setting mac address message */
Tony Cho143eb952015-09-21 12:16:32 +09005163 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005164 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
Tony Cho410c2482015-09-21 12:16:35 +09005165 memcpy(msg.body.strHostIfSetMacAddress.u8MacAddress, pu8MacAddress, ETH_ALEN);
Tony Cho143eb952015-09-21 12:16:32 +09005166 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005167
Tony Cho143eb952015-09-21 12:16:32 +09005168 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005169 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005170 PRINT_ER("Failed to send message queue: Set mac address\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005171
5172 return s32Error;
5173
5174}
5175
5176/**
5177 * @brief host_int_get_RSNAConfigPSKPassPhrase
5178 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
5179 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5180 * The length of the field can vary from 8 to 64 bytes,
5181 * the lower layer should get the
5182 * @param[in,out] handle to the wifi driver,
5183 * String containing PSK
5184 * @return Error code indicating success/failure
5185 * @note
5186 * @author zsalah
5187 * @date 8 March 2012
5188 * @version 1.0
5189 */
Johnny Kim218dc402015-08-13 13:41:19 +09005190s32 host_int_get_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005191 u8 *pu8PassPhrase, u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005192{
Leo Kime6e12662015-09-16 18:36:03 +09005193 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005194 tstrWID strWID;
5195 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5196
Chaehyun Limd85f5322015-06-11 14:35:54 +09005197 strWID.u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005198 strWID.enuWIDtype = WID_STR;
5199 strWID.s32ValueSize = u8Psklength;
5200 strWID.ps8WidVal = pu8PassPhrase;
5201
5202 return s32Error;
5203}
5204
5205/**
5206 * @brief host_int_get_site_survey_results
5207 * @details gets the site survey results
5208 * @param[in,out] handle to the wifi driver,
5209 * Message containing site survey results in the
5210 * following format
5211 *|---------------------------------------------------|
5212 | MsgLength | fragNo. | MsgBodyLength | MsgBody |
5213 ||-----------|-----------|---------------|-----------|
5214 | 1 | 1 | 1 | 1 |
5215 | ----------------------------------------- | ----------------
5216 |
5217 ||---------------------------------------|
5218 | Network1 | Netweork2 | ... | Network5 |
5219 ||---------------------------------------|
5220 | 44 | 44 | ... | 44 |
5221 | -------------------------- | ---------------------------------------
5222 |
5223 ||---------------------------------------------------------------------|
5224 | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved |
5225 |
5226 |
5227 ||------|----------|---------|----------------|-------|------|---------|
5228 | 33 | 1 | 1 | 1 | 6 | 1 | 1 |
5229 ||---------------------------------------------------------------------|
5230 * @return Error code indicating success/failure
5231 * @note
5232 * @author zsalah
5233 * @date 8 March 2012
5234 * @version 1.0
5235 */
5236#ifndef CONNECT_DIRECT
Johnny Kim218dc402015-08-13 13:41:19 +09005237s32 host_int_get_site_survey_results(tstrWILC_WFIDrv *hWFIDrv,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005238 u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE],
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005239 u32 u32MaxSiteSrvyFragLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005240{
Leo Kime6e12662015-09-16 18:36:03 +09005241 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005242 tstrWID astrWIDList[2];
5243 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5244
Chaehyun Limd85f5322015-06-11 14:35:54 +09005245 astrWIDList[0].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005246 astrWIDList[0].enuWIDtype = WID_STR;
5247 astrWIDList[0].ps8WidVal = ppu8RcvdSiteSurveyResults[0];
5248 astrWIDList[0].s32ValueSize = u32MaxSiteSrvyFragLen;
5249
Chaehyun Limd85f5322015-06-11 14:35:54 +09005250 astrWIDList[1].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005251 astrWIDList[1].enuWIDtype = WID_STR;
5252 astrWIDList[1].ps8WidVal = ppu8RcvdSiteSurveyResults[1];
5253 astrWIDList[1].s32ValueSize = u32MaxSiteSrvyFragLen;
5254
Johnny Kimd42ab082015-08-20 16:32:52 +09005255 s32Error = SendConfigPkt(GET_CFG, astrWIDList, 2, true,
5256 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005257
5258 /*get the value by searching the local copy*/
5259 if (s32Error) {
5260 PRINT_ER("Failed to send config packet to get survey results\n");
Leo Kim24db7132015-09-16 18:36:01 +09005261 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005262 }
5263
5264 return s32Error;
5265}
5266#endif
5267
5268/**
5269 * @brief sets a start scan request
5270 * @details
5271 * @param[in,out] handle to the wifi driver,
5272 * @param[in] Scan Source one of the following values
5273 * DEFAULT_SCAN 0
5274 * USER_SCAN BIT0
5275 * OBSS_PERIODIC_SCAN BIT1
5276 * OBSS_ONETIME_SCAN BIT2
5277 * @return Error code indicating success/failure
5278 * @note
5279 * @author zsalah
5280 * @date 8 March 2012
5281 * @version 1.0
5282 */
Johnny Kim218dc402015-08-13 13:41:19 +09005283s32 host_int_set_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 scanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005284{
Leo Kime6e12662015-09-16 18:36:03 +09005285 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005286 tstrWID strWID;
5287 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5288
Chaehyun Limd85f5322015-06-11 14:35:54 +09005289 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005290 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005291 strWID.ps8WidVal = (s8 *)&scanSource;
Dean Lee576917a2015-06-15 11:58:57 +09005292 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005293
5294 return s32Error;
5295}
5296
5297/**
5298 * @brief host_int_get_start_scan_req
5299 * @details gets a start scan request
5300 * @param[in,out] handle to the wifi driver,
5301 * @param[in] Scan Source one of the following values
5302 * DEFAULT_SCAN 0
5303 * USER_SCAN BIT0
5304 * OBSS_PERIODIC_SCAN BIT1
5305 * OBSS_ONETIME_SCAN BIT2
5306 * @return Error code indicating success/failure
5307 * @note
5308 * @author zsalah
5309 * @date 8 March 2012
5310 * @version 1.0
5311 */
5312
Johnny Kim218dc402015-08-13 13:41:19 +09005313s32 host_int_get_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ScanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005314{
Leo Kime6e12662015-09-16 18:36:03 +09005315 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005316 tstrWID strWID;
5317 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5318
Chaehyun Limd85f5322015-06-11 14:35:54 +09005319 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005320 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005321 strWID.ps8WidVal = (s8 *)pu8ScanSource;
Dean Lee576917a2015-06-15 11:58:57 +09005322 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005323
5324 return s32Error;
5325}
5326
5327/**
5328 * @brief host_int_set_join_req
5329 * @details sets a join request
5330 * @param[in,out] handle to the wifi driver,
5331 * @param[in] Index of the bss descriptor
5332 * @return Error code indicating success/failure
5333 * @note
5334 * @author zsalah
5335 * @date 8 March 2012
5336 * @version 1.0
5337 */
Johnny Kim218dc402015-08-13 13:41:19 +09005338s32 host_int_set_join_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8bssid,
Arnd Bergmann057d1e92015-06-01 21:06:44 +02005339 const u8 *pu8ssid, size_t ssidLen,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005340 const u8 *pu8IEs, size_t IEsLen,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005341 tWILCpfConnectResult pfConnectResult, void *pvUserArg,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005342 u8 u8security, AUTHTYPE_T tenuAuth_type,
5343 u8 u8channel,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005344 void *pJoinParams)
5345{
Leo Kime6e12662015-09-16 18:36:03 +09005346 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005347 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005348 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005349 tenuScanConnTimer enuScanConnTimer;
5350
Leo Kim24db7132015-09-16 18:36:01 +09005351 if (pstrWFIDrv == NULL || pfConnectResult == NULL) {
5352 s32Error = -EFAULT;
5353 PRINT_ER("Driver is null\n");
5354 return s32Error;
5355 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005356
5357 if (hWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005358 PRINT_ER("Driver is null\n");
5359 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005360 }
5361
5362 if (pJoinParams == NULL) {
5363 PRINT_ER("Unable to Join - JoinParams is NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09005364 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005365 }
Leo Kim24db7132015-09-16 18:36:01 +09005366
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005367 /* prepare the Connect Message */
Tony Cho143eb952015-09-21 12:16:32 +09005368 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005369
Tony Choa9f812a2015-09-21 12:16:33 +09005370 msg.id = HOST_IF_MSG_CONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005371
Tony Cho410c2482015-09-21 12:16:35 +09005372 msg.body.strHostIFconnectAttr.u8security = u8security;
5373 msg.body.strHostIFconnectAttr.tenuAuth_type = tenuAuth_type;
5374 msg.body.strHostIFconnectAttr.u8channel = u8channel;
5375 msg.body.strHostIFconnectAttr.pfConnectResult = pfConnectResult;
5376 msg.body.strHostIFconnectAttr.pvUserArg = pvUserArg;
5377 msg.body.strHostIFconnectAttr.pJoinParams = pJoinParams;
Tony Cho143eb952015-09-21 12:16:32 +09005378 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005379
5380 if (pu8bssid != NULL) {
Tony Cho410c2482015-09-21 12:16:35 +09005381 msg.body.strHostIFconnectAttr.pu8bssid = kmalloc(6, GFP_KERNEL); /* will be deallocated by the receiving thread */
5382 memcpy(msg.body.strHostIFconnectAttr.pu8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005383 pu8bssid, 6);
5384 }
5385
5386 if (pu8ssid != NULL) {
Tony Cho410c2482015-09-21 12:16:35 +09005387 msg.body.strHostIFconnectAttr.ssidLen = ssidLen;
5388 msg.body.strHostIFconnectAttr.pu8ssid = kmalloc(ssidLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5389 memcpy(msg.body.strHostIFconnectAttr.pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005390
5391 pu8ssid, ssidLen);
5392 }
5393
5394 if (pu8IEs != NULL) {
Tony Cho410c2482015-09-21 12:16:35 +09005395 msg.body.strHostIFconnectAttr.IEsLen = IEsLen;
5396 msg.body.strHostIFconnectAttr.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5397 memcpy(msg.body.strHostIFconnectAttr.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005398 pu8IEs, IEsLen);
5399 }
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05305400 if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005401 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05305402 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005403 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate);
5404
5405 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005406 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005407 if (s32Error) {
5408 PRINT_ER("Failed to send message queue: Set join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09005409 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005410 }
5411
5412 enuScanConnTimer = CONNECT_TIMER;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005413 pstrWFIDrv->hConnectTimer.data = (unsigned long)hWFIDrv;
5414 mod_timer(&pstrWFIDrv->hConnectTimer,
5415 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005416
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005417 return s32Error;
5418}
5419
5420/**
5421 * @brief Flush a join request parameters to FW, but actual connection
5422 * @details The function is called in situation where WILC is connected to AP and
5423 * required to switch to hybrid FW for P2P connection
5424 * @param[in] handle to the wifi driver,
5425 * @return Error code indicating success/failure
5426 * @note
5427 * @author Amr Abdel-Moghny
5428 * @date 19 DEC 2013
5429 * @version 8.0
5430 */
5431
Johnny Kim218dc402015-08-13 13:41:19 +09005432s32 host_int_flush_join_req(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005433{
Leo Kime6e12662015-09-16 18:36:03 +09005434 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005435 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005436
5437 if (!gu8FlushedJoinReq) {
Leo Kime6e12662015-09-16 18:36:03 +09005438 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005439 return s32Error;
5440 }
5441
5442
Leo Kim24db7132015-09-16 18:36:01 +09005443 if (hWFIDrv == NULL) {
5444 s32Error = -EFAULT;
5445 PRINT_ER("Driver is null\n");
5446 return s32Error;
5447 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005448
Tony Choa9f812a2015-09-21 12:16:33 +09005449 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
Tony Cho143eb952015-09-21 12:16:32 +09005450 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005451
5452 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005453 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005454 if (s32Error) {
5455 PRINT_ER("Failed to send message queue: Flush join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09005456 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005457 }
5458
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005459 return s32Error;
5460}
5461
5462/**
5463 * @brief host_int_disconnect
5464 * @details disconnects from the currently associated network
5465 * @param[in,out] handle to the wifi driver,
5466 * @param[in] Reason Code of the Disconnection
5467 * @return Error code indicating success/failure
5468 * @note
5469 * @author zsalah
5470 * @date 8 March 2012
5471 * @version 1.0
5472 */
Johnny Kim218dc402015-08-13 13:41:19 +09005473s32 host_int_disconnect(tstrWILC_WFIDrv *hWFIDrv, u16 u16ReasonCode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005474{
Leo Kime6e12662015-09-16 18:36:03 +09005475 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005476 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005477 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5478
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005479 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005480 PRINT_ER("Driver is null\n");
5481 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005482 }
5483
5484 /* prepare the Disconnect Message */
Tony Cho143eb952015-09-21 12:16:32 +09005485 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005486
Tony Choa9f812a2015-09-21 12:16:33 +09005487 msg.id = HOST_IF_MSG_DISCONNECT;
Tony Cho143eb952015-09-21 12:16:32 +09005488 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005489
5490 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005491 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005492 if (s32Error)
5493 PRINT_ER("Failed to send message queue: disconnect\n");
5494 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005495 down(&(pstrWFIDrv->hSemTestDisconnectBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005496 /* /////// */
5497
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005498 return s32Error;
5499}
5500
5501/**
5502 * @brief host_int_disconnect_station
5503 * @details disconnects a sta
5504 * @param[in,out] handle to the wifi driver,
5505 * @param[in] Association Id of the station to be disconnected
5506 * @return Error code indicating success/failure
5507 * @note
5508 * @author zsalah
5509 * @date 8 March 2012
5510 * @version 1.0
5511 */
Johnny Kim218dc402015-08-13 13:41:19 +09005512s32 host_int_disconnect_station(tstrWILC_WFIDrv *hWFIDrv, u8 assoc_id)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005513{
Leo Kime6e12662015-09-16 18:36:03 +09005514 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005515 tstrWID strWID;
5516 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5517
Chaehyun Limd85f5322015-06-11 14:35:54 +09005518 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005519 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005520 strWID.ps8WidVal = (s8 *)&assoc_id;
Dean Lee576917a2015-06-15 11:58:57 +09005521 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005522
5523 return s32Error;
5524}
5525
5526/**
5527 * @brief host_int_get_assoc_req_info
5528 * @details gets a Association request info
5529 * @param[in,out] handle to the wifi driver,
5530 * Message containg assoc. req info in the following format
5531 * ------------------------------------------------------------------------
5532 | Management Frame Format |
5533 ||-------------------------------------------------------------------|
5534 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5535 ||-------------|--------|--|--|-----|----------------|----------|----|
5536 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5537 ||-------------------------------------------------------------------|
5538 | |
5539 | Association Request Frame - Frame Body |
5540 ||-------------------------------------------------------------------|
5541 | Capability Information | Listen Interval | SSID | Supported Rates |
5542 ||------------------------|-----------------|------|-----------------|
5543 | 2 | 2 | 2-34 | 3-10 |
5544 | ---------------------------------------------------------------------
5545 * @return Error code indicating success/failure
5546 * @note
5547 * @author zsalah
5548 * @date 8 March 2012
5549 * @version 1.0
5550 */
5551
Johnny Kim218dc402015-08-13 13:41:19 +09005552s32 host_int_get_assoc_req_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocReqInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005553 u32 u32AssocReqInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005554{
Leo Kime6e12662015-09-16 18:36:03 +09005555 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005556 tstrWID strWID;
5557 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5558
Chaehyun Limd85f5322015-06-11 14:35:54 +09005559 strWID.u16WIDid = (u16)WID_ASSOC_REQ_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005560 strWID.enuWIDtype = WID_STR;
5561 strWID.ps8WidVal = pu8AssocReqInfo;
5562 strWID.s32ValueSize = u32AssocReqInfoLen;
5563
5564
5565 return s32Error;
5566}
5567
5568/**
5569 * @brief gets a Association Response info
5570 * @details
5571 * @param[in,out] handle to the wifi driver,
5572 * Message containg assoc. resp info
5573 * @return Error code indicating success/failure
5574 * @note
5575 * @author zsalah
5576 * @date 8 March 2012
5577 * @version 1.0
5578 */
Johnny Kim218dc402015-08-13 13:41:19 +09005579s32 host_int_get_assoc_res_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocRespInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005580 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005581{
Leo Kime6e12662015-09-16 18:36:03 +09005582 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005583 tstrWID strWID;
5584 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5585
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005586 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005587 PRINT_ER("Driver is null\n");
5588 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005589 }
5590
Chaehyun Limd85f5322015-06-11 14:35:54 +09005591 strWID.u16WIDid = (u16)WID_ASSOC_RES_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005592 strWID.enuWIDtype = WID_STR;
5593 strWID.ps8WidVal = pu8AssocRespInfo;
5594 strWID.s32ValueSize = u32MaxAssocRespInfoLen;
5595
5596
5597 /* Sending Configuration packet */
Johnny Kimd42ab082015-08-20 16:32:52 +09005598 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
5599 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005600 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005601 *pu32RcvdAssocRespInfoLen = 0;
Leo Kim24db7132015-09-16 18:36:01 +09005602 PRINT_ER("Failed to send association response config packet\n");
5603 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005604 } else {
5605 *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize;
5606 }
5607
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005608 return s32Error;
5609}
5610
5611/**
5612 * @brief gets a Association Response info
5613 * @details Valid only in STA mode. This function gives the RSSI
5614 * values observed in all the channels at the time of scanning.
5615 * The length of the field is 1 greater that the total number of
5616 * channels supported. Byte 0 contains the number of channels while
5617 * each of Byte N contains the observed RSSI value for the channel index N.
5618 * @param[in,out] handle to the wifi driver,
5619 * array of scanned channels' RSSI
5620 * @return Error code indicating success/failure
5621 * @note
5622 * @author zsalah
5623 * @date 8 March 2012
5624 * @version 1.0
5625 */
Johnny Kim218dc402015-08-13 13:41:19 +09005626s32 host_int_get_rx_power_level(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8RxPowerLevel,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005627 u32 u32RxPowerLevelLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005628{
Leo Kime6e12662015-09-16 18:36:03 +09005629 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005630 tstrWID strWID;
5631 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5632
Chaehyun Limd85f5322015-06-11 14:35:54 +09005633 strWID.u16WIDid = (u16)WID_RX_POWER_LEVEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005634 strWID.enuWIDtype = WID_STR;
5635 strWID.ps8WidVal = pu8RxPowerLevel;
5636 strWID.s32ValueSize = u32RxPowerLevelLen;
5637
5638
5639 return s32Error;
5640}
5641
5642/**
5643 * @brief sets a channel
5644 * @details
5645 * @param[in,out] handle to the wifi driver,
5646 * @param[in] Index of the channel to be set
5647 *|-------------------------------------------------------------------|
5648 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5649 | Input: 1 2 14 |
5650 ||-------------------------------------------------------------------|
5651 * @return Error code indicating success/failure
5652 * @note
5653 * @author zsalah
5654 * @date 8 March 2012
5655 * @version 1.0
5656 */
Johnny Kim218dc402015-08-13 13:41:19 +09005657s32 host_int_set_mac_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 u8ChNum)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005658{
Leo Kime6e12662015-09-16 18:36:03 +09005659 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005660 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005661 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005662
Leo Kim24db7132015-09-16 18:36:01 +09005663 if (pstrWFIDrv == NULL) {
5664 PRINT_ER("driver is null\n");
5665 return -EFAULT;
5666 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005667
5668 /* prepare the set channel message */
Tony Cho143eb952015-09-21 12:16:32 +09005669 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005670 msg.id = HOST_IF_MSG_SET_CHANNEL;
Tony Cho410c2482015-09-21 12:16:35 +09005671 msg.body.strHostIFSetChan.u8SetChan = u8ChNum;
Tony Cho143eb952015-09-21 12:16:32 +09005672 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005673
Tony Cho143eb952015-09-21 12:16:32 +09005674 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005675 if (s32Error) {
5676 PRINT_ER("wilc mq send fail\n");
5677 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005678 }
5679
5680 return s32Error;
5681}
5682
5683
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005684s32 host_int_wait_msg_queue_idle(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005685{
Leo Kime6e12662015-09-16 18:36:03 +09005686 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005687
Tony Cho143eb952015-09-21 12:16:32 +09005688 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005689
5690 /* prepare the set driver handler message */
5691
Tony Cho143eb952015-09-21 12:16:32 +09005692 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005693 msg.id = HOST_IF_MSG_Q_IDLE;
Tony Cho143eb952015-09-21 12:16:32 +09005694 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005695 if (s32Error) {
5696 PRINT_ER("wilc mq send fail\n");
5697 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005698 }
5699
5700 /* wait untill MSG Q is empty */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005701 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005702
5703 return s32Error;
5704
5705}
5706
Johnny Kim218dc402015-08-13 13:41:19 +09005707s32 host_int_set_wfi_drv_handler(tstrWILC_WFIDrv *u32address)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005708{
Leo Kime6e12662015-09-16 18:36:03 +09005709 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005710
Tony Cho143eb952015-09-21 12:16:32 +09005711 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005712
5713
5714 /* prepare the set driver handler message */
5715
Tony Cho143eb952015-09-21 12:16:32 +09005716 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005717 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
Tony Cho410c2482015-09-21 12:16:35 +09005718 msg.body.strHostIfSetDrvHandler.u32Address = get_id_from_handler(u32address);
Tony Cho143eb952015-09-21 12:16:32 +09005719 msg.drvHandler = u32address;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005720
Tony Cho143eb952015-09-21 12:16:32 +09005721 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005722 if (s32Error) {
5723 PRINT_ER("wilc mq send fail\n");
5724 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005725 }
5726
5727 return s32Error;
5728}
5729
5730
5731
Johnny Kim218dc402015-08-13 13:41:19 +09005732s32 host_int_set_operation_mode(tstrWILC_WFIDrv *hWFIDrv, u32 u32mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005733{
Leo Kime6e12662015-09-16 18:36:03 +09005734 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005735
Tony Cho143eb952015-09-21 12:16:32 +09005736 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005737
5738
5739 /* prepare the set driver handler message */
5740
Tony Cho143eb952015-09-21 12:16:32 +09005741 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005742 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
Tony Cho410c2482015-09-21 12:16:35 +09005743 msg.body.strHostIfSetOperationMode.u32Mode = u32mode;
Tony Cho143eb952015-09-21 12:16:32 +09005744 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005745
Tony Cho143eb952015-09-21 12:16:32 +09005746 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005747 if (s32Error) {
5748 PRINT_ER("wilc mq send fail\n");
5749 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005750 }
5751
5752 return s32Error;
5753}
5754
5755/**
5756 * @brief gets the current channel index
5757 * @details
5758 * @param[in,out] handle to the wifi driver,
5759 * current channel index
5760 *|-----------------------------------------------------------------------|
5761 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5762 | Input: 1 2 14 |
5763 ||-----------------------------------------------------------------------|
5764 * @return Error code indicating success/failure
5765 * @note
5766 * @author zsalah
5767 * @date 8 March 2012
5768 * @version 1.0
5769 */
Johnny Kim218dc402015-08-13 13:41:19 +09005770s32 host_int_get_host_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ChNo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005771{
Leo Kime6e12662015-09-16 18:36:03 +09005772 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005773 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005774 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005775
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005776 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005777 PRINT_ER("driver is null\n");
5778 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005779 }
5780
5781 /* prepare the Get Channel Message */
Tony Cho143eb952015-09-21 12:16:32 +09005782 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005783
Tony Choa9f812a2015-09-21 12:16:33 +09005784 msg.id = HOST_IF_MSG_GET_CHNL;
Tony Cho143eb952015-09-21 12:16:32 +09005785 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005786
5787 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005788 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005789 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09005790 PRINT_ER("wilc mq send fail\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005791 down(&(pstrWFIDrv->hSemGetCHNL));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005792 /* gu8Chnl = 11; */
5793
5794 *pu8ChNo = gu8Chnl;
5795
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005796 return s32Error;
5797
5798
5799}
5800
5801
5802/**
5803 * @brief host_int_test_set_int_wid
5804 * @details Test function for setting wids
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005805 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005806 * @return Error code indicating success/failure
5807 * @note
5808 * @author zsalah
5809 * @date 8 March 2012
5810 * @version 1.0
5811 */
Johnny Kim218dc402015-08-13 13:41:19 +09005812s32 host_int_test_set_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 u32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005813{
Leo Kime6e12662015-09-16 18:36:03 +09005814 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005815 tstrWID strWID;
5816 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5817
5818
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005819 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005820 PRINT_ER("driver is null\n");
5821 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005822 }
5823
5824 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +09005825 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005826 strWID.enuWIDtype = WID_INT;
Dean Lee576917a2015-06-15 11:58:57 +09005827 strWID.ps8WidVal = (char *)&u32TestMemAddr;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005828 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005829
5830 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09005831 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
5832 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005833 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09005834 PRINT_ER("Failed to set wid value\n");
5835 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005836 } else {
5837 PRINT_D(HOSTINF_DBG, "Successfully set wid value\n");
5838
5839 }
5840
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005841 return s32Error;
5842}
5843
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005844/**
5845 * @brief host_int_get_inactive_time
5846 * @details
5847 * @param[in,out] handle to the wifi driver,
5848 * current sta macaddress, inactive_time
5849 * @return
5850 * @note
5851 * @author
5852 * @date
5853 * @version 1.0
5854 */
Johnny Kim218dc402015-08-13 13:41:19 +09005855s32 host_int_get_inactive_time(tstrWILC_WFIDrv *hWFIDrv, const u8 *mac, u32 *pu32InactiveTime)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005856{
Leo Kime6e12662015-09-16 18:36:03 +09005857 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005858 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005859 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005860
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005861 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005862 PRINT_ER("driver is null\n");
5863 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005864 }
5865
Tony Cho143eb952015-09-21 12:16:32 +09005866 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005867
5868
Tony Cho410c2482015-09-21 12:16:35 +09005869 memcpy(msg.body.strHostIfStaInactiveT.mac,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005870 mac, ETH_ALEN);
5871
Tony Choa9f812a2015-09-21 12:16:33 +09005872 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
Tony Cho143eb952015-09-21 12:16:32 +09005873 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005874
5875 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005876 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005877 if (s32Error)
5878 PRINT_ER("Failed to send get host channel param's message queue ");
5879
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005880 down(&(pstrWFIDrv->hSemInactiveTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005881
5882 *pu32InactiveTime = gu32InactiveTime;
5883
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005884 return s32Error;
5885}
Glen Lee108b3432015-09-16 18:53:20 +09005886
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005887/**
5888 * @brief host_int_test_get_int_wid
5889 * @details Test function for getting wids
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005890 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005891 * @return Error code indicating success/failure
5892 * @note
5893 * @author zsalah
5894 * @date 8 March 2012
5895 * @version 1.0
5896 */
Johnny Kim218dc402015-08-13 13:41:19 +09005897s32 host_int_test_get_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 *pu32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005898{
5899
Leo Kime6e12662015-09-16 18:36:03 +09005900 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005901 tstrWID strWID;
5902 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5903
5904
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005905 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005906 PRINT_ER("driver is null\n");
5907 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005908 }
5909
Chaehyun Limd85f5322015-06-11 14:35:54 +09005910 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005911 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005912 strWID.ps8WidVal = (s8 *)pu32TestMemAddr;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005913 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005914
Johnny Kimd42ab082015-08-20 16:32:52 +09005915 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
5916 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005917 /*get the value by searching the local copy*/
5918 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09005919 PRINT_ER("Failed to get wid value\n");
5920 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005921 } else {
5922 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
5923
5924 }
5925
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005926 return s32Error;
5927}
5928
5929
5930/**
5931 * @brief host_int_get_rssi
5932 * @details gets the currently maintained RSSI value for the station.
5933 * The received signal strength value in dB.
5934 * The range of valid values is -128 to 0.
5935 * @param[in,out] handle to the wifi driver,
5936 * rssi value in dB
5937 * @return Error code indicating success/failure
5938 * @note
5939 * @author zsalah
5940 * @date 8 March 2012
5941 * @version 1.0
5942 */
Johnny Kim218dc402015-08-13 13:41:19 +09005943s32 host_int_get_rssi(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005944{
Leo Kime6e12662015-09-16 18:36:03 +09005945 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005946 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005947 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5948
5949
5950 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09005951 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005952
Tony Choa9f812a2015-09-21 12:16:33 +09005953 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Cho143eb952015-09-21 12:16:32 +09005954 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005955
5956 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005957 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005958 if (s32Error) {
5959 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005960 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005961 }
5962
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005963 down(&(pstrWFIDrv->hSemGetRSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005964
5965
5966 if (ps8Rssi == NULL) {
5967 PRINT_ER("RSS pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09005968 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005969 }
5970
5971
5972 *ps8Rssi = gs8Rssi;
5973
5974
5975 return s32Error;
5976}
5977
Johnny Kim218dc402015-08-13 13:41:19 +09005978s32 host_int_get_link_speed(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8lnkspd)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005979{
Tony Cho143eb952015-09-21 12:16:32 +09005980 struct host_if_msg msg;
Leo Kime6e12662015-09-16 18:36:03 +09005981 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005982
5983 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5984
5985
5986
5987 /* prepare the Get LINKSPEED Message */
Tony Cho143eb952015-09-21 12:16:32 +09005988 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005989
Tony Choa9f812a2015-09-21 12:16:33 +09005990 msg.id = HOST_IF_MSG_GET_LINKSPEED;
Tony Cho143eb952015-09-21 12:16:32 +09005991 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005992
5993 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005994 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005995 if (s32Error) {
5996 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005997 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005998 }
5999
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006000 down(&(pstrWFIDrv->hSemGetLINKSPEED));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006001
6002
6003 if (ps8lnkspd == NULL) {
6004 PRINT_ER("LINKSPEED pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09006005 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006006 }
6007
6008
6009 *ps8lnkspd = gs8lnkspd;
6010
6011
6012 return s32Error;
6013}
6014
Johnny Kim218dc402015-08-13 13:41:19 +09006015s32 host_int_get_statistics(tstrWILC_WFIDrv *hWFIDrv, tstrStatistics *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006016{
Leo Kime6e12662015-09-16 18:36:03 +09006017 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006018 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006019
6020
6021 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09006022 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006023
Tony Choa9f812a2015-09-21 12:16:33 +09006024 msg.id = HOST_IF_MSG_GET_STATISTICS;
Tony Cho410c2482015-09-21 12:16:35 +09006025 msg.body.pUserData = (char *)pstrStatistics;
Tony Cho143eb952015-09-21 12:16:32 +09006026 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006027 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006028 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006029 if (s32Error) {
6030 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09006031 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006032 }
6033
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006034 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006035 return s32Error;
6036}
6037
6038
6039/**
6040 * @brief host_int_scan
6041 * @details scans a set of channels
6042 * @param[in,out] handle to the wifi driver,
6043 * @param[in] Scan source
6044 * Scan Type PASSIVE_SCAN = 0,
6045 * ACTIVE_SCAN = 1
6046 * Channels Array
6047 * Channels Array length
6048 * Scan Callback function
6049 * @return Error code indicating success/failure
6050 * @note
6051 * @author zsalah
6052 * @date 8 March 2012
6053 * @version 1.0
6054 */
Johnny Kim218dc402015-08-13 13:41:19 +09006055s32 host_int_scan(tstrWILC_WFIDrv *hWFIDrv, u8 u8ScanSource,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006056 u8 u8ScanType, u8 *pu8ChnlFreqList,
6057 u8 u8ChnlListLen, const u8 *pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006058 size_t IEsLen, tWILCpfScanResult ScanResult,
6059 void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork)
6060{
Leo Kime6e12662015-09-16 18:36:03 +09006061 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006062 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006063 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006064 tenuScanConnTimer enuScanConnTimer;
6065
Leo Kim24db7132015-09-16 18:36:01 +09006066 if (pstrWFIDrv == NULL || ScanResult == NULL) {
6067 PRINT_ER("pstrWFIDrv or ScanResult = NULL\n");
6068 return -EFAULT;
6069 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006070
6071 /* prepare the Scan Message */
Tony Cho143eb952015-09-21 12:16:32 +09006072 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006073
Tony Choa9f812a2015-09-21 12:16:33 +09006074 msg.id = HOST_IF_MSG_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006075
6076 if (pstrHiddenNetwork != NULL) {
Tony Cho410c2482015-09-21 12:16:35 +09006077 msg.body.strHostIFscanAttr.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
6078 msg.body.strHostIFscanAttr.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006079
6080 } else
6081 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
6082
Tony Cho143eb952015-09-21 12:16:32 +09006083 msg.drvHandler = hWFIDrv;
Tony Cho410c2482015-09-21 12:16:35 +09006084 msg.body.strHostIFscanAttr.u8ScanSource = u8ScanSource;
6085 msg.body.strHostIFscanAttr.u8ScanType = u8ScanType;
6086 msg.body.strHostIFscanAttr.pfScanResult = ScanResult;
6087 msg.body.strHostIFscanAttr.pvUserArg = pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006088
Tony Cho410c2482015-09-21 12:16:35 +09006089 msg.body.strHostIFscanAttr.u8ChnlListLen = u8ChnlListLen;
6090 msg.body.strHostIFscanAttr.pu8ChnlFreqList = kmalloc(u8ChnlListLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
6091 memcpy(msg.body.strHostIFscanAttr.pu8ChnlFreqList,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006092 pu8ChnlFreqList, u8ChnlListLen);
6093
Tony Cho410c2482015-09-21 12:16:35 +09006094 msg.body.strHostIFscanAttr.IEsLen = IEsLen;
6095 msg.body.strHostIFscanAttr.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
6096 memcpy(msg.body.strHostIFscanAttr.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006097 pu8IEs, IEsLen);
6098
6099 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006100 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006101 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09006102 PRINT_ER("Error in sending message queue\n");
6103 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006104 }
6105
6106 enuScanConnTimer = SCAN_TIMER;
6107 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07006108 pstrWFIDrv->hScanTimer.data = (unsigned long)hWFIDrv;
6109 mod_timer(&pstrWFIDrv->hScanTimer,
6110 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006111
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006112 return s32Error;
6113
6114}
6115/**
6116 * @brief hif_set_cfg
6117 * @details sets configuration wids values
6118 * @param[in,out] handle to the wifi driver,
6119 * @param[in] WID, WID value
6120 * @return Error code indicating success/failure
6121 * @note
6122 * @author zsalah
6123 * @date 8 March 2012
6124 * @version 1.0
6125 */
Johnny Kim218dc402015-08-13 13:41:19 +09006126s32 hif_set_cfg(tstrWILC_WFIDrv *hWFIDrv, tstrCfgParamVal *pstrCfgParamVal)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006127{
6128
Leo Kime6e12662015-09-16 18:36:03 +09006129 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006130 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6131
Tony Cho143eb952015-09-21 12:16:32 +09006132 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006133
6134
Leo Kim24db7132015-09-16 18:36:01 +09006135 if (pstrWFIDrv == NULL) {
6136 PRINT_ER("pstrWFIDrv NULL\n");
6137 return -EFAULT;
6138 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006139 /* prepare the WiphyParams Message */
Tony Cho143eb952015-09-21 12:16:32 +09006140 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09006141 msg.id = HOST_IF_MSG_CFG_PARAMS;
Tony Cho410c2482015-09-21 12:16:35 +09006142 msg.body.strHostIFCfgParamAttr.pstrCfgParamVal = *pstrCfgParamVal;
Tony Cho143eb952015-09-21 12:16:32 +09006143 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006144
Tony Cho143eb952015-09-21 12:16:32 +09006145 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006146
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006147 return s32Error;
6148
6149}
6150
6151
6152/**
6153 * @brief hif_get_cfg
6154 * @details gets configuration wids values
6155 * @param[in,out] handle to the wifi driver,
6156 * WID value
6157 * @param[in] WID,
6158 * @return Error code indicating success/failure
6159 * @note
6160 * @author zsalah
6161 *
6162 * @date 8 March 2012
6163 * @version 1.0
6164 */
Johnny Kim218dc402015-08-13 13:41:19 +09006165s32 hif_get_cfg(tstrWILC_WFIDrv *hWFIDrv, u16 u16WID, u16 *pu16WID_Value)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006166{
Leo Kime6e12662015-09-16 18:36:03 +09006167 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006168 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6169
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006170 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006171
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006172 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09006173 PRINT_ER("pstrWFIDrv NULL\n");
6174 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006175 }
6176 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
6177 switch (u16WID) {
6178
6179 case WID_BSS_TYPE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006180 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006181 break;
6182
6183 case WID_AUTH_TYPE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006184 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006185 break;
6186
6187 case WID_AUTH_TIMEOUT:
6188 *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout;
6189 break;
6190
6191 case WID_POWER_MANAGEMENT:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006192 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006193 break;
6194
6195 case WID_SHORT_RETRY_LIMIT:
6196 *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit;
6197 break;
6198
6199 case WID_LONG_RETRY_LIMIT:
6200 *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit;
6201 break;
6202
6203 case WID_FRAG_THRESHOLD:
6204 *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold;
6205 break;
6206
6207 case WID_RTS_THRESHOLD:
6208 *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold;
6209 break;
6210
6211 case WID_PREAMBLE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006212 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006213 break;
6214
6215 case WID_SHORT_SLOT_ALLOWED:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006216 *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006217 break;
6218
6219 case WID_11N_TXOP_PROT_DISABLE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006220 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006221 break;
6222
6223 case WID_BEACON_INTERVAL:
6224 *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval;
6225 break;
6226
6227 case WID_DTIM_PERIOD:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006228 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006229 break;
6230
6231 case WID_SITE_SURVEY:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006232 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006233 break;
6234
6235 case WID_SITE_SURVEY_SCAN_TIME:
6236 *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time;
6237 break;
6238
6239 case WID_ACTIVE_SCAN_TIME:
6240 *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time;
6241 break;
6242
6243 case WID_PASSIVE_SCAN_TIME:
6244 *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time;
6245 break;
6246
6247 case WID_CURRENT_TX_RATE:
6248 *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate;
6249 break;
6250
6251 default:
6252 break;
6253 }
6254
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006255 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006256
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006257 return s32Error;
6258
6259}
6260
6261/*****************************************************************************/
6262/* Notification Functions */
6263/*****************************************************************************/
6264/**
6265 * @brief notifies host with join and leave requests
6266 * @details This function prepares an Information frame having the
6267 * information about a joining/leaving station.
6268 * @param[in,out] handle to the wifi driver,
6269 * @param[in] 6 byte Sta Adress
6270 * Join or leave flag:
6271 * Join = 1,
6272 * Leave =0
6273 * @return Error code indicating success/failure
6274 * @note
6275 * @author zsalah
6276 * @date 8 March 2012
6277 * @version 1.0
6278 */
6279void host_int_send_join_leave_info_to_host
Dean Lee72ed4dc2015-06-12 14:11:44 +09006280 (u16 assocId, u8 *stationAddr, bool joining)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006281{
6282}
6283/**
6284 * @brief notifies host with stations found in scan
6285 * @details sends the beacon/probe response from scan
6286 * @param[in,out] handle to the wifi driver,
6287 * @param[in] Sta Address,
6288 * Frame length,
6289 * Rssi of the Station found
6290 * @return Error code indicating success/failure
6291 * @note
6292 * @author zsalah
6293 * @date 8 March 2012
6294 * @version 1.0
6295 */
6296
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006297static void GetPeriodicRSSI(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006298{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006299 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006300
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006301 if (pstrWFIDrv == NULL) {
6302 PRINT_ER("Driver handler is NULL\n");
6303 return;
6304 }
6305
6306 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
Leo Kime6e12662015-09-16 18:36:03 +09006307 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006308 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006309
6310 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09006311 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006312
Tony Choa9f812a2015-09-21 12:16:33 +09006313 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Cho143eb952015-09-21 12:16:32 +09006314 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006315
6316 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006317 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006318 if (s32Error) {
6319 PRINT_ER("Failed to send get host channel param's message queue ");
6320 return;
6321 }
6322 }
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07006323 g_hPeriodicRSSI.data = (unsigned long)pstrWFIDrv;
6324 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006325}
6326
6327
6328void host_int_send_network_info_to_host
Chaehyun Limca356ad2015-06-11 14:35:57 +09006329 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006330{
6331}
6332/**
6333 * @brief host_int_init
6334 * @details host interface initialization function
6335 * @param[in,out] handle to the wifi driver,
6336 * @note
6337 * @author zsalah
6338 * @date 8 March 2012
6339 * @version 1.0
6340 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006341static u32 u32Intialized;
6342static u32 msgQ_created;
6343static u32 clients_count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006344
Johnny Kim218dc402015-08-13 13:41:19 +09006345s32 host_int_init(tstrWILC_WFIDrv **phWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006346{
Leo Kime6e12662015-09-16 18:36:03 +09006347 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006348 tstrWILC_WFIDrv *pstrWFIDrv;
Johnny Kimd42ab082015-08-20 16:32:52 +09006349 int err;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006350
6351 /*if(u32Intialized == 1)
6352 * {
6353 * PRINT_D(HOSTINF_DBG,"Host interface is previously initialized\n");
6354 * *phWFIDrv = (WILC_WFIDrvHandle)gWFiDrvHandle; //Will be adjusted later for P2P
6355 * return 0;
6356 * } */
6357 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
6358
Dean Lee72ed4dc2015-06-12 14:11:44 +09006359 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006360
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006361 sema_init(&hWaitResponse, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006362
6363
6364
6365 /*Allocate host interface private structure*/
Glen Leef3052582015-09-10 12:03:04 +09006366 pstrWFIDrv = kmalloc(sizeof(tstrWILC_WFIDrv), GFP_KERNEL);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006367 if (pstrWFIDrv == NULL) {
Leo Kime6e12662015-09-16 18:36:03 +09006368 s32Error = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006369 PRINT_ER("Failed to allocate memory\n");
6370 goto _fail_timer_2;
6371 }
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006372 memset(pstrWFIDrv, 0, sizeof(tstrWILC_WFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006373 /*return driver handle to user*/
Johnny Kim218dc402015-08-13 13:41:19 +09006374 *phWFIDrv = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006375 /*save into globl handle*/
Johnny Kimd42ab082015-08-20 16:32:52 +09006376 err = add_handler_in_list(pstrWFIDrv);
6377 if (err) {
Leo Kime6e12662015-09-16 18:36:03 +09006378 s32Error = -EFAULT;
Johnny Kimd42ab082015-08-20 16:32:52 +09006379 goto _fail_timer_2;
6380 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006381
6382 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
6383
Dean Lee72ed4dc2015-06-12 14:11:44 +09006384 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006385 #endif
6386
Johnny Kim8a143302015-06-10 17:06:46 +09006387 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006388 /* /////////////////////////////////////// */
6389 if (clients_count == 0) {
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006390 sema_init(&hSemHostIFthrdEnd, 0);
6391 sema_init(&hSemDeinitDrvHandle, 0);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006392 sema_init(&hSemHostIntDeinit, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006393 }
6394
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006395 sema_init(&(pstrWFIDrv->hSemTestKeyBlock), 0);
6396 sema_init(&(pstrWFIDrv->hSemTestDisconnectBlock), 0);
6397 sema_init(&(pstrWFIDrv->hSemGetRSSI), 0);
6398 sema_init(&(pstrWFIDrv->hSemGetLINKSPEED), 0);
6399 sema_init(&(pstrWFIDrv->hSemGetCHNL), 0);
6400 sema_init(&(pstrWFIDrv->hSemInactiveTime), 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006401
6402 /* /////////////////////////////////////// */
6403
6404
6405
6406 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
6407
6408 if (clients_count == 0) {
Chaehyun Limcd08fc72015-08-19 15:59:05 +09006409 s32Error = wilc_mq_create(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006410
6411 if (s32Error < 0) {
6412 PRINT_ER("Failed to creat MQ\n");
6413 goto _fail_;
6414 }
6415 msgQ_created = 1;
Arnd Bergmann1999bd52015-05-29 22:52:14 +02006416 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
6417 if (IS_ERR(HostIFthreadHandler)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006418 PRINT_ER("Failed to creat Thread\n");
Leo Kime6e12662015-09-16 18:36:03 +09006419 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006420 goto _fail_mq_;
6421 }
Greg Kroah-Hartman507d7fc2015-08-17 12:59:42 -07006422 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
6423 (unsigned long)pstrWFIDrv);
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07006424 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006425 }
6426
6427
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006428 setup_timer(&pstrWFIDrv->hScanTimer, TimerCB_Scan, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006429
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006430 setup_timer(&pstrWFIDrv->hConnectTimer, TimerCB_Connect, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006431
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006432 /*Remain on channel timer*/
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006433 setup_timer(&pstrWFIDrv->hRemainOnChannel, ListenTimerCB, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006434
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006435 sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1);
6436 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006437
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006438 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09006439 /* gWFiDrvHandle->bPendingConnRequest = false; */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006440
6441 /*Initialize CFG WIDS Defualt Values*/
6442
6443 pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
6444 pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN;
6445 pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
6446 pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
6447 pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE;
6448
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006449 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
6450
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006451 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",
6452
6453 pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source,
6454 pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time,
6455 pstrWFIDrv->strCfgValues.curr_tx_rate);
6456
6457
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006458 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006459
6460 /*TODO Code to setup simulation to be removed later*/
6461 /*Intialize configurator module*/
6462 s32Error = CoreConfiguratorInit();
6463 if (s32Error < 0) {
6464 PRINT_ER("Failed to initialize core configurator\n");
6465 goto _fail_mem_;
6466 }
6467
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006468 u32Intialized = 1;
6469 clients_count++; /* increase number of created entities */
6470
6471 return s32Error;
6472
6473
6474_fail_mem_:
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006475 if (pstrWFIDrv != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006476 kfree(pstrWFIDrv);
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006477 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006478_fail_timer_2:
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006479 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006480 del_timer_sync(&pstrWFIDrv->hConnectTimer);
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006481 del_timer_sync(&pstrWFIDrv->hScanTimer);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02006482 kthread_stop(HostIFthreadHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006483_fail_mq_:
Chaehyun Lim1b128f62015-08-19 15:59:08 +09006484 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006485_fail_:
6486 return s32Error;
6487
6488
6489}
6490/**
6491 * @brief host_int_deinit
6492 * @details host interface initialization function
6493 * @param[in,out] handle to the wifi driver,
6494 * @note
6495 * @author zsalah
6496 * @date 8 March 2012
6497 * @version 1.0
6498 */
6499
Johnny Kim218dc402015-08-13 13:41:19 +09006500s32 host_int_deinit(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006501{
Leo Kime6e12662015-09-16 18:36:03 +09006502 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006503 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006504 int ret;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006505
6506 /*obtain driver handle*/
6507 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6508 /*if(u32Intialized == 0)
6509 * {
6510 * PRINT_ER("Host Interface is not initialized\n");
6511 * return 0;
6512 * }*/
6513
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006514
6515 if (pstrWFIDrv == NULL) {
6516 PRINT_ER("pstrWFIDrv = NULL\n");
6517 return 0;
6518 }
6519
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006520 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006521
6522 terminated_handle = pstrWFIDrv;
6523 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
6524
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006525 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
6526 /*to guarantee handling all messages befor proceeding*/
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006527 if (del_timer_sync(&pstrWFIDrv->hScanTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006528 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006529 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
6530 }
6531
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006532 if (del_timer_sync(&pstrWFIDrv->hConnectTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006533 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006534 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6535 }
6536
6537
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006538 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006539 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006540 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6541 }
6542
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006543 /*Destroy Remain-onchannel Timer*/
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006544 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006545
Johnny Kim218dc402015-08-13 13:41:19 +09006546 host_int_set_wfi_drv_handler(NULL);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006547 down(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006548
6549
6550 /*Calling the CFG80211 scan done function with the abort flag set to true*/
6551 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006552 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006553 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
6554
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006555 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006556 }
6557 /*deinit configurator and simulator*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006558 CoreConfiguratorDeInit();
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006559
6560 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6561
Dean Lee72ed4dc2015-06-12 14:11:44 +09006562 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006563
Tony Cho143eb952015-09-21 12:16:32 +09006564 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006565
6566 if (clients_count == 1) {
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006567 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006568 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006569 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6570 }
Tony Choa9f812a2015-09-21 12:16:33 +09006571 msg.id = HOST_IF_MSG_EXIT;
Tony Cho143eb952015-09-21 12:16:32 +09006572 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006573
6574
Tony Cho143eb952015-09-21 12:16:32 +09006575 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kime6e12662015-09-16 18:36:03 +09006576 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006577 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006578
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006579 down(&hSemHostIFthrdEnd);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006580
Chaehyun Lim1b128f62015-08-19 15:59:08 +09006581 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006582 msgQ_created = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006583 }
6584
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006585 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006586
6587 /*Setting the gloabl driver handler with NULL*/
6588 u32Intialized = 0;
6589 /* gWFiDrvHandle = NULL; */
Johnny Kimd42ab082015-08-20 16:32:52 +09006590 ret = remove_handler_in_list(pstrWFIDrv);
6591 if (ret)
Leo Kime6e12662015-09-16 18:36:03 +09006592 s32Error = -ENOENT;
Johnny Kimd42ab082015-08-20 16:32:52 +09006593
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006594 if (pstrWFIDrv != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09006595 kfree(pstrWFIDrv);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006596 /* pstrWFIDrv=NULL; */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006597
6598 }
6599
6600 clients_count--; /* Decrease number of created entities */
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006601 terminated_handle = NULL;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006602 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006603 return s32Error;
6604}
6605
6606
6607/**
6608 * @brief NetworkInfoReceived
6609 * @details function to to be called when network info packet is received
6610 * @param[in] pu8Buffer the received packet
6611 * @param[in] u32Length length of the received packet
6612 * @return none
6613 * @note
6614 * @author
6615 * @date 1 Mar 2012
6616 * @version 1.0
6617 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006618void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006619{
Leo Kime6e12662015-09-16 18:36:03 +09006620 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006621 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006622 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006623 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006624
Johnny Kimd42ab082015-08-20 16:32:52 +09006625 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6626 pstrWFIDrv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006627
6628
6629
6630
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006631 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
Johnny Kim8a143302015-06-10 17:06:46 +09006632 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006633 return;
6634 }
6635
6636 /* prepare the Asynchronous Network Info message */
Tony Cho143eb952015-09-21 12:16:32 +09006637 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006638
Tony Choa9f812a2015-09-21 12:16:33 +09006639 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
Tony Cho143eb952015-09-21 12:16:32 +09006640 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006641
Tony Cho410c2482015-09-21 12:16:35 +09006642 msg.body.strRcvdNetworkInfo.u32Length = u32Length;
6643 msg.body.strRcvdNetworkInfo.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
6644 memcpy(msg.body.strRcvdNetworkInfo.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006645 pu8Buffer, u32Length);
6646
6647 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006648 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006649 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006650 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006651}
6652
6653/**
6654 * @brief GnrlAsyncInfoReceived
6655 * @details function to be called when general Asynchronous info packet is received
6656 * @param[in] pu8Buffer the received packet
6657 * @param[in] u32Length length of the received packet
6658 * @return none
6659 * @note
6660 * @author
6661 * @date 15 Mar 2012
6662 * @version 1.0
6663 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006664void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006665{
Leo Kime6e12662015-09-16 18:36:03 +09006666 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006667 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006668 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006669 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006670
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006671 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006672
Johnny Kimd42ab082015-08-20 16:32:52 +09006673 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6674 pstrWFIDrv = get_handler_from_id(id);
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006675 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006676
6677
6678 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6679 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006680 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006681 return;
6682 }
6683
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006684 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006685 /* received mac status is not needed when there is no current Connect Request */
6686 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006687 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006688 return;
6689 }
6690
6691 /* prepare the General Asynchronous Info message */
Tony Cho143eb952015-09-21 12:16:32 +09006692 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006693
6694
Tony Choa9f812a2015-09-21 12:16:33 +09006695 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
Tony Cho143eb952015-09-21 12:16:32 +09006696 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006697
6698
Tony Cho410c2482015-09-21 12:16:35 +09006699 msg.body.strRcvdGnrlAsyncInfo.u32Length = u32Length;
6700 msg.body.strRcvdGnrlAsyncInfo.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
6701 memcpy(msg.body.strRcvdGnrlAsyncInfo.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006702 pu8Buffer, u32Length);
6703
6704 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006705 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006706 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006707 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006708
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006709 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006710}
6711
6712/**
6713 * @brief host_int_ScanCompleteReceived
6714 * @details Setting scan complete received notifcation in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006715 * @param[in] u8* pu8Buffer, u32 u32Length
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006716 * @return Error code.
6717 * @author
6718 * @date
6719 * @version 1.0
6720 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006721void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006722{
Leo Kime6e12662015-09-16 18:36:03 +09006723 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006724 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006725 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006726 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006727
Johnny Kimd42ab082015-08-20 16:32:52 +09006728 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6729 pstrWFIDrv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006730
6731
Johnny Kim8a143302015-06-10 17:06:46 +09006732 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006733
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006734 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006735 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006736
6737 /*if there is an ongoing scan request*/
6738 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6739 /* prepare theScan Done message */
Tony Cho143eb952015-09-21 12:16:32 +09006740 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006741
Tony Choa9f812a2015-09-21 12:16:33 +09006742 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
Tony Cho143eb952015-09-21 12:16:32 +09006743 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006744
6745
6746 /* will be deallocated by the receiving thread */
6747 /*no need to send message body*/
6748
Tony Cho410c2482015-09-21 12:16:35 +09006749 /*msg.body.strScanComplete.u32Length = u32Length;
6750 * msg.body.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
6751 * memcpy(msg.body.strScanComplete.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006752 * pu8Buffer, u32Length); */
6753
6754 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006755 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006756 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006757 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006758 }
6759
6760
6761 return;
6762
6763}
6764
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006765/**
6766 * @brief host_int_remain_on_channel
6767 * @details
6768 * @param[in] Handle to wifi driver
6769 * Duration to remain on channel
6770 * Channel to remain on
6771 * Pointer to fn to be called on receive frames in listen state
6772 * Pointer to remain-on-channel expired fn
6773 * Priv
6774 * @return Error code.
6775 * @author
6776 * @date
6777 * @version 1.0
6778 */
Johnny Kim218dc402015-08-13 13:41:19 +09006779s32 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 +09006780{
Leo Kime6e12662015-09-16 18:36:03 +09006781 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006782 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006783 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006784
Leo Kim24db7132015-09-16 18:36:01 +09006785 if (pstrWFIDrv == NULL) {
6786 PRINT_ER("driver is null\n");
6787 return -EFAULT;
6788 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006789
6790 /* prepare the remainonchan Message */
Tony Cho143eb952015-09-21 12:16:32 +09006791 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006792
6793 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006794 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
Tony Cho410c2482015-09-21 12:16:35 +09006795 msg.body.strHostIfRemainOnChan.u16Channel = chan;
6796 msg.body.strHostIfRemainOnChan.pRemainOnChanExpired = RemainOnChanExpired;
6797 msg.body.strHostIfRemainOnChan.pRemainOnChanReady = RemainOnChanReady;
6798 msg.body.strHostIfRemainOnChan.pVoid = pvUserArg;
6799 msg.body.strHostIfRemainOnChan.u32duration = u32duration;
6800 msg.body.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
Tony Cho143eb952015-09-21 12:16:32 +09006801 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006802
Tony Cho143eb952015-09-21 12:16:32 +09006803 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006804 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006805 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006806
6807 return s32Error;
6808}
6809
6810/**
6811 * @brief host_int_ListenStateExpired
6812 * @details
6813 * @param[in] Handle to wifi driver
6814 * Duration to remain on channel
6815 * Channel to remain on
6816 * Pointer to fn to be called on receive frames in listen state
6817 * Pointer to remain-on-channel expired fn
6818 * Priv
6819 * @return Error code.
6820 * @author
6821 * @date
6822 * @version 1.0
6823 */
Johnny Kim218dc402015-08-13 13:41:19 +09006824s32 host_int_ListenStateExpired(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006825{
Leo Kime6e12662015-09-16 18:36:03 +09006826 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006827 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006828 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006829
Leo Kim24db7132015-09-16 18:36:01 +09006830 if (pstrWFIDrv == NULL) {
6831 PRINT_ER("driver is null\n");
6832 return -EFAULT;
6833 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006834
6835 /*Stopping remain-on-channel timer*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07006836 del_timer(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006837
6838 /* prepare the timer fire Message */
Tony Cho143eb952015-09-21 12:16:32 +09006839 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09006840 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Cho143eb952015-09-21 12:16:32 +09006841 msg.drvHandler = hWFIDrv;
Tony Cho410c2482015-09-21 12:16:35 +09006842 msg.body.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006843
Tony Cho143eb952015-09-21 12:16:32 +09006844 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006845 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006846 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006847
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006848 return s32Error;
6849}
6850
6851/**
6852 * @brief host_int_frame_register
6853 * @details
6854 * @param[in] Handle to wifi driver
6855 * @return Error code.
6856 * @author
6857 * @date
6858 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09006859s32 host_int_frame_register(tstrWILC_WFIDrv *hWFIDrv, u16 u16FrameType, bool bReg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006860{
Leo Kime6e12662015-09-16 18:36:03 +09006861 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006862 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006863 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006864
Leo Kim24db7132015-09-16 18:36:01 +09006865 if (pstrWFIDrv == NULL) {
6866 PRINT_ER("driver is null\n");
6867 return -EFAULT;
6868 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006869
Tony Cho143eb952015-09-21 12:16:32 +09006870 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006871
6872 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006873 msg.id = HOST_IF_MSG_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006874 switch (u16FrameType) {
6875 case ACTION:
6876 PRINT_D(HOSTINF_DBG, "ACTION\n");
Tony Cho410c2482015-09-21 12:16:35 +09006877 msg.body.strHostIfRegisterFrame.u8Regid = ACTION_FRM_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006878 break;
6879
6880 case PROBE_REQ:
6881 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
Tony Cho410c2482015-09-21 12:16:35 +09006882 msg.body.strHostIfRegisterFrame.u8Regid = PROBE_REQ_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006883 break;
6884
6885 default:
6886 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
6887 break;
6888 }
Tony Cho410c2482015-09-21 12:16:35 +09006889 msg.body.strHostIfRegisterFrame.u16FrameType = u16FrameType;
6890 msg.body.strHostIfRegisterFrame.bReg = bReg;
Tony Cho143eb952015-09-21 12:16:32 +09006891 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006892
Tony Cho143eb952015-09-21 12:16:32 +09006893 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006894 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006895 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006896
6897 return s32Error;
6898
6899
6900}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006901
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006902/**
6903 * @brief host_int_add_beacon
6904 * @details Setting add beacon params in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006905 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
6906 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
6907 * u32 u32TailLen, u8* pu8Tail
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006908 * @return Error code.
6909 * @author
6910 * @date
6911 * @version 1.0
6912 */
Johnny Kim218dc402015-08-13 13:41:19 +09006913s32 host_int_add_beacon(tstrWILC_WFIDrv *hWFIDrv, u32 u32Interval,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006914 u32 u32DTIMPeriod,
6915 u32 u32HeadLen, u8 *pu8Head,
6916 u32 u32TailLen, u8 *pu8Tail)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006917{
Leo Kime6e12662015-09-16 18:36:03 +09006918 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006919 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006920 struct host_if_msg msg;
Tony Cho410c2482015-09-21 12:16:35 +09006921 tstrHostIFSetBeacon *pstrSetBeaconParam = &msg.body.strHostIFSetBeacon;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006922
Leo Kim24db7132015-09-16 18:36:01 +09006923 if (pstrWFIDrv == NULL) {
6924 PRINT_ER("driver is null\n");
6925 return -EFAULT;
6926 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006927
Tony Cho143eb952015-09-21 12:16:32 +09006928 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006929
6930 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
6931
6932
6933 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006934 msg.id = HOST_IF_MSG_ADD_BEACON;
Tony Cho143eb952015-09-21 12:16:32 +09006935 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006936 pstrSetBeaconParam->u32Interval = u32Interval;
6937 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
6938 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
Glen Leef3052582015-09-10 12:03:04 +09006939 pstrSetBeaconParam->pu8Head = kmalloc(u32HeadLen, GFP_KERNEL);
Leo Kim24db7132015-09-16 18:36:01 +09006940 if (pstrSetBeaconParam->pu8Head == NULL) {
6941 s32Error = -ENOMEM;
6942 goto ERRORHANDLER;
6943 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006944 memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006945 pstrSetBeaconParam->u32TailLen = u32TailLen;
6946
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006947 if (u32TailLen > 0) {
Glen Leef3052582015-09-10 12:03:04 +09006948 pstrSetBeaconParam->pu8Tail = kmalloc(u32TailLen, GFP_KERNEL);
Leo Kim24db7132015-09-16 18:36:01 +09006949 if (pstrSetBeaconParam->pu8Tail == NULL) {
6950 s32Error = -ENOMEM;
6951 goto ERRORHANDLER;
6952 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006953 memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006954 } else {
6955 pstrSetBeaconParam->pu8Tail = NULL;
6956 }
6957
Tony Cho143eb952015-09-21 12:16:32 +09006958 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006959 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006960 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006961
Leo Kim24db7132015-09-16 18:36:01 +09006962ERRORHANDLER:
6963 if (s32Error) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006964 if (pstrSetBeaconParam->pu8Head != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006965 kfree(pstrSetBeaconParam->pu8Head);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006966
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006967 if (pstrSetBeaconParam->pu8Tail != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006968 kfree(pstrSetBeaconParam->pu8Tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006969 }
6970
6971 return s32Error;
6972
6973}
6974
6975
6976/**
6977 * @brief host_int_del_beacon
6978 * @details Setting add beacon params in message queue
6979 * @param[in] WILC_WFIDrvHandle hWFIDrv
6980 * @return Error code.
6981 * @author
6982 * @date
6983 * @version 1.0
6984 */
Johnny Kim218dc402015-08-13 13:41:19 +09006985s32 host_int_del_beacon(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006986{
Leo Kime6e12662015-09-16 18:36:03 +09006987 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006988 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006989 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006990
Leo Kim24db7132015-09-16 18:36:01 +09006991 if (pstrWFIDrv == NULL) {
6992 PRINT_ER("driver is null\n");
6993 return -EFAULT;
6994 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006995
6996 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006997 msg.id = HOST_IF_MSG_DEL_BEACON;
Tony Cho143eb952015-09-21 12:16:32 +09006998 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006999 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
7000
Tony Cho143eb952015-09-21 12:16:32 +09007001 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim7dc1d0c2015-09-16 18:36:00 +09007002 if (s32Error)
7003 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007004
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007005 return s32Error;
7006}
7007
7008
7009/**
7010 * @brief host_int_add_station
7011 * @details Setting add station params in message queue
7012 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7013 * @return Error code.
7014 * @author
7015 * @date
7016 * @version 1.0
7017 */
Johnny Kim218dc402015-08-13 13:41:19 +09007018s32 host_int_add_station(tstrWILC_WFIDrv *hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007019{
Leo Kime6e12662015-09-16 18:36:03 +09007020 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007021 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007022 struct host_if_msg msg;
Tony Cho410c2482015-09-21 12:16:35 +09007023 tstrWILC_AddStaParam *pstrAddStationMsg = &msg.body.strAddStaParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007024
7025
Leo Kim24db7132015-09-16 18:36:01 +09007026 if (pstrWFIDrv == NULL) {
7027 PRINT_ER("driver is null\n");
7028 return -EFAULT;
7029 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007030
Tony Cho143eb952015-09-21 12:16:32 +09007031 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007032
7033 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
7034
7035
7036 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007037 msg.id = HOST_IF_MSG_ADD_STATION;
Tony Cho143eb952015-09-21 12:16:32 +09007038 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007039
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007040 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007041 if (pstrAddStationMsg->u8NumRates > 0) {
Glen Leef3052582015-09-10 12:03:04 +09007042 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02007043
Leo Kim7ae43362015-09-16 18:35:59 +09007044 if (!rates)
7045 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007046
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007047 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02007048 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007049 }
7050
7051
Tony Cho143eb952015-09-21 12:16:32 +09007052 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007053 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007054 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007055 return s32Error;
7056}
7057
7058/**
7059 * @brief host_int_del_station
7060 * @details Setting delete station params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007061 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007062 * @return Error code.
7063 * @author
7064 * @date
7065 * @version 1.0
7066 */
Johnny Kim218dc402015-08-13 13:41:19 +09007067s32 host_int_del_station(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8MacAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007068{
Leo Kime6e12662015-09-16 18:36:03 +09007069 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007070 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007071 struct host_if_msg msg;
Tony Cho410c2482015-09-21 12:16:35 +09007072 tstrHostIFDelSta *pstrDelStationMsg = &msg.body.strDelStaParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007073
Leo Kim24db7132015-09-16 18:36:01 +09007074 if (pstrWFIDrv == NULL) {
7075 PRINT_ER("driver is null\n");
7076 return -EFAULT;
7077 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007078
Tony Cho143eb952015-09-21 12:16:32 +09007079 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007080
7081 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
7082
7083
7084
7085 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007086 msg.id = HOST_IF_MSG_DEL_STATION;
Tony Cho143eb952015-09-21 12:16:32 +09007087 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007088
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09007089 if (pu8MacAddr == NULL)
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007090 memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007091 else
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007092 memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007093
Tony Cho143eb952015-09-21 12:16:32 +09007094 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007095 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007096 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007097 return s32Error;
7098}
7099/**
7100 * @brief host_int_del_allstation
7101 * @details Setting del station params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007102 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007103 * @return Error code.
7104 * @author
7105 * @date
7106 * @version 1.0
7107 */
Johnny Kim218dc402015-08-13 13:41:19 +09007108s32 host_int_del_allstation(tstrWILC_WFIDrv *hWFIDrv, u8 pu8MacAddr[][ETH_ALEN])
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007109{
Leo Kime6e12662015-09-16 18:36:03 +09007110 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007111 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007112 struct host_if_msg msg;
Tony Cho410c2482015-09-21 12:16:35 +09007113 tstrHostIFDelAllSta *pstrDelAllStationMsg = &msg.body.strHostIFDelAllSta;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007114 u8 au8Zero_Buff[ETH_ALEN] = {0};
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09007115 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007116 u8 u8AssocNumb = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007117
7118
Leo Kim24db7132015-09-16 18:36:01 +09007119 if (pstrWFIDrv == NULL) {
7120 PRINT_ER("driver is null\n");
7121 return -EFAULT;
7122 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007123
Tony Cho143eb952015-09-21 12:16:32 +09007124 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007125
7126 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
7127
7128 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007129 msg.id = HOST_IF_MSG_DEL_ALL_STA;
Tony Cho143eb952015-09-21 12:16:32 +09007130 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007131
7132 /* Handling situation of deauthenticing all associated stations*/
7133 for (i = 0; i < MAX_NUM_STA; i++) {
7134 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007135 memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007136 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],
7137 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
7138 u8AssocNumb++;
7139 }
7140 }
7141 if (!u8AssocNumb) {
7142 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
7143 return s32Error;
7144 }
7145
7146 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
Tony Cho143eb952015-09-21 12:16:32 +09007147 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007148
7149
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007150 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007151 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007152
Arnd Bergmann83383ea2015-06-01 21:06:43 +02007153 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007154
7155 return s32Error;
7156
7157}
7158
7159/**
7160 * @brief host_int_edit_station
7161 * @details Setting edit station params in message queue
7162 * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
7163 * @return Error code.
7164 * @author
7165 * @date
7166 * @version 1.0
7167 */
Johnny Kim218dc402015-08-13 13:41:19 +09007168s32 host_int_edit_station(tstrWILC_WFIDrv *hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007169{
Leo Kime6e12662015-09-16 18:36:03 +09007170 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007171 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007172 struct host_if_msg msg;
Tony Cho410c2482015-09-21 12:16:35 +09007173 tstrWILC_AddStaParam *pstrAddStationMsg = &msg.body.strAddStaParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007174
Leo Kim24db7132015-09-16 18:36:01 +09007175 if (pstrWFIDrv == NULL) {
7176 PRINT_ER("driver is null\n");
7177 return -EFAULT;
7178 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007179
7180 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
7181
Tony Cho143eb952015-09-21 12:16:32 +09007182 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007183
7184
7185 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007186 msg.id = HOST_IF_MSG_EDIT_STATION;
Tony Cho143eb952015-09-21 12:16:32 +09007187 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007188
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007189 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007190 if (pstrAddStationMsg->u8NumRates > 0) {
Glen Leef3052582015-09-10 12:03:04 +09007191 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02007192
Leo Kim7ae43362015-09-16 18:35:59 +09007193 if (!rates)
7194 return -ENOMEM;
7195
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007196 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02007197 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007198 }
7199
Tony Cho143eb952015-09-21 12:16:32 +09007200 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007201 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007202 PRINT_ER("wilc_mq_send fail\n");
7203
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007204 return s32Error;
7205}
Glen Lee108b3432015-09-16 18:53:20 +09007206
Johnny Kim218dc402015-08-13 13:41:19 +09007207s32 host_int_set_power_mgmt(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32Timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007208{
Leo Kime6e12662015-09-16 18:36:03 +09007209 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007210 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007211 struct host_if_msg msg;
Tony Cho410c2482015-09-21 12:16:35 +09007212 tstrHostIfPowerMgmtParam *pstrPowerMgmtParam = &msg.body.strPowerMgmtparam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007213
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007214 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007215
Leo Kim24db7132015-09-16 18:36:01 +09007216 if (pstrWFIDrv == NULL) {
7217 PRINT_ER("driver is null\n");
7218 return -EFAULT;
7219 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007220
7221 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
7222
Tony Cho143eb952015-09-21 12:16:32 +09007223 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007224
7225
7226 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007227 msg.id = HOST_IF_MSG_POWER_MGMT;
Tony Cho143eb952015-09-21 12:16:32 +09007228 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007229
7230 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
7231 pstrPowerMgmtParam->u32Timeout = u32Timeout;
7232
7233
Tony Cho143eb952015-09-21 12:16:32 +09007234 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007235 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007236 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007237 return s32Error;
7238}
7239
Johnny Kim218dc402015-08-13 13:41:19 +09007240s32 host_int_setup_multicast_filter(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32count)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007241{
Leo Kime6e12662015-09-16 18:36:03 +09007242 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007243
7244 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007245 struct host_if_msg msg;
Tony Cho410c2482015-09-21 12:16:35 +09007246 tstrHostIFSetMulti *pstrMulticastFilterParam = &msg.body.strHostIfSetMulti;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007247
7248
Leo Kim24db7132015-09-16 18:36:01 +09007249 if (pstrWFIDrv == NULL) {
7250 PRINT_ER("driver is null\n");
7251 return -EFAULT;
7252 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007253
7254 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
7255
Tony Cho143eb952015-09-21 12:16:32 +09007256 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007257
7258
7259 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007260 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
Tony Cho143eb952015-09-21 12:16:32 +09007261 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007262
7263 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
7264 pstrMulticastFilterParam->u32count = u32count;
7265
Tony Cho143eb952015-09-21 12:16:32 +09007266 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007267 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007268 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007269 return s32Error;
7270}
7271
7272
7273
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007274#ifdef WILC_PARSE_SCAN_IN_HOST
7275
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007276/**
7277 * @brief host_int_ParseJoinBssParam
7278 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
7279 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7280 * @return
7281 * @author zsalah
7282 * @date
7283 * @version 1.0**/
7284static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
7285{
7286 tstrJoinBssParam *pNewJoinBssParam = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007287 u8 *pu8IEs;
Chaehyun Limd85f5322015-06-11 14:35:54 +09007288 u16 u16IEsLen;
7289 u16 index = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007290 u8 suppRatesNo = 0;
7291 u8 extSuppRatesNo;
Chaehyun Limd85f5322015-06-11 14:35:54 +09007292 u16 jumpOffset;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007293 u8 pcipherCount;
7294 u8 authCount;
7295 u8 pcipherTotalCount = 0;
7296 u8 authTotalCount = 0;
7297 u8 i, j;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007298
7299 pu8IEs = ptstrNetworkInfo->pu8IEs;
7300 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
7301
Glen Leef3052582015-09-10 12:03:04 +09007302 pNewJoinBssParam = kmalloc(sizeof(tstrJoinBssParam), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007303 if (pNewJoinBssParam != NULL) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007304 memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007305 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
7306 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
7307 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007308 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007309 /*for(i=0; i<6;i++)
7310 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007311 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007312 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007313 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
7314 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007315 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
7316 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
7317
7318 /* parse supported rates: */
7319 while (index < u16IEsLen) {
7320 /* supportedRates IE */
7321 if (pu8IEs[index] == SUPP_RATES_IE) {
7322 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
7323 suppRatesNo = pu8IEs[index + 1];
7324 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
7325 index += 2; /* skipping ID and length bytes; */
7326
7327 for (i = 0; i < suppRatesNo; i++) {
7328 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
7329 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
7330 }
7331 index += suppRatesNo;
7332 continue;
7333 }
7334 /* Ext SupportedRates IE */
7335 else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
7336 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
7337 /* checking if no of ext. supp and supp rates < max limit */
7338 extSuppRatesNo = pu8IEs[index + 1];
7339 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
7340 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
7341 else
7342 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
7343 index += 2;
7344 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
7345 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
7346 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
7347 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
7348 }
7349 index += extSuppRatesNo;
7350 continue;
7351 }
7352 /* HT Cap. IE */
7353 else if (pu8IEs[index] == HT_CAPABILITY_IE) {
7354 /* if IE found set the flag */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09007355 pNewJoinBssParam->ht_capable = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007356 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7357 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
7358 continue;
7359 } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
7360 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
7361 (pu8IEs[index + 4] == 0xF2) && /* OUI */
7362 (pu8IEs[index + 5] == 0x02) && /* OUI Type */
7363 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
7364 (pu8IEs[index + 7] == 0x01)) {
7365 /* Presence of WMM Info/Param element indicates WMM capability */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09007366 pNewJoinBssParam->wmm_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007367
7368 /* Check if Bit 7 is set indicating U-APSD capability */
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007369 if (pu8IEs[index + 8] & (1 << 7))
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09007370 pNewJoinBssParam->uapsd_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007371 index += pu8IEs[index + 1] + 2;
7372 continue;
7373 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007374 else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
7375 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
7376 (pu8IEs[index + 4] == 0x9a) && /* OUI */
7377 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
Chaehyun Limd85f5322015-06-11 14:35:54 +09007378 u16 u16P2P_count;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02007379
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007380 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
7381 pNewJoinBssParam->u8NoaEnbaled = 1;
7382 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
7383
7384 /* Check if Bit 7 is set indicating Opss capability */
7385 if (pu8IEs[index + 10] & (1 << 7)) {
7386 pNewJoinBssParam->u8OppEnable = 1;
7387 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
7388 } else
7389 pNewJoinBssParam->u8OppEnable = 0;
7390 /* HOSTINF_DBG */
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007391 PRINT_D(GENERIC_DBG, "P2P Dump\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007392 for (i = 0; i < pu8IEs[index + 7]; i++)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007393 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007394
7395 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
7396 u16P2P_count = index + 12;
7397
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007398 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007399 u16P2P_count += 4;
7400
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007401 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007402 u16P2P_count += 4;
7403
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007404 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007405
7406 index += pu8IEs[index + 1] + 2;
7407 continue;
7408
7409 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007410 else if ((pu8IEs[index] == RSN_IE) ||
7411 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
7412 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
7413 (pu8IEs[index + 5] == 0x01))) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09007414 u16 rsnIndex = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007415 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
7416 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
7417 * {
7418 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
7419 * }*/
7420 if (pu8IEs[rsnIndex] == RSN_IE) {
7421 pNewJoinBssParam->mode_802_11i = 2;
7422 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
7423 } else { /* check if rsn was previously parsed */
7424 if (pNewJoinBssParam->mode_802_11i == 0)
7425 pNewJoinBssParam->mode_802_11i = 1;
7426 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
7427 rsnIndex += 4;
7428 }
7429 rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
7430 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
7431 rsnIndex++;
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007432 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007433 /* initialize policies with invalid values */
7434
7435 jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
7436
7437 /*parsing pairwise cipher*/
7438
7439 /* saving 3 pcipher max. */
7440 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7441 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7442
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007443 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007444 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
7445 /* each count corresponds to 4 bytes, only last byte is saved */
7446 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7447 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
7448 }
7449 pcipherTotalCount += pcipherCount;
7450 rsnIndex += jumpOffset;
7451
7452 jumpOffset = pu8IEs[rsnIndex] * 4;
7453
7454 /*parsing AKM suite (auth_policy)*/
7455 /* saving 3 auth policies max. */
7456 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7457 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7458
7459 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
7460 /* each count corresponds to 4 bytes, only last byte is saved */
7461 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7462 }
7463 authTotalCount += authCount;
7464 rsnIndex += jumpOffset;
7465 /*pasring rsn cap. only if rsn IE*/
7466 if (pu8IEs[index] == RSN_IE) {
7467 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
7468 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
7469 rsnIndex += 2;
7470 }
Abdul Hussainf717c0eb2015-06-16 09:49:49 +00007471 pNewJoinBssParam->rsn_found = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007472 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7473 continue;
7474 } else
7475 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7476
7477 }
7478
7479
7480 }
7481
7482 return (void *)pNewJoinBssParam;
7483
7484}
7485
7486void host_int_freeJoinParams(void *pJoinParams)
7487{
7488 if ((tstrJoinBssParam *)pJoinParams != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09007489 kfree((tstrJoinBssParam *)pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007490 else
7491 PRINT_ER("Unable to FREE null pointer\n");
7492}
7493#endif /*WILC_PARSE_SCAN_IN_HOST*/
7494
7495
7496/**
7497 * @brief host_int_addBASession
7498 * @details Open a block Ack session with the given parameters
7499 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7500 * @return
7501 * @author anoureldin
7502 * @date
7503 * @version 1.0**/
7504
Johnny Kim2b05df52015-08-13 13:41:21 +09007505static int host_int_addBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID, short int BufferSize,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007506 short int SessionTimeout, void *drvHandler)
7507{
Leo Kime6e12662015-09-16 18:36:03 +09007508 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007509 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007510 struct host_if_msg msg;
Tony Cho410c2482015-09-21 12:16:35 +09007511 tstrHostIfBASessionInfo *pBASessionInfo = &msg.body.strHostIfBASessionInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007512
Leo Kim24db7132015-09-16 18:36:01 +09007513 if (pstrWFIDrv == NULL) {
7514 PRINT_ER("driver is null\n");
7515 return -EFAULT;
7516 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007517
Tony Cho143eb952015-09-21 12:16:32 +09007518 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007519
7520 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007521 msg.id = HOST_IF_MSG_ADD_BA_SESSION;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007522
7523 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7524 pBASessionInfo->u8Ted = TID;
7525 pBASessionInfo->u16BufferSize = BufferSize;
7526 pBASessionInfo->u16SessionTimeout = SessionTimeout;
Tony Cho143eb952015-09-21 12:16:32 +09007527 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007528
Tony Cho143eb952015-09-21 12:16:32 +09007529 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007530 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007531 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007532
7533 return s32Error;
7534}
7535
7536
Johnny Kim218dc402015-08-13 13:41:19 +09007537s32 host_int_delBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007538{
Leo Kime6e12662015-09-16 18:36:03 +09007539 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007540 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007541 struct host_if_msg msg;
Tony Cho410c2482015-09-21 12:16:35 +09007542 tstrHostIfBASessionInfo *pBASessionInfo = &msg.body.strHostIfBASessionInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007543
Leo Kim24db7132015-09-16 18:36:01 +09007544 if (pstrWFIDrv == NULL) {
7545 PRINT_ER("driver is null\n");
7546 return -EFAULT;
7547 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007548
Tony Cho143eb952015-09-21 12:16:32 +09007549 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007550
7551 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007552 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007553
7554 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7555 pBASessionInfo->u8Ted = TID;
Tony Cho143eb952015-09-21 12:16:32 +09007556 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007557
Tony Cho143eb952015-09-21 12:16:32 +09007558 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007559 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007560 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007561
Arnd Bergmann83383ea2015-06-01 21:06:43 +02007562 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007563
7564 return s32Error;
7565}
7566
Johnny Kim218dc402015-08-13 13:41:19 +09007567s32 host_int_del_All_Rx_BASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007568{
Leo Kime6e12662015-09-16 18:36:03 +09007569 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007570 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007571 struct host_if_msg msg;
Tony Cho410c2482015-09-21 12:16:35 +09007572 tstrHostIfBASessionInfo *pBASessionInfo = &msg.body.strHostIfBASessionInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007573
Leo Kim24db7132015-09-16 18:36:01 +09007574 if (pstrWFIDrv == NULL) {
7575 PRINT_ER("driver is null\n");
7576 return -EFAULT;
7577 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007578
Tony Cho143eb952015-09-21 12:16:32 +09007579 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007580
7581 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007582 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007583
7584 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7585 pBASessionInfo->u8Ted = TID;
Tony Cho143eb952015-09-21 12:16:32 +09007586 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007587
Tony Cho143eb952015-09-21 12:16:32 +09007588 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007589 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007590 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007591
Arnd Bergmann83383ea2015-06-01 21:06:43 +02007592 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007593
7594 return s32Error;
7595}
7596
7597/**
7598 * @brief host_int_setup_ipaddress
7599 * @details setup IP in firmware
7600 * @param[in] Handle to wifi driver
7601 * @return Error code.
7602 * @author Abdelrahman Sobhy
7603 * @date
7604 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09007605s32 host_int_setup_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007606{
Leo Kime6e12662015-09-16 18:36:03 +09007607 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007608 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007609 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007610
7611 /* TODO: Enable This feature on softap firmware */
7612 return 0;
7613
Leo Kim24db7132015-09-16 18:36:01 +09007614 if (pstrWFIDrv == NULL) {
7615 PRINT_ER("driver is null\n");
7616 return -EFAULT;
7617 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007618
Tony Cho143eb952015-09-21 12:16:32 +09007619 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007620
7621 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007622 msg.id = HOST_IF_MSG_SET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007623
Tony Cho410c2482015-09-21 12:16:35 +09007624 msg.body.strHostIfSetIP.au8IPAddr = u16ipadd;
Tony Cho143eb952015-09-21 12:16:32 +09007625 msg.drvHandler = hWFIDrv;
Tony Cho410c2482015-09-21 12:16:35 +09007626 msg.body.strHostIfSetIP.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007627
Tony Cho143eb952015-09-21 12:16:32 +09007628 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007629 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007630 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007631
7632 return s32Error;
7633
7634
7635}
7636
7637/**
7638 * @brief host_int_get_ipaddress
7639 * @details Get IP from firmware
7640 * @param[in] Handle to wifi driver
7641 * @return Error code.
7642 * @author Abdelrahman Sobhy
7643 * @date
7644 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09007645s32 host_int_get_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007646{
Leo Kime6e12662015-09-16 18:36:03 +09007647 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007648 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007649 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007650
Leo Kim24db7132015-09-16 18:36:01 +09007651 if (pstrWFIDrv == NULL) {
7652 PRINT_ER("driver is null\n");
7653 return -EFAULT;
7654 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007655
Tony Cho143eb952015-09-21 12:16:32 +09007656 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007657
7658 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007659 msg.id = HOST_IF_MSG_GET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007660
Tony Cho410c2482015-09-21 12:16:35 +09007661 msg.body.strHostIfSetIP.au8IPAddr = u16ipadd;
Tony Cho143eb952015-09-21 12:16:32 +09007662 msg.drvHandler = hWFIDrv;
Tony Cho410c2482015-09-21 12:16:35 +09007663 msg.body.strHostIfSetIP.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007664
Tony Cho143eb952015-09-21 12:16:32 +09007665 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007666 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007667 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007668
7669 return s32Error;
7670
7671
7672}