blob: c1fc145cbdea7f2533933ee0c6e4149a055afeba [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/*!
Tony Cho361ff842015-09-21 12:16:41 +090068 * @struct cfg_param_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +090069 * @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 */
Tony Cho361ff842015-09-21 12:16:41 +090077struct cfg_param_attr {
Johnny Kimc5c77ba2015-05-11 14:30:56 +090078 tstrCfgParamVal pstrCfgParamVal;
Tony Cho361ff842015-09-21 12:16:41 +090079};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090080
81/*!
82 * @struct tstrHostIFwpaAttr
83 * @brief Structure to hold Host IF Scan Attributes
84 * @details
85 * @todo
86 * @sa
87 * @author Mai Daftedar
88 * @date 25 March 2012
89 * @version 1.0
90 */
91typedef struct _tstrHostIFwpaAttr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090092 u8 *pu8key;
93 const u8 *pu8macaddr;
94 u8 *pu8seq;
95 u8 u8seqlen;
96 u8 u8keyidx;
97 u8 u8Keylen;
98 u8 u8Ciphermode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090099} tstrHostIFwpaAttr;
100
101
102/*!
103 * @struct tstrHostIFwepAttr
104 * @brief Structure to hold Host IF Scan Attributes
105 * @details
106 * @todo
107 * @sa
108 * @author Mai Daftedar
109 * @date 25 March 2012
110 * @version 1.0
111 */
112typedef struct _tstrHostIFwepAttr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900113 u8 *pu8WepKey;
114 u8 u8WepKeylen;
115 u8 u8Wepidx;
116 u8 u8mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900117 AUTHTYPE_T tenuAuth_type;
118
119} tstrHostIFwepAttr;
120
121/*!
122 * @struct tuniHostIFkeyAttr
123 * @brief Structure to hold Host IF Scan Attributes
124 * @details
125 * @todo
126 * @sa
127 * @author Mai Daftedar
128 * @date 25 March 2012
129 * @version 1.0
130 */
131typedef union _tuniHostIFkeyAttr {
132 tstrHostIFwepAttr strHostIFwepAttr;
133 tstrHostIFwpaAttr strHostIFwpaAttr;
134 tstrHostIFpmkidAttr strHostIFpmkidAttr;
135} tuniHostIFkeyAttr;
136
137/*!
Tony Choc98387a2015-09-21 12:16:40 +0900138 * @struct key_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900139 * @brief Structure to hold Host IF Scan Attributes
140 * @details
141 * @todo
142 * @sa
143 * @author Mai Daftedar
144 * @date 25 March 2012
145 * @version 1.0
146 */
Tony Choc98387a2015-09-21 12:16:40 +0900147struct key_attr {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900148 tenuKeyType enuKeyType;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900149 u8 u8KeyAction;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900150 tuniHostIFkeyAttr uniHostIFkeyAttr;
Tony Choc98387a2015-09-21 12:16:40 +0900151};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900152
153
154
155
156/*!
Tony Choc476feb2015-09-21 12:16:36 +0900157 * @struct scan_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900158 * @brief Structure to hold Host IF Scan Attributes
159 * @details
160 * @todo
161 * @sa
162 * @author Mostafa Abu Bakr
163 * @date 25 March 2012
164 * @version 1.0
165 */
Tony Choc476feb2015-09-21 12:16:36 +0900166struct scan_attr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900167 u8 u8ScanSource;
168 u8 u8ScanType;
169 u8 *pu8ChnlFreqList;
170 u8 u8ChnlListLen;
171 u8 *pu8IEs;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900172 size_t IEsLen;
173 tWILCpfScanResult pfScanResult;
174 void *pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900175 tstrHiddenNetwork strHiddenNetwork;
Tony Choc476feb2015-09-21 12:16:36 +0900176};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900177
178/*!
Tony Cho120ae592015-09-21 12:16:37 +0900179 * @struct connect_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900180 * @brief Structure to hold Host IF Connect Attributes
181 * @details
182 * @todo
183 * @sa
184 * @author Mostafa Abu Bakr
185 * @date 25 March 2012
186 * @version 1.0
187 */
Tony Cho120ae592015-09-21 12:16:37 +0900188struct connect_attr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900189 u8 *pu8bssid;
190 u8 *pu8ssid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900191 size_t ssidLen;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900192 u8 *pu8IEs;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900193 size_t IEsLen;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900194 u8 u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900195 tWILCpfConnectResult pfConnectResult;
196 void *pvUserArg;
197 AUTHTYPE_T tenuAuth_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900198 u8 u8channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900199 void *pJoinParams;
Tony Cho120ae592015-09-21 12:16:37 +0900200};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900201
202/*!
Tony Chof23a9ea2015-09-21 12:16:39 +0900203 * @struct rcvd_async_info
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900204 * @brief Structure to hold Received General Asynchronous info
205 * @details
206 * @todo
207 * @sa
208 * @author Mostafa Abu Bakr
209 * @date 25 March 2012
210 * @version 1.0
211 */
Tony Chof23a9ea2015-09-21 12:16:39 +0900212struct rcvd_async_info {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900213 u8 *pu8Buffer;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900214 u32 u32Length;
Tony Chof23a9ea2015-09-21 12:16:39 +0900215};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900216
217/*!
Tony Cho326b3232015-09-21 12:16:42 +0900218 * @struct set_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900219 * @brief Set Channel message body
220 * @details
221 * @todo
222 * @sa
223 * @author Mai Daftedar
224 * @date 25 March 2012
225 * @version 1.0
226 */
Tony Cho326b3232015-09-21 12:16:42 +0900227struct set_channel {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900228 u8 u8SetChan;
Tony Cho326b3232015-09-21 12:16:42 +0900229};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900230
231/*!
Tony Cho29f84002015-09-21 12:16:43 +0900232 * @struct get_channel
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900233 * @brief Get Channel message body
234 * @details
235 * @todo
236 * @sa
237 * @author Mai Daftedar
238 * @date 01 Jule 2012
239 * @version 1.0
240 */
Tony Cho29f84002015-09-21 12:16:43 +0900241struct get_channel {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900242 u8 u8GetChan;
Tony Cho29f84002015-09-21 12:16:43 +0900243};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900244
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900245/*!
246 * @struct tstrScanComplete
247 * @brief hold received Async. Scan Complete message body
248 * @details
249 * @todo
250 * @sa
251 * @author zsalah
252 * @date 25 March 2012
253 * @version 1.0
254 */
255/*typedef struct _tstrScanComplete
256 * {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900257 * u8* pu8Buffer;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900258 * u32 u32Length;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900259 * } tstrScanComplete;*/
260
261/*!
Tony Cho902362b2015-09-21 12:16:44 +0900262 * @struct set_beacon
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900263 * @brief Set Beacon message body
264 * @details
265 * @todo
266 * @sa
267 * @author Adham Abozaeid
268 * @date 10 July 2012
269 * @version 1.0
270 */
Tony Cho902362b2015-09-21 12:16:44 +0900271struct set_beacon {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900272 u32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */
273 u32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900274 * (including the current frame) appear before the next DTIM */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900275 u32 u32HeadLen; /*!< Length of the head buffer in bytes */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900276 u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900277 * from the beacon's start till the TIM element, NOT including the TIM */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900278 u32 u32TailLen; /*!< Length of the tail buffer in bytes */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900279 u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900280 * after the TIM inormation element */
Tony Cho902362b2015-09-21 12:16:44 +0900281};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900282
283
284
285/*!
Tony Chod0227fc2015-09-21 12:16:45 +0900286 * @struct del_beacon
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900287 * @brief Del Beacon message body
288 * @details
289 * @todo
290 * @sa
291 * @author Adham Abozaeid
292 * @date 15 July 2012
293 * @version 1.0
294 */
Tony Chod0227fc2015-09-21 12:16:45 +0900295struct del_beacon {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900296 u8 u8dummy;
Tony Chod0227fc2015-09-21 12:16:45 +0900297};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900298
299/*!
Tony Cho641210a2015-09-21 12:16:52 +0900300 * @struct set_multicast
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900301 * @brief set Multicast filter Address
302 * @details
303 * @todo
304 * @sa
305 * @author Abdelrahman Sobhy
306 * @date 30 August 2013
307 * @version 1.0 Description
308 */
309
Tony Cho641210a2015-09-21 12:16:52 +0900310struct set_multicast {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900311 bool bIsEnabled;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900312 u32 u32count;
Tony Cho641210a2015-09-21 12:16:52 +0900313};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900314
315/*!
316 * @struct tstrHostIFDelAllSta
317 * @brief Deauth station message body
318 * @details
319 * @todo
320 * @sa
321 * @author Mai Daftedar
322 * @date 09 April 2014
323 * @version 1.0 Description
324 */
325
326typedef struct {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900327 u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN];
328 u8 u8Num_AssocSta;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900329} tstrHostIFDelAllSta;
330
331/*!
332 * @struct tstrHostIFDelSta
333 * @brief Delete station message body
334 * @details
335 * @todo
336 * @sa
337 * @author Adham Abozaeid
338 * @date 15 July 2012
339 * @version 1.0 Description
340 */
341
342typedef struct {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900343 u8 au8MacAddr[ETH_ALEN];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900344} tstrHostIFDelSta;
345
346/*!
Tony Cho52581932015-09-21 12:16:47 +0900347 * @struct timer_cb
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900348 * @brief Timer callback message body
349 * @details
350 * @todo
351 * @sa
352 * @author Mostafa Abu Bakr
353 * @date 25 March 2012
354 * @version 1.0
355 */
Tony Cho52581932015-09-21 12:16:47 +0900356struct timer_cb {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900357 void *pvUsrArg; /*!< Private data passed at timer start */
Tony Cho52581932015-09-21 12:16:47 +0900358};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900359
360/*!
Tony Cho5a008f12015-09-21 12:16:48 +0900361 * @struct power_mgmt_param
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900362 * @brief Power management message body
363 * @details
364 * @todo
365 * @sa
366 * @author Adham Abozaeid
367 * @date 24 November 2012
368 * @version 1.0
369 */
Tony Cho5a008f12015-09-21 12:16:48 +0900370struct power_mgmt_param {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900371
Dean Lee72ed4dc2015-06-12 14:11:44 +0900372 bool bIsEnabled;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900373 u32 u32Timeout;
Tony Cho5a008f12015-09-21 12:16:48 +0900374};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900375
376/*!
Tony Cho15191ea2015-09-21 12:16:50 +0900377 * @struct set_ip_addr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900378 * @brief set IP Address message body
379 * @details
380 * @todo
381 * @sa
382 * @author Abdelrahman Sobhy
383 * @date 30 August 2013
384 * @version 1.0 Description
385 */
Tony Cho15191ea2015-09-21 12:16:50 +0900386struct set_ip_addr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900387 u8 *au8IPAddr;
388 u8 idx;
Tony Cho15191ea2015-09-21 12:16:50 +0900389};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900390
391/*!
Tony Cho3d1eac02015-09-21 12:16:49 +0900392 * @struct sta_inactive_t
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900393 * @brief Get station message body
394 * @details
395 * @todo
396 * @sa
397 * @author Mai Daftedar
398 * @date 16 April 2013
399 * @version 1.0
400 */
Tony Cho3d1eac02015-09-21 12:16:49 +0900401struct sta_inactive_t {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900402 u8 mac[6];
Tony Cho3d1eac02015-09-21 12:16:49 +0900403};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900404/**/
405/*!
Tony Chodfc76632015-09-21 12:16:34 +0900406 * @union message_body
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900407 * @brief Message body for the Host Interface message_q
408 * @details
409 * @todo
410 * @sa
411 * @author Mostafa Abu Bakr
412 * @date 25 March 2012
413 * @version 1.0
414 */
Tony Chodfc76632015-09-21 12:16:34 +0900415union message_body {
Tony Choc476feb2015-09-21 12:16:36 +0900416 struct scan_attr strHostIFscanAttr; /*!< Host IF Scan Request Attributes message body */
Tony Cho120ae592015-09-21 12:16:37 +0900417 struct connect_attr strHostIFconnectAttr; /*!< Host IF Connect Request Attributes message body */
Tony Cho3bbd59f2015-09-21 12:16:38 +0900418 struct rcvd_net_info strRcvdNetworkInfo; /*!< Received Asynchronous Network Info message body */
Tony Chof23a9ea2015-09-21 12:16:39 +0900419 struct rcvd_async_info strRcvdGnrlAsyncInfo; /*!< Received General Asynchronous Info message body */
Tony Choc98387a2015-09-21 12:16:40 +0900420 struct key_attr strHostIFkeyAttr; /*!<>*/
Tony Cho361ff842015-09-21 12:16:41 +0900421 struct cfg_param_attr strHostIFCfgParamAttr; /*! <CFG Parameter message Body> */
Tony Cho326b3232015-09-21 12:16:42 +0900422 struct set_channel strHostIFSetChan;
Tony Cho29f84002015-09-21 12:16:43 +0900423 struct get_channel strHostIFGetChan;
Tony Cho902362b2015-09-21 12:16:44 +0900424 struct set_beacon strHostIFSetBeacon; /*!< Set beacon message body */
Tony Chod0227fc2015-09-21 12:16:45 +0900425 struct del_beacon strHostIFDelBeacon; /*!< Del beacon message body */
Tony Cho6a89ba92015-09-21 12:16:46 +0900426 struct add_sta_param strAddStaParam; /*!< Add station message body */
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900427 tstrHostIFDelSta strDelStaParam; /*!< Del Station message body */
Tony Cho6a89ba92015-09-21 12:16:46 +0900428 struct add_sta_param strEditStaParam; /*!< Edit station message body */
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900429 /* tstrScanComplete strScanComplete; / *Received Async. Scan Complete message body* / */
Tony Cho52581932015-09-21 12:16:47 +0900430 struct timer_cb strTimerCb; /*!< Timer callback message body */
Tony Cho5a008f12015-09-21 12:16:48 +0900431 struct power_mgmt_param strPowerMgmtparam; /*!< Power Management message body */
Tony Cho3d1eac02015-09-21 12:16:49 +0900432 struct sta_inactive_t strHostIfStaInactiveT;
Tony Cho15191ea2015-09-21 12:16:50 +0900433 struct set_ip_addr strHostIfSetIP;
Tony Cho127f9d92015-09-21 12:16:51 +0900434 struct drv_handler strHostIfSetDrvHandler;
Tony Cho641210a2015-09-21 12:16:52 +0900435 struct set_multicast strHostIfSetMulti;
Tony Cho801bee52015-09-21 12:16:53 +0900436 struct op_mode strHostIfSetOperationMode;
Tony Chob7611a82015-09-21 12:16:54 +0900437 struct set_mac_addr strHostIfSetMacAddress;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900438 tstrHostIfGetMacAddress strHostIfGetMacAddress;
439 tstrHostIfBASessionInfo strHostIfBASessionInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900440 tstrHostIfRemainOnChan strHostIfRemainOnChan;
441 tstrHostIfRegisterFrame strHostIfRegisterFrame;
Dean Lee576917a2015-06-15 11:58:57 +0900442 char *pUserData;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900443 tstrHostIFDelAllSta strHostIFDelAllSta;
Tony Chodfc76632015-09-21 12:16:34 +0900444};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900445
446/*!
Tony Cho3a8c41b2015-09-18 18:11:04 +0900447 * @struct struct host_if_msg
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900448 * @brief Host Interface message
449 * @details
450 * @todo
451 * @sa
452 * @author Mostafa Abu Bakr
453 * @date 25 March 2012
454 * @version 1.0
455 */
Tony Cho3a8c41b2015-09-18 18:11:04 +0900456struct host_if_msg {
Tony Choa9f812a2015-09-21 12:16:33 +0900457 u16 id; /*!< Message ID */
Tony Cho410c2482015-09-21 12:16:35 +0900458 union message_body body; /*!< Message body */
Johnny Kim11f58c82015-08-13 13:41:20 +0900459 tstrWILC_WFIDrv *drvHandler;
Tony Cho3a8c41b2015-09-18 18:11:04 +0900460};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900461
462#ifdef CONNECT_DIRECT
463typedef struct _tstrWidJoinReqExt {
Dean Lee576917a2015-06-15 11:58:57 +0900464 char SSID[MAX_SSID_LEN];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900465 u8 u8channel;
466 u8 BSSID[6];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900467} tstrWidJoinReqExt;
468#endif
469
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900470#ifdef WILC_PARSE_SCAN_IN_HOST
471/*Struct containg joinParam of each AP*/
472typedef struct _tstrJoinBssParam {
473 BSSTYPE_T bss_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900474 u8 dtim_period;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900475 u16 beacon_period;
476 u16 cap_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900477 u8 au8bssid[6];
Dean Lee576917a2015-06-15 11:58:57 +0900478 char ssid[MAX_SSID_LEN];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900479 u8 ssidLen;
480 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
481 u8 ht_capable;
482 u8 wmm_cap;
483 u8 uapsd_cap;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900484 bool rsn_found;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900485 u8 rsn_grp_policy;
486 u8 mode_802_11i;
487 u8 rsn_pcip_policy[3];
488 u8 rsn_auth_policy[3];
489 u8 rsn_cap[2];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900490 struct _tstrJoinParam *nextJoinBss;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900491 u32 tsf;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900492 u8 u8NoaEnbaled;
493 u8 u8OppEnable;
494 u8 u8CtWindow;
495 u8 u8Count;
496 u8 u8Index;
497 u8 au8Duration[4];
498 u8 au8Interval[4];
499 u8 au8StartTime[4];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900500} tstrJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900501/*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
502typedef struct _tstrBssTable {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900503 u8 u8noBssEntries;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900504 tstrJoinBssParam *head;
505 tstrJoinBssParam *tail;
506} tstrBssTable;
507#endif /*WILC_PARSE_SCAN_IN_HOST*/
508
509typedef enum {
510 SCAN_TIMER = 0,
511 CONNECT_TIMER = 1,
512 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
513} tenuScanConnTimer;
514
515/*****************************************************************************/
516/* */
517/* Global Variabls */
518/* */
519/*****************************************************************************/
Johnny Kimd42ab082015-08-20 16:32:52 +0900520/* Zero is not used, because a zero ID means termination */
521static tstrWILC_WFIDrv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
Daniel Machon6fdb3022015-07-06 19:48:04 +0200522tstrWILC_WFIDrv *terminated_handle;
523tstrWILC_WFIDrv *gWFiDrvHandle;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900524#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
Dean Lee72ed4dc2015-06-12 14:11:44 +0900525bool g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900526#endif
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900527u8 P2P_LISTEN_STATE;
Arnd Bergmann1999bd52015-05-29 22:52:14 +0200528static struct task_struct *HostIFthreadHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900529static WILC_MsgQueueHandle gMsgQHostIF;
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200530static struct semaphore hSemHostIFthrdEnd;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900531
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200532struct semaphore hSemDeinitDrvHandle;
533static struct semaphore hWaitResponse;
534struct semaphore hSemHostIntDeinit;
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -0700535struct timer_list g_hPeriodicRSSI;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900536
537
538
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900539u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900540
541#ifndef CONNECT_DIRECT
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900542static u8 gapu8RcvdSurveyResults[2][MAX_SURVEY_RESULT_FRAG_SIZE];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900543#endif
544
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900545static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900546
Dean Lee72ed4dc2015-06-12 14:11:44 +0900547bool gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900548
Chaehyun Limca356ad2015-06-11 14:35:57 +0900549static s8 gs8Rssi;
550static s8 gs8lnkspd;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900551static u8 gu8Chnl;
552static u8 gs8SetIP[2][4];
553static u8 gs8GetIP[2][4];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900554static u32 gu32InactiveTime;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900555static u8 gu8DelBcn;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900556static u32 gu32WidConnRstHack;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900557
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900558u8 *gu8FlushedJoinReq;
559u8 *gu8FlushedInfoElemAsoc;
560u8 gu8Flushed11iMode;
561u8 gu8FlushedAuthType;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900562u32 gu32FlushedJoinReqSize;
563u32 gu32FlushedInfoElemAsocSize;
Johnny Kim8a625ca2015-08-20 16:32:50 +0900564tstrWILC_WFIDrv *gu8FlushedJoinReqDrvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900565#define REAL_JOIN_REQ 0
566#define FLUSHED_JOIN_REQ 1
567#define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
568
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900569#ifdef WILC_PARSE_SCAN_IN_HOST
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900570static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
571#endif /*WILC_PARSE_SCAN_IN_HOST*/
572
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900573extern void chip_sleep_manually(u32 u32SleepTime);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900574extern int linux_wlan_get_num_conn_ifcs(void);
575
Johnny Kimd42ab082015-08-20 16:32:52 +0900576static int add_handler_in_list(tstrWILC_WFIDrv *handler)
577{
578 int i;
579
580 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
581 if (!wfidrv_list[i]) {
582 wfidrv_list[i] = handler;
583 return 0;
584 }
585 }
586
587 return -ENOBUFS;
588}
589
590static int remove_handler_in_list(tstrWILC_WFIDrv *handler)
591{
592 int i;
593
594 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
595 if (wfidrv_list[i] == handler) {
596 wfidrv_list[i] = NULL;
597 return 0;
598 }
599 }
600
601 return -EINVAL;
602}
603
604static int get_id_from_handler(tstrWILC_WFIDrv *handler)
605{
606 int i;
607
608 if (!handler)
609 return 0;
610
611 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
612 if (wfidrv_list[i] == handler)
613 return i;
614 }
615
616 return 0;
617}
618
619static tstrWILC_WFIDrv *get_handler_from_id(int id)
620{
Dan Carpenter6ae9ac02015-09-15 09:54:33 +0300621 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
Johnny Kimd42ab082015-08-20 16:32:52 +0900622 return NULL;
623 return wfidrv_list[id];
624}
625
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900626/**
627 * @brief Handle_SetChannel
628 * @details Sending config packet to firmware to set channel
Tony Cho326b3232015-09-21 12:16:42 +0900629 * @param[in] struct set_channel *pstrHostIFSetChan
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900630 * @return Error code.
631 * @author
632 * @date
633 * @version 1.0
634 */
Tony Cho326b3232015-09-21 12:16:42 +0900635static s32 Handle_SetChannel(tstrWILC_WFIDrv *drvHandler,
636 struct set_channel *pstrHostIFSetChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900637{
638
Leo Kime6e12662015-09-16 18:36:03 +0900639 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900640 tstrWID strWID;
641 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
642
643 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900644 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900645 strWID.enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900646 strWID.ps8WidVal = (char *)&(pstrHostIFSetChan->u8SetChan);
647 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900648
649 PRINT_D(HOSTINF_DBG, "Setting channel\n");
650 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +0900651 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
652 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900653 if (s32Error) {
654 PRINT_ER("Failed to set channel\n");
Leo Kim24db7132015-09-16 18:36:01 +0900655 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900656 }
657
658 return s32Error;
659}
660/**
661 * @brief Handle_SetWfiDrvHandler
662 * @details Sending config packet to firmware to set driver handler
Tony Cho127f9d92015-09-21 12:16:51 +0900663 * @param[in] void * drvHandler,
664 * struct drv_handler *pstrHostIfSetDrvHandler
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900665 * @return Error code.
666 * @author
667 * @date
668 * @version 1.0
669 */
Johnny Kim53a84402015-08-20 16:32:51 +0900670static s32 Handle_SetWfiDrvHandler(tstrWILC_WFIDrv *drvHandler,
Tony Cho127f9d92015-09-21 12:16:51 +0900671 struct drv_handler *pstrHostIfSetDrvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900672{
673
Leo Kime6e12662015-09-16 18:36:03 +0900674 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900675 tstrWID strWID;
Johnny Kim53a84402015-08-20 16:32:51 +0900676 tstrWILC_WFIDrv *pstrWFIDrv = drvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900677
678
679 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900680 strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900681 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900682 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900683 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900684
685 /*Sending Cfg*/
686
Johnny Kimd42ab082015-08-20 16:32:52 +0900687 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
688 pstrHostIfSetDrvHandler->u32Address);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900689
Johnny Kim53a84402015-08-20 16:32:51 +0900690 if (pstrWFIDrv == NULL)
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200691 up(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900692
693
694 if (s32Error) {
695 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900696 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900697 }
698
699 return s32Error;
700}
701
702/**
703 * @brief Handle_SetWfiAPDrvHandler
704 * @details Sending config packet to firmware to set driver handler
705 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
706 * @return Error code.
707 * @author
708 * @date
709 * @version 1.0
710 */
Tony Cho801bee52015-09-21 12:16:53 +0900711static s32 Handle_SetOperationMode(tstrWILC_WFIDrv *drvHandler,
712 struct op_mode *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 */
Tony Chob7611a82015-09-21 12:16:54 +0900849static s32 Handle_SetMacAddress(tstrWILC_WFIDrv *drvHandler,
850 struct set_mac_addr *pstrHostIfSetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900851{
852
Leo Kime6e12662015-09-16 18:36:03 +0900853 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900854 tstrWID strWID;
855 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Glen Leef3052582015-09-10 12:03:04 +0900856 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +0200857
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900858 if (mac_buf == NULL) {
859 PRINT_ER("No buffer to send mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +0900860 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900861 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900862 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900863
864 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900865 strWID.u16WIDid = (u16)WID_MAC_ADDR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900866 strWID.enuWIDtype = WID_STR;
867 strWID.ps8WidVal = mac_buf;
868 strWID.s32ValueSize = ETH_ALEN;
Alexander Kuleshov310a28f2015-09-04 00:48:14 +0600869 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900870 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +0900871 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
872 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900873 if (s32Error) {
874 PRINT_ER("Failed to set mac address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900875 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900876 }
877
Chaehyun Lim49188af2015-08-11 10:32:41 +0900878 kfree(mac_buf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900879 return s32Error;
880}
881
882
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900883/**
884 * @brief Handle_GetMacAddress
885 * @details Getting mac address
886 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
887 * @return Error code.
888 * @author Amr Abdel-Moghny
889 * @date JAN 2013
890 * @version 8.0
891 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900892static s32 Handle_GetMacAddress(tstrWILC_WFIDrv *drvHandler, tstrHostIfGetMacAddress *pstrHostIfGetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900893{
894
Leo Kime6e12662015-09-16 18:36:03 +0900895 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900896 tstrWID strWID;
897
898 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900899 strWID.u16WIDid = (u16)WID_MAC_ADDR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900900 strWID.enuWIDtype = WID_STR;
901 strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress;
902 strWID.s32ValueSize = ETH_ALEN;
903
904 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +0900905 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, false,
906 get_id_from_handler(drvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900907 if (s32Error) {
908 PRINT_ER("Failed to get mac address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900909 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900910 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200911 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900912
913 return s32Error;
914}
915
916
917/**
918 * @brief Handle_CfgParam
919 * @details Sending config packet to firmware to set CFG params
Tony Cho361ff842015-09-21 12:16:41 +0900920 * @param[in] struct cfg_param_attr *strHostIFCfgParamAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900921 * @return Error code.
922 * @author
923 * @date
924 * @version 1.0
925 */
Tony Cho361ff842015-09-21 12:16:41 +0900926static s32 Handle_CfgParam(tstrWILC_WFIDrv *drvHandler,
927 struct cfg_param_attr *strHostIFCfgParamAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900928{
Leo Kime6e12662015-09-16 18:36:03 +0900929 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900930 tstrWID strWIDList[32];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900931 u8 u8WidCnt = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900932 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
933
934
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200935 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900936
937
938 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
939
940 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) {
941 /*----------------------------------------------------------*/
942 /*Input Value: INFRASTRUCTURE = 1, */
943 /* INDEPENDENT= 2, */
944 /* ANY_BSS= 3 */
945 /*----------------------------------------------------------*/
946 /* validate input then copy>> need to check value 4 and 5 */
947 if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) {
948 strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900949 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900950 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900951 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900952 pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900953 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900954 PRINT_ER("check value 6 over\n");
955 s32Error = -EINVAL;
956 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900957 }
958 u8WidCnt++;
959 }
960 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) {
961 /*------------------------------------------------------*/
962 /*Input Values: OPEN_SYSTEM = 0, */
963 /* SHARED_KEY = 1, */
964 /* ANY = 2 */
965 /*------------------------------------------------------*/
966 /*validate Possible values*/
967 if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) {
968 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900969 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900970 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900971 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900972 pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900973 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900974 PRINT_ER("Impossible value \n");
975 s32Error = -EINVAL;
976 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900977 }
978 u8WidCnt++;
979 }
980 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) {
981 /* range is 1 to 65535. */
982 if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) {
983 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900984 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900985 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900986 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900987 pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
988 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900989 PRINT_ER("Range(1 ~ 65535) over\n");
990 s32Error = -EINVAL;
991 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900992 }
993 u8WidCnt++;
994 }
995 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) {
996 /*-----------------------------------------------------------*/
997 /*Input Values: NO_POWERSAVE = 0, */
998 /* MIN_FAST_PS = 1, */
999 /* MAX_FAST_PS = 2, */
1000 /* MIN_PSPOLL_PS = 3, */
1001 /* MAX_PSPOLL_PS = 4 */
1002 /*----------------------------------------------------------*/
1003 if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) {
1004 strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001005 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001006 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001007 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001008 pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001009 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001010 PRINT_ER("Invalide power mode\n");
1011 s32Error = -EINVAL;
1012 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001013 }
1014 u8WidCnt++;
1015 }
1016 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) {
1017 /* range from 1 to 256 */
1018 if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) {
1019 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001020 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001021 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001022 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001023 pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
1024 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001025 PRINT_ER("Range(1~256) over\n");
1026 s32Error = -EINVAL;
1027 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001028 }
1029 u8WidCnt++;
1030 }
1031 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) {
1032 /* range from 1 to 256 */
1033 if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) {
1034 strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001035 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001036
1037 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001038 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001039 pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
1040 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001041 PRINT_ER("Range(1~256) over\n");
1042 s32Error = -EINVAL;
1043 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001044 }
1045 u8WidCnt++;
1046 }
1047 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) {
1048
1049 if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) {
1050 strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001051 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001052 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001053 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001054 pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
1055 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001056 PRINT_ER("Threshold Range fail\n");
1057 s32Error = -EINVAL;
1058 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001059 }
1060 u8WidCnt++;
1061 }
1062 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) {
1063 /* range 256 to 65535 */
1064 if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) {
1065 strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001066 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001067 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001068 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001069 pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1070 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001071 PRINT_ER("Threshold Range fail\n");
1072 s32Error = -EINVAL;
1073 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001074 }
1075 u8WidCnt++;
1076 }
1077 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) {
1078 /*-----------------------------------------------------*/
1079 /*Input Values: Short= 0, */
1080 /* Long= 1, */
1081 /* Auto= 2 */
1082 /*------------------------------------------------------*/
1083 if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) {
1084 strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001085 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001086 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001087 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001088 pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1089 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001090 PRINT_ER("Preamle Range(0~2) over\n");
1091 s32Error = -EINVAL;
1092 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001093 }
1094 u8WidCnt++;
1095 }
1096 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) {
1097 if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) {
1098 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001099 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001100 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001101 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001102 pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001103 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001104 PRINT_ER("Short slot(2) over\n");
1105 s32Error = -EINVAL;
1106 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001107 }
1108 u8WidCnt++;
1109 }
1110 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) {
1111 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1112 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1113 /* this information is useful for external supplicant */
1114 /*Input Values: 1 for enable and 0 for disable. */
1115 if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) {
1116 strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001117 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001118 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001119 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001120 pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001121 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001122 PRINT_ER("TXOP prot disable\n");
1123 s32Error = -EINVAL;
1124 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001125 }
1126 u8WidCnt++;
1127 }
1128 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) {
1129 /* range is 1 to 65535. */
1130 if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) {
1131 strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001132 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001133 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001134 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001135 pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1136 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001137 PRINT_ER("Beacon interval(1~65535) fail\n");
1138 s32Error = -EINVAL;
1139 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001140 }
1141 u8WidCnt++;
1142 }
1143 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) {
1144 /* range is 1 to 255. */
1145 if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) {
1146 strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001147 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001148 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001149 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001150 pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1151 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001152 PRINT_ER("DTIM range(1~255) fail\n");
1153 s32Error = -EINVAL;
1154 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001155 }
1156 u8WidCnt++;
1157 }
1158 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) {
1159 /*----------------------------------------------------------------------*/
1160 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1161 /* SITE_SURVEY_ALL_CH = 1, */
1162 /* SITE_SURVEY_OFF = 2 */
1163 /*----------------------------------------------------------------------*/
1164 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) {
1165 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001166 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001167 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001168 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001169 pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001170 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001171 PRINT_ER("Site survey disable\n");
1172 s32Error = -EINVAL;
1173 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001174 }
1175 u8WidCnt++;
1176 }
1177 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) {
1178 /* range is 1 to 65535. */
1179 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) {
1180 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001181 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001182 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001183 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001184 pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1185 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001186 PRINT_ER("Site survey scan time(1~65535) over\n");
1187 s32Error = -EINVAL;
1188 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001189 }
1190 u8WidCnt++;
1191 }
1192 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) {
1193 /* range is 1 to 65535. */
1194 if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) {
1195 strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001196 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001197 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001198 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001199 pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1200 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001201 PRINT_ER("Active scan time(1~65535) over\n");
1202 s32Error = -EINVAL;
1203 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001204 }
1205 u8WidCnt++;
1206 }
1207 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) {
1208 /* range is 1 to 65535. */
1209 if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) {
1210 strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001211 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001212 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001213 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001214 pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1215 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001216 PRINT_ER("Passive scan time(1~65535) over\n");
1217 s32Error = -EINVAL;
1218 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001219 }
1220 u8WidCnt++;
1221 }
1222 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) {
1223 CURRENT_TX_RATE_T curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate;
1224 /*----------------------------------------------------------------------*/
1225 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1226 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1227 /*----------------------------------------------------------------------*/
1228 /* validate rate */
1229 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
1230 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
1231 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
1232 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
1233 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
1234 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
1235 strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001236 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001237 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001238 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001239 pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001240 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001241 PRINT_ER("out of TX rate\n");
1242 s32Error = -EINVAL;
1243 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001244 }
1245 u8WidCnt++;
1246 }
Johnny Kimd42ab082015-08-20 16:32:52 +09001247 s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, false,
1248 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001249
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001250 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001251 PRINT_ER("Error in setting CFG params\n");
1252
Leo Kim24db7132015-09-16 18:36:01 +09001253ERRORHANDLER:
Arnd Bergmann83383ea2015-06-01 21:06:43 +02001254 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001255 return s32Error;
1256}
1257
1258
1259/**
1260 * @brief Handle_wait_msg_q_empty
1261 * @details this should be the last msg and then the msg Q becomes idle
1262 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1263 * @return Error code.
1264 * @author
1265 * @date
1266 * @version 1.0
1267 */
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001268static s32 Handle_wait_msg_q_empty(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001269{
Leo Kime6e12662015-09-16 18:36:03 +09001270 s32 s32Error = 0;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02001271
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001272 g_wilc_initialized = 0;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02001273 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001274 return s32Error;
1275}
1276
1277/**
1278 * @brief Handle_Scan
1279 * @details Sending config packet to firmware to set the scan params
Tony Choc476feb2015-09-21 12:16:36 +09001280 * @param[in] struct scan_attr *pstrHostIFscanAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001281 * @return Error code.
1282 * @author
1283 * @date
1284 * @version 1.0
1285 */
Tony Choc476feb2015-09-21 12:16:36 +09001286static s32 Handle_Scan(tstrWILC_WFIDrv *drvHandler,
1287 struct scan_attr *pstrHostIFscanAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001288{
Leo Kime6e12662015-09-16 18:36:03 +09001289 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001290 tstrWID strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001291 u32 u32WidsCount = 0;
1292 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001293 u8 *pu8Buffer;
1294 u8 valuesize = 0;
1295 u8 *pu8HdnNtwrksWidVal = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001296 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1297
1298 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001299 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", pstrWFIDrv->enuHostIFstate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001300
1301 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
1302 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
1303
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001304 if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) {
1305 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1306 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate);
Leo Kim24db7132015-09-16 18:36:01 +09001307 PRINT_ER("Already scan\n");
1308 s32Error = -EBUSY;
1309 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001310 }
1311
1312 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
1313 if (g_obtainingIP || connecting) {
1314 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +09001315 PRINT_ER("Don't do obss scan\n");
1316 s32Error = -EBUSY;
1317 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001318 }
1319 #endif
1320
1321 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1322
1323
1324 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0;
1325
Chaehyun Limd85f5322015-06-11 14:35:54 +09001326 strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001327 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1328
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001329 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001330 valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
Glen Leef3052582015-09-10 12:03:04 +09001331 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001332 strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001333 if (strWIDList[u32WidsCount].ps8WidVal != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001334 pu8Buffer = strWIDList[u32WidsCount].ps8WidVal;
1335
1336 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
1337
1338 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
1339
1340 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1341 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001342 memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001343 pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1344 }
1345
1346
1347
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001348 strWIDList[u32WidsCount].s32ValueSize = (s32)(valuesize + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001349 u32WidsCount++;
1350 }
1351
1352 /*filling cfg param array*/
1353
1354 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1355 {
1356 /* IEs to be inserted in Probe Request */
1357 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE;
1358 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1359 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs;
1360 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen;
1361 u32WidsCount++;
1362 }
1363
1364 /*Scan Type*/
1365 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE;
1366 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001367 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001368 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001369 u32WidsCount++;
1370
1371 /*list of channels to be scanned*/
1372 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST;
1373 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1374
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001375 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
1376 int i;
1377
1378 for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001379 if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001380 pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001381 }
1382 }
1383
1384 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList;
1385 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen;
1386 u32WidsCount++;
1387
1388 /*Scan Request*/
1389 strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ;
1390 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001391 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001392 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001393 u32WidsCount++;
1394
1395 /*keep the state as is , no need to change it*/
1396 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1397
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301398 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001399 gbScanWhileConnected = true;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301400 else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001401 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001402
Johnny Kimd42ab082015-08-20 16:32:52 +09001403 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false,
1404 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001405
Leo Kim24db7132015-09-16 18:36:01 +09001406 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001407 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09001408 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001409 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001410
Leo Kim24db7132015-09-16 18:36:01 +09001411ERRORHANDLER:
1412 if (s32Error) {
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07001413 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001414 /*if there is an ongoing scan request*/
1415 Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED);
1416 }
1417
1418 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1419 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001420 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001421 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1422 }
1423
1424 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1425 if (pstrHostIFscanAttr->pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001426 kfree(pstrHostIFscanAttr->pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001427 pstrHostIFscanAttr->pu8IEs = NULL;
1428 }
1429 if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001430 kfree(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001431 pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
1432 }
1433
1434 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1435 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001436 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001437 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1438 }
1439
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001440 if (pu8HdnNtwrksWidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001441 kfree(pu8HdnNtwrksWidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001442
1443 return s32Error;
1444}
1445
1446/**
1447 * @brief Handle_ScanDone
1448 * @details Call scan notification callback function
1449 * @param[in] NONE
1450 * @return Error code.
1451 * @author
1452 * @date
1453 * @version 1.0
1454 */
Johnny Kim2b05df52015-08-13 13:41:21 +09001455static s32 Handle_ScanDone(tstrWILC_WFIDrv *drvHandler, tenuScanEvent enuEvent)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001456{
Leo Kime6e12662015-09-16 18:36:03 +09001457 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001458
1459 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
1460
1461
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001462 u8 u8abort_running_scan;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001463 tstrWID strWID;
1464
1465
1466 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
1467
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001468 /*Ask FW to abort the running scan, if any*/
1469 if (enuEvent == SCAN_EVENT_ABORTED) {
1470 PRINT_D(GENERIC_DBG, "Abort running scan\n");
1471 u8abort_running_scan = 1;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001472 strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001473 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001474 strWID.ps8WidVal = (s8 *)&u8abort_running_scan;
Dean Lee576917a2015-06-15 11:58:57 +09001475 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001476
1477 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09001478 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
1479 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09001480 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001481 PRINT_ER("Failed to set abort running scan\n");
Leo Kim24db7132015-09-16 18:36:01 +09001482 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001483 }
1484 }
1485
1486 if (pstrWFIDrv == NULL) {
1487 PRINT_ER("Driver handler is NULL\n");
1488 return s32Error;
1489 }
1490
1491 /*if there is an ongoing scan request*/
1492 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001493 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001494 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1495 /*delete current scan request*/
1496 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1497 }
1498
1499 return s32Error;
1500}
1501
1502/**
1503 * @brief Handle_Connect
1504 * @details Sending config packet to firmware to starting connection
Tony Cho120ae592015-09-21 12:16:37 +09001505 * @param[in] struct connect_attr *pstrHostIFconnectAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001506 * @return Error code.
1507 * @author
1508 * @date
1509 * @version 1.0
1510 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001511u8 u8ConnectedSSID[6] = {0};
Tony Cho120ae592015-09-21 12:16:37 +09001512static s32 Handle_Connect(tstrWILC_WFIDrv *drvHandler,
1513 struct connect_attr *pstrHostIFconnectAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001514{
1515 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
Leo Kime6e12662015-09-16 18:36:03 +09001516 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001517 tstrWID strWIDList[8];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001518 u32 u32WidsCount = 0, dummyval = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001519 /* char passphrase[] = "12345678"; */
1520 #ifndef CONNECT_DIRECT
Leo Kime6e12662015-09-16 18:36:03 +09001521 s32 s32Err = 0;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001522 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001523 u8 u8bssDscListIndex;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001524 wid_site_survey_reslts_s *pstrSurveyResults = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001525 #else
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001526 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001527 #ifdef WILC_PARSE_SCAN_IN_HOST
1528 tstrJoinBssParam *ptstrJoinBssParam;
1529 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1530
1531 #endif
1532
1533 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1534
1535 #ifndef CONNECT_DIRECT
Hari Prasath Gujulan Elango3a79a7f2015-08-20 09:59:44 +00001536 memset(gapu8RcvdSurveyResults, 0, sizeof(gapu8RcvdSurveyResults));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001537
1538
1539 PRINT_D(HOSTINF_DBG, "Getting site survey results\n");
Johnny Kim218dc402015-08-13 13:41:19 +09001540 s32Err = host_int_get_site_survey_results(pstrWFIDrv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001541 gapu8RcvdSurveyResults,
1542 MAX_SURVEY_RESULT_FRAG_SIZE);
1543 if (s32Err) {
1544 PRINT_ER("Failed to get site survey results\n");
Leo Kim24db7132015-09-16 18:36:01 +09001545 s32Error = -EFAULT;
1546 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001547 }
1548 s32Err = ParseSurveyResults(gapu8RcvdSurveyResults, &pstrSurveyResults,
1549 &pstrWFIDrv->u32SurveyResultsCount);
1550
1551
Leo Kime6e12662015-09-16 18:36:03 +09001552 if (s32Err == 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001553 /* use the parsed info in pstrSurveyResults, then deallocate it */
1554 PRINT_D(HOSTINF_DBG, "Copying site survey results in global structure, then deallocate\n");
1555 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001556 memcpy(&pstrWFIDrv->astrSurveyResults[i], &pstrSurveyResults[i],
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001557 sizeof(wid_site_survey_reslts_s));
1558 }
1559
1560 DeallocateSurveyResults(pstrSurveyResults);
1561 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001562 PRINT_ER("ParseSurveyResults() Error\n");
1563 s32Error = -EFAULT;
1564 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001565 }
1566
1567
1568 for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001569 if (memcmp(pstrWFIDrv->astrSurveyResults[i].SSID,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001570 pstrHostIFconnectAttr->pu8ssid,
1571 pstrHostIFconnectAttr->ssidLen) == 0) {
1572 PRINT_INFO(HOSTINF_DBG, "Network with required SSID is found %s\n", pstrHostIFconnectAttr->pu8ssid);
1573 if (pstrHostIFconnectAttr->pu8bssid == NULL) {
1574 /* BSSID is not passed from the user, so decision of matching
1575 * is done by SSID only */
1576 PRINT_INFO(HOSTINF_DBG, "BSSID is not passed from the user\n");
1577 break;
1578 } else {
1579 /* BSSID is also passed from the user, so decision of matching
1580 * should consider also this passed BSSID */
1581
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001582 if (memcmp(pstrWFIDrv->astrSurveyResults[i].BSSID,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001583 pstrHostIFconnectAttr->pu8bssid,
1584 6) == 0) {
1585 PRINT_INFO(HOSTINF_DBG, "BSSID is passed from the user and matched\n");
1586 break;
1587 }
1588 }
1589 }
1590 }
1591
1592 if (i < pstrWFIDrv->u32SurveyResultsCount) {
1593 u8bssDscListIndex = i;
1594
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001595 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 +09001596 u8bssDscListIndex, pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].SSID,
1597 pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].Channel);
1598
1599 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1600
1601 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001602 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001603 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001604 }
1605
1606 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1607 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001608 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssidLen + 1, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001609 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001610 pstrHostIFconnectAttr->ssidLen);
1611 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1612 }
1613
1614 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1615 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001616 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001617 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001618 pstrHostIFconnectAttr->IEsLen);
1619 }
1620
1621 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1622 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1623 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1624 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1625
1626
1627 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1628 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1629 {
1630 /* IEs to be inserted in Association Request */
1631 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1632 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1633 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1634 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1635 u32WidsCount++;
1636 }
Chaehyun Limd85f5322015-06-11 14:35:54 +09001637 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001638 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001639 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001640 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001641 u32WidsCount++;
1642
1643 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1644
Chaehyun Limd85f5322015-06-11 14:35:54 +09001645 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001646 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001647 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001648 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001649 u32WidsCount++;
1650
1651 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1652 /*
Chaehyun Limd85f5322015-06-11 14:35:54 +09001653 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001654 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1655 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001656 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001657 * u32WidsCount++;
1658 */
1659
Chaehyun Limd85f5322015-06-11 14:35:54 +09001660 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001661 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001662 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001663 strWIDList[u32WidsCount].ps8WidVal = (s8 *)&u8bssDscListIndex;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001664 u32WidsCount++;
1665
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001666 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1667 * firmware at chip reset when processing the WIDs of the Connect Request.
1668 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1669 /* ////////////////////// */
1670 gu32WidConnRstHack = 0;
1671 /* ////////////////////// */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001672
Johnny Kimd42ab082015-08-20 16:32:52 +09001673 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false,
1674 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001675 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09001676 PRINT_ER("failed to send config packet\n");
1677 s32Error = -EINVAL;
1678 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001679 } else {
1680 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1681 }
1682
1683 } else {
1684 PRINT_ER("Required BSSID not found\n");
Leo Kim24db7132015-09-16 18:36:01 +09001685 s32Error = -ENOENT;
1686 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001687 }
1688
1689 #else
1690
1691 /* if we try to connect to an already connected AP then discard the request */
1692
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001693 if (memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001694
Leo Kime6e12662015-09-16 18:36:03 +09001695 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001696 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1697 return s32Error;
1698 }
1699
1700 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1701
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001702 #ifdef WILC_PARSE_SCAN_IN_HOST
1703 ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams;
1704 if (ptstrJoinBssParam == NULL) {
1705 PRINT_ER("Required BSSID not found\n");
Leo Kim24db7132015-09-16 18:36:01 +09001706 s32Error = -ENOENT;
1707 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001708 }
1709 #endif /*WILC_PARSE_SCAN_IN_HOST*/
1710
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001711 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001712 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001713 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001714 }
1715
1716 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1717 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001718 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssidLen + 1, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001719 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001720 pstrHostIFconnectAttr->ssidLen);
1721 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1722 }
1723
1724 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1725 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001726 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001727 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001728 pstrHostIFconnectAttr->IEsLen);
1729 }
1730
1731 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1732 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1733 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1734 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1735
1736 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
1737 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001738 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001739 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001740 u32WidsCount++;
1741
1742 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
1743 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001744 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001745 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001746 u32WidsCount++;
1747
1748 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
1749 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001750 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001751 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001752 u32WidsCount++;
1753
1754 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1755 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1756 {
1757 /* IEs to be inserted in Association Request */
1758 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1759 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1760 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1761 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1762 u32WidsCount++;
1763
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001764 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001765
1766 gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001767 gu8FlushedInfoElemAsoc = kmalloc(gu32FlushedInfoElemAsocSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001768 memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1769 gu32FlushedInfoElemAsocSize);
1770 }
1771 }
Chaehyun Limd85f5322015-06-11 14:35:54 +09001772 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001773 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001774 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001775 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001776 u32WidsCount++;
1777
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001778 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001779 gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security;
1780
1781 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1782
1783
Chaehyun Limd85f5322015-06-11 14:35:54 +09001784 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001785 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001786 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001787 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001788 u32WidsCount++;
1789
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001790 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001791 gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001792
1793 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1794 /*
Chaehyun Limd85f5322015-06-11 14:35:54 +09001795 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001796 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1797 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001798 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001799 * u32WidsCount++;
1800 */
1801
1802 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1803 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
1804
1805
1806#ifndef WILC_PARSE_SCAN_IN_HOST
Chaehyun Limd85f5322015-06-11 14:35:54 +09001807 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001808 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1809 strWIDList[u32WidsCount].s32ValueSize = MAX_SSID_LEN + 7;
Glen Leef3052582015-09-10 12:03:04 +09001810 strWIDList[u32WidsCount].ps8WidVal = kmalloc(strWIDList[u32WidsCount].s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001811
Leo Kim24db7132015-09-16 18:36:01 +09001812 if (strWIDList[u32WidsCount].ps8WidVal == NULL) {
1813 s32Error = -EFAULT;
1814 goto ERRORHANDLER;
1815 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001816
1817 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1818
1819 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001820 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001821 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1822 }
1823 pu8CurrByte += MAX_SSID_LEN;
1824 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1825 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1826 } else {
1827 PRINT_ER("Channel out of range\n");
1828 *(pu8CurrByte++) = 0xFF;
1829 }
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001830 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001831 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001832 pu8CurrByte += 6;
1833
1834 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1835 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1836
1837 #else
1838
Chaehyun Limd85f5322015-06-11 14:35:54 +09001839 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001840 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1841
1842 /*Sending NoA attributes during connection*/
1843 strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */
Glen Leef3052582015-09-10 12:03:04 +09001844 strWIDList[u32WidsCount].ps8WidVal = kmalloc(strWIDList[u32WidsCount].s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001845
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001846 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001847 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize;
Glen Leef3052582015-09-10 12:03:04 +09001848 gu8FlushedJoinReq = kmalloc(gu32FlushedJoinReqSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001849 }
Leo Kim24db7132015-09-16 18:36:01 +09001850 if (strWIDList[u32WidsCount].ps8WidVal == NULL) {
1851 s32Error = -EFAULT;
1852 goto ERRORHANDLER;
1853 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001854
1855 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1856
1857
1858 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001859 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001860 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1861 }
1862 pu8CurrByte += MAX_SSID_LEN;
1863
1864 /* BSS type*/
1865 *(pu8CurrByte++) = INFRASTRUCTURE;
1866 /* Channel*/
1867 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1868 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1869 } else {
1870 PRINT_ER("Channel out of range\n");
1871 *(pu8CurrByte++) = 0xFF;
1872 }
1873 /* Cap Info*/
1874 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1875 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1876 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1877
1878 /* sa*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001879 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001880 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001881 pu8CurrByte += 6;
1882
1883 /* bssid*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001884 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001885 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001886 pu8CurrByte += 6;
1887
1888 /* Beacon Period*/
1889 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1890 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1891 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1892 /* DTIM Period*/
1893 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1894 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1895 /* Supported rates*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001896 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001897 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1898
1899 /* wmm cap*/
1900 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1901 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1902 /* uapsd cap*/
1903 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1904
1905 /* ht cap*/
1906 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1907 /* copy this information to the user request */
1908 pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1909
1910 /* rsn found*/
1911 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1912 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1913 /* rsn group policy*/
1914 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1915 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1916 /* mode_802_11i*/
1917 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1918 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1919 /* rsn pcip policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001920 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001921 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1922
1923 /* rsn auth policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001924 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001925 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1926
1927 /* rsn auth policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001928 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001929 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1930
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001931 *(pu8CurrByte++) = REAL_JOIN_REQ;
1932
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001933 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1934 if (ptstrJoinBssParam->u8NoaEnbaled) {
1935 PRINT_D(HOSTINF_DBG, "NOA present\n");
1936
1937 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1938 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1939 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1940 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1941
1942 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1943
1944 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1945
1946 if (ptstrJoinBssParam->u8OppEnable)
1947 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1948
1949 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1950
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001951 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001952
1953 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1954
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001955 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001956
1957 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1958
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001959 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001960
1961 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1962
1963 } else
1964 PRINT_D(HOSTINF_DBG, "NOA not present\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001965
1966 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1967 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1968
1969
1970 #endif /* #ifdef WILC_PARSE_SCAN_IN_HOST*/
1971 u32WidsCount++;
1972
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001973 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1974 * firmware at chip reset when processing the WIDs of the Connect Request.
1975 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1976 /* ////////////////////// */
1977 gu32WidConnRstHack = 0;
1978 /* ////////////////////// */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001979
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001980 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001981 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
Johnny Kim8a625ca2015-08-20 16:32:50 +09001982 gu8FlushedJoinReqDrvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001983 }
1984
1985 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1986
1987 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001988 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001989
Alexander Kuleshov310a28f2015-09-04 00:48:14 +06001990 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->pu8bssid);
1991 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001992 }
1993
Johnny Kimd42ab082015-08-20 16:32:52 +09001994 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false,
1995 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001996 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09001997 PRINT_ER("failed to send config packet\n");
1998 s32Error = -EFAULT;
1999 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002000 } else {
2001 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
2002 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
2003 }
2004 #endif
2005
Leo Kim24db7132015-09-16 18:36:01 +09002006ERRORHANDLER:
2007 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002008 tstrConnectInfo strConnectInfo;
2009
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002010 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002011
2012 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
2013
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002014 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002015
2016 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002017 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002018 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002019
2020 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
2021 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
Glen Leef3052582015-09-10 12:03:04 +09002022 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002023 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002024 pstrHostIFconnectAttr->pu8IEs,
2025 pstrHostIFconnectAttr->IEsLen);
2026 }
2027
2028 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2029 &strConnectInfo,
2030 MAC_DISCONNECTED,
2031 NULL,
2032 pstrHostIFconnectAttr->pvUserArg);
2033 /*Change state to idle*/
2034 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2035 /* Deallocation */
2036 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002037 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002038 strConnectInfo.pu8ReqIEs = NULL;
2039 }
2040
2041 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002042 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002043 }
2044 }
2045
2046 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
2047 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
2048 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002049 kfree(pstrHostIFconnectAttr->pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002050 pstrHostIFconnectAttr->pu8bssid = NULL;
2051 }
2052
2053 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
2054 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002055 kfree(pstrHostIFconnectAttr->pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002056 pstrHostIFconnectAttr->pu8ssid = NULL;
2057 }
2058
2059 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
2060 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002061 kfree(pstrHostIFconnectAttr->pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002062 pstrHostIFconnectAttr->pu8IEs = NULL;
2063 }
2064
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002065 if (pu8CurrByte != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09002066 kfree(pu8CurrByte);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002067 return s32Error;
2068}
2069
2070/**
2071 * @brief Handle_FlushConnect
2072 * @details Sending config packet to firmware to flush an old connection
2073 * after switching FW from station one to hybrid one
2074 * @param[in] void * drvHandler
2075 * @return Error code.
2076 * @author Amr Abdel-Moghny
2077 * @date 19 DEC 2013
2078 * @version 8.0
2079 */
2080
Johnny Kim2b05df52015-08-13 13:41:21 +09002081static s32 Handle_FlushConnect(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002082{
Leo Kime6e12662015-09-16 18:36:03 +09002083 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002084 tstrWID strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002085 u32 u32WidsCount = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002086 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002087
2088
2089 /* IEs to be inserted in Association Request */
2090 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
2091 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
2092 strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc;
2093 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize;
2094 u32WidsCount++;
2095
Chaehyun Limd85f5322015-06-11 14:35:54 +09002096 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002097 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002098 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002099 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002100 u32WidsCount++;
2101
2102
2103
Chaehyun Limd85f5322015-06-11 14:35:54 +09002104 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002105 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002106 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002107 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002108 u32WidsCount++;
2109
2110
2111 #ifdef WILC_PARSE_SCAN_IN_HOST
Chaehyun Limd85f5322015-06-11 14:35:54 +09002112 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002113 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
2114 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002115 strWIDList[u32WidsCount].ps8WidVal = (s8 *)gu8FlushedJoinReq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002116 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
2117
2118 pu8CurrByte += FLUSHED_BYTE_POS;
2119 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
2120
2121 u32WidsCount++;
2122
2123 #endif
2124
Johnny Kimd42ab082015-08-20 16:32:52 +09002125 s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, false,
2126 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002127 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09002128 PRINT_ER("failed to send config packet\n");
2129 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002130 }
2131
2132 return s32Error;
2133}
2134
2135/**
2136 * @brief Handle_ConnectTimeout
2137 * @details Call connect notification callback function indicating connection failure
2138 * @param[in] NONE
2139 * @return Error code.
2140 * @author
2141 * @date
2142 * @version 1.0
2143 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002144static s32 Handle_ConnectTimeout(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002145{
Leo Kime6e12662015-09-16 18:36:03 +09002146 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002147 tstrConnectInfo strConnectInfo;
2148 tstrWID strWID;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002149 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002150 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
2151
2152 if (pstrWFIDrv == NULL) {
2153 PRINT_ER("Driver handler is NULL\n");
2154 return s32Error;
2155 }
2156
2157 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2158
Dean Lee72ed4dc2015-06-12 14:11:44 +09002159 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002160
2161
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002162 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002163
2164
2165 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
2166 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2167 * WID_DISCONNECT} */
2168 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2169 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002170 memcpy(strConnectInfo.au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002171 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
2172 }
2173
2174 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2175 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09002176 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002177 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002178 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2179 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2180 }
2181
2182 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2183 &strConnectInfo,
2184 MAC_DISCONNECTED,
2185 NULL,
2186 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2187
2188 /* Deallocation of strConnectInfo.pu8ReqIEs */
2189 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002190 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002191 strConnectInfo.pu8ReqIEs = NULL;
2192 }
2193 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002194 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002195 }
2196
2197 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
2198 * WID_DISCONNECT} */
Chaehyun Limd85f5322015-06-11 14:35:54 +09002199 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002200 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002201 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
Dean Lee576917a2015-06-15 11:58:57 +09002202 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002203
2204 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2205
Johnny Kimd42ab082015-08-20 16:32:52 +09002206 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
2207 get_id_from_handler(pstrWFIDrv));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002208 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002209 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002210
2211 /* Deallocation of the Saved Connect Request in the global Handle */
2212 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2213 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002214 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002215 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2216 }
2217
2218 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002219 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002220 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2221 }
2222
2223 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2224 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002225 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002226 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2227 }
2228
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002229 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002230 /*Freeing flushed join request params on connect timeout*/
Johnny Kim8a625ca2015-08-20 16:32:50 +09002231 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002232 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002233 gu8FlushedJoinReq = NULL;
2234 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09002235 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002236 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002237 gu8FlushedInfoElemAsoc = NULL;
2238 }
2239
2240 return s32Error;
2241}
2242
2243/**
2244 * @brief Handle_RcvdNtwrkInfo
2245 * @details Handling received network information
Tony Cho3bbd59f2015-09-21 12:16:38 +09002246 * @param[in] struct rcvd_net_info *pstrRcvdNetworkInfo
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002247 * @return Error code.
2248 * @author
2249 * @date
2250 * @version 1.0
2251 */
Tony Cho3bbd59f2015-09-21 12:16:38 +09002252static s32 Handle_RcvdNtwrkInfo(tstrWILC_WFIDrv *drvHandler,
2253 struct rcvd_net_info *pstrRcvdNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002254{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002255 u32 i;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002256 bool bNewNtwrkFound;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002257
2258
2259
Leo Kime6e12662015-09-16 18:36:03 +09002260 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002261 tstrNetworkInfo *pstrNetworkInfo = NULL;
2262 void *pJoinParams = NULL;
2263
2264 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2265
2266
2267
Dean Lee72ed4dc2015-06-12 14:11:44 +09002268 bNewNtwrkFound = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002269 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
2270
2271 /*if there is a an ongoing scan request*/
2272 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2273 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
2274 ParseNetworkInfo(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
2275 if ((pstrNetworkInfo == NULL)
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002276 || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
Leo Kim24db7132015-09-16 18:36:01 +09002277 PRINT_ER("driver is null\n");
2278 s32Error = -EINVAL;
2279 goto done;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002280 }
2281
2282 /* check whether this network is discovered before */
2283 for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
2284
2285 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
2286 (pstrNetworkInfo->au8bssid != NULL)) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002287 if (memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002288 pstrNetworkInfo->au8bssid, 6) == 0) {
2289 if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
2290 /*we have already found this network with better rssi, so keep the old cached one and don't
2291 * send anything to the upper layer */
2292 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
2293 goto done;
2294 } else {
2295 /* here the same already found network is found again but with a better rssi, so just update
2296 * the rssi for this cached network and send this updated network to the upper layer but
2297 * don't add a new record for it */
2298 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002299 bNewNtwrkFound = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002300 break;
2301 }
2302 }
2303 }
2304 }
2305
Dean Lee72ed4dc2015-06-12 14:11:44 +09002306 if (bNewNtwrkFound == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002307 /* here it is confirmed that it is a new discovered network,
2308 * so add its record then call the User CallBack function */
2309
2310 PRINT_D(HOSTINF_DBG, "New network found\n");
2311
2312 if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
2313 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
2314
2315 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
2316 && (pstrNetworkInfo->au8bssid != NULL)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002317 memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002318 pstrNetworkInfo->au8bssid, 6);
2319
2320 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++;
2321
Dean Lee72ed4dc2015-06-12 14:11:44 +09002322 pstrNetworkInfo->bNewNetwork = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002323 /* add new BSS to JoinBssTable */
2324 #ifdef WILC_PARSE_SCAN_IN_HOST
2325 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
2326 #endif /*WILC_PARSE_SCAN_IN_HOST*/
2327
2328 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2329 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid,
2330 pJoinParams);
2331
2332
2333 }
2334 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002335 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002336 }
2337 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002338 pstrNetworkInfo->bNewNetwork = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002339 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2340 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2341 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2342 }
2343 }
2344
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002345done:
2346 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2347 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002348 kfree(pstrRcvdNetworkInfo->pu8Buffer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002349 pstrRcvdNetworkInfo->pu8Buffer = NULL;
2350 }
2351
2352 /*free structure allocated*/
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002353 if (pstrNetworkInfo != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002354 DeallocateNetworkInfo(pstrNetworkInfo);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002355 pstrNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002356 }
2357
2358 return s32Error;
2359}
2360
2361/**
2362 * @brief Handle_RcvdGnrlAsyncInfo
2363 * @details Handling received asynchrous general network information
Tony Chof23a9ea2015-09-21 12:16:39 +09002364 * @param[in] struct rcvd_async_info *pstrRcvdGnrlAsyncInfo
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002365 * @return Error code.
2366 * @author
2367 * @date
2368 * @version 1.0
2369 */
Tony Chof23a9ea2015-09-21 12:16:39 +09002370static s32 Handle_RcvdGnrlAsyncInfo(tstrWILC_WFIDrv *drvHandler,
2371 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002372{
2373 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2374 /* which carries only 1 WID which have WID ID = WID_STATUS */
Leo Kime6e12662015-09-16 18:36:03 +09002375 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002376 u8 u8MsgType = 0;
2377 u8 u8MsgID = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002378 u16 u16MsgLen = 0;
2379 u16 u16WidID = (u16)WID_NIL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002380 u8 u8WidLen = 0;
2381 u8 u8MacStatus;
2382 u8 u8MacStatusReasonCode;
2383 u8 u8MacStatusAdditionalInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002384 tstrConnectInfo strConnectInfo;
2385 tstrDisconnectNotifInfo strDisconnectNotifInfo;
Leo Kime6e12662015-09-16 18:36:03 +09002386 s32 s32Err = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002387 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002388
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002389 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002390 PRINT_ER("Driver handler is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002391 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
2392 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
2393
2394 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
2395 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) ||
2396 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2397 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002398 (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
Leo Kim24db7132015-09-16 18:36:01 +09002399 PRINT_ER("driver is null\n");
2400 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002401 }
2402
2403 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
2404
2405 /* Check whether the received message type is 'I' */
2406 if ('I' != u8MsgType) {
2407 PRINT_ER("Received Message format incorrect.\n");
Leo Kim24db7132015-09-16 18:36:01 +09002408 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002409 }
2410
2411 /* Extract message ID */
2412 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
2413
2414 /* Extract message Length */
2415 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
2416
2417 /* Extract WID ID [expected to be = WID_STATUS] */
2418 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
2419
2420 /* Extract WID Length [expected to be = 1] */
2421 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
2422
2423 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2424 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
2425 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
2426 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
2427 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2428 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2429 /* 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 +09002430 u32 u32RcvdAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002431 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
2432
2433 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2434
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002435 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002436
2437 if (u8MacStatus == MAC_CONNECTED) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002438 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002439
Johnny Kim218dc402015-08-13 13:41:19 +09002440 host_int_get_assoc_res_info(pstrWFIDrv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002441 gapu8RcvdAssocResp,
2442 MAX_ASSOC_RESP_FRAME_SIZE,
2443 &u32RcvdAssocRespInfoLen);
2444
2445 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
2446
2447 if (u32RcvdAssocRespInfoLen != 0) {
2448
2449 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
2450 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
2451 &pstrConnectRespInfo);
2452 if (s32Err) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002453 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002454 } else {
2455 /* use the necessary parsed Info from the Received Association Response */
2456 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
2457
2458 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
2459 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
2460 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
2461 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
2462
2463
Glen Leef3052582015-09-10 12:03:04 +09002464 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002465 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002466 pstrConnectRespInfo->u16RespIEsLen);
2467 }
2468 }
2469
2470 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2471 if (pstrConnectRespInfo != NULL) {
2472 DeallocateAssocRespInfo(pstrConnectRespInfo);
2473 pstrConnectRespInfo = NULL;
2474 }
2475 }
2476 }
2477 }
2478
2479 /* The station has just received mac status and it also received assoc. response which
2480 * it was waiting for.
2481 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2482 if ((u8MacStatus == MAC_CONNECTED) &&
2483 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002484 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 +09002485 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002486
2487 } else if (u8MacStatus == MAC_DISCONNECTED) {
2488 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002489 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002490 }
2491
2492 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2493 /* through a structure of type tstrConnectRespInfo */
2494 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2495 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002496 memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002497
2498 if ((u8MacStatus == MAC_CONNECTED) &&
2499 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002500 memcpy(pstrWFIDrv->au8AssociatedBSSID,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002501 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
2502 }
2503 }
2504
2505
2506 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2507 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09002508 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002509 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002510 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2511 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2512 }
2513
2514
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002515 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002516 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2517 &strConnectInfo,
2518 u8MacStatus,
2519 NULL,
2520 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2521
2522
2523 /* if received mac status is MAC_CONNECTED and
2524 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2525 * else change state to IDLE */
2526 if ((u8MacStatus == MAC_CONNECTED) &&
2527 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
2528 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2529
Johnny Kim218dc402015-08-13 13:41:19 +09002530 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002531 #endif
2532
2533 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
2534 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED;
2535
2536 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2537 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +09002538 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002539 mod_timer(&hDuringIpTimer,
2540 jiffies + msecs_to_jiffies(10000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002541 #endif
2542
2543 #ifdef WILC_PARSE_SCAN_IN_HOST
2544 /* open a BA session if possible */
2545 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
2546
2547 #endif
2548
2549 /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
2550 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2551 } else {
2552 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
2553 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002554 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002555 }
2556
2557 /* Deallocation */
2558 if (strConnectInfo.pu8RespIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002559 kfree(strConnectInfo.pu8RespIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002560 strConnectInfo.pu8RespIEs = NULL;
2561 }
2562
2563 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002564 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002565 strConnectInfo.pu8ReqIEs = NULL;
2566 }
2567
2568
2569 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2570 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002571 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002572 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2573 }
2574
2575 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002576 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002577 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2578 }
2579
2580 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2581 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002582 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002583 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2584 }
2585
2586 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2587 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) {
2588 /* Disassociation or Deauthentication frame has been received */
2589 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
2590
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002591 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002592
2593 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002594 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002595 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002596 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2597 }
2598
2599 strDisconnectNotifInfo.u16reason = 0;
2600 strDisconnectNotifInfo.ie = NULL;
2601 strDisconnectNotifInfo.ie_len = 0;
2602
2603 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2604 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
2605
Dean Lee72ed4dc2015-06-12 14:11:44 +09002606 g_obtainingIP = false;
Johnny Kim218dc402015-08-13 13:41:19 +09002607 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002608 #endif
2609
2610 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2611 NULL,
2612 0,
2613 &strDisconnectNotifInfo,
2614 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2615
2616 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002617 PRINT_ER("Connect result callback function is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002618 }
2619
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002620 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002621
2622
2623 /* Deallocation */
2624
2625 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2626 * should be deallocated here */
2627 /*
2628 * if(strDisconnectNotifInfo.ie != NULL)
2629 * {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002630 * kfree(strDisconnectNotifInfo.ie);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002631 * strDisconnectNotifInfo.ie = NULL;
2632 * }
2633 */
2634
2635 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2636 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002637 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002638 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2639 }
2640
2641 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002642 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002643 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2644 }
2645
2646 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2647 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002648 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002649 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2650 }
2651
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002652 /*Freeing flushed join request params on receiving*/
2653 /*MAC_DISCONNECTED while connected*/
Johnny Kim8a625ca2015-08-20 16:32:50 +09002654 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002655 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002656 gu8FlushedJoinReq = NULL;
2657 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09002658 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002659 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002660 gu8FlushedInfoElemAsoc = NULL;
2661 }
2662
2663 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002664 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002665
2666 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2667 (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
2668 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002669 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002670 /*Abort the running scan*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002671 del_timer(&pstrWFIDrv->hScanTimer);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002672 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult)
Johnny Kim2b05df52015-08-13 13:41:21 +09002673 Handle_ScanDone(pstrWFIDrv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002674
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002675 }
2676
2677 }
2678
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002679 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2680 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002681 kfree(pstrRcvdGnrlAsyncInfo->pu8Buffer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002682 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
2683 }
2684
2685 return s32Error;
2686}
2687
2688/**
2689 * @brief Handle_Key
2690 * @details Sending config packet to firmware to set key
Tony Choc98387a2015-09-21 12:16:40 +09002691 * @param[in] struct key_attr *pstrHostIFkeyAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002692 * @return Error code.
2693 * @author
2694 * @date
2695 * @version 1.0
2696 */
Tony Choc98387a2015-09-21 12:16:40 +09002697static int Handle_Key(tstrWILC_WFIDrv *drvHandler,
2698 struct key_attr *pstrHostIFkeyAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002699{
Leo Kime6e12662015-09-16 18:36:03 +09002700 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002701 tstrWID strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002702 tstrWID strWIDList[5];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002703 u8 i;
2704 u8 *pu8keybuf;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002705 s8 s8idxarray[1];
2706 s8 ret = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002707 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2708
2709
2710 switch (pstrHostIFkeyAttr->enuKeyType) {
2711
2712
2713 case WEP:
2714
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002715 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2716
2717 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2718 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Chaehyun Limd85f5322015-06-11 14:35:54 +09002719 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002720 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002721 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002722 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002723
2724 strWIDList[1].u16WIDid = WID_AUTH_TYPE;
2725 strWIDList[1].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002726 strWIDList[1].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002727 strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002728
Chaehyun Limd85f5322015-06-11 14:35:54 +09002729 strWIDList[2].u16WIDid = (u16)WID_KEY_ID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002730 strWIDList[2].enuWIDtype = WID_CHAR;
2731
Chaehyun Limca356ad2015-06-11 14:35:57 +09002732 strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Dean Lee576917a2015-06-15 11:58:57 +09002733 strWIDList[2].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002734
2735
Glen Leef3052582015-09-10 12:03:04 +09002736 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002737
2738
2739 if (pu8keybuf == NULL) {
2740 PRINT_ER("No buffer to send Key\n");
2741 return -1;
2742 }
2743
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002744 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002745 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2746
2747
Chaehyun Lim49188af2015-08-11 10:32:41 +09002748 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002749
Chaehyun Limd85f5322015-06-11 14:35:54 +09002750 strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002751 strWIDList[3].enuWIDtype = WID_STR;
2752 strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002753 strWIDList[3].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002754
2755
Johnny Kimd42ab082015-08-20 16:32:52 +09002756 s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, true,
2757 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002758 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002759
2760
2761 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002762
2763 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2764 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Glen Leef3052582015-09-10 12:03:04 +09002765 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002766 if (pu8keybuf == NULL) {
2767 PRINT_ER("No buffer to send Key\n");
2768 return -1;
2769 }
2770 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2771
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002772 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002773
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002774 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002775 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2776
Chaehyun Lim49188af2015-08-11 10:32:41 +09002777 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002778
Chaehyun Limd85f5322015-06-11 14:35:54 +09002779 strWID.u16WIDid = (u16)WID_ADD_WEP_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002780 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002781 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002782 strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2;
2783
Johnny Kimd42ab082015-08-20 16:32:52 +09002784 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2785 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002786 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002787 } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) {
2788
2789 PRINT_D(HOSTINF_DBG, "Removing key\n");
Chaehyun Limd85f5322015-06-11 14:35:54 +09002790 strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002791 strWID.enuWIDtype = WID_STR;
2792
Chaehyun Limca356ad2015-06-11 14:35:57 +09002793 s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002794 strWID.ps8WidVal = s8idxarray;
2795 strWID.s32ValueSize = 1;
2796
Johnny Kimd42ab082015-08-20 16:32:52 +09002797 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2798 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002799 } else {
Chaehyun Limd85f5322015-06-11 14:35:54 +09002800 strWID.u16WIDid = (u16)WID_KEY_ID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002801 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002802 strWID.ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Dean Lee576917a2015-06-15 11:58:57 +09002803 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002804
2805 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
2806
Johnny Kimd42ab082015-08-20 16:32:52 +09002807 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2808 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002809 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002810 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002811 break;
2812
2813 case WPARxGtk:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002814 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
Glen Leef3052582015-09-10 12:03:04 +09002815 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002816 if (pu8keybuf == NULL) {
2817 PRINT_ER("No buffer to send RxGTK Key\n");
2818 ret = -1;
2819 goto _WPARxGtk_end_case_;
2820 }
2821
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002822 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002823
2824
2825 /*|----------------------------------------------------------------------------|
2826 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2827 * |------------|---------|-------|------------|---------------|----------------|
2828 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2829
2830
2831
2832 if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002833 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002834
2835
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002836 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002837
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002838 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002839
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002840 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002841 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2842 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
Chaehyun Limd85f5322015-06-11 14:35:54 +09002843 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002844 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002845 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002846 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002847
Chaehyun Limd85f5322015-06-11 14:35:54 +09002848 strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002849 strWIDList[1].enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002850 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002851 strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN;
2852
Johnny Kimd42ab082015-08-20 16:32:52 +09002853 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true,
2854 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002855
Chaehyun Lim49188af2015-08-11 10:32:41 +09002856 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002857
2858 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002859 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002860 /* ///////////////////////// */
2861 }
2862
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002863 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2864 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
2865
Glen Leef3052582015-09-10 12:03:04 +09002866 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002867 if (pu8keybuf == NULL) {
2868 PRINT_ER("No buffer to send RxGTK Key\n");
2869 ret = -1;
2870 goto _WPARxGtk_end_case_;
2871 }
2872
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002873 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002874
2875
2876 /*|----------------------------------------------------------------------------|
2877 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2878 * |------------|---------|-------|------------|---------------|----------------|
2879 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2880
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302881 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002882 memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302883 else
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002884 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002885
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002886 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002887
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002888 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002889
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002890 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2891 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002892 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2893
Chaehyun Limd85f5322015-06-11 14:35:54 +09002894 strWID.u16WIDid = (u16)WID_ADD_RX_GTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002895 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002896 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002897 strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN;
2898
Johnny Kimd42ab082015-08-20 16:32:52 +09002899 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2900 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002901
Chaehyun Lim49188af2015-08-11 10:32:41 +09002902 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002903
2904 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002905 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002906 /* ///////////////////////// */
2907 }
2908_WPARxGtk_end_case_:
Chaehyun Lim49188af2015-08-11 10:32:41 +09002909 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2910 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002911 if (ret == -1)
2912 return ret;
2913
2914 break;
2915
2916 case WPAPtk:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002917 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2918
2919
Glen Leef3052582015-09-10 12:03:04 +09002920 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002921
2922
2923
2924 if (pu8keybuf == NULL) {
2925 PRINT_ER("No buffer to send PTK Key\n");
2926 ret = -1;
2927 goto _WPAPtk_end_case_;
2928
2929 }
2930
2931 /*|-----------------------------------------------------------------------------|
2932 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2933 * |----------------|------------ |--------------|----------------|---------------|
2934 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2935 |-----------------------------------------------------------------------------|*/
2936
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002937 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002938
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002939 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2940 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002941 /*16 byte TK*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002942 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002943 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2944
2945
Chaehyun Limd85f5322015-06-11 14:35:54 +09002946 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002947 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002948 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002949 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002950
Chaehyun Limd85f5322015-06-11 14:35:54 +09002951 strWIDList[1].u16WIDid = (u16)WID_ADD_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002952 strWIDList[1].enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002953 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002954 strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1;
2955
Johnny Kimd42ab082015-08-20 16:32:52 +09002956 s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, true,
2957 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002958 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002959
2960 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002961 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002962 /* ///////////////////////// */
2963 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002964 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2965
2966
Glen Leef3052582015-09-10 12:03:04 +09002967 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002968
2969
2970
2971 if (pu8keybuf == NULL) {
2972 PRINT_ER("No buffer to send PTK Key\n");
2973 ret = -1;
2974 goto _WPAPtk_end_case_;
2975
2976 }
2977
2978 /*|-----------------------------------------------------------------------------|
2979 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
2980 * |----------------|------------|--------------|----------------|---------------|
2981 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
2982 |-----------------------------------------------------------------------------|*/
2983
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002984 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002985
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002986 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002987 /*16 byte TK*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002988 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002989 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2990
2991
Chaehyun Limd85f5322015-06-11 14:35:54 +09002992 strWID.u16WIDid = (u16)WID_ADD_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002993 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002994 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002995 strWID.s32ValueSize = PTK_KEY_MSG_LEN;
2996
Johnny Kimd42ab082015-08-20 16:32:52 +09002997 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
2998 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002999 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003000
3001 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003002 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003003 /* ///////////////////////// */
3004 }
3005
3006_WPAPtk_end_case_:
Chaehyun Lim49188af2015-08-11 10:32:41 +09003007 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003008 if (ret == -1)
3009 return ret;
3010
3011 break;
3012
3013
3014 case PMKSA:
3015
3016 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
3017
Glen Leef3052582015-09-10 12:03:04 +09003018 pu8keybuf = kmalloc((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003019 if (pu8keybuf == NULL) {
3020 PRINT_ER("No buffer to send PMKSA Key\n");
3021 return -1;
3022 }
3023
3024 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
3025
3026 for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
3027
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003028 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
3029 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003030 }
3031
Chaehyun Limd85f5322015-06-11 14:35:54 +09003032 strWID.u16WIDid = (u16)WID_PMKID_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003033 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003034 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003035 strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1;
3036
Johnny Kimd42ab082015-08-20 16:32:52 +09003037 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3038 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003039
Chaehyun Lim49188af2015-08-11 10:32:41 +09003040 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003041 break;
3042 }
3043
3044 if (s32Error)
3045 PRINT_ER("Failed to send key config packet\n");
3046
3047
3048 return s32Error;
3049}
3050
3051
3052/**
3053 * @brief Handle_Disconnect
3054 * @details Sending config packet to firmware to disconnect
3055 * @param[in] NONE
3056 * @return NONE
3057 * @author
3058 * @date
3059 * @version 1.0
3060 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003061static void Handle_Disconnect(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003062{
3063 tstrWID strWID;
3064
Leo Kime6e12662015-09-16 18:36:03 +09003065 s32 s32Error = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09003066 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003067 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3068
3069
Chaehyun Limd85f5322015-06-11 14:35:54 +09003070 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003071 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003072 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
Dean Lee576917a2015-06-15 11:58:57 +09003073 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003074
3075
3076
3077 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
3078
3079 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3080
Dean Lee72ed4dc2015-06-12 14:11:44 +09003081 g_obtainingIP = false;
Johnny Kim218dc402015-08-13 13:41:19 +09003082 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003083 #endif
3084
Chaehyun Lim2cc46832015-08-07 09:02:01 +09003085 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003086
Johnny Kimd42ab082015-08-20 16:32:52 +09003087 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3088 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003089
3090 if (s32Error) {
3091 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003092 } else {
3093 tstrDisconnectNotifInfo strDisconnectNotifInfo;
3094
Chaehyun Lim2cc46832015-08-07 09:02:01 +09003095 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003096
3097 strDisconnectNotifInfo.u16reason = 0;
3098 strDisconnectNotifInfo.ie = NULL;
3099 strDisconnectNotifInfo.ie_len = 0;
3100
3101 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07003102 del_timer(&pstrWFIDrv->hScanTimer);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003103 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003104 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
3105
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003106 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003107 }
3108
3109 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
3110
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003111 /*Stop connect timer, if connection in progress*/
3112 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3113 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07003114 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003115 }
3116
3117 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
3118 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
3119 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003120 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003121 }
3122
Dean Lee72ed4dc2015-06-12 14:11:44 +09003123 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003124
3125 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
3126
Chaehyun Lim2cc46832015-08-07 09:02:01 +09003127 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003128
3129
3130 /* Deallocation */
3131 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
3132 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003133 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003134 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
3135 }
3136
3137 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003138 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003139 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
3140 }
3141
3142 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
3143 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003144 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003145 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
3146 }
3147
3148
Johnny Kim8a625ca2015-08-20 16:32:50 +09003149 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003150 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003151 gu8FlushedJoinReq = NULL;
3152 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09003153 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09003154 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003155 gu8FlushedInfoElemAsoc = NULL;
3156 }
3157
3158 }
3159
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003160 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003161 up(&(pstrWFIDrv->hSemTestDisconnectBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003162 /* ///////////////////////// */
3163
3164}
3165
3166
Johnny Kim2b05df52015-08-13 13:41:21 +09003167void resolve_disconnect_aberration(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003168{
3169 tstrWILC_WFIDrv *pstrWFIDrv;
3170
3171 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003172 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003173 return;
3174 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
3175 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
Johnny Kim218dc402015-08-13 13:41:19 +09003176 host_int_disconnect(pstrWFIDrv, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003177 }
3178}
Johnny Kim2b05df52015-08-13 13:41:21 +09003179static s32 Switch_Log_Terminal(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003180{
3181
3182
Leo Kime6e12662015-09-16 18:36:03 +09003183 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003184 tstrWID strWID;
3185 static char dummy = 9;
3186 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3187
Chaehyun Limd85f5322015-06-11 14:35:54 +09003188 strWID.u16WIDid = (u16)WID_LOGTerminal_Switch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003189 strWID.enuWIDtype = WID_CHAR;
3190 strWID.ps8WidVal = &dummy;
Dean Lee576917a2015-06-15 11:58:57 +09003191 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003192
Johnny Kimd42ab082015-08-20 16:32:52 +09003193 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3194 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003195
3196
3197 if (s32Error) {
3198 PRINT_D(HOSTINF_DBG, "Failed to switch log terminal\n");
Leo Kim24db7132015-09-16 18:36:01 +09003199 PRINT_ER("Failed to switch log terminal\n");
3200 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003201 }
3202
Leo Kim24db7132015-09-16 18:36:01 +09003203 PRINT_INFO(HOSTINF_DBG, "MAC address set ::\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003204
3205 return s32Error;
3206}
3207
3208/**
3209 * @brief Handle_GetChnl
3210 * @details Sending config packet to get channel
3211 * @param[in] NONE
3212 * @return NONE
3213 *
3214 * @author
3215 * @date
3216 * @version 1.0
3217 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003218static s32 Handle_GetChnl(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003219{
3220
Leo Kime6e12662015-09-16 18:36:03 +09003221 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003222 tstrWID strWID;
3223 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
3224 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003225
Chaehyun Limd85f5322015-06-11 14:35:54 +09003226 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003227 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003228 strWID.ps8WidVal = (s8 *)&gu8Chnl;
Dean Lee576917a2015-06-15 11:58:57 +09003229 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003230
3231 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
3232
Johnny Kimd42ab082015-08-20 16:32:52 +09003233 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
3234 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003235 /*get the value by searching the local copy*/
3236 if (s32Error) {
3237 PRINT_ER("Failed to get channel number\n");
Leo Kim24db7132015-09-16 18:36:01 +09003238 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003239 }
3240
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003241 up(&(pstrWFIDrv->hSemGetCHNL));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003242
3243 return s32Error;
3244
3245
3246
3247}
3248
3249
3250/**
3251 * @brief Handle_GetRssi
3252 * @details Sending config packet to get RSSI
3253 * @param[in] NONE
3254 * @return NONE
3255 * @author
3256 * @date
3257 * @version 1.0
3258 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003259static void Handle_GetRssi(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003260{
Leo Kime6e12662015-09-16 18:36:03 +09003261 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003262 tstrWID strWID;
3263 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3264
Chaehyun Limd85f5322015-06-11 14:35:54 +09003265 strWID.u16WIDid = (u16)WID_RSSI;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003266 strWID.enuWIDtype = WID_CHAR;
3267 strWID.ps8WidVal = &gs8Rssi;
Dean Lee576917a2015-06-15 11:58:57 +09003268 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003269
3270 /*Sending Cfg*/
3271 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
3272
Johnny Kimd42ab082015-08-20 16:32:52 +09003273 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
3274 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003275 if (s32Error) {
3276 PRINT_ER("Failed to get RSSI value\n");
Leo Kim24db7132015-09-16 18:36:01 +09003277 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003278 }
3279
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003280 up(&(pstrWFIDrv->hSemGetRSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003281
3282
3283}
3284
3285
Johnny Kim2b05df52015-08-13 13:41:21 +09003286static void Handle_GetLinkspeed(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003287{
Leo Kime6e12662015-09-16 18:36:03 +09003288 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003289 tstrWID strWID;
3290 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3291
3292 gs8lnkspd = 0;
3293
Chaehyun Limd85f5322015-06-11 14:35:54 +09003294 strWID.u16WIDid = (u16)WID_LINKSPEED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003295 strWID.enuWIDtype = WID_CHAR;
3296 strWID.ps8WidVal = &gs8lnkspd;
Dean Lee576917a2015-06-15 11:58:57 +09003297 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003298 /*Sending Cfg*/
3299 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
3300
Johnny Kimd42ab082015-08-20 16:32:52 +09003301 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
3302 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003303 if (s32Error) {
3304 PRINT_ER("Failed to get LINKSPEED value\n");
Leo Kim24db7132015-09-16 18:36:01 +09003305 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003306 }
3307
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003308 up(&(pstrWFIDrv->hSemGetLINKSPEED));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003309
3310
3311}
3312
Johnny Kim2b05df52015-08-13 13:41:21 +09003313s32 Handle_GetStatistics(tstrWILC_WFIDrv *drvHandler, tstrStatistics *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003314{
3315 tstrWID strWIDList[5];
Chaehyun Limfbc2fe12015-09-15 14:06:16 +09003316 u32 u32WidsCount = 0, s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003317
3318 strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED;
3319 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003320 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003321 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003322 u32WidsCount++;
3323
3324 strWIDList[u32WidsCount].u16WIDid = WID_RSSI;
3325 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003326 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003327 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->s8RSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003328 u32WidsCount++;
3329
3330 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
3331 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003332 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003333 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003334 u32WidsCount++;
3335
3336 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
3337 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003338 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003339 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32RxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003340 u32WidsCount++;
3341
3342 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
3343 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003344 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003345 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxFailureCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003346 u32WidsCount++;
3347
Johnny Kimd42ab082015-08-20 16:32:52 +09003348 s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, false,
3349 get_id_from_handler(drvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003350
Leo Kim24db7132015-09-16 18:36:01 +09003351 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003352 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09003353
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003354 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003355 return 0;
3356
3357}
3358
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003359/**
3360 * @brief Handle_Get_InActiveTime
3361 * @details Sending config packet to set mac adddress for station and
3362 * get inactive time
3363 * @param[in] NONE
3364 * @return NONE
3365 *
3366 * @author
3367 * @date
3368 * @version 1.0
3369 */
Tony Cho3d1eac02015-09-21 12:16:49 +09003370static s32 Handle_Get_InActiveTime(tstrWILC_WFIDrv *drvHandler,
3371 struct sta_inactive_t *strHostIfStaInactiveT)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003372{
3373
Leo Kime6e12662015-09-16 18:36:03 +09003374 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003375 u8 *stamac;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003376 tstrWID strWID;
3377 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3378
3379
Chaehyun Limd85f5322015-06-11 14:35:54 +09003380 strWID.u16WIDid = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003381 strWID.enuWIDtype = WID_STR;
3382 strWID.s32ValueSize = ETH_ALEN;
Glen Leef3052582015-09-10 12:03:04 +09003383 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003384
3385
3386 stamac = strWID.ps8WidVal;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003387 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003388
3389
3390 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
3391
3392
Johnny Kimd42ab082015-08-20 16:32:52 +09003393 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3394 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003395 /*get the value by searching the local copy*/
3396 if (s32Error) {
3397 PRINT_ER("Failed to SET incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09003398 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003399 }
3400
3401
Chaehyun Limd85f5322015-06-11 14:35:54 +09003402 strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003403 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003404 strWID.ps8WidVal = (s8 *)&gu32InactiveTime;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003405 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003406
3407
Johnny Kimd42ab082015-08-20 16:32:52 +09003408 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
3409 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003410 /*get the value by searching the local copy*/
3411 if (s32Error) {
3412 PRINT_ER("Failed to get incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09003413 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003414 }
3415
3416
3417 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
3418
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003419 up(&(pstrWFIDrv->hSemInactiveTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003420
3421 return s32Error;
3422
3423
3424
3425}
3426
3427
3428/**
3429 * @brief Handle_AddBeacon
3430 * @details Sending config packet to add beacon
Tony Cho902362b2015-09-21 12:16:44 +09003431 * @param[in] struct set_beacon *pstrSetBeaconParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003432 * @return NONE
3433 * @author
3434 * @date
3435 * @version 1.0
3436 */
Tony Cho902362b2015-09-21 12:16:44 +09003437static void Handle_AddBeacon(tstrWILC_WFIDrv *drvHandler,
3438 struct set_beacon *pstrSetBeaconParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003439{
Leo Kime6e12662015-09-16 18:36:03 +09003440 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003441 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003442 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003443 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003444
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003445 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
3446
Chaehyun Limd85f5322015-06-11 14:35:54 +09003447 strWID.u16WIDid = (u16)WID_ADD_BEACON;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003448 strWID.enuWIDtype = WID_BIN;
3449 strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
Glen Leef3052582015-09-10 12:03:04 +09003450 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003451 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003452 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003453
3454 pu8CurrByte = strWID.ps8WidVal;
3455 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
3456 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
3457 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
3458 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
3459
3460 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
3461 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
3462 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
3463 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
3464
3465 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
3466 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
3467 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
3468 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
3469
3470 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
3471 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
3472
3473 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
3474 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
3475 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
3476 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
3477
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003478 if (pstrSetBeaconParam->pu8Tail > 0)
3479 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
3480 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
3481
3482
3483
3484 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003485 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3486 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003487 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003488 PRINT_ER("Failed to send add beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003489
Leo Kim24db7132015-09-16 18:36:01 +09003490ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003491 kfree(strWID.ps8WidVal);
3492 kfree(pstrSetBeaconParam->pu8Head);
3493 kfree(pstrSetBeaconParam->pu8Tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003494}
3495
3496
3497/**
3498 * @brief Handle_AddBeacon
3499 * @details Sending config packet to delete beacon
Tony Chod0227fc2015-09-21 12:16:45 +09003500 * @param[in] struct del_beacon *pstrDelBeacon
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003501 * @return NONE
3502 * @author
3503 * @date
3504 * @version 1.0
3505 */
Tony Chod0227fc2015-09-21 12:16:45 +09003506static void Handle_DelBeacon(tstrWILC_WFIDrv *drvHandler,
3507 struct del_beacon *pstrDelBeacon)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003508{
Leo Kime6e12662015-09-16 18:36:03 +09003509 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003510 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003511 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003512 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003513
Chaehyun Limd85f5322015-06-11 14:35:54 +09003514 strWID.u16WIDid = (u16)WID_DEL_BEACON;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003515 strWID.enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003516 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003517 strWID.ps8WidVal = &gu8DelBcn;
3518
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003519 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003520 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003521
3522 pu8CurrByte = strWID.ps8WidVal;
3523
3524 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
3525 /* TODO: build del beacon message*/
3526
3527 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003528 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3529 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003530 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003531 PRINT_ER("Failed to send delete beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003532}
3533
3534
3535/**
3536 * @brief WILC_HostIf_PackStaParam
3537 * @details Handling packing of the station params in a buffer
Tony Cho6a89ba92015-09-21 12:16:46 +09003538 * @param[in] u8* pu8Buffer, struct add_sta_param *pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003539 * @return NONE
3540 * @author
3541 * @date
3542 * @version 1.0
3543 */
Tony Cho6a89ba92015-09-21 12:16:46 +09003544static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
3545 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003546{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003547 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003548
3549 pu8CurrByte = pu8Buffer;
3550
3551 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003552 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003553 pu8CurrByte += ETH_ALEN;
3554
3555 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
3556 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
3557
3558 *pu8CurrByte++ = pstrStationParam->u8NumRates;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003559 if (pstrStationParam->u8NumRates > 0)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003560 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003561 pu8CurrByte += pstrStationParam->u8NumRates;
3562
3563 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
3564 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
3565 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
3566
3567 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003568 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003569 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
3570
3571 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
3572 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
3573
3574 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
3575 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
3576 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
3577 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
3578
3579 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
3580
3581 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
3582 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
3583
3584 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
3585 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
3586
3587 return pu8CurrByte - pu8Buffer;
3588}
3589
3590/**
3591 * @brief Handle_AddStation
3592 * @details Sending config packet to add station
Tony Cho6a89ba92015-09-21 12:16:46 +09003593 * @param[in] struct add_sta_param *pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003594 * @return NONE
3595 * @author
3596 * @date
3597 * @version 1.0
3598 */
Tony Cho6a89ba92015-09-21 12:16:46 +09003599static void Handle_AddStation(tstrWILC_WFIDrv *drvHandler,
3600 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003601{
Leo Kime6e12662015-09-16 18:36:03 +09003602 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003603 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003604 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003605 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003606
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003607 PRINT_D(HOSTINF_DBG, "Handling add station\n");
Chaehyun Limd85f5322015-06-11 14:35:54 +09003608 strWID.u16WIDid = (u16)WID_ADD_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003609 strWID.enuWIDtype = WID_BIN;
3610 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3611
Glen Leef3052582015-09-10 12:03:04 +09003612 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003613 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003614 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003615
3616 pu8CurrByte = strWID.ps8WidVal;
3617 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3618
3619 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003620 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3621 get_id_from_handler(pstrWFIDrv));
Leo Kime6e12662015-09-16 18:36:03 +09003622 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003623 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003624
Leo Kim24db7132015-09-16 18:36:01 +09003625ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003626 kfree(pstrStationParam->pu8Rates);
3627 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003628}
3629
3630/**
3631 * @brief Handle_DelAllSta
3632 * @details Sending config packet to delete station
3633 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3634 * @return NONE
3635 * @author
3636 * @date
3637 * @version 1.0
3638 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003639static void Handle_DelAllSta(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelAllSta *pstrDelAllStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003640{
Leo Kime6e12662015-09-16 18:36:03 +09003641 s32 s32Error = 0;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003642
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003643 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003644 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003645 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003646 u8 i;
Chaehyun Lim37034802015-06-11 14:34:32 +09003647 u8 au8Zero_Buff[6] = {0};
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003648
Chaehyun Limd85f5322015-06-11 14:35:54 +09003649 strWID.u16WIDid = (u16)WID_DEL_ALL_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003650 strWID.enuWIDtype = WID_STR;
3651 strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
3652
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003653 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003654
Glen Leef3052582015-09-10 12:03:04 +09003655 strWID.ps8WidVal = kmalloc((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003656 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003657 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003658
3659 pu8CurrByte = strWID.ps8WidVal;
3660
3661 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
3662
3663 for (i = 0; i < MAX_NUM_STA; i++) {
3664 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003665 memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003666 else
3667 continue;
3668
3669 pu8CurrByte += ETH_ALEN;
3670 }
3671
3672 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003673 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3674 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003675 if (s32Error)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02003676 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003677
Leo Kim24db7132015-09-16 18:36:01 +09003678ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003679 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003680
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003681 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003682}
3683
3684
3685/**
3686 * @brief Handle_DelStation
3687 * @details Sending config packet to delete station
3688 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3689 * @return NONE
3690 * @author
3691 * @date
3692 * @version 1.0
3693 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003694static void Handle_DelStation(tstrWILC_WFIDrv *drvHandler, tstrHostIFDelSta *pstrDelStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003695{
Leo Kime6e12662015-09-16 18:36:03 +09003696 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003697 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003698 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003699 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3700
Chaehyun Limd85f5322015-06-11 14:35:54 +09003701 strWID.u16WIDid = (u16)WID_REMOVE_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003702 strWID.enuWIDtype = WID_BIN;
3703 strWID.s32ValueSize = ETH_ALEN;
3704
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003705 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003706
Glen Leef3052582015-09-10 12:03:04 +09003707 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003708 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003709 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003710
3711 pu8CurrByte = strWID.ps8WidVal;
3712
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003713 memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003714
3715 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003716 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3717 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003718 if (s32Error)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02003719 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003720
Leo Kim24db7132015-09-16 18:36:01 +09003721ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003722 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003723}
3724
3725
3726/**
3727 * @brief Handle_EditStation
3728 * @details Sending config packet to edit station
Tony Cho6a89ba92015-09-21 12:16:46 +09003729 * @param[in] struct add_sta_param *pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003730 * @return NONE
3731 * @author
3732 * @date
3733 * @version 1.0
3734 */
Tony Cho6a89ba92015-09-21 12:16:46 +09003735static void Handle_EditStation(tstrWILC_WFIDrv *drvHandler,
3736 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003737{
Leo Kime6e12662015-09-16 18:36:03 +09003738 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003739 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003740 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003741 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3742
Chaehyun Limd85f5322015-06-11 14:35:54 +09003743 strWID.u16WIDid = (u16)WID_EDIT_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003744 strWID.enuWIDtype = WID_BIN;
3745 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3746
3747 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
Glen Leef3052582015-09-10 12:03:04 +09003748 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003749 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003750 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003751
3752 pu8CurrByte = strWID.ps8WidVal;
3753 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3754
3755 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003756 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
3757 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003758 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003759 PRINT_ER("Failed to send edit station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003760
Leo Kim24db7132015-09-16 18:36:01 +09003761ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003762 kfree(pstrStationParam->pu8Rates);
3763 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003764}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003765
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003766/**
3767 * @brief Handle_RemainOnChan
3768 * @details Sending config packet to edit station
3769 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3770 * @return NONE
3771 * @author
3772 * @date
3773 * @version 1.0
3774 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003775static int Handle_RemainOnChan(tstrWILC_WFIDrv *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003776{
Leo Kime6e12662015-09-16 18:36:03 +09003777 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003778 u8 u8remain_on_chan_flag;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003779 tstrWID strWID;
3780 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3781
3782 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3783 if (!pstrWFIDrv->u8RemainOnChan_pendingreq) {
3784 pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
3785 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
3786 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
3787 pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
3788 pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
3789 } else {
3790 /*Set the channel to use it as a wid val*/
3791 pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel;
3792 }
3793
3794 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3795 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
3796 pstrWFIDrv->u8RemainOnChan_pendingreq = 1;
Leo Kim24db7132015-09-16 18:36:01 +09003797 s32Error = -EBUSY;
3798 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003799 }
3800 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3801 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
Leo Kim24db7132015-09-16 18:36:01 +09003802 s32Error = -EBUSY;
3803 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003804 }
3805
3806 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
3807 if (g_obtainingIP || connecting) {
3808 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +09003809 s32Error = -EBUSY;
3810 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003811 }
3812 #endif
3813
3814 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
3815
Dean Lee72ed4dc2015-06-12 14:11:44 +09003816 u8remain_on_chan_flag = true;
Chaehyun Limd85f5322015-06-11 14:35:54 +09003817 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003818 strWID.enuWIDtype = WID_STR;
3819 strWID.s32ValueSize = 2;
Glen Leef3052582015-09-10 12:03:04 +09003820 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003821
Leo Kim24db7132015-09-16 18:36:01 +09003822 if (strWID.ps8WidVal == NULL) {
3823 s32Error = -ENOMEM;
3824 goto ERRORHANDLER;
3825 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003826
3827 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003828 strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003829
3830 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003831 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3832 get_id_from_handler(pstrWFIDrv));
Leo Kime6e12662015-09-16 18:36:03 +09003833 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003834 PRINT_ER("Failed to set remain on channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003835
Leo Kim24db7132015-09-16 18:36:01 +09003836ERRORHANDLER:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003837 {
3838 P2P_LISTEN_STATE = 1;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003839 pstrWFIDrv->hRemainOnChannel.data = (unsigned long)pstrWFIDrv;
3840 mod_timer(&pstrWFIDrv->hRemainOnChannel,
3841 jiffies +
3842 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003843
3844 /*Calling CFG ready_on_channel*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003845 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003846 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003847
3848 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3849 pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
3850 }
3851 return s32Error;
3852}
3853
3854/**
3855 * @brief Handle_RegisterFrame
3856 * @details
3857 * @param[in]
3858 * @return NONE
3859 * @author
3860 * @date
3861 * @version 1.0
3862 */
Johnny Kim2b05df52015-08-13 13:41:21 +09003863static int Handle_RegisterFrame(tstrWILC_WFIDrv *drvHandler, tstrHostIfRegisterFrame *pstrHostIfRegisterFrame)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003864{
Leo Kime6e12662015-09-16 18:36:03 +09003865 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003866 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003867 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003868 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3869
3870 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
3871
3872 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +09003873 strWID.u16WIDid = (u16)WID_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003874 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09003875 strWID.ps8WidVal = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003876 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003877 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003878
3879 pu8CurrByte = strWID.ps8WidVal;
3880
3881 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
3882 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003883 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003884
3885
Chaehyun Limd85f5322015-06-11 14:35:54 +09003886 strWID.s32ValueSize = sizeof(u16) + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003887
3888
3889 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003890 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3891 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003892 if (s32Error) {
3893 PRINT_ER("Failed to frame register config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09003894 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003895 }
3896
3897 return s32Error;
3898
3899}
3900
3901/**
3902 * @brief Handle_ListenStateExpired
3903 * @details Handle of listen state expiration
3904 * @param[in] NONE
3905 * @return Error code.
3906 * @author
3907 * @date
3908 * @version 1.0
3909 */
3910#define FALSE_FRMWR_CHANNEL 100
Johnny Kim2b05df52015-08-13 13:41:21 +09003911static u32 Handle_ListenStateExpired(tstrWILC_WFIDrv *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003912{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003913 u8 u8remain_on_chan_flag;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003914 tstrWID strWID;
Leo Kime6e12662015-09-16 18:36:03 +09003915 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003916 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3917
3918 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
3919
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003920 /*Make sure we are already in listen state*/
3921 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
3922 if (P2P_LISTEN_STATE) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003923 u8remain_on_chan_flag = false;
Chaehyun Limd85f5322015-06-11 14:35:54 +09003924 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003925 strWID.enuWIDtype = WID_STR;
3926 strWID.s32ValueSize = 2;
Glen Leef3052582015-09-10 12:03:04 +09003927 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003928
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003929 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003930 PRINT_ER("Failed to allocate memory\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003931
3932 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3933 strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL;
3934
3935 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09003936 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
3937 get_id_from_handler(pstrWFIDrv));
Leo Kime6e12662015-09-16 18:36:03 +09003938 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003939 PRINT_ER("Failed to set remain on channel\n");
3940 goto _done_;
3941 }
3942
3943 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) {
3944 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid
3945 , pstrHostIfRemainOnChan->u32ListenSessionID);
3946 }
3947 P2P_LISTEN_STATE = 0;
3948 } else {
3949 PRINT_D(GENERIC_DBG, "Not in listen state\n");
Leo Kime6e12662015-09-16 18:36:03 +09003950 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003951 }
3952
3953_done_:
3954 return s32Error;
3955}
3956
3957
3958/**
3959 * @brief ListenTimerCB
3960 * @details Callback function of remain-on-channel timer
3961 * @param[in] NONE
3962 * @return Error code.
3963 * @author
3964 * @date
3965 * @version 1.0
3966 */
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003967static void ListenTimerCB(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003968{
Leo Kime6e12662015-09-16 18:36:03 +09003969 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003970 struct host_if_msg msg;
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003971 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003972 /*Stopping remain-on-channel timer*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07003973 del_timer(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003974
3975 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09003976 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003977 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Cho143eb952015-09-21 12:16:32 +09003978 msg.drvHandler = pstrWFIDrv;
Tony Cho410c2482015-09-21 12:16:35 +09003979 msg.body.strHostIfRemainOnChan.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003980
3981 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09003982 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003983 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09003984 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003985}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003986
3987/**
3988 * @brief Handle_EditStation
3989 * @details Sending config packet to edit station
3990 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3991 * @return NONE
3992 * @author
3993 * @date
3994 * @version 1.0
3995 */
Tony Cho5a008f12015-09-21 12:16:48 +09003996static void Handle_PowerManagement(tstrWILC_WFIDrv *drvHandler,
3997 struct power_mgmt_param *strPowerMgmtParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003998{
Leo Kime6e12662015-09-16 18:36:03 +09003999 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004000 tstrWID strWID;
Chaehyun Limca356ad2015-06-11 14:35:57 +09004001 s8 s8PowerMode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004002 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004003
Chaehyun Limd85f5322015-06-11 14:35:54 +09004004 strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004005
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05304006 if (strPowerMgmtParam->bIsEnabled == true)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004007 s8PowerMode = MIN_FAST_PS;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05304008 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004009 s8PowerMode = NO_POWERSAVE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004010 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
4011 strWID.ps8WidVal = &s8PowerMode;
Dean Lee576917a2015-06-15 11:58:57 +09004012 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004013
4014 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
4015
4016 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09004017 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4018 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09004019 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004020 PRINT_ER("Failed to send power management config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004021}
4022
4023/**
4024 * @brief Handle_SetMulticastFilter
4025 * @details Set Multicast filter in firmware
Tony Cho641210a2015-09-21 12:16:52 +09004026 * @param[in] struct set_multicast *strHostIfSetMulti
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004027 * @return NONE
4028 * @author asobhy
4029 * @date
4030 * @version 1.0
4031 */
Tony Cho641210a2015-09-21 12:16:52 +09004032static void Handle_SetMulticastFilter(tstrWILC_WFIDrv *drvHandler,
4033 struct set_multicast *strHostIfSetMulti)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004034{
Leo Kime6e12662015-09-16 18:36:03 +09004035 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004036 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004037 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004038
4039 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
4040
Chaehyun Limd85f5322015-06-11 14:35:54 +09004041 strWID.u16WIDid = (u16)WID_SETUP_MULTICAST_FILTER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004042 strWID.enuWIDtype = WID_BIN;
Tony Cho641210a2015-09-21 12:16:52 +09004043 strWID.s32ValueSize = sizeof(struct set_multicast) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
Glen Leef3052582015-09-10 12:03:04 +09004044 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004045 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09004046 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004047
4048 pu8CurrByte = strWID.ps8WidVal;
4049 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
4050 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
4051 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
4052 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
4053
4054 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
4055 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
4056 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
4057 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
4058
4059 if ((strHostIfSetMulti->u32count) > 0)
4060 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
4061
4062 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09004063 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, false,
4064 get_id_from_handler(drvHandler));
Leo Kim24db7132015-09-16 18:36:01 +09004065 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004066 PRINT_ER("Failed to send setup multicast config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004067
Leo Kim24db7132015-09-16 18:36:01 +09004068ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07004069 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004070
4071}
4072
4073
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004074/**
4075 * @brief Handle_AddBASession
4076 * @details Add block ack session
4077 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4078 * @return NONE
4079 * @author Amr Abdel-Moghny
4080 * @date Feb. 2014
4081 * @version 9.0
4082 */
Johnny Kim2b05df52015-08-13 13:41:21 +09004083static s32 Handle_AddBASession(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004084{
Leo Kime6e12662015-09-16 18:36:03 +09004085 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004086 tstrWID strWID;
4087 int AddbaTimeout = 100;
4088 char *ptr = NULL;
4089 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4090
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004091 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 +09004092 strHostIfBASessionInfo->au8Bssid[0],
4093 strHostIfBASessionInfo->au8Bssid[1],
4094 strHostIfBASessionInfo->au8Bssid[2],
4095 strHostIfBASessionInfo->u16BufferSize,
4096 strHostIfBASessionInfo->u16SessionTimeout,
4097 strHostIfBASessionInfo->u8Ted);
4098
Chaehyun Limd85f5322015-06-11 14:35:54 +09004099 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004100 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09004101 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004102 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4103 ptr = strWID.ps8WidVal;
4104 /* *ptr++ = 0x14; */
4105 *ptr++ = 0x14;
4106 *ptr++ = 0x3;
4107 *ptr++ = 0x0;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004108 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004109 ptr += ETH_ALEN;
4110 *ptr++ = strHostIfBASessionInfo->u8Ted;
4111 /* BA Policy*/
4112 *ptr++ = 1;
4113 /* Buffer size*/
4114 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4115 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
4116 /* BA timeout*/
4117 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
4118 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4119 /* ADDBA timeout*/
4120 *ptr++ = (AddbaTimeout & 0xFF);
4121 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
4122 /* Group Buffer Max Frames*/
4123 *ptr++ = 8;
4124 /* Group Buffer Timeout */
4125 *ptr++ = 0;
4126
Johnny Kimd42ab082015-08-20 16:32:52 +09004127 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4128 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004129 if (s32Error)
4130 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
4131
4132
Chaehyun Limd85f5322015-06-11 14:35:54 +09004133 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004134 strWID.enuWIDtype = WID_STR;
4135 strWID.s32ValueSize = 15;
4136 ptr = strWID.ps8WidVal;
4137 /* *ptr++ = 0x14; */
4138 *ptr++ = 15;
4139 *ptr++ = 7;
4140 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004141 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004142 ptr += ETH_ALEN;
4143 /* TID*/
4144 *ptr++ = strHostIfBASessionInfo->u8Ted;
4145 /* Max Num MSDU */
4146 *ptr++ = 8;
4147 /* BA timeout*/
4148 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
4149 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
4150 /*Ack-Policy */
4151 *ptr++ = 3;
Johnny Kimd42ab082015-08-20 16:32:52 +09004152 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4153 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004154
4155 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09004156 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004157
4158 return s32Error;
4159
4160}
4161
4162
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004163/**
4164 * @brief Handle_DelBASession
4165 * @details Delete block ack session
4166 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4167 * @return NONE
4168 * @author Amr Abdel-Moghny
4169 * @date Feb. 2013
4170 * @version 9.0
4171 */
Johnny Kim2b05df52015-08-13 13:41:21 +09004172static s32 Handle_DelBASession(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004173{
Leo Kime6e12662015-09-16 18:36:03 +09004174 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004175 tstrWID strWID;
4176 char *ptr = NULL;
4177 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4178
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004179 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004180 strHostIfBASessionInfo->au8Bssid[0],
4181 strHostIfBASessionInfo->au8Bssid[1],
4182 strHostIfBASessionInfo->au8Bssid[2],
4183 strHostIfBASessionInfo->u8Ted);
4184
Chaehyun Limd85f5322015-06-11 14:35:54 +09004185 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004186 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09004187 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004188 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4189 ptr = strWID.ps8WidVal;
4190 /* *ptr++ = 0x14; */
4191 *ptr++ = 0x14;
4192 *ptr++ = 0x3;
4193 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004194 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004195 ptr += ETH_ALEN;
4196 *ptr++ = strHostIfBASessionInfo->u8Ted;
4197 /* BA direction = recipent*/
4198 *ptr++ = 0;
4199 /* Delba Reason */
4200 *ptr++ = 32; /* Unspecific QOS reason */
4201
Johnny Kimd42ab082015-08-20 16:32:52 +09004202 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4203 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004204 if (s32Error)
4205 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4206
4207
Chaehyun Limd85f5322015-06-11 14:35:54 +09004208 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004209 strWID.enuWIDtype = WID_STR;
4210 strWID.s32ValueSize = 15;
4211 ptr = strWID.ps8WidVal;
4212 /* *ptr++ = 0x14; */
4213 *ptr++ = 15;
4214 *ptr++ = 7;
4215 *ptr++ = 0x3;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004216 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004217 ptr += ETH_ALEN;
4218 /* TID*/
4219 *ptr++ = strHostIfBASessionInfo->u8Ted;
4220
Johnny Kimd42ab082015-08-20 16:32:52 +09004221 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4222 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004223
4224 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09004225 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004226
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004227 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004228
4229 return s32Error;
4230
4231}
4232
4233
4234/**
4235 * @brief Handle_DelAllRxBASessions
4236 * @details Delete all Rx BA sessions
4237 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
4238 * @return NONE
4239 * @author Abdelrahman Sobhy
4240 * @date Feb. 2013
4241 * @version 9.0
4242 */
Johnny Kim2b05df52015-08-13 13:41:21 +09004243static s32 Handle_DelAllRxBASessions(tstrWILC_WFIDrv *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004244{
Leo Kime6e12662015-09-16 18:36:03 +09004245 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004246 tstrWID strWID;
4247 char *ptr = NULL;
4248 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
4249
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004250 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004251 strHostIfBASessionInfo->au8Bssid[0],
4252 strHostIfBASessionInfo->au8Bssid[1],
4253 strHostIfBASessionInfo->au8Bssid[2],
4254 strHostIfBASessionInfo->u8Ted);
4255
Chaehyun Limd85f5322015-06-11 14:35:54 +09004256 strWID.u16WIDid = (u16)WID_DEL_ALL_RX_BA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004257 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09004258 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004259 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
4260 ptr = strWID.ps8WidVal;
4261 *ptr++ = 0x14;
4262 *ptr++ = 0x3;
4263 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004264 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004265 ptr += ETH_ALEN;
4266 *ptr++ = strHostIfBASessionInfo->u8Ted;
4267 /* BA direction = recipent*/
4268 *ptr++ = 0;
4269 /* Delba Reason */
4270 *ptr++ = 32; /* Unspecific QOS reason */
4271
Johnny Kimd42ab082015-08-20 16:32:52 +09004272 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
4273 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004274 if (s32Error)
4275 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4276
4277
4278 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09004279 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004280
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004281 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004282
4283 return s32Error;
4284
4285}
4286
4287/**
4288 * @brief hostIFthread
4289 * @details Main thread to handle message queue requests
4290 * @param[in] void* pvArg
4291 * @return NONE
4292 * @author
4293 * @date
4294 * @version 1.0
4295 */
Arnd Bergmann1999bd52015-05-29 22:52:14 +02004296static int hostIFthread(void *pvArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004297{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004298 u32 u32Ret;
Tony Cho143eb952015-09-21 12:16:32 +09004299 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004300 tstrWILC_WFIDrv *pstrWFIDrv;
4301
Tony Cho143eb952015-09-21 12:16:32 +09004302 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004303
4304 while (1) {
Tony Cho143eb952015-09-21 12:16:32 +09004305 wilc_mq_recv(&gMsgQHostIF, &msg, sizeof(struct host_if_msg), &u32Ret);
4306 pstrWFIDrv = (tstrWILC_WFIDrv *)msg.drvHandler;
Tony Choa9f812a2015-09-21 12:16:33 +09004307 if (msg.id == HOST_IF_MSG_EXIT) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004308 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
4309 break;
4310 }
4311
4312
4313 /*Re-Queue HIF message*/
4314 if ((!g_wilc_initialized)) {
4315 PRINT_D(GENERIC_DBG, "--WAIT--");
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07004316 usleep_range(200 * 1000, 200 * 1000);
Tony Cho143eb952015-09-21 12:16:32 +09004317 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004318 continue;
4319 }
4320
Tony Choa9f812a2015-09-21 12:16:33 +09004321 if (msg.id == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004322 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
Tony Cho143eb952015-09-21 12:16:32 +09004323 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07004324 usleep_range(2 * 1000, 2 * 1000);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004325 continue;
4326 }
4327
Tony Choa9f812a2015-09-21 12:16:33 +09004328 switch (msg.id) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004329 case HOST_IF_MSG_Q_IDLE:
4330 Handle_wait_msg_q_empty();
4331 break;
4332
4333 case HOST_IF_MSG_SCAN:
Tony Cho410c2482015-09-21 12:16:35 +09004334 Handle_Scan(msg.drvHandler, &msg.body.strHostIFscanAttr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004335 break;
4336
4337 case HOST_IF_MSG_CONNECT:
Tony Cho410c2482015-09-21 12:16:35 +09004338 Handle_Connect(msg.drvHandler, &msg.body.strHostIFconnectAttr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004339 break;
4340
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004341 case HOST_IF_MSG_FLUSH_CONNECT:
Tony Cho143eb952015-09-21 12:16:32 +09004342 Handle_FlushConnect(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004343 break;
4344
4345 case HOST_IF_MSG_RCVD_NTWRK_INFO:
Tony Cho410c2482015-09-21 12:16:35 +09004346 Handle_RcvdNtwrkInfo(msg.drvHandler, &msg.body.strRcvdNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004347 break;
4348
4349 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
Tony Cho410c2482015-09-21 12:16:35 +09004350 Handle_RcvdGnrlAsyncInfo(msg.drvHandler, &msg.body.strRcvdGnrlAsyncInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004351 break;
4352
4353 case HOST_IF_MSG_KEY:
Tony Cho410c2482015-09-21 12:16:35 +09004354 Handle_Key(msg.drvHandler, &msg.body.strHostIFkeyAttr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004355 break;
4356
4357 case HOST_IF_MSG_CFG_PARAMS:
4358
Tony Cho410c2482015-09-21 12:16:35 +09004359 Handle_CfgParam(msg.drvHandler, &msg.body.strHostIFCfgParamAttr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004360 break;
4361
4362 case HOST_IF_MSG_SET_CHANNEL:
Tony Cho410c2482015-09-21 12:16:35 +09004363 Handle_SetChannel(msg.drvHandler, &msg.body.strHostIFSetChan);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004364 break;
4365
4366 case HOST_IF_MSG_DISCONNECT:
Tony Cho143eb952015-09-21 12:16:32 +09004367 Handle_Disconnect(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004368 break;
4369
4370 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07004371 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004372 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
4373
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004374 /*Allow chip sleep, only if both interfaces are not connected*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004375 if (!linux_wlan_get_num_conn_ifcs())
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004376 chip_sleep_manually(INFINITE_SLEEP_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004377
Tony Cho143eb952015-09-21 12:16:32 +09004378 Handle_ScanDone(msg.drvHandler, SCAN_EVENT_DONE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004379
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004380 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
Tony Cho410c2482015-09-21 12:16:35 +09004381 Handle_RemainOnChan(msg.drvHandler, &msg.body.strHostIfRemainOnChan);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004382
4383 break;
4384
4385 case HOST_IF_MSG_GET_RSSI:
Tony Cho143eb952015-09-21 12:16:32 +09004386 Handle_GetRssi(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004387 break;
4388
4389 case HOST_IF_MSG_GET_LINKSPEED:
Tony Cho143eb952015-09-21 12:16:32 +09004390 Handle_GetLinkspeed(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004391 break;
4392
4393 case HOST_IF_MSG_GET_STATISTICS:
Tony Cho410c2482015-09-21 12:16:35 +09004394 Handle_GetStatistics(msg.drvHandler, (tstrStatistics *)msg.body.pUserData);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004395 break;
4396
4397 case HOST_IF_MSG_GET_CHNL:
Tony Cho143eb952015-09-21 12:16:32 +09004398 Handle_GetChnl(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004399 break;
4400
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004401 case HOST_IF_MSG_ADD_BEACON:
Tony Cho410c2482015-09-21 12:16:35 +09004402 Handle_AddBeacon(msg.drvHandler, &msg.body.strHostIFSetBeacon);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004403 break;
4404
4405 case HOST_IF_MSG_DEL_BEACON:
Tony Cho410c2482015-09-21 12:16:35 +09004406 Handle_DelBeacon(msg.drvHandler, &msg.body.strHostIFDelBeacon);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004407 break;
4408
4409 case HOST_IF_MSG_ADD_STATION:
Tony Cho410c2482015-09-21 12:16:35 +09004410 Handle_AddStation(msg.drvHandler, &msg.body.strAddStaParam);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004411 break;
4412
4413 case HOST_IF_MSG_DEL_STATION:
Tony Cho410c2482015-09-21 12:16:35 +09004414 Handle_DelStation(msg.drvHandler, &msg.body.strDelStaParam);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004415 break;
4416
4417 case HOST_IF_MSG_EDIT_STATION:
Tony Cho410c2482015-09-21 12:16:35 +09004418 Handle_EditStation(msg.drvHandler, &msg.body.strEditStaParam);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004419 break;
4420
4421 case HOST_IF_MSG_GET_INACTIVETIME:
Tony Cho410c2482015-09-21 12:16:35 +09004422 Handle_Get_InActiveTime(msg.drvHandler, &msg.body.strHostIfStaInactiveT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004423 break;
4424
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004425 case HOST_IF_MSG_SCAN_TIMER_FIRED:
4426 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
4427
Tony Cho143eb952015-09-21 12:16:32 +09004428 Handle_ScanDone(msg.drvHandler, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004429 break;
4430
4431 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004432 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
Tony Cho143eb952015-09-21 12:16:32 +09004433 Handle_ConnectTimeout(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004434 break;
4435
4436 case HOST_IF_MSG_POWER_MGMT:
Tony Cho410c2482015-09-21 12:16:35 +09004437 Handle_PowerManagement(msg.drvHandler, &msg.body.strPowerMgmtparam);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004438 break;
4439
4440 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
Tony Cho143eb952015-09-21 12:16:32 +09004441 Handle_SetWfiDrvHandler(msg.drvHandler,
Tony Cho410c2482015-09-21 12:16:35 +09004442 &msg.body.strHostIfSetDrvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004443 break;
4444
4445 case HOST_IF_MSG_SET_OPERATION_MODE:
Tony Cho410c2482015-09-21 12:16:35 +09004446 Handle_SetOperationMode(msg.drvHandler, &msg.body.strHostIfSetOperationMode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004447 break;
4448
4449 case HOST_IF_MSG_SET_IPADDRESS:
4450 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Tony Cho410c2482015-09-21 12:16:35 +09004451 Handle_set_IPAddress(msg.drvHandler, msg.body.strHostIfSetIP.au8IPAddr, msg.body.strHostIfSetIP.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004452 break;
4453
4454 case HOST_IF_MSG_GET_IPADDRESS:
4455 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Tony Cho410c2482015-09-21 12:16:35 +09004456 Handle_get_IPAddress(msg.drvHandler, msg.body.strHostIfSetIP.au8IPAddr, msg.body.strHostIfSetIP.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004457 break;
4458
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004459 case HOST_IF_MSG_SET_MAC_ADDRESS:
Tony Cho410c2482015-09-21 12:16:35 +09004460 Handle_SetMacAddress(msg.drvHandler, &msg.body.strHostIfSetMacAddress);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004461 break;
4462
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004463 case HOST_IF_MSG_GET_MAC_ADDRESS:
Tony Cho410c2482015-09-21 12:16:35 +09004464 Handle_GetMacAddress(msg.drvHandler, &msg.body.strHostIfGetMacAddress);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004465 break;
4466
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004467 case HOST_IF_MSG_REMAIN_ON_CHAN:
4468 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
Tony Cho410c2482015-09-21 12:16:35 +09004469 Handle_RemainOnChan(msg.drvHandler, &msg.body.strHostIfRemainOnChan);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004470 break;
4471
4472 case HOST_IF_MSG_REGISTER_FRAME:
4473 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
Tony Cho410c2482015-09-21 12:16:35 +09004474 Handle_RegisterFrame(msg.drvHandler, &msg.body.strHostIfRegisterFrame);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004475 break;
4476
4477 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
Tony Cho410c2482015-09-21 12:16:35 +09004478 Handle_ListenStateExpired(msg.drvHandler, &msg.body.strHostIfRemainOnChan);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004479 break;
4480
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004481 case HOST_IF_MSG_SET_MULTICAST_FILTER:
4482 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
Tony Cho410c2482015-09-21 12:16:35 +09004483 Handle_SetMulticastFilter(msg.drvHandler, &msg.body.strHostIfSetMulti);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004484 break;
4485
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004486 case HOST_IF_MSG_ADD_BA_SESSION:
Tony Cho410c2482015-09-21 12:16:35 +09004487 Handle_AddBASession(msg.drvHandler, &msg.body.strHostIfBASessionInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004488 break;
4489
4490 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
Tony Cho410c2482015-09-21 12:16:35 +09004491 Handle_DelAllRxBASessions(msg.drvHandler, &msg.body.strHostIfBASessionInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004492 break;
4493
4494 case HOST_IF_MSG_DEL_ALL_STA:
Tony Cho410c2482015-09-21 12:16:35 +09004495 Handle_DelAllSta(msg.drvHandler, &msg.body.strHostIFDelAllSta);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004496 break;
4497
4498 default:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004499 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004500 break;
4501 }
4502 }
4503
4504 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004505 up(&hSemHostIFthrdEnd);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02004506 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004507}
4508
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004509static void TimerCB_Scan(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004510{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004511 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09004512 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004513
4514 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09004515 memset(&msg, 0, sizeof(struct host_if_msg));
4516 msg.drvHandler = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09004517 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004518
4519 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004520 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004521}
4522
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004523static void TimerCB_Connect(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004524{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004525 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09004526 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004527
4528 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09004529 memset(&msg, 0, sizeof(struct host_if_msg));
4530 msg.drvHandler = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09004531 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004532
4533 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004534 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004535}
4536
4537
4538/**
4539 * @brief removes wpa/wpa2 keys
4540 * @details only in BSS STA mode if External Supplicant support is enabled.
4541 * removes all WPA/WPA2 station key entries from MAC hardware.
4542 * @param[in,out] handle to the wifi driver
4543 * @param[in] 6 bytes of Station Adress in the station entry table
4544 * @return Error code indicating success/failure
4545 * @note
4546 * @author zsalah
4547 * @date 8 March 2012
4548 * @version 1.0
4549 */
4550/* Check implementation in core adding 9 bytes to the input! */
Johnny Kim218dc402015-08-13 13:41:19 +09004551s32 host_int_remove_key(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8StaAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004552{
Leo Kime6e12662015-09-16 18:36:03 +09004553 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004554 tstrWID strWID;
4555 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4556
Chaehyun Limd85f5322015-06-11 14:35:54 +09004557 strWID.u16WIDid = (u16)WID_REMOVE_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004558 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09004559 strWID.ps8WidVal = (s8 *)pu8StaAddress;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004560 strWID.s32ValueSize = 6;
4561
4562 return s32Error;
4563
4564}
4565
4566/**
4567 * @brief removes WEP key
4568 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4569 * remove a WEP key entry from MAC HW.
4570 * The BSS Station automatically finds the index of the entry using its
4571 * BSS ID and removes that entry from the MAC hardware.
4572 * @param[in,out] handle to the wifi driver
4573 * @param[in] 6 bytes of Station Adress in the station entry table
4574 * @return Error code indicating success/failure
4575 * @note NO need for the STA add since it is not used for processing
4576 * @author zsalah
4577 * @date 8 March 2012
4578 * @version 1.0
4579 */
Johnny Kim218dc402015-08-13 13:41:19 +09004580s32 host_int_remove_wep_key(tstrWILC_WFIDrv *hWFIDrv, u8 u8keyIdx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004581{
Leo Kime6e12662015-09-16 18:36:03 +09004582 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004583 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004584 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004585
4586
Leo Kim24db7132015-09-16 18:36:01 +09004587 if (pstrWFIDrv == NULL) {
4588 s32Error = -EFAULT;
4589 PRINT_ER("Failed to send setup multicast config packet\n");
4590 return s32Error;
4591 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004592
4593 /* prepare the Remove Wep Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004594 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004595
4596
Tony Choa9f812a2015-09-21 12:16:33 +09004597 msg.id = HOST_IF_MSG_KEY;
Tony Cho410c2482015-09-21 12:16:35 +09004598 msg.body.strHostIFkeyAttr.enuKeyType = WEP;
4599 msg.body.strHostIFkeyAttr.u8KeyAction = REMOVEKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004600 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004601
4602
4603
Tony Cho410c2482015-09-21 12:16:35 +09004604 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004605 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8keyIdx;
4606
4607 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004608 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004609 if (s32Error)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004610 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004611 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004612
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004613 return s32Error;
4614}
4615
4616/**
4617 * @brief sets WEP default key
4618 * @details Sets the index of the WEP encryption key in use,
4619 * in the key table
4620 * @param[in,out] handle to the wifi driver
4621 * @param[in] key index ( 0, 1, 2, 3)
4622 * @return Error code indicating success/failure
4623 * @note
4624 * @author zsalah
4625 * @date 8 March 2012
4626 * @version 1.0
4627 */
Johnny Kim218dc402015-08-13 13:41:19 +09004628s32 host_int_set_WEPDefaultKeyID(tstrWILC_WFIDrv *hWFIDrv, u8 u8Index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004629{
Leo Kime6e12662015-09-16 18:36:03 +09004630 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004631 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004632 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004633
4634
Leo Kim24db7132015-09-16 18:36:01 +09004635 if (pstrWFIDrv == NULL) {
4636 s32Error = -EFAULT;
4637 PRINT_ER("driver is null\n");
4638 return s32Error;
4639 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004640
4641 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004642 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004643
4644
Tony Choa9f812a2015-09-21 12:16:33 +09004645 msg.id = HOST_IF_MSG_KEY;
Tony Cho410c2482015-09-21 12:16:35 +09004646 msg.body.strHostIFkeyAttr.enuKeyType = WEP;
4647 msg.body.strHostIFkeyAttr.u8KeyAction = DEFAULTKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004648 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004649
4650
Tony Cho410c2482015-09-21 12:16:35 +09004651 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004652 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
4653
4654 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004655 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004656 if (s32Error)
4657 PRINT_ER("Error in sending message queue : Default key index\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004658 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004659
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004660 return s32Error;
4661}
4662
4663/**
4664 * @brief sets WEP deafault key
4665 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4666 * sets WEP key entry into MAC hardware when it receives the
4667 * corresponding request from NDIS.
4668 * @param[in,out] handle to the wifi driver
4669 * @param[in] message containing WEP Key in the following format
4670 *|---------------------------------------|
4671 *|Key ID Value | Key Length | Key |
4672 *|-------------|------------|------------|
4673 | 1byte | 1byte | Key Length |
4674 ||---------------------------------------|
4675 |
4676 * @return Error code indicating success/failure
4677 * @note
4678 * @author zsalah
4679 * @date 8 March 2012
4680 * @version 1.0
4681 */
Johnny Kim218dc402015-08-13 13:41:19 +09004682s32 host_int_add_wep_key_bss_sta(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004683{
4684
Leo Kime6e12662015-09-16 18:36:03 +09004685 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004686 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004687 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004688
Leo Kim24db7132015-09-16 18:36:01 +09004689 if (pstrWFIDrv == NULL) {
4690 s32Error = -EFAULT;
4691 PRINT_ER("driver is null\n");
4692 return s32Error;
4693 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004694
4695 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004696 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004697
4698
Tony Choa9f812a2015-09-21 12:16:33 +09004699 msg.id = HOST_IF_MSG_KEY;
Tony Cho410c2482015-09-21 12:16:35 +09004700 msg.body.strHostIFkeyAttr.enuKeyType = WEP;
4701 msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004702 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004703
4704
Tony Cho410c2482015-09-21 12:16:35 +09004705 msg.body.strHostIFkeyAttr.
Glen Leef3052582015-09-10 12:03:04 +09004706 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004707
Tony Cho410c2482015-09-21 12:16:35 +09004708 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004709 pu8WepKey, u8WepKeylen);
4710
4711
Tony Cho410c2482015-09-21 12:16:35 +09004712 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004713 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4714
Tony Cho410c2482015-09-21 12:16:35 +09004715 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004716 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4717
4718 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004719 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004720 if (s32Error)
4721 PRINT_ER("Error in sending message queue :WEP Key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004722 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004723
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004724 return s32Error;
4725
4726}
4727
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004728/**
4729 *
4730 * @brief host_int_add_wep_key_bss_ap
4731 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4732 * sets WEP key entry into MAC hardware when it receives the
4733 *
4734 * corresponding request from NDIS.
4735 * @param[in,out] handle to the wifi driver
4736 *
4737 *
4738 * @return Error code indicating success/failure
4739 * @note
4740 * @author mdaftedar
4741 * @date 28 FEB 2013
4742 * @version 1.0
4743 */
Johnny Kim218dc402015-08-13 13:41:19 +09004744s32 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 +09004745{
4746
Leo Kime6e12662015-09-16 18:36:03 +09004747 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004748 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004749 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004750 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004751
Leo Kim24db7132015-09-16 18:36:01 +09004752 if (pstrWFIDrv == NULL) {
4753 s32Error = -EFAULT;
4754 PRINT_ER("driver is null\n");
4755 return s32Error;
4756 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004757
4758 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004759 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004760
4761 if (INFO) {
4762 for (i = 0; i < u8WepKeylen; i++)
4763 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4764 }
Tony Choa9f812a2015-09-21 12:16:33 +09004765 msg.id = HOST_IF_MSG_KEY;
Tony Cho410c2482015-09-21 12:16:35 +09004766 msg.body.strHostIFkeyAttr.enuKeyType = WEP;
4767 msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
Tony Cho143eb952015-09-21 12:16:32 +09004768 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004769
4770
Tony Cho410c2482015-09-21 12:16:35 +09004771 msg.body.strHostIFkeyAttr.
Glen Leef3052582015-09-10 12:03:04 +09004772 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004773
4774
Tony Cho410c2482015-09-21 12:16:35 +09004775 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004776 pu8WepKey, (u8WepKeylen));
4777
4778
Tony Cho410c2482015-09-21 12:16:35 +09004779 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004780 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4781
Tony Cho410c2482015-09-21 12:16:35 +09004782 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004783 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4784
Tony Cho410c2482015-09-21 12:16:35 +09004785 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004786 uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
4787
Tony Cho410c2482015-09-21 12:16:35 +09004788 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004789 uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
4790 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004791 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004792
4793 if (s32Error)
4794 PRINT_ER("Error in sending message queue :WEP Key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004795 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004796
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004797 return s32Error;
4798
4799}
Glen Lee108b3432015-09-16 18:53:20 +09004800
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004801/**
4802 * @brief adds ptk Key
4803 * @details
4804 * @param[in,out] handle to the wifi driver
4805 * @param[in] message containing PTK Key in the following format
4806 *|-----------------------------------------------------------------------------|
4807 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4808 *|----------------|------------|--------------|----------------|---------------|
4809 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4810 ||-----------------------------------------------------------------------------|
4811 * @return Error code indicating success/failure
4812 * @note
4813 * @author zsalah
4814 * @date 8 March 2012
4815 * @version 1.0
4816 */
Johnny Kim218dc402015-08-13 13:41:19 +09004817s32 host_int_add_ptk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004818 const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004819{
Leo Kime6e12662015-09-16 18:36:03 +09004820 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004821 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004822 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004823 u8 u8KeyLen = u8PtkKeylen;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004824 u32 i;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004825
Leo Kim24db7132015-09-16 18:36:01 +09004826 if (pstrWFIDrv == NULL) {
4827 s32Error = -EFAULT;
4828 PRINT_ER("driver is null\n");
4829 return s32Error;
4830 }
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004831 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004832 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004833 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004834 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004835
4836 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004837 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004838
4839
Tony Choa9f812a2015-09-21 12:16:33 +09004840 msg.id = HOST_IF_MSG_KEY;
Tony Cho410c2482015-09-21 12:16:35 +09004841 msg.body.strHostIFkeyAttr.enuKeyType = WPAPtk;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004842 if (mode == AP_MODE) {
Tony Cho410c2482015-09-21 12:16:35 +09004843 msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4844 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004845 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
4846 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004847 if (mode == STATION_MODE)
Tony Cho410c2482015-09-21 12:16:35 +09004848 msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004849
4850
Tony Cho410c2482015-09-21 12:16:35 +09004851 msg.body.strHostIFkeyAttr.
Glen Leef3052582015-09-10 12:03:04 +09004852 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8PtkKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004853
4854
Tony Cho410c2482015-09-21 12:16:35 +09004855 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004856 pu8Ptk, u8PtkKeylen);
4857
4858 if (pu8RxMic != NULL) {
4859
Tony Cho410c2482015-09-21 12:16:35 +09004860 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004861 pu8RxMic, RX_MIC_KEY_LEN);
4862 if (INFO) {
4863 for (i = 0; i < RX_MIC_KEY_LEN; i++)
4864 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
4865 }
4866 }
4867 if (pu8TxMic != NULL) {
4868
Tony Cho410c2482015-09-21 12:16:35 +09004869 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004870 pu8TxMic, TX_MIC_KEY_LEN);
4871 if (INFO) {
4872 for (i = 0; i < TX_MIC_KEY_LEN; i++)
4873 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
4874 }
4875 }
4876
Tony Cho410c2482015-09-21 12:16:35 +09004877 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004878 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4879
Tony Cho410c2482015-09-21 12:16:35 +09004880 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004881 uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
Tony Cho410c2482015-09-21 12:16:35 +09004882 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004883 uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
Tony Cho143eb952015-09-21 12:16:32 +09004884 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004885
4886 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004887 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004888
4889 if (s32Error)
4890 PRINT_ER("Error in sending message queue: PTK Key\n");
4891
4892 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004893 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004894 /* /////// */
4895
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004896 return s32Error;
4897}
4898
4899/**
4900 * @brief adds Rx GTk Key
4901 * @details
4902 * @param[in,out] handle to the wifi driver
4903 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
4904 * u8GtkKeylen :The total key length
4905 *
4906 * @return Error code indicating success/failure
4907 * @note
4908 * @author zsalah
4909 * @date 8 March 2012
4910 * @version 1.0
4911 */
Johnny Kim218dc402015-08-13 13:41:19 +09004912s32 host_int_add_rx_gtk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004913 u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004914 const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004915{
Leo Kime6e12662015-09-16 18:36:03 +09004916 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004917 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004918 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004919 u8 u8KeyLen = u8GtkKeylen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004920
Leo Kim24db7132015-09-16 18:36:01 +09004921 if (pstrWFIDrv == NULL) {
4922 s32Error = -EFAULT;
4923 PRINT_ER("driver is null\n");
4924 return s32Error;
4925 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004926 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004927 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004928
4929
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004930 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004931 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004932 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004933 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004934 if (KeyRSC != NULL) {
Tony Cho410c2482015-09-21 12:16:35 +09004935 msg.body.strHostIFkeyAttr.
Glen Leef3052582015-09-10 12:03:04 +09004936 uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004937
Tony Cho410c2482015-09-21 12:16:35 +09004938 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004939 KeyRSC, u32KeyRSClen);
4940 }
4941
4942
Tony Choa9f812a2015-09-21 12:16:33 +09004943 msg.id = HOST_IF_MSG_KEY;
Tony Cho410c2482015-09-21 12:16:35 +09004944 msg.body.strHostIFkeyAttr.enuKeyType = WPARxGtk;
Tony Cho143eb952015-09-21 12:16:32 +09004945 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004946
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004947 if (mode == AP_MODE) {
Tony Cho410c2482015-09-21 12:16:35 +09004948 msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
4949 msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004950 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004951 if (mode == STATION_MODE)
Tony Cho410c2482015-09-21 12:16:35 +09004952 msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004953
4954
Tony Cho410c2482015-09-21 12:16:35 +09004955 msg.body.strHostIFkeyAttr.
Glen Leef3052582015-09-10 12:03:04 +09004956 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8KeyLen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004957
Tony Cho410c2482015-09-21 12:16:35 +09004958 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004959 pu8RxGtk, u8GtkKeylen);
4960
4961 if (pu8RxMic != NULL) {
4962
Tony Cho410c2482015-09-21 12:16:35 +09004963 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004964 pu8RxMic, RX_MIC_KEY_LEN);
4965
4966 }
4967 if (pu8TxMic != NULL) {
4968
Tony Cho410c2482015-09-21 12:16:35 +09004969 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004970 pu8TxMic, TX_MIC_KEY_LEN);
4971
4972 }
4973
Tony Cho410c2482015-09-21 12:16:35 +09004974 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004975 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
Tony Cho410c2482015-09-21 12:16:35 +09004976 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004977 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4978
Tony Cho410c2482015-09-21 12:16:35 +09004979 msg.body.strHostIFkeyAttr.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004980 uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
4981
4982
4983
4984 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004985 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004986 if (s32Error)
4987 PRINT_ER("Error in sending message queue: RX GTK\n");
4988 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004989 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004990 /* /////// */
4991
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004992 return s32Error;
4993}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004994
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004995/**
4996 * @brief host_int_set_pmkid_info
4997 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
4998 * support is enabled. This Function sets the PMKID in firmware
4999 * when host drivr receives the corresponding request from NDIS.
5000 * The firmware then includes theset PMKID in the appropriate
5001 * management frames
5002 * @param[in,out] handle to the wifi driver
5003 * @param[in] message containing PMKID Info in the following format
5004 *|-----------------------------------------------------------------|
5005 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5006 *|-----------|------------|----------|-------|----------|----------|
5007 | 1 | 6 | 16 | ... | 6 | 16 |
5008 ||-----------------------------------------------------------------|
5009 * @return Error code indicating success/failure
5010 * @note
5011 * @author zsalah
5012 * @date 8 March 2012
5013 * @version 1.0
5014 */
Johnny Kim218dc402015-08-13 13:41:19 +09005015s32 host_int_set_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005016{
Leo Kime6e12662015-09-16 18:36:03 +09005017 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005018 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005019 struct host_if_msg msg;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005020 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005021
5022
Leo Kim24db7132015-09-16 18:36:01 +09005023 if (pstrWFIDrv == NULL) {
5024 s32Error = -EFAULT;
5025 PRINT_ER("driver is null\n");
5026 return s32Error;
5027 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005028
5029 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09005030 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005031
Tony Choa9f812a2015-09-21 12:16:33 +09005032 msg.id = HOST_IF_MSG_KEY;
Tony Cho410c2482015-09-21 12:16:35 +09005033 msg.body.strHostIFkeyAttr.enuKeyType = PMKSA;
5034 msg.body.strHostIFkeyAttr.u8KeyAction = ADDKEY;
Tony Cho143eb952015-09-21 12:16:32 +09005035 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005036
5037 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
5038
Tony Cho410c2482015-09-21 12:16:35 +09005039 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005040 ETH_ALEN);
5041
Tony Cho410c2482015-09-21 12:16:35 +09005042 memcpy(msg.body.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005043 PMKID_LEN);
5044 }
5045
5046 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005047 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005048 if (s32Error)
5049 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
5050
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005051 return s32Error;
5052}
5053
5054/**
5055 * @brief gets the cached the pmkid info
5056 * @details valid only in BSS STA mode if External Supplicant
5057 * support is enabled. This Function sets the PMKID in firmware
5058 * when host drivr receives the corresponding request from NDIS.
5059 * The firmware then includes theset PMKID in the appropriate
5060 * management frames
5061 * @param[in,out] handle to the wifi driver,
5062 * message containing PMKID Info in the following format
5063 *|-----------------------------------------------------------------|
5064 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
5065 *|-----------|------------|----------|-------|----------|----------|
5066 | 1 | 6 | 16 | ... | 6 | 16 |
5067 ||-----------------------------------------------------------------|
5068 * @param[in]
5069 * @return Error code indicating success/failure
5070 * @note
5071 * @author zsalah
5072 * @date 8 March 2012
5073 * @version 1.0
5074 */
Johnny Kim218dc402015-08-13 13:41:19 +09005075s32 host_int_get_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PmkidInfoArray,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005076 u32 u32PmkidInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005077{
Leo Kime6e12662015-09-16 18:36:03 +09005078 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005079 tstrWID strWID;
5080 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5081
Chaehyun Limd85f5322015-06-11 14:35:54 +09005082 strWID.u16WIDid = (u16)WID_PMKID_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005083 strWID.enuWIDtype = WID_STR;
5084 strWID.s32ValueSize = u32PmkidInfoLen;
5085 strWID.ps8WidVal = pu8PmkidInfoArray;
5086
5087 return s32Error;
5088}
5089
5090/**
5091 * @brief sets the pass phrase
5092 * @details AP/STA mode. This function gives the pass phrase used to
5093 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5094 * The length of the field can vary from 8 to 64 bytes,
5095 * the lower layer should get the
5096 * @param[in,out] handle to the wifi driver,
5097 * @param[in] String containing PSK
5098 * @return Error code indicating success/failure
5099 * @note
5100 * @author zsalah
5101 * @date 8 March 2012
5102 * @version 1.0
5103 */
Johnny Kim218dc402015-08-13 13:41:19 +09005104s32 host_int_set_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PassPhrase,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005105 u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005106{
Leo Kime6e12662015-09-16 18:36:03 +09005107 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005108 tstrWID strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005109
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005110 /*validating psk length*/
5111 if ((u8Psklength > 7) && (u8Psklength < 65)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09005112 strWID.u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005113 strWID.enuWIDtype = WID_STR;
5114 strWID.ps8WidVal = pu8PassPhrase;
5115 strWID.s32ValueSize = u8Psklength;
5116 }
5117
5118 return s32Error;
5119}
5120/**
5121 * @brief host_int_get_MacAddress
5122 * @details gets mac address
5123 * @param[in,out] handle to the wifi driver,
5124 *
5125 * @return Error code indicating success/failure
5126 * @note
5127 * @author mdaftedar
5128 * @date 19 April 2012
5129 * @version 1.0
5130 */
Johnny Kim218dc402015-08-13 13:41:19 +09005131s32 host_int_get_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005132{
Leo Kime6e12662015-09-16 18:36:03 +09005133 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005134 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005135
5136
5137 /* prepare the Message */
Tony Cho143eb952015-09-21 12:16:32 +09005138 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005139
Tony Choa9f812a2015-09-21 12:16:33 +09005140 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
Tony Cho410c2482015-09-21 12:16:35 +09005141 msg.body.strHostIfGetMacAddress.u8MacAddress = pu8MacAddress;
Tony Cho143eb952015-09-21 12:16:32 +09005142 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005143 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005144 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005145 if (s32Error) {
5146 PRINT_ER("Failed to send get mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +09005147 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005148 }
5149
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005150 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005151 return s32Error;
5152}
5153
5154/**
5155 * @brief host_int_set_MacAddress
5156 * @details sets mac address
5157 * @param[in,out] handle to the wifi driver,
5158 *
5159 * @return Error code indicating success/failure
5160 * @note
5161 * @author mabubakr
5162 * @date 16 July 2012
5163 * @version 1.0
5164 */
Johnny Kim218dc402015-08-13 13:41:19 +09005165s32 host_int_set_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005166{
Leo Kime6e12662015-09-16 18:36:03 +09005167 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005168 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005169
5170 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
5171
5172 /* prepare setting mac address message */
Tony Cho143eb952015-09-21 12:16:32 +09005173 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005174 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
Tony Cho410c2482015-09-21 12:16:35 +09005175 memcpy(msg.body.strHostIfSetMacAddress.u8MacAddress, pu8MacAddress, ETH_ALEN);
Tony Cho143eb952015-09-21 12:16:32 +09005176 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005177
Tony Cho143eb952015-09-21 12:16:32 +09005178 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005179 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005180 PRINT_ER("Failed to send message queue: Set mac address\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005181
5182 return s32Error;
5183
5184}
5185
5186/**
5187 * @brief host_int_get_RSNAConfigPSKPassPhrase
5188 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
5189 * generate the Pre-Shared Key when WPA/WPA2 is enabled
5190 * The length of the field can vary from 8 to 64 bytes,
5191 * the lower layer should get the
5192 * @param[in,out] handle to the wifi driver,
5193 * String containing PSK
5194 * @return Error code indicating success/failure
5195 * @note
5196 * @author zsalah
5197 * @date 8 March 2012
5198 * @version 1.0
5199 */
Johnny Kim218dc402015-08-13 13:41:19 +09005200s32 host_int_get_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005201 u8 *pu8PassPhrase, u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005202{
Leo Kime6e12662015-09-16 18:36:03 +09005203 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005204 tstrWID strWID;
5205 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5206
Chaehyun Limd85f5322015-06-11 14:35:54 +09005207 strWID.u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005208 strWID.enuWIDtype = WID_STR;
5209 strWID.s32ValueSize = u8Psklength;
5210 strWID.ps8WidVal = pu8PassPhrase;
5211
5212 return s32Error;
5213}
5214
5215/**
5216 * @brief host_int_get_site_survey_results
5217 * @details gets the site survey results
5218 * @param[in,out] handle to the wifi driver,
5219 * Message containing site survey results in the
5220 * following format
5221 *|---------------------------------------------------|
5222 | MsgLength | fragNo. | MsgBodyLength | MsgBody |
5223 ||-----------|-----------|---------------|-----------|
5224 | 1 | 1 | 1 | 1 |
5225 | ----------------------------------------- | ----------------
5226 |
5227 ||---------------------------------------|
5228 | Network1 | Netweork2 | ... | Network5 |
5229 ||---------------------------------------|
5230 | 44 | 44 | ... | 44 |
5231 | -------------------------- | ---------------------------------------
5232 |
5233 ||---------------------------------------------------------------------|
5234 | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved |
5235 |
5236 |
5237 ||------|----------|---------|----------------|-------|------|---------|
5238 | 33 | 1 | 1 | 1 | 6 | 1 | 1 |
5239 ||---------------------------------------------------------------------|
5240 * @return Error code indicating success/failure
5241 * @note
5242 * @author zsalah
5243 * @date 8 March 2012
5244 * @version 1.0
5245 */
5246#ifndef CONNECT_DIRECT
Johnny Kim218dc402015-08-13 13:41:19 +09005247s32 host_int_get_site_survey_results(tstrWILC_WFIDrv *hWFIDrv,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005248 u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE],
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005249 u32 u32MaxSiteSrvyFragLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005250{
Leo Kime6e12662015-09-16 18:36:03 +09005251 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005252 tstrWID astrWIDList[2];
5253 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5254
Chaehyun Limd85f5322015-06-11 14:35:54 +09005255 astrWIDList[0].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005256 astrWIDList[0].enuWIDtype = WID_STR;
5257 astrWIDList[0].ps8WidVal = ppu8RcvdSiteSurveyResults[0];
5258 astrWIDList[0].s32ValueSize = u32MaxSiteSrvyFragLen;
5259
Chaehyun Limd85f5322015-06-11 14:35:54 +09005260 astrWIDList[1].u16WIDid = (u16)WID_SITE_SURVEY_RESULTS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005261 astrWIDList[1].enuWIDtype = WID_STR;
5262 astrWIDList[1].ps8WidVal = ppu8RcvdSiteSurveyResults[1];
5263 astrWIDList[1].s32ValueSize = u32MaxSiteSrvyFragLen;
5264
Johnny Kimd42ab082015-08-20 16:32:52 +09005265 s32Error = SendConfigPkt(GET_CFG, astrWIDList, 2, true,
5266 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005267
5268 /*get the value by searching the local copy*/
5269 if (s32Error) {
5270 PRINT_ER("Failed to send config packet to get survey results\n");
Leo Kim24db7132015-09-16 18:36:01 +09005271 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005272 }
5273
5274 return s32Error;
5275}
5276#endif
5277
5278/**
5279 * @brief sets a start scan request
5280 * @details
5281 * @param[in,out] handle to the wifi driver,
5282 * @param[in] Scan Source one of the following values
5283 * DEFAULT_SCAN 0
5284 * USER_SCAN BIT0
5285 * OBSS_PERIODIC_SCAN BIT1
5286 * OBSS_ONETIME_SCAN BIT2
5287 * @return Error code indicating success/failure
5288 * @note
5289 * @author zsalah
5290 * @date 8 March 2012
5291 * @version 1.0
5292 */
Johnny Kim218dc402015-08-13 13:41:19 +09005293s32 host_int_set_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 scanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005294{
Leo Kime6e12662015-09-16 18:36:03 +09005295 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005296 tstrWID strWID;
5297 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5298
Chaehyun Limd85f5322015-06-11 14:35:54 +09005299 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005300 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005301 strWID.ps8WidVal = (s8 *)&scanSource;
Dean Lee576917a2015-06-15 11:58:57 +09005302 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005303
5304 return s32Error;
5305}
5306
5307/**
5308 * @brief host_int_get_start_scan_req
5309 * @details gets a start scan request
5310 * @param[in,out] handle to the wifi driver,
5311 * @param[in] Scan Source one of the following values
5312 * DEFAULT_SCAN 0
5313 * USER_SCAN BIT0
5314 * OBSS_PERIODIC_SCAN BIT1
5315 * OBSS_ONETIME_SCAN BIT2
5316 * @return Error code indicating success/failure
5317 * @note
5318 * @author zsalah
5319 * @date 8 March 2012
5320 * @version 1.0
5321 */
5322
Johnny Kim218dc402015-08-13 13:41:19 +09005323s32 host_int_get_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ScanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005324{
Leo Kime6e12662015-09-16 18:36:03 +09005325 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005326 tstrWID strWID;
5327 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5328
Chaehyun Limd85f5322015-06-11 14:35:54 +09005329 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005330 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005331 strWID.ps8WidVal = (s8 *)pu8ScanSource;
Dean Lee576917a2015-06-15 11:58:57 +09005332 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005333
5334 return s32Error;
5335}
5336
5337/**
5338 * @brief host_int_set_join_req
5339 * @details sets a join request
5340 * @param[in,out] handle to the wifi driver,
5341 * @param[in] Index of the bss descriptor
5342 * @return Error code indicating success/failure
5343 * @note
5344 * @author zsalah
5345 * @date 8 March 2012
5346 * @version 1.0
5347 */
Johnny Kim218dc402015-08-13 13:41:19 +09005348s32 host_int_set_join_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8bssid,
Arnd Bergmann057d1e92015-06-01 21:06:44 +02005349 const u8 *pu8ssid, size_t ssidLen,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005350 const u8 *pu8IEs, size_t IEsLen,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005351 tWILCpfConnectResult pfConnectResult, void *pvUserArg,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005352 u8 u8security, AUTHTYPE_T tenuAuth_type,
5353 u8 u8channel,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005354 void *pJoinParams)
5355{
Leo Kime6e12662015-09-16 18:36:03 +09005356 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005357 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005358 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005359 tenuScanConnTimer enuScanConnTimer;
5360
Leo Kim24db7132015-09-16 18:36:01 +09005361 if (pstrWFIDrv == NULL || pfConnectResult == NULL) {
5362 s32Error = -EFAULT;
5363 PRINT_ER("Driver is null\n");
5364 return s32Error;
5365 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005366
5367 if (hWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005368 PRINT_ER("Driver is null\n");
5369 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005370 }
5371
5372 if (pJoinParams == NULL) {
5373 PRINT_ER("Unable to Join - JoinParams is NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09005374 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005375 }
Leo Kim24db7132015-09-16 18:36:01 +09005376
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005377 /* prepare the Connect Message */
Tony Cho143eb952015-09-21 12:16:32 +09005378 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005379
Tony Choa9f812a2015-09-21 12:16:33 +09005380 msg.id = HOST_IF_MSG_CONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005381
Tony Cho410c2482015-09-21 12:16:35 +09005382 msg.body.strHostIFconnectAttr.u8security = u8security;
5383 msg.body.strHostIFconnectAttr.tenuAuth_type = tenuAuth_type;
5384 msg.body.strHostIFconnectAttr.u8channel = u8channel;
5385 msg.body.strHostIFconnectAttr.pfConnectResult = pfConnectResult;
5386 msg.body.strHostIFconnectAttr.pvUserArg = pvUserArg;
5387 msg.body.strHostIFconnectAttr.pJoinParams = pJoinParams;
Tony Cho143eb952015-09-21 12:16:32 +09005388 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005389
5390 if (pu8bssid != NULL) {
Tony Cho410c2482015-09-21 12:16:35 +09005391 msg.body.strHostIFconnectAttr.pu8bssid = kmalloc(6, GFP_KERNEL); /* will be deallocated by the receiving thread */
5392 memcpy(msg.body.strHostIFconnectAttr.pu8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005393 pu8bssid, 6);
5394 }
5395
5396 if (pu8ssid != NULL) {
Tony Cho410c2482015-09-21 12:16:35 +09005397 msg.body.strHostIFconnectAttr.ssidLen = ssidLen;
5398 msg.body.strHostIFconnectAttr.pu8ssid = kmalloc(ssidLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5399 memcpy(msg.body.strHostIFconnectAttr.pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005400
5401 pu8ssid, ssidLen);
5402 }
5403
5404 if (pu8IEs != NULL) {
Tony Cho410c2482015-09-21 12:16:35 +09005405 msg.body.strHostIFconnectAttr.IEsLen = IEsLen;
5406 msg.body.strHostIFconnectAttr.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5407 memcpy(msg.body.strHostIFconnectAttr.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005408 pu8IEs, IEsLen);
5409 }
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05305410 if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005411 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05305412 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005413 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate);
5414
5415 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005416 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005417 if (s32Error) {
5418 PRINT_ER("Failed to send message queue: Set join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09005419 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005420 }
5421
5422 enuScanConnTimer = CONNECT_TIMER;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005423 pstrWFIDrv->hConnectTimer.data = (unsigned long)hWFIDrv;
5424 mod_timer(&pstrWFIDrv->hConnectTimer,
5425 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005426
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005427 return s32Error;
5428}
5429
5430/**
5431 * @brief Flush a join request parameters to FW, but actual connection
5432 * @details The function is called in situation where WILC is connected to AP and
5433 * required to switch to hybrid FW for P2P connection
5434 * @param[in] handle to the wifi driver,
5435 * @return Error code indicating success/failure
5436 * @note
5437 * @author Amr Abdel-Moghny
5438 * @date 19 DEC 2013
5439 * @version 8.0
5440 */
5441
Johnny Kim218dc402015-08-13 13:41:19 +09005442s32 host_int_flush_join_req(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005443{
Leo Kime6e12662015-09-16 18:36:03 +09005444 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005445 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005446
5447 if (!gu8FlushedJoinReq) {
Leo Kime6e12662015-09-16 18:36:03 +09005448 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005449 return s32Error;
5450 }
5451
5452
Leo Kim24db7132015-09-16 18:36:01 +09005453 if (hWFIDrv == NULL) {
5454 s32Error = -EFAULT;
5455 PRINT_ER("Driver is null\n");
5456 return s32Error;
5457 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005458
Tony Choa9f812a2015-09-21 12:16:33 +09005459 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
Tony Cho143eb952015-09-21 12:16:32 +09005460 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005461
5462 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005463 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005464 if (s32Error) {
5465 PRINT_ER("Failed to send message queue: Flush join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09005466 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005467 }
5468
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005469 return s32Error;
5470}
5471
5472/**
5473 * @brief host_int_disconnect
5474 * @details disconnects from the currently associated network
5475 * @param[in,out] handle to the wifi driver,
5476 * @param[in] Reason Code of the Disconnection
5477 * @return Error code indicating success/failure
5478 * @note
5479 * @author zsalah
5480 * @date 8 March 2012
5481 * @version 1.0
5482 */
Johnny Kim218dc402015-08-13 13:41:19 +09005483s32 host_int_disconnect(tstrWILC_WFIDrv *hWFIDrv, u16 u16ReasonCode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005484{
Leo Kime6e12662015-09-16 18:36:03 +09005485 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005486 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005487 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5488
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005489 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005490 PRINT_ER("Driver is null\n");
5491 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005492 }
5493
5494 /* prepare the Disconnect Message */
Tony Cho143eb952015-09-21 12:16:32 +09005495 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005496
Tony Choa9f812a2015-09-21 12:16:33 +09005497 msg.id = HOST_IF_MSG_DISCONNECT;
Tony Cho143eb952015-09-21 12:16:32 +09005498 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005499
5500 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005501 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005502 if (s32Error)
5503 PRINT_ER("Failed to send message queue: disconnect\n");
5504 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005505 down(&(pstrWFIDrv->hSemTestDisconnectBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005506 /* /////// */
5507
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005508 return s32Error;
5509}
5510
5511/**
5512 * @brief host_int_disconnect_station
5513 * @details disconnects a sta
5514 * @param[in,out] handle to the wifi driver,
5515 * @param[in] Association Id of the station to be disconnected
5516 * @return Error code indicating success/failure
5517 * @note
5518 * @author zsalah
5519 * @date 8 March 2012
5520 * @version 1.0
5521 */
Johnny Kim218dc402015-08-13 13:41:19 +09005522s32 host_int_disconnect_station(tstrWILC_WFIDrv *hWFIDrv, u8 assoc_id)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005523{
Leo Kime6e12662015-09-16 18:36:03 +09005524 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005525 tstrWID strWID;
5526 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5527
Chaehyun Limd85f5322015-06-11 14:35:54 +09005528 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005529 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005530 strWID.ps8WidVal = (s8 *)&assoc_id;
Dean Lee576917a2015-06-15 11:58:57 +09005531 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005532
5533 return s32Error;
5534}
5535
5536/**
5537 * @brief host_int_get_assoc_req_info
5538 * @details gets a Association request info
5539 * @param[in,out] handle to the wifi driver,
5540 * Message containg assoc. req info in the following format
5541 * ------------------------------------------------------------------------
5542 | Management Frame Format |
5543 ||-------------------------------------------------------------------|
5544 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5545 ||-------------|--------|--|--|-----|----------------|----------|----|
5546 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5547 ||-------------------------------------------------------------------|
5548 | |
5549 | Association Request Frame - Frame Body |
5550 ||-------------------------------------------------------------------|
5551 | Capability Information | Listen Interval | SSID | Supported Rates |
5552 ||------------------------|-----------------|------|-----------------|
5553 | 2 | 2 | 2-34 | 3-10 |
5554 | ---------------------------------------------------------------------
5555 * @return Error code indicating success/failure
5556 * @note
5557 * @author zsalah
5558 * @date 8 March 2012
5559 * @version 1.0
5560 */
5561
Johnny Kim218dc402015-08-13 13:41:19 +09005562s32 host_int_get_assoc_req_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocReqInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005563 u32 u32AssocReqInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005564{
Leo Kime6e12662015-09-16 18:36:03 +09005565 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005566 tstrWID strWID;
5567 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5568
Chaehyun Limd85f5322015-06-11 14:35:54 +09005569 strWID.u16WIDid = (u16)WID_ASSOC_REQ_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005570 strWID.enuWIDtype = WID_STR;
5571 strWID.ps8WidVal = pu8AssocReqInfo;
5572 strWID.s32ValueSize = u32AssocReqInfoLen;
5573
5574
5575 return s32Error;
5576}
5577
5578/**
5579 * @brief gets a Association Response info
5580 * @details
5581 * @param[in,out] handle to the wifi driver,
5582 * Message containg assoc. resp info
5583 * @return Error code indicating success/failure
5584 * @note
5585 * @author zsalah
5586 * @date 8 March 2012
5587 * @version 1.0
5588 */
Johnny Kim218dc402015-08-13 13:41:19 +09005589s32 host_int_get_assoc_res_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocRespInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005590 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005591{
Leo Kime6e12662015-09-16 18:36:03 +09005592 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005593 tstrWID strWID;
5594 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5595
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005596 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005597 PRINT_ER("Driver is null\n");
5598 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005599 }
5600
Chaehyun Limd85f5322015-06-11 14:35:54 +09005601 strWID.u16WIDid = (u16)WID_ASSOC_RES_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005602 strWID.enuWIDtype = WID_STR;
5603 strWID.ps8WidVal = pu8AssocRespInfo;
5604 strWID.s32ValueSize = u32MaxAssocRespInfoLen;
5605
5606
5607 /* Sending Configuration packet */
Johnny Kimd42ab082015-08-20 16:32:52 +09005608 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
5609 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005610 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005611 *pu32RcvdAssocRespInfoLen = 0;
Leo Kim24db7132015-09-16 18:36:01 +09005612 PRINT_ER("Failed to send association response config packet\n");
5613 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005614 } else {
5615 *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize;
5616 }
5617
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005618 return s32Error;
5619}
5620
5621/**
5622 * @brief gets a Association Response info
5623 * @details Valid only in STA mode. This function gives the RSSI
5624 * values observed in all the channels at the time of scanning.
5625 * The length of the field is 1 greater that the total number of
5626 * channels supported. Byte 0 contains the number of channels while
5627 * each of Byte N contains the observed RSSI value for the channel index N.
5628 * @param[in,out] handle to the wifi driver,
5629 * array of scanned channels' RSSI
5630 * @return Error code indicating success/failure
5631 * @note
5632 * @author zsalah
5633 * @date 8 March 2012
5634 * @version 1.0
5635 */
Johnny Kim218dc402015-08-13 13:41:19 +09005636s32 host_int_get_rx_power_level(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8RxPowerLevel,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005637 u32 u32RxPowerLevelLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005638{
Leo Kime6e12662015-09-16 18:36:03 +09005639 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005640 tstrWID strWID;
5641 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5642
Chaehyun Limd85f5322015-06-11 14:35:54 +09005643 strWID.u16WIDid = (u16)WID_RX_POWER_LEVEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005644 strWID.enuWIDtype = WID_STR;
5645 strWID.ps8WidVal = pu8RxPowerLevel;
5646 strWID.s32ValueSize = u32RxPowerLevelLen;
5647
5648
5649 return s32Error;
5650}
5651
5652/**
5653 * @brief sets a channel
5654 * @details
5655 * @param[in,out] handle to the wifi driver,
5656 * @param[in] Index of the channel to be set
5657 *|-------------------------------------------------------------------|
5658 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5659 | Input: 1 2 14 |
5660 ||-------------------------------------------------------------------|
5661 * @return Error code indicating success/failure
5662 * @note
5663 * @author zsalah
5664 * @date 8 March 2012
5665 * @version 1.0
5666 */
Johnny Kim218dc402015-08-13 13:41:19 +09005667s32 host_int_set_mac_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 u8ChNum)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005668{
Leo Kime6e12662015-09-16 18:36:03 +09005669 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005670 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005671 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005672
Leo Kim24db7132015-09-16 18:36:01 +09005673 if (pstrWFIDrv == NULL) {
5674 PRINT_ER("driver is null\n");
5675 return -EFAULT;
5676 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005677
5678 /* prepare the set channel message */
Tony Cho143eb952015-09-21 12:16:32 +09005679 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005680 msg.id = HOST_IF_MSG_SET_CHANNEL;
Tony Cho410c2482015-09-21 12:16:35 +09005681 msg.body.strHostIFSetChan.u8SetChan = u8ChNum;
Tony Cho143eb952015-09-21 12:16:32 +09005682 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005683
Tony Cho143eb952015-09-21 12:16:32 +09005684 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005685 if (s32Error) {
5686 PRINT_ER("wilc mq send fail\n");
5687 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005688 }
5689
5690 return s32Error;
5691}
5692
5693
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005694s32 host_int_wait_msg_queue_idle(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005695{
Leo Kime6e12662015-09-16 18:36:03 +09005696 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005697
Tony Cho143eb952015-09-21 12:16:32 +09005698 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005699
5700 /* prepare the set driver handler message */
5701
Tony Cho143eb952015-09-21 12:16:32 +09005702 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005703 msg.id = HOST_IF_MSG_Q_IDLE;
Tony Cho143eb952015-09-21 12:16:32 +09005704 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005705 if (s32Error) {
5706 PRINT_ER("wilc mq send fail\n");
5707 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005708 }
5709
5710 /* wait untill MSG Q is empty */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005711 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005712
5713 return s32Error;
5714
5715}
5716
Johnny Kim218dc402015-08-13 13:41:19 +09005717s32 host_int_set_wfi_drv_handler(tstrWILC_WFIDrv *u32address)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005718{
Leo Kime6e12662015-09-16 18:36:03 +09005719 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005720
Tony Cho143eb952015-09-21 12:16:32 +09005721 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005722
5723
5724 /* prepare the set driver handler message */
5725
Tony Cho143eb952015-09-21 12:16:32 +09005726 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005727 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
Tony Cho410c2482015-09-21 12:16:35 +09005728 msg.body.strHostIfSetDrvHandler.u32Address = get_id_from_handler(u32address);
Tony Cho143eb952015-09-21 12:16:32 +09005729 msg.drvHandler = u32address;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005730
Tony Cho143eb952015-09-21 12:16:32 +09005731 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005732 if (s32Error) {
5733 PRINT_ER("wilc mq send fail\n");
5734 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005735 }
5736
5737 return s32Error;
5738}
5739
5740
5741
Johnny Kim218dc402015-08-13 13:41:19 +09005742s32 host_int_set_operation_mode(tstrWILC_WFIDrv *hWFIDrv, u32 u32mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005743{
Leo Kime6e12662015-09-16 18:36:03 +09005744 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005745
Tony Cho143eb952015-09-21 12:16:32 +09005746 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005747
5748
5749 /* prepare the set driver handler message */
5750
Tony Cho143eb952015-09-21 12:16:32 +09005751 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005752 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
Tony Cho410c2482015-09-21 12:16:35 +09005753 msg.body.strHostIfSetOperationMode.u32Mode = u32mode;
Tony Cho143eb952015-09-21 12:16:32 +09005754 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005755
Tony Cho143eb952015-09-21 12:16:32 +09005756 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005757 if (s32Error) {
5758 PRINT_ER("wilc mq send fail\n");
5759 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005760 }
5761
5762 return s32Error;
5763}
5764
5765/**
5766 * @brief gets the current channel index
5767 * @details
5768 * @param[in,out] handle to the wifi driver,
5769 * current channel index
5770 *|-----------------------------------------------------------------------|
5771 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5772 | Input: 1 2 14 |
5773 ||-----------------------------------------------------------------------|
5774 * @return Error code indicating success/failure
5775 * @note
5776 * @author zsalah
5777 * @date 8 March 2012
5778 * @version 1.0
5779 */
Johnny Kim218dc402015-08-13 13:41:19 +09005780s32 host_int_get_host_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ChNo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005781{
Leo Kime6e12662015-09-16 18:36:03 +09005782 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005783 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005784 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005785
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005786 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005787 PRINT_ER("driver is null\n");
5788 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005789 }
5790
5791 /* prepare the Get Channel Message */
Tony Cho143eb952015-09-21 12:16:32 +09005792 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005793
Tony Choa9f812a2015-09-21 12:16:33 +09005794 msg.id = HOST_IF_MSG_GET_CHNL;
Tony Cho143eb952015-09-21 12:16:32 +09005795 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005796
5797 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005798 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005799 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09005800 PRINT_ER("wilc mq send fail\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005801 down(&(pstrWFIDrv->hSemGetCHNL));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005802 /* gu8Chnl = 11; */
5803
5804 *pu8ChNo = gu8Chnl;
5805
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005806 return s32Error;
5807
5808
5809}
5810
5811
5812/**
5813 * @brief host_int_test_set_int_wid
5814 * @details Test function for setting wids
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005815 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005816 * @return Error code indicating success/failure
5817 * @note
5818 * @author zsalah
5819 * @date 8 March 2012
5820 * @version 1.0
5821 */
Johnny Kim218dc402015-08-13 13:41:19 +09005822s32 host_int_test_set_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 u32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005823{
Leo Kime6e12662015-09-16 18:36:03 +09005824 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005825 tstrWID strWID;
5826 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5827
5828
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005829 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005830 PRINT_ER("driver is null\n");
5831 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005832 }
5833
5834 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +09005835 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005836 strWID.enuWIDtype = WID_INT;
Dean Lee576917a2015-06-15 11:58:57 +09005837 strWID.ps8WidVal = (char *)&u32TestMemAddr;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005838 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005839
5840 /*Sending Cfg*/
Johnny Kimd42ab082015-08-20 16:32:52 +09005841 s32Error = SendConfigPkt(SET_CFG, &strWID, 1, true,
5842 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005843 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09005844 PRINT_ER("Failed to set wid value\n");
5845 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005846 } else {
5847 PRINT_D(HOSTINF_DBG, "Successfully set wid value\n");
5848
5849 }
5850
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005851 return s32Error;
5852}
5853
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005854/**
5855 * @brief host_int_get_inactive_time
5856 * @details
5857 * @param[in,out] handle to the wifi driver,
5858 * current sta macaddress, inactive_time
5859 * @return
5860 * @note
5861 * @author
5862 * @date
5863 * @version 1.0
5864 */
Johnny Kim218dc402015-08-13 13:41:19 +09005865s32 host_int_get_inactive_time(tstrWILC_WFIDrv *hWFIDrv, const u8 *mac, u32 *pu32InactiveTime)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005866{
Leo Kime6e12662015-09-16 18:36:03 +09005867 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005868 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005869 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005870
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005871 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005872 PRINT_ER("driver is null\n");
5873 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005874 }
5875
Tony Cho143eb952015-09-21 12:16:32 +09005876 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005877
5878
Tony Cho410c2482015-09-21 12:16:35 +09005879 memcpy(msg.body.strHostIfStaInactiveT.mac,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005880 mac, ETH_ALEN);
5881
Tony Choa9f812a2015-09-21 12:16:33 +09005882 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
Tony Cho143eb952015-09-21 12:16:32 +09005883 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005884
5885 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005886 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005887 if (s32Error)
5888 PRINT_ER("Failed to send get host channel param's message queue ");
5889
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005890 down(&(pstrWFIDrv->hSemInactiveTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005891
5892 *pu32InactiveTime = gu32InactiveTime;
5893
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005894 return s32Error;
5895}
Glen Lee108b3432015-09-16 18:53:20 +09005896
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005897/**
5898 * @brief host_int_test_get_int_wid
5899 * @details Test function for getting wids
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005900 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005901 * @return Error code indicating success/failure
5902 * @note
5903 * @author zsalah
5904 * @date 8 March 2012
5905 * @version 1.0
5906 */
Johnny Kim218dc402015-08-13 13:41:19 +09005907s32 host_int_test_get_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 *pu32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005908{
5909
Leo Kime6e12662015-09-16 18:36:03 +09005910 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005911 tstrWID strWID;
5912 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5913
5914
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005915 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005916 PRINT_ER("driver is null\n");
5917 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005918 }
5919
Chaehyun Limd85f5322015-06-11 14:35:54 +09005920 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005921 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005922 strWID.ps8WidVal = (s8 *)pu32TestMemAddr;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005923 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005924
Johnny Kimd42ab082015-08-20 16:32:52 +09005925 s32Error = SendConfigPkt(GET_CFG, &strWID, 1, true,
5926 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005927 /*get the value by searching the local copy*/
5928 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09005929 PRINT_ER("Failed to get wid value\n");
5930 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005931 } else {
5932 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
5933
5934 }
5935
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005936 return s32Error;
5937}
5938
5939
5940/**
5941 * @brief host_int_get_rssi
5942 * @details gets the currently maintained RSSI value for the station.
5943 * The received signal strength value in dB.
5944 * The range of valid values is -128 to 0.
5945 * @param[in,out] handle to the wifi driver,
5946 * rssi value in dB
5947 * @return Error code indicating success/failure
5948 * @note
5949 * @author zsalah
5950 * @date 8 March 2012
5951 * @version 1.0
5952 */
Johnny Kim218dc402015-08-13 13:41:19 +09005953s32 host_int_get_rssi(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005954{
Leo Kime6e12662015-09-16 18:36:03 +09005955 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005956 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005957 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5958
5959
5960 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09005961 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005962
Tony Choa9f812a2015-09-21 12:16:33 +09005963 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Cho143eb952015-09-21 12:16:32 +09005964 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005965
5966 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005967 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005968 if (s32Error) {
5969 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005970 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005971 }
5972
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005973 down(&(pstrWFIDrv->hSemGetRSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005974
5975
5976 if (ps8Rssi == NULL) {
5977 PRINT_ER("RSS pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09005978 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005979 }
5980
5981
5982 *ps8Rssi = gs8Rssi;
5983
5984
5985 return s32Error;
5986}
5987
Johnny Kim218dc402015-08-13 13:41:19 +09005988s32 host_int_get_link_speed(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8lnkspd)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005989{
Tony Cho143eb952015-09-21 12:16:32 +09005990 struct host_if_msg msg;
Leo Kime6e12662015-09-16 18:36:03 +09005991 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005992
5993 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5994
5995
5996
5997 /* prepare the Get LINKSPEED Message */
Tony Cho143eb952015-09-21 12:16:32 +09005998 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005999
Tony Choa9f812a2015-09-21 12:16:33 +09006000 msg.id = HOST_IF_MSG_GET_LINKSPEED;
Tony Cho143eb952015-09-21 12:16:32 +09006001 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006002
6003 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006004 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006005 if (s32Error) {
6006 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09006007 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006008 }
6009
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006010 down(&(pstrWFIDrv->hSemGetLINKSPEED));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006011
6012
6013 if (ps8lnkspd == NULL) {
6014 PRINT_ER("LINKSPEED pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09006015 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006016 }
6017
6018
6019 *ps8lnkspd = gs8lnkspd;
6020
6021
6022 return s32Error;
6023}
6024
Johnny Kim218dc402015-08-13 13:41:19 +09006025s32 host_int_get_statistics(tstrWILC_WFIDrv *hWFIDrv, tstrStatistics *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006026{
Leo Kime6e12662015-09-16 18:36:03 +09006027 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006028 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006029
6030
6031 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09006032 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006033
Tony Choa9f812a2015-09-21 12:16:33 +09006034 msg.id = HOST_IF_MSG_GET_STATISTICS;
Tony Cho410c2482015-09-21 12:16:35 +09006035 msg.body.pUserData = (char *)pstrStatistics;
Tony Cho143eb952015-09-21 12:16:32 +09006036 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006037 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006038 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006039 if (s32Error) {
6040 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09006041 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006042 }
6043
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006044 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006045 return s32Error;
6046}
6047
6048
6049/**
6050 * @brief host_int_scan
6051 * @details scans a set of channels
6052 * @param[in,out] handle to the wifi driver,
6053 * @param[in] Scan source
6054 * Scan Type PASSIVE_SCAN = 0,
6055 * ACTIVE_SCAN = 1
6056 * Channels Array
6057 * Channels Array length
6058 * Scan Callback function
6059 * @return Error code indicating success/failure
6060 * @note
6061 * @author zsalah
6062 * @date 8 March 2012
6063 * @version 1.0
6064 */
Johnny Kim218dc402015-08-13 13:41:19 +09006065s32 host_int_scan(tstrWILC_WFIDrv *hWFIDrv, u8 u8ScanSource,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006066 u8 u8ScanType, u8 *pu8ChnlFreqList,
6067 u8 u8ChnlListLen, const u8 *pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006068 size_t IEsLen, tWILCpfScanResult ScanResult,
6069 void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork)
6070{
Leo Kime6e12662015-09-16 18:36:03 +09006071 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006072 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006073 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006074 tenuScanConnTimer enuScanConnTimer;
6075
Leo Kim24db7132015-09-16 18:36:01 +09006076 if (pstrWFIDrv == NULL || ScanResult == NULL) {
6077 PRINT_ER("pstrWFIDrv or ScanResult = NULL\n");
6078 return -EFAULT;
6079 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006080
6081 /* prepare the Scan Message */
Tony Cho143eb952015-09-21 12:16:32 +09006082 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006083
Tony Choa9f812a2015-09-21 12:16:33 +09006084 msg.id = HOST_IF_MSG_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006085
6086 if (pstrHiddenNetwork != NULL) {
Tony Cho410c2482015-09-21 12:16:35 +09006087 msg.body.strHostIFscanAttr.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
6088 msg.body.strHostIFscanAttr.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006089
6090 } else
6091 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
6092
Tony Cho143eb952015-09-21 12:16:32 +09006093 msg.drvHandler = hWFIDrv;
Tony Cho410c2482015-09-21 12:16:35 +09006094 msg.body.strHostIFscanAttr.u8ScanSource = u8ScanSource;
6095 msg.body.strHostIFscanAttr.u8ScanType = u8ScanType;
6096 msg.body.strHostIFscanAttr.pfScanResult = ScanResult;
6097 msg.body.strHostIFscanAttr.pvUserArg = pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006098
Tony Cho410c2482015-09-21 12:16:35 +09006099 msg.body.strHostIFscanAttr.u8ChnlListLen = u8ChnlListLen;
6100 msg.body.strHostIFscanAttr.pu8ChnlFreqList = kmalloc(u8ChnlListLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
6101 memcpy(msg.body.strHostIFscanAttr.pu8ChnlFreqList,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006102 pu8ChnlFreqList, u8ChnlListLen);
6103
Tony Cho410c2482015-09-21 12:16:35 +09006104 msg.body.strHostIFscanAttr.IEsLen = IEsLen;
6105 msg.body.strHostIFscanAttr.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
6106 memcpy(msg.body.strHostIFscanAttr.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006107 pu8IEs, IEsLen);
6108
6109 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006110 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006111 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09006112 PRINT_ER("Error in sending message queue\n");
6113 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006114 }
6115
6116 enuScanConnTimer = SCAN_TIMER;
6117 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07006118 pstrWFIDrv->hScanTimer.data = (unsigned long)hWFIDrv;
6119 mod_timer(&pstrWFIDrv->hScanTimer,
6120 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006121
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006122 return s32Error;
6123
6124}
6125/**
6126 * @brief hif_set_cfg
6127 * @details sets configuration wids values
6128 * @param[in,out] handle to the wifi driver,
6129 * @param[in] WID, WID value
6130 * @return Error code indicating success/failure
6131 * @note
6132 * @author zsalah
6133 * @date 8 March 2012
6134 * @version 1.0
6135 */
Johnny Kim218dc402015-08-13 13:41:19 +09006136s32 hif_set_cfg(tstrWILC_WFIDrv *hWFIDrv, tstrCfgParamVal *pstrCfgParamVal)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006137{
6138
Leo Kime6e12662015-09-16 18:36:03 +09006139 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006140 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6141
Tony Cho143eb952015-09-21 12:16:32 +09006142 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006143
6144
Leo Kim24db7132015-09-16 18:36:01 +09006145 if (pstrWFIDrv == NULL) {
6146 PRINT_ER("pstrWFIDrv NULL\n");
6147 return -EFAULT;
6148 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006149 /* prepare the WiphyParams Message */
Tony Cho143eb952015-09-21 12:16:32 +09006150 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09006151 msg.id = HOST_IF_MSG_CFG_PARAMS;
Tony Cho410c2482015-09-21 12:16:35 +09006152 msg.body.strHostIFCfgParamAttr.pstrCfgParamVal = *pstrCfgParamVal;
Tony Cho143eb952015-09-21 12:16:32 +09006153 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006154
Tony Cho143eb952015-09-21 12:16:32 +09006155 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006156
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006157 return s32Error;
6158
6159}
6160
6161
6162/**
6163 * @brief hif_get_cfg
6164 * @details gets configuration wids values
6165 * @param[in,out] handle to the wifi driver,
6166 * WID value
6167 * @param[in] WID,
6168 * @return Error code indicating success/failure
6169 * @note
6170 * @author zsalah
6171 *
6172 * @date 8 March 2012
6173 * @version 1.0
6174 */
Johnny Kim218dc402015-08-13 13:41:19 +09006175s32 hif_get_cfg(tstrWILC_WFIDrv *hWFIDrv, u16 u16WID, u16 *pu16WID_Value)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006176{
Leo Kime6e12662015-09-16 18:36:03 +09006177 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006178 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6179
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006180 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006181
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006182 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09006183 PRINT_ER("pstrWFIDrv NULL\n");
6184 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006185 }
6186 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
6187 switch (u16WID) {
6188
6189 case WID_BSS_TYPE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006190 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006191 break;
6192
6193 case WID_AUTH_TYPE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006194 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006195 break;
6196
6197 case WID_AUTH_TIMEOUT:
6198 *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout;
6199 break;
6200
6201 case WID_POWER_MANAGEMENT:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006202 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006203 break;
6204
6205 case WID_SHORT_RETRY_LIMIT:
6206 *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit;
6207 break;
6208
6209 case WID_LONG_RETRY_LIMIT:
6210 *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit;
6211 break;
6212
6213 case WID_FRAG_THRESHOLD:
6214 *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold;
6215 break;
6216
6217 case WID_RTS_THRESHOLD:
6218 *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold;
6219 break;
6220
6221 case WID_PREAMBLE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006222 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006223 break;
6224
6225 case WID_SHORT_SLOT_ALLOWED:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006226 *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006227 break;
6228
6229 case WID_11N_TXOP_PROT_DISABLE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006230 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006231 break;
6232
6233 case WID_BEACON_INTERVAL:
6234 *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval;
6235 break;
6236
6237 case WID_DTIM_PERIOD:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006238 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006239 break;
6240
6241 case WID_SITE_SURVEY:
Chaehyun Limd85f5322015-06-11 14:35:54 +09006242 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006243 break;
6244
6245 case WID_SITE_SURVEY_SCAN_TIME:
6246 *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time;
6247 break;
6248
6249 case WID_ACTIVE_SCAN_TIME:
6250 *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time;
6251 break;
6252
6253 case WID_PASSIVE_SCAN_TIME:
6254 *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time;
6255 break;
6256
6257 case WID_CURRENT_TX_RATE:
6258 *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate;
6259 break;
6260
6261 default:
6262 break;
6263 }
6264
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006265 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006266
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006267 return s32Error;
6268
6269}
6270
6271/*****************************************************************************/
6272/* Notification Functions */
6273/*****************************************************************************/
6274/**
6275 * @brief notifies host with join and leave requests
6276 * @details This function prepares an Information frame having the
6277 * information about a joining/leaving station.
6278 * @param[in,out] handle to the wifi driver,
6279 * @param[in] 6 byte Sta Adress
6280 * Join or leave flag:
6281 * Join = 1,
6282 * Leave =0
6283 * @return Error code indicating success/failure
6284 * @note
6285 * @author zsalah
6286 * @date 8 March 2012
6287 * @version 1.0
6288 */
6289void host_int_send_join_leave_info_to_host
Dean Lee72ed4dc2015-06-12 14:11:44 +09006290 (u16 assocId, u8 *stationAddr, bool joining)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006291{
6292}
6293/**
6294 * @brief notifies host with stations found in scan
6295 * @details sends the beacon/probe response from scan
6296 * @param[in,out] handle to the wifi driver,
6297 * @param[in] Sta Address,
6298 * Frame length,
6299 * Rssi of the Station found
6300 * @return Error code indicating success/failure
6301 * @note
6302 * @author zsalah
6303 * @date 8 March 2012
6304 * @version 1.0
6305 */
6306
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006307static void GetPeriodicRSSI(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006308{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006309 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006310
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006311 if (pstrWFIDrv == NULL) {
6312 PRINT_ER("Driver handler is NULL\n");
6313 return;
6314 }
6315
6316 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
Leo Kime6e12662015-09-16 18:36:03 +09006317 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006318 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006319
6320 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09006321 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006322
Tony Choa9f812a2015-09-21 12:16:33 +09006323 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Cho143eb952015-09-21 12:16:32 +09006324 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006325
6326 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006327 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006328 if (s32Error) {
6329 PRINT_ER("Failed to send get host channel param's message queue ");
6330 return;
6331 }
6332 }
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07006333 g_hPeriodicRSSI.data = (unsigned long)pstrWFIDrv;
6334 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006335}
6336
6337
6338void host_int_send_network_info_to_host
Chaehyun Limca356ad2015-06-11 14:35:57 +09006339 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006340{
6341}
6342/**
6343 * @brief host_int_init
6344 * @details host interface initialization function
6345 * @param[in,out] handle to the wifi driver,
6346 * @note
6347 * @author zsalah
6348 * @date 8 March 2012
6349 * @version 1.0
6350 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006351static u32 u32Intialized;
6352static u32 msgQ_created;
6353static u32 clients_count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006354
Johnny Kim218dc402015-08-13 13:41:19 +09006355s32 host_int_init(tstrWILC_WFIDrv **phWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006356{
Leo Kime6e12662015-09-16 18:36:03 +09006357 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006358 tstrWILC_WFIDrv *pstrWFIDrv;
Johnny Kimd42ab082015-08-20 16:32:52 +09006359 int err;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006360
6361 /*if(u32Intialized == 1)
6362 * {
6363 * PRINT_D(HOSTINF_DBG,"Host interface is previously initialized\n");
6364 * *phWFIDrv = (WILC_WFIDrvHandle)gWFiDrvHandle; //Will be adjusted later for P2P
6365 * return 0;
6366 * } */
6367 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
6368
Dean Lee72ed4dc2015-06-12 14:11:44 +09006369 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006370
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006371 sema_init(&hWaitResponse, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006372
6373
6374
6375 /*Allocate host interface private structure*/
Glen Leef3052582015-09-10 12:03:04 +09006376 pstrWFIDrv = kmalloc(sizeof(tstrWILC_WFIDrv), GFP_KERNEL);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006377 if (pstrWFIDrv == NULL) {
Leo Kime6e12662015-09-16 18:36:03 +09006378 s32Error = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006379 PRINT_ER("Failed to allocate memory\n");
6380 goto _fail_timer_2;
6381 }
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006382 memset(pstrWFIDrv, 0, sizeof(tstrWILC_WFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006383 /*return driver handle to user*/
Johnny Kim218dc402015-08-13 13:41:19 +09006384 *phWFIDrv = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006385 /*save into globl handle*/
Johnny Kimd42ab082015-08-20 16:32:52 +09006386 err = add_handler_in_list(pstrWFIDrv);
6387 if (err) {
Leo Kime6e12662015-09-16 18:36:03 +09006388 s32Error = -EFAULT;
Johnny Kimd42ab082015-08-20 16:32:52 +09006389 goto _fail_timer_2;
6390 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006391
6392 #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
6393
Dean Lee72ed4dc2015-06-12 14:11:44 +09006394 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006395 #endif
6396
Johnny Kim8a143302015-06-10 17:06:46 +09006397 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006398 /* /////////////////////////////////////// */
6399 if (clients_count == 0) {
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006400 sema_init(&hSemHostIFthrdEnd, 0);
6401 sema_init(&hSemDeinitDrvHandle, 0);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006402 sema_init(&hSemHostIntDeinit, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006403 }
6404
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006405 sema_init(&(pstrWFIDrv->hSemTestKeyBlock), 0);
6406 sema_init(&(pstrWFIDrv->hSemTestDisconnectBlock), 0);
6407 sema_init(&(pstrWFIDrv->hSemGetRSSI), 0);
6408 sema_init(&(pstrWFIDrv->hSemGetLINKSPEED), 0);
6409 sema_init(&(pstrWFIDrv->hSemGetCHNL), 0);
6410 sema_init(&(pstrWFIDrv->hSemInactiveTime), 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006411
6412 /* /////////////////////////////////////// */
6413
6414
6415
6416 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
6417
6418 if (clients_count == 0) {
Chaehyun Limcd08fc72015-08-19 15:59:05 +09006419 s32Error = wilc_mq_create(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006420
6421 if (s32Error < 0) {
6422 PRINT_ER("Failed to creat MQ\n");
6423 goto _fail_;
6424 }
6425 msgQ_created = 1;
Arnd Bergmann1999bd52015-05-29 22:52:14 +02006426 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
6427 if (IS_ERR(HostIFthreadHandler)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006428 PRINT_ER("Failed to creat Thread\n");
Leo Kime6e12662015-09-16 18:36:03 +09006429 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006430 goto _fail_mq_;
6431 }
Greg Kroah-Hartman507d7fc2015-08-17 12:59:42 -07006432 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
6433 (unsigned long)pstrWFIDrv);
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07006434 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006435 }
6436
6437
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006438 setup_timer(&pstrWFIDrv->hScanTimer, TimerCB_Scan, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006439
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006440 setup_timer(&pstrWFIDrv->hConnectTimer, TimerCB_Connect, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006441
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006442 /*Remain on channel timer*/
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006443 setup_timer(&pstrWFIDrv->hRemainOnChannel, ListenTimerCB, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006444
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006445 sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1);
6446 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006447
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006448 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09006449 /* gWFiDrvHandle->bPendingConnRequest = false; */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006450
6451 /*Initialize CFG WIDS Defualt Values*/
6452
6453 pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
6454 pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN;
6455 pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
6456 pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
6457 pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE;
6458
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006459 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
6460
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006461 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",
6462
6463 pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source,
6464 pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time,
6465 pstrWFIDrv->strCfgValues.curr_tx_rate);
6466
6467
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006468 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006469
6470 /*TODO Code to setup simulation to be removed later*/
6471 /*Intialize configurator module*/
6472 s32Error = CoreConfiguratorInit();
6473 if (s32Error < 0) {
6474 PRINT_ER("Failed to initialize core configurator\n");
6475 goto _fail_mem_;
6476 }
6477
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006478 u32Intialized = 1;
6479 clients_count++; /* increase number of created entities */
6480
6481 return s32Error;
6482
6483
6484_fail_mem_:
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006485 if (pstrWFIDrv != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006486 kfree(pstrWFIDrv);
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006487 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006488_fail_timer_2:
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006489 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006490 del_timer_sync(&pstrWFIDrv->hConnectTimer);
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006491 del_timer_sync(&pstrWFIDrv->hScanTimer);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02006492 kthread_stop(HostIFthreadHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006493_fail_mq_:
Chaehyun Lim1b128f62015-08-19 15:59:08 +09006494 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006495_fail_:
6496 return s32Error;
6497
6498
6499}
6500/**
6501 * @brief host_int_deinit
6502 * @details host interface initialization function
6503 * @param[in,out] handle to the wifi driver,
6504 * @note
6505 * @author zsalah
6506 * @date 8 March 2012
6507 * @version 1.0
6508 */
6509
Johnny Kim218dc402015-08-13 13:41:19 +09006510s32 host_int_deinit(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006511{
Leo Kime6e12662015-09-16 18:36:03 +09006512 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006513 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006514 int ret;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006515
6516 /*obtain driver handle*/
6517 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
6518 /*if(u32Intialized == 0)
6519 * {
6520 * PRINT_ER("Host Interface is not initialized\n");
6521 * return 0;
6522 * }*/
6523
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006524
6525 if (pstrWFIDrv == NULL) {
6526 PRINT_ER("pstrWFIDrv = NULL\n");
6527 return 0;
6528 }
6529
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006530 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006531
6532 terminated_handle = pstrWFIDrv;
6533 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
6534
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006535 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
6536 /*to guarantee handling all messages befor proceeding*/
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006537 if (del_timer_sync(&pstrWFIDrv->hScanTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006538 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006539 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
6540 }
6541
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006542 if (del_timer_sync(&pstrWFIDrv->hConnectTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006543 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006544 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6545 }
6546
6547
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006548 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006549 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006550 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6551 }
6552
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006553 /*Destroy Remain-onchannel Timer*/
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006554 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006555
Johnny Kim218dc402015-08-13 13:41:19 +09006556 host_int_set_wfi_drv_handler(NULL);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006557 down(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006558
6559
6560 /*Calling the CFG80211 scan done function with the abort flag set to true*/
6561 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006562 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006563 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
6564
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006565 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006566 }
6567 /*deinit configurator and simulator*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006568 CoreConfiguratorDeInit();
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006569
6570 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6571
Dean Lee72ed4dc2015-06-12 14:11:44 +09006572 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006573
Tony Cho143eb952015-09-21 12:16:32 +09006574 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006575
6576 if (clients_count == 1) {
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006577 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006578 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006579 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6580 }
Tony Choa9f812a2015-09-21 12:16:33 +09006581 msg.id = HOST_IF_MSG_EXIT;
Tony Cho143eb952015-09-21 12:16:32 +09006582 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006583
6584
Tony Cho143eb952015-09-21 12:16:32 +09006585 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kime6e12662015-09-16 18:36:03 +09006586 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006587 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006588
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006589 down(&hSemHostIFthrdEnd);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006590
Chaehyun Lim1b128f62015-08-19 15:59:08 +09006591 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006592 msgQ_created = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006593 }
6594
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006595 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006596
6597 /*Setting the gloabl driver handler with NULL*/
6598 u32Intialized = 0;
6599 /* gWFiDrvHandle = NULL; */
Johnny Kimd42ab082015-08-20 16:32:52 +09006600 ret = remove_handler_in_list(pstrWFIDrv);
6601 if (ret)
Leo Kime6e12662015-09-16 18:36:03 +09006602 s32Error = -ENOENT;
Johnny Kimd42ab082015-08-20 16:32:52 +09006603
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006604 if (pstrWFIDrv != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09006605 kfree(pstrWFIDrv);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006606 /* pstrWFIDrv=NULL; */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006607
6608 }
6609
6610 clients_count--; /* Decrease number of created entities */
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006611 terminated_handle = NULL;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006612 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006613 return s32Error;
6614}
6615
6616
6617/**
6618 * @brief NetworkInfoReceived
6619 * @details function to to be called when network info packet is received
6620 * @param[in] pu8Buffer the received packet
6621 * @param[in] u32Length length of the received packet
6622 * @return none
6623 * @note
6624 * @author
6625 * @date 1 Mar 2012
6626 * @version 1.0
6627 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006628void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006629{
Leo Kime6e12662015-09-16 18:36:03 +09006630 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006631 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006632 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006633 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006634
Johnny Kimd42ab082015-08-20 16:32:52 +09006635 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6636 pstrWFIDrv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006637
6638
6639
6640
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006641 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
Johnny Kim8a143302015-06-10 17:06:46 +09006642 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006643 return;
6644 }
6645
6646 /* prepare the Asynchronous Network Info message */
Tony Cho143eb952015-09-21 12:16:32 +09006647 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006648
Tony Choa9f812a2015-09-21 12:16:33 +09006649 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
Tony Cho143eb952015-09-21 12:16:32 +09006650 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006651
Tony Cho410c2482015-09-21 12:16:35 +09006652 msg.body.strRcvdNetworkInfo.u32Length = u32Length;
6653 msg.body.strRcvdNetworkInfo.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
6654 memcpy(msg.body.strRcvdNetworkInfo.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006655 pu8Buffer, u32Length);
6656
6657 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006658 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006659 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006660 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006661}
6662
6663/**
6664 * @brief GnrlAsyncInfoReceived
6665 * @details function to be called when general Asynchronous info packet is received
6666 * @param[in] pu8Buffer the received packet
6667 * @param[in] u32Length length of the received packet
6668 * @return none
6669 * @note
6670 * @author
6671 * @date 15 Mar 2012
6672 * @version 1.0
6673 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006674void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006675{
Leo Kime6e12662015-09-16 18:36:03 +09006676 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006677 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006678 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006679 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006680
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006681 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006682
Johnny Kimd42ab082015-08-20 16:32:52 +09006683 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6684 pstrWFIDrv = get_handler_from_id(id);
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006685 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006686
6687
6688 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6689 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006690 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006691 return;
6692 }
6693
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006694 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006695 /* received mac status is not needed when there is no current Connect Request */
6696 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006697 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006698 return;
6699 }
6700
6701 /* prepare the General Asynchronous Info message */
Tony Cho143eb952015-09-21 12:16:32 +09006702 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006703
6704
Tony Choa9f812a2015-09-21 12:16:33 +09006705 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
Tony Cho143eb952015-09-21 12:16:32 +09006706 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006707
6708
Tony Cho410c2482015-09-21 12:16:35 +09006709 msg.body.strRcvdGnrlAsyncInfo.u32Length = u32Length;
6710 msg.body.strRcvdGnrlAsyncInfo.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
6711 memcpy(msg.body.strRcvdGnrlAsyncInfo.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006712 pu8Buffer, u32Length);
6713
6714 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006715 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006716 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006717 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006718
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006719 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006720}
6721
6722/**
6723 * @brief host_int_ScanCompleteReceived
6724 * @details Setting scan complete received notifcation in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006725 * @param[in] u8* pu8Buffer, u32 u32Length
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006726 * @return Error code.
6727 * @author
6728 * @date
6729 * @version 1.0
6730 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006731void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006732{
Leo Kime6e12662015-09-16 18:36:03 +09006733 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006734 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006735 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006736 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006737
Johnny Kimd42ab082015-08-20 16:32:52 +09006738 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6739 pstrWFIDrv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006740
6741
Johnny Kim8a143302015-06-10 17:06:46 +09006742 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006743
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006744 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006745 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006746
6747 /*if there is an ongoing scan request*/
6748 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6749 /* prepare theScan Done message */
Tony Cho143eb952015-09-21 12:16:32 +09006750 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006751
Tony Choa9f812a2015-09-21 12:16:33 +09006752 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
Tony Cho143eb952015-09-21 12:16:32 +09006753 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006754
6755
6756 /* will be deallocated by the receiving thread */
6757 /*no need to send message body*/
6758
Tony Cho410c2482015-09-21 12:16:35 +09006759 /*msg.body.strScanComplete.u32Length = u32Length;
6760 * msg.body.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
6761 * memcpy(msg.body.strScanComplete.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006762 * pu8Buffer, u32Length); */
6763
6764 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006765 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006766 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006767 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006768 }
6769
6770
6771 return;
6772
6773}
6774
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006775/**
6776 * @brief host_int_remain_on_channel
6777 * @details
6778 * @param[in] Handle to wifi driver
6779 * Duration to remain on channel
6780 * Channel to remain on
6781 * Pointer to fn to be called on receive frames in listen state
6782 * Pointer to remain-on-channel expired fn
6783 * Priv
6784 * @return Error code.
6785 * @author
6786 * @date
6787 * @version 1.0
6788 */
Johnny Kim218dc402015-08-13 13:41:19 +09006789s32 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 +09006790{
Leo Kime6e12662015-09-16 18:36:03 +09006791 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006792 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006793 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006794
Leo Kim24db7132015-09-16 18:36:01 +09006795 if (pstrWFIDrv == NULL) {
6796 PRINT_ER("driver is null\n");
6797 return -EFAULT;
6798 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006799
6800 /* prepare the remainonchan Message */
Tony Cho143eb952015-09-21 12:16:32 +09006801 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006802
6803 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006804 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
Tony Cho410c2482015-09-21 12:16:35 +09006805 msg.body.strHostIfRemainOnChan.u16Channel = chan;
6806 msg.body.strHostIfRemainOnChan.pRemainOnChanExpired = RemainOnChanExpired;
6807 msg.body.strHostIfRemainOnChan.pRemainOnChanReady = RemainOnChanReady;
6808 msg.body.strHostIfRemainOnChan.pVoid = pvUserArg;
6809 msg.body.strHostIfRemainOnChan.u32duration = u32duration;
6810 msg.body.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
Tony Cho143eb952015-09-21 12:16:32 +09006811 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006812
Tony Cho143eb952015-09-21 12:16:32 +09006813 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006814 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006815 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006816
6817 return s32Error;
6818}
6819
6820/**
6821 * @brief host_int_ListenStateExpired
6822 * @details
6823 * @param[in] Handle to wifi driver
6824 * Duration to remain on channel
6825 * Channel to remain on
6826 * Pointer to fn to be called on receive frames in listen state
6827 * Pointer to remain-on-channel expired fn
6828 * Priv
6829 * @return Error code.
6830 * @author
6831 * @date
6832 * @version 1.0
6833 */
Johnny Kim218dc402015-08-13 13:41:19 +09006834s32 host_int_ListenStateExpired(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006835{
Leo Kime6e12662015-09-16 18:36:03 +09006836 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006837 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006838 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006839
Leo Kim24db7132015-09-16 18:36:01 +09006840 if (pstrWFIDrv == NULL) {
6841 PRINT_ER("driver is null\n");
6842 return -EFAULT;
6843 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006844
6845 /*Stopping remain-on-channel timer*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07006846 del_timer(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006847
6848 /* prepare the timer fire Message */
Tony Cho143eb952015-09-21 12:16:32 +09006849 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09006850 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Cho143eb952015-09-21 12:16:32 +09006851 msg.drvHandler = hWFIDrv;
Tony Cho410c2482015-09-21 12:16:35 +09006852 msg.body.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006853
Tony Cho143eb952015-09-21 12:16:32 +09006854 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006855 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006856 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006857
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006858 return s32Error;
6859}
6860
6861/**
6862 * @brief host_int_frame_register
6863 * @details
6864 * @param[in] Handle to wifi driver
6865 * @return Error code.
6866 * @author
6867 * @date
6868 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09006869s32 host_int_frame_register(tstrWILC_WFIDrv *hWFIDrv, u16 u16FrameType, bool bReg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006870{
Leo Kime6e12662015-09-16 18:36:03 +09006871 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006872 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006873 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006874
Leo Kim24db7132015-09-16 18:36:01 +09006875 if (pstrWFIDrv == NULL) {
6876 PRINT_ER("driver is null\n");
6877 return -EFAULT;
6878 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006879
Tony Cho143eb952015-09-21 12:16:32 +09006880 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006881
6882 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006883 msg.id = HOST_IF_MSG_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006884 switch (u16FrameType) {
6885 case ACTION:
6886 PRINT_D(HOSTINF_DBG, "ACTION\n");
Tony Cho410c2482015-09-21 12:16:35 +09006887 msg.body.strHostIfRegisterFrame.u8Regid = ACTION_FRM_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006888 break;
6889
6890 case PROBE_REQ:
6891 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
Tony Cho410c2482015-09-21 12:16:35 +09006892 msg.body.strHostIfRegisterFrame.u8Regid = PROBE_REQ_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006893 break;
6894
6895 default:
6896 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
6897 break;
6898 }
Tony Cho410c2482015-09-21 12:16:35 +09006899 msg.body.strHostIfRegisterFrame.u16FrameType = u16FrameType;
6900 msg.body.strHostIfRegisterFrame.bReg = bReg;
Tony Cho143eb952015-09-21 12:16:32 +09006901 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006902
Tony Cho143eb952015-09-21 12:16:32 +09006903 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006904 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006905 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006906
6907 return s32Error;
6908
6909
6910}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006911
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006912/**
6913 * @brief host_int_add_beacon
6914 * @details Setting add beacon params in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006915 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
6916 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
6917 * u32 u32TailLen, u8* pu8Tail
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006918 * @return Error code.
6919 * @author
6920 * @date
6921 * @version 1.0
6922 */
Johnny Kim218dc402015-08-13 13:41:19 +09006923s32 host_int_add_beacon(tstrWILC_WFIDrv *hWFIDrv, u32 u32Interval,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006924 u32 u32DTIMPeriod,
6925 u32 u32HeadLen, u8 *pu8Head,
6926 u32 u32TailLen, u8 *pu8Tail)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006927{
Leo Kime6e12662015-09-16 18:36:03 +09006928 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006929 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006930 struct host_if_msg msg;
Tony Cho902362b2015-09-21 12:16:44 +09006931 struct set_beacon *pstrSetBeaconParam = &msg.body.strHostIFSetBeacon;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006932
Leo Kim24db7132015-09-16 18:36:01 +09006933 if (pstrWFIDrv == NULL) {
6934 PRINT_ER("driver is null\n");
6935 return -EFAULT;
6936 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006937
Tony Cho143eb952015-09-21 12:16:32 +09006938 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006939
6940 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
6941
6942
6943 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006944 msg.id = HOST_IF_MSG_ADD_BEACON;
Tony Cho143eb952015-09-21 12:16:32 +09006945 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006946 pstrSetBeaconParam->u32Interval = u32Interval;
6947 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
6948 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
Glen Leef3052582015-09-10 12:03:04 +09006949 pstrSetBeaconParam->pu8Head = kmalloc(u32HeadLen, GFP_KERNEL);
Leo Kim24db7132015-09-16 18:36:01 +09006950 if (pstrSetBeaconParam->pu8Head == NULL) {
6951 s32Error = -ENOMEM;
6952 goto ERRORHANDLER;
6953 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006954 memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006955 pstrSetBeaconParam->u32TailLen = u32TailLen;
6956
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006957 if (u32TailLen > 0) {
Glen Leef3052582015-09-10 12:03:04 +09006958 pstrSetBeaconParam->pu8Tail = kmalloc(u32TailLen, GFP_KERNEL);
Leo Kim24db7132015-09-16 18:36:01 +09006959 if (pstrSetBeaconParam->pu8Tail == NULL) {
6960 s32Error = -ENOMEM;
6961 goto ERRORHANDLER;
6962 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006963 memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006964 } else {
6965 pstrSetBeaconParam->pu8Tail = NULL;
6966 }
6967
Tony Cho143eb952015-09-21 12:16:32 +09006968 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006969 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006970 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006971
Leo Kim24db7132015-09-16 18:36:01 +09006972ERRORHANDLER:
6973 if (s32Error) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006974 if (pstrSetBeaconParam->pu8Head != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006975 kfree(pstrSetBeaconParam->pu8Head);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006976
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006977 if (pstrSetBeaconParam->pu8Tail != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006978 kfree(pstrSetBeaconParam->pu8Tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006979 }
6980
6981 return s32Error;
6982
6983}
6984
6985
6986/**
6987 * @brief host_int_del_beacon
6988 * @details Setting add beacon params in message queue
6989 * @param[in] WILC_WFIDrvHandle hWFIDrv
6990 * @return Error code.
6991 * @author
6992 * @date
6993 * @version 1.0
6994 */
Johnny Kim218dc402015-08-13 13:41:19 +09006995s32 host_int_del_beacon(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006996{
Leo Kime6e12662015-09-16 18:36:03 +09006997 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006998 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006999 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007000
Leo Kim24db7132015-09-16 18:36:01 +09007001 if (pstrWFIDrv == NULL) {
7002 PRINT_ER("driver is null\n");
7003 return -EFAULT;
7004 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007005
7006 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007007 msg.id = HOST_IF_MSG_DEL_BEACON;
Tony Cho143eb952015-09-21 12:16:32 +09007008 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007009 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
7010
Tony Cho143eb952015-09-21 12:16:32 +09007011 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim7dc1d0c2015-09-16 18:36:00 +09007012 if (s32Error)
7013 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007014
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007015 return s32Error;
7016}
7017
7018
7019/**
7020 * @brief host_int_add_station
7021 * @details Setting add station params in message queue
Tony Cho6a89ba92015-09-21 12:16:46 +09007022 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007023 * @return Error code.
7024 * @author
7025 * @date
7026 * @version 1.0
7027 */
Tony Cho6a89ba92015-09-21 12:16:46 +09007028s32 host_int_add_station(tstrWILC_WFIDrv *hWFIDrv,
7029 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007030{
Leo Kime6e12662015-09-16 18:36:03 +09007031 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007032 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007033 struct host_if_msg msg;
Tony Cho6a89ba92015-09-21 12:16:46 +09007034 struct add_sta_param *pstrAddStationMsg = &msg.body.strAddStaParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007035
7036
Leo Kim24db7132015-09-16 18:36:01 +09007037 if (pstrWFIDrv == NULL) {
7038 PRINT_ER("driver is null\n");
7039 return -EFAULT;
7040 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007041
Tony Cho143eb952015-09-21 12:16:32 +09007042 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007043
7044 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
7045
7046
7047 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007048 msg.id = HOST_IF_MSG_ADD_STATION;
Tony Cho143eb952015-09-21 12:16:32 +09007049 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007050
Tony Cho6a89ba92015-09-21 12:16:46 +09007051 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007052 if (pstrAddStationMsg->u8NumRates > 0) {
Glen Leef3052582015-09-10 12:03:04 +09007053 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02007054
Leo Kim7ae43362015-09-16 18:35:59 +09007055 if (!rates)
7056 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007057
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007058 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02007059 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007060 }
7061
7062
Tony Cho143eb952015-09-21 12:16:32 +09007063 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007064 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007065 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007066 return s32Error;
7067}
7068
7069/**
7070 * @brief host_int_del_station
7071 * @details Setting delete station params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007072 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007073 * @return Error code.
7074 * @author
7075 * @date
7076 * @version 1.0
7077 */
Johnny Kim218dc402015-08-13 13:41:19 +09007078s32 host_int_del_station(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8MacAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007079{
Leo Kime6e12662015-09-16 18:36:03 +09007080 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007081 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007082 struct host_if_msg msg;
Tony Cho410c2482015-09-21 12:16:35 +09007083 tstrHostIFDelSta *pstrDelStationMsg = &msg.body.strDelStaParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007084
Leo Kim24db7132015-09-16 18:36:01 +09007085 if (pstrWFIDrv == NULL) {
7086 PRINT_ER("driver is null\n");
7087 return -EFAULT;
7088 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007089
Tony Cho143eb952015-09-21 12:16:32 +09007090 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007091
7092 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
7093
7094
7095
7096 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007097 msg.id = HOST_IF_MSG_DEL_STATION;
Tony Cho143eb952015-09-21 12:16:32 +09007098 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007099
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09007100 if (pu8MacAddr == NULL)
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007101 memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007102 else
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007103 memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007104
Tony Cho143eb952015-09-21 12:16:32 +09007105 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007106 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007107 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007108 return s32Error;
7109}
7110/**
7111 * @brief host_int_del_allstation
7112 * @details Setting del station params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007113 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007114 * @return Error code.
7115 * @author
7116 * @date
7117 * @version 1.0
7118 */
Johnny Kim218dc402015-08-13 13:41:19 +09007119s32 host_int_del_allstation(tstrWILC_WFIDrv *hWFIDrv, u8 pu8MacAddr[][ETH_ALEN])
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007120{
Leo Kime6e12662015-09-16 18:36:03 +09007121 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007122 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007123 struct host_if_msg msg;
Tony Cho410c2482015-09-21 12:16:35 +09007124 tstrHostIFDelAllSta *pstrDelAllStationMsg = &msg.body.strHostIFDelAllSta;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007125 u8 au8Zero_Buff[ETH_ALEN] = {0};
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09007126 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007127 u8 u8AssocNumb = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007128
7129
Leo Kim24db7132015-09-16 18:36:01 +09007130 if (pstrWFIDrv == NULL) {
7131 PRINT_ER("driver is null\n");
7132 return -EFAULT;
7133 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007134
Tony Cho143eb952015-09-21 12:16:32 +09007135 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007136
7137 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
7138
7139 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007140 msg.id = HOST_IF_MSG_DEL_ALL_STA;
Tony Cho143eb952015-09-21 12:16:32 +09007141 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007142
7143 /* Handling situation of deauthenticing all associated stations*/
7144 for (i = 0; i < MAX_NUM_STA; i++) {
7145 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007146 memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007147 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],
7148 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
7149 u8AssocNumb++;
7150 }
7151 }
7152 if (!u8AssocNumb) {
7153 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
7154 return s32Error;
7155 }
7156
7157 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
Tony Cho143eb952015-09-21 12:16:32 +09007158 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007159
7160
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007161 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007162 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007163
Arnd Bergmann83383ea2015-06-01 21:06:43 +02007164 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007165
7166 return s32Error;
7167
7168}
7169
7170/**
7171 * @brief host_int_edit_station
7172 * @details Setting edit station params in message queue
Tony Cho6a89ba92015-09-21 12:16:46 +09007173 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007174 * @return Error code.
7175 * @author
7176 * @date
7177 * @version 1.0
7178 */
Tony Cho6a89ba92015-09-21 12:16:46 +09007179s32 host_int_edit_station(tstrWILC_WFIDrv *hWFIDrv,
7180 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007181{
Leo Kime6e12662015-09-16 18:36:03 +09007182 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007183 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007184 struct host_if_msg msg;
Tony Cho6a89ba92015-09-21 12:16:46 +09007185 struct add_sta_param *pstrAddStationMsg = &msg.body.strAddStaParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007186
Leo Kim24db7132015-09-16 18:36:01 +09007187 if (pstrWFIDrv == NULL) {
7188 PRINT_ER("driver is null\n");
7189 return -EFAULT;
7190 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007191
7192 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
7193
Tony Cho143eb952015-09-21 12:16:32 +09007194 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007195
7196
7197 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007198 msg.id = HOST_IF_MSG_EDIT_STATION;
Tony Cho143eb952015-09-21 12:16:32 +09007199 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007200
Tony Cho6a89ba92015-09-21 12:16:46 +09007201 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007202 if (pstrAddStationMsg->u8NumRates > 0) {
Glen Leef3052582015-09-10 12:03:04 +09007203 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02007204
Leo Kim7ae43362015-09-16 18:35:59 +09007205 if (!rates)
7206 return -ENOMEM;
7207
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007208 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02007209 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007210 }
7211
Tony Cho143eb952015-09-21 12:16:32 +09007212 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007213 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007214 PRINT_ER("wilc_mq_send fail\n");
7215
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007216 return s32Error;
7217}
Glen Lee108b3432015-09-16 18:53:20 +09007218
Johnny Kim218dc402015-08-13 13:41:19 +09007219s32 host_int_set_power_mgmt(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32Timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007220{
Leo Kime6e12662015-09-16 18:36:03 +09007221 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007222 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007223 struct host_if_msg msg;
Tony Cho5a008f12015-09-21 12:16:48 +09007224 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.strPowerMgmtparam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007225
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007226 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007227
Leo Kim24db7132015-09-16 18:36:01 +09007228 if (pstrWFIDrv == NULL) {
7229 PRINT_ER("driver is null\n");
7230 return -EFAULT;
7231 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007232
7233 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
7234
Tony Cho143eb952015-09-21 12:16:32 +09007235 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007236
7237
7238 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007239 msg.id = HOST_IF_MSG_POWER_MGMT;
Tony Cho143eb952015-09-21 12:16:32 +09007240 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007241
7242 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
7243 pstrPowerMgmtParam->u32Timeout = u32Timeout;
7244
7245
Tony Cho143eb952015-09-21 12:16:32 +09007246 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007247 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007248 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007249 return s32Error;
7250}
7251
Johnny Kim218dc402015-08-13 13:41:19 +09007252s32 host_int_setup_multicast_filter(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32count)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007253{
Leo Kime6e12662015-09-16 18:36:03 +09007254 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007255
7256 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007257 struct host_if_msg msg;
Tony Cho641210a2015-09-21 12:16:52 +09007258 struct set_multicast *pstrMulticastFilterParam = &msg.body.strHostIfSetMulti;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007259
7260
Leo Kim24db7132015-09-16 18:36:01 +09007261 if (pstrWFIDrv == NULL) {
7262 PRINT_ER("driver is null\n");
7263 return -EFAULT;
7264 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007265
7266 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
7267
Tony Cho143eb952015-09-21 12:16:32 +09007268 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007269
7270
7271 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007272 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
Tony Cho143eb952015-09-21 12:16:32 +09007273 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007274
7275 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
7276 pstrMulticastFilterParam->u32count = u32count;
7277
Tony Cho143eb952015-09-21 12:16:32 +09007278 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007279 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007280 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007281 return s32Error;
7282}
7283
7284
7285
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007286#ifdef WILC_PARSE_SCAN_IN_HOST
7287
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007288/**
7289 * @brief host_int_ParseJoinBssParam
7290 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
7291 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7292 * @return
7293 * @author zsalah
7294 * @date
7295 * @version 1.0**/
7296static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
7297{
7298 tstrJoinBssParam *pNewJoinBssParam = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007299 u8 *pu8IEs;
Chaehyun Limd85f5322015-06-11 14:35:54 +09007300 u16 u16IEsLen;
7301 u16 index = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007302 u8 suppRatesNo = 0;
7303 u8 extSuppRatesNo;
Chaehyun Limd85f5322015-06-11 14:35:54 +09007304 u16 jumpOffset;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09007305 u8 pcipherCount;
7306 u8 authCount;
7307 u8 pcipherTotalCount = 0;
7308 u8 authTotalCount = 0;
7309 u8 i, j;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007310
7311 pu8IEs = ptstrNetworkInfo->pu8IEs;
7312 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
7313
Glen Leef3052582015-09-10 12:03:04 +09007314 pNewJoinBssParam = kmalloc(sizeof(tstrJoinBssParam), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007315 if (pNewJoinBssParam != NULL) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007316 memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007317 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
7318 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
7319 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007320 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007321 /*for(i=0; i<6;i++)
7322 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007323 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007324 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
Chaehyun Lim2cc46832015-08-07 09:02:01 +09007325 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
7326 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007327 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
7328 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
7329
7330 /* parse supported rates: */
7331 while (index < u16IEsLen) {
7332 /* supportedRates IE */
7333 if (pu8IEs[index] == SUPP_RATES_IE) {
7334 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
7335 suppRatesNo = pu8IEs[index + 1];
7336 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
7337 index += 2; /* skipping ID and length bytes; */
7338
7339 for (i = 0; i < suppRatesNo; i++) {
7340 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
7341 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
7342 }
7343 index += suppRatesNo;
7344 continue;
7345 }
7346 /* Ext SupportedRates IE */
7347 else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
7348 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
7349 /* checking if no of ext. supp and supp rates < max limit */
7350 extSuppRatesNo = pu8IEs[index + 1];
7351 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
7352 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
7353 else
7354 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
7355 index += 2;
7356 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
7357 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
7358 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
7359 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
7360 }
7361 index += extSuppRatesNo;
7362 continue;
7363 }
7364 /* HT Cap. IE */
7365 else if (pu8IEs[index] == HT_CAPABILITY_IE) {
7366 /* if IE found set the flag */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09007367 pNewJoinBssParam->ht_capable = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007368 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7369 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
7370 continue;
7371 } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
7372 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
7373 (pu8IEs[index + 4] == 0xF2) && /* OUI */
7374 (pu8IEs[index + 5] == 0x02) && /* OUI Type */
7375 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
7376 (pu8IEs[index + 7] == 0x01)) {
7377 /* Presence of WMM Info/Param element indicates WMM capability */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09007378 pNewJoinBssParam->wmm_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007379
7380 /* Check if Bit 7 is set indicating U-APSD capability */
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007381 if (pu8IEs[index + 8] & (1 << 7))
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09007382 pNewJoinBssParam->uapsd_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007383 index += pu8IEs[index + 1] + 2;
7384 continue;
7385 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007386 else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
7387 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
7388 (pu8IEs[index + 4] == 0x9a) && /* OUI */
7389 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
Chaehyun Limd85f5322015-06-11 14:35:54 +09007390 u16 u16P2P_count;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02007391
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007392 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
7393 pNewJoinBssParam->u8NoaEnbaled = 1;
7394 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
7395
7396 /* Check if Bit 7 is set indicating Opss capability */
7397 if (pu8IEs[index + 10] & (1 << 7)) {
7398 pNewJoinBssParam->u8OppEnable = 1;
7399 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
7400 } else
7401 pNewJoinBssParam->u8OppEnable = 0;
7402 /* HOSTINF_DBG */
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007403 PRINT_D(GENERIC_DBG, "P2P Dump\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007404 for (i = 0; i < pu8IEs[index + 7]; i++)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007405 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007406
7407 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
7408 u16P2P_count = index + 12;
7409
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007410 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007411 u16P2P_count += 4;
7412
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007413 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007414 u16P2P_count += 4;
7415
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007416 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007417
7418 index += pu8IEs[index + 1] + 2;
7419 continue;
7420
7421 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007422 else if ((pu8IEs[index] == RSN_IE) ||
7423 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
7424 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
7425 (pu8IEs[index + 5] == 0x01))) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09007426 u16 rsnIndex = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007427 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
7428 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
7429 * {
7430 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
7431 * }*/
7432 if (pu8IEs[rsnIndex] == RSN_IE) {
7433 pNewJoinBssParam->mode_802_11i = 2;
7434 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
7435 } else { /* check if rsn was previously parsed */
7436 if (pNewJoinBssParam->mode_802_11i == 0)
7437 pNewJoinBssParam->mode_802_11i = 1;
7438 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
7439 rsnIndex += 4;
7440 }
7441 rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
7442 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
7443 rsnIndex++;
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007444 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007445 /* initialize policies with invalid values */
7446
7447 jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
7448
7449 /*parsing pairwise cipher*/
7450
7451 /* saving 3 pcipher max. */
7452 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7453 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7454
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007455 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007456 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
7457 /* each count corresponds to 4 bytes, only last byte is saved */
7458 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7459 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
7460 }
7461 pcipherTotalCount += pcipherCount;
7462 rsnIndex += jumpOffset;
7463
7464 jumpOffset = pu8IEs[rsnIndex] * 4;
7465
7466 /*parsing AKM suite (auth_policy)*/
7467 /* saving 3 auth policies max. */
7468 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7469 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7470
7471 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
7472 /* each count corresponds to 4 bytes, only last byte is saved */
7473 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7474 }
7475 authTotalCount += authCount;
7476 rsnIndex += jumpOffset;
7477 /*pasring rsn cap. only if rsn IE*/
7478 if (pu8IEs[index] == RSN_IE) {
7479 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
7480 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
7481 rsnIndex += 2;
7482 }
Abdul Hussainf717c0eb2015-06-16 09:49:49 +00007483 pNewJoinBssParam->rsn_found = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007484 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7485 continue;
7486 } else
7487 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7488
7489 }
7490
7491
7492 }
7493
7494 return (void *)pNewJoinBssParam;
7495
7496}
7497
7498void host_int_freeJoinParams(void *pJoinParams)
7499{
7500 if ((tstrJoinBssParam *)pJoinParams != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09007501 kfree((tstrJoinBssParam *)pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007502 else
7503 PRINT_ER("Unable to FREE null pointer\n");
7504}
7505#endif /*WILC_PARSE_SCAN_IN_HOST*/
7506
7507
7508/**
7509 * @brief host_int_addBASession
7510 * @details Open a block Ack session with the given parameters
7511 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7512 * @return
7513 * @author anoureldin
7514 * @date
7515 * @version 1.0**/
7516
Johnny Kim2b05df52015-08-13 13:41:21 +09007517static int host_int_addBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID, short int BufferSize,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007518 short int SessionTimeout, void *drvHandler)
7519{
Leo Kime6e12662015-09-16 18:36:03 +09007520 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007521 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007522 struct host_if_msg msg;
Tony Cho410c2482015-09-21 12:16:35 +09007523 tstrHostIfBASessionInfo *pBASessionInfo = &msg.body.strHostIfBASessionInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007524
Leo Kim24db7132015-09-16 18:36:01 +09007525 if (pstrWFIDrv == NULL) {
7526 PRINT_ER("driver is null\n");
7527 return -EFAULT;
7528 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007529
Tony Cho143eb952015-09-21 12:16:32 +09007530 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007531
7532 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007533 msg.id = HOST_IF_MSG_ADD_BA_SESSION;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007534
7535 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7536 pBASessionInfo->u8Ted = TID;
7537 pBASessionInfo->u16BufferSize = BufferSize;
7538 pBASessionInfo->u16SessionTimeout = SessionTimeout;
Tony Cho143eb952015-09-21 12:16:32 +09007539 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007540
Tony Cho143eb952015-09-21 12:16:32 +09007541 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007542 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007543 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007544
7545 return s32Error;
7546}
7547
7548
Johnny Kim218dc402015-08-13 13:41:19 +09007549s32 host_int_delBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007550{
Leo Kime6e12662015-09-16 18:36:03 +09007551 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007552 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007553 struct host_if_msg msg;
Tony Cho410c2482015-09-21 12:16:35 +09007554 tstrHostIfBASessionInfo *pBASessionInfo = &msg.body.strHostIfBASessionInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007555
Leo Kim24db7132015-09-16 18:36:01 +09007556 if (pstrWFIDrv == NULL) {
7557 PRINT_ER("driver is null\n");
7558 return -EFAULT;
7559 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007560
Tony Cho143eb952015-09-21 12:16:32 +09007561 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007562
7563 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007564 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007565
7566 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7567 pBASessionInfo->u8Ted = TID;
Tony Cho143eb952015-09-21 12:16:32 +09007568 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007569
Tony Cho143eb952015-09-21 12:16:32 +09007570 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007571 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007572 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007573
Arnd Bergmann83383ea2015-06-01 21:06:43 +02007574 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007575
7576 return s32Error;
7577}
7578
Johnny Kim218dc402015-08-13 13:41:19 +09007579s32 host_int_del_All_Rx_BASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007580{
Leo Kime6e12662015-09-16 18:36:03 +09007581 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007582 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007583 struct host_if_msg msg;
Tony Cho410c2482015-09-21 12:16:35 +09007584 tstrHostIfBASessionInfo *pBASessionInfo = &msg.body.strHostIfBASessionInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007585
Leo Kim24db7132015-09-16 18:36:01 +09007586 if (pstrWFIDrv == NULL) {
7587 PRINT_ER("driver is null\n");
7588 return -EFAULT;
7589 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007590
Tony Cho143eb952015-09-21 12:16:32 +09007591 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007592
7593 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007594 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007595
7596 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7597 pBASessionInfo->u8Ted = TID;
Tony Cho143eb952015-09-21 12:16:32 +09007598 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007599
Tony Cho143eb952015-09-21 12:16:32 +09007600 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007601 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007602 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007603
Arnd Bergmann83383ea2015-06-01 21:06:43 +02007604 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007605
7606 return s32Error;
7607}
7608
7609/**
7610 * @brief host_int_setup_ipaddress
7611 * @details setup IP in firmware
7612 * @param[in] Handle to wifi driver
7613 * @return Error code.
7614 * @author Abdelrahman Sobhy
7615 * @date
7616 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09007617s32 host_int_setup_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007618{
Leo Kime6e12662015-09-16 18:36:03 +09007619 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007620 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007621 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007622
7623 /* TODO: Enable This feature on softap firmware */
7624 return 0;
7625
Leo Kim24db7132015-09-16 18:36:01 +09007626 if (pstrWFIDrv == NULL) {
7627 PRINT_ER("driver is null\n");
7628 return -EFAULT;
7629 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007630
Tony Cho143eb952015-09-21 12:16:32 +09007631 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007632
7633 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007634 msg.id = HOST_IF_MSG_SET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007635
Tony Cho410c2482015-09-21 12:16:35 +09007636 msg.body.strHostIfSetIP.au8IPAddr = u16ipadd;
Tony Cho143eb952015-09-21 12:16:32 +09007637 msg.drvHandler = hWFIDrv;
Tony Cho410c2482015-09-21 12:16:35 +09007638 msg.body.strHostIfSetIP.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007639
Tony Cho143eb952015-09-21 12:16:32 +09007640 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007641 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007642 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007643
7644 return s32Error;
7645
7646
7647}
7648
7649/**
7650 * @brief host_int_get_ipaddress
7651 * @details Get IP from firmware
7652 * @param[in] Handle to wifi driver
7653 * @return Error code.
7654 * @author Abdelrahman Sobhy
7655 * @date
7656 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09007657s32 host_int_get_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007658{
Leo Kime6e12662015-09-16 18:36:03 +09007659 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007660 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007661 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007662
Leo Kim24db7132015-09-16 18:36:01 +09007663 if (pstrWFIDrv == NULL) {
7664 PRINT_ER("driver is null\n");
7665 return -EFAULT;
7666 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007667
Tony Cho143eb952015-09-21 12:16:32 +09007668 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007669
7670 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007671 msg.id = HOST_IF_MSG_GET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007672
Tony Cho410c2482015-09-21 12:16:35 +09007673 msg.body.strHostIfSetIP.au8IPAddr = u16ipadd;
Tony Cho143eb952015-09-21 12:16:32 +09007674 msg.drvHandler = hWFIDrv;
Tony Cho410c2482015-09-21 12:16:35 +09007675 msg.body.strHostIfSetIP.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007676
Tony Cho143eb952015-09-21 12:16:32 +09007677 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007678 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007679 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007680
7681 return s32Error;
7682
7683
7684}