blob: 9dac90686c11aca7fc4354a8365b93a693363d87 [file] [log] [blame]
Chaehyun Lime215a872015-09-30 08:15:41 +09001#include <linux/slab.h>
2#include <linux/time.h>
3#include <linux/kthread.h>
4#include <linux/delay.h>
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005#include "host_interface.h"
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006#include "coreconfigurator.h"
Chaehyun Lim53660122015-09-17 16:48:49 +09007#include "wilc_wlan_if.h"
Chaehyun Limf23eb982015-09-23 18:03:47 +09008#include "wilc_msgqueue.h"
Johnny Kimc5c77ba2015-05-11 14:30:56 +09009
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090010extern u8 connecting;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090011
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -070012extern struct timer_list hDuringIpTimer;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090013
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090014extern u8 g_wilc_initialized;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090015/*****************************************************************************/
16/* Macros */
17/*****************************************************************************/
18
19/* Message types of the Host IF Message Queue*/
Chaehyun Lim9eac3a12015-06-18 22:08:51 +090020#define HOST_IF_MSG_SCAN 0
21#define HOST_IF_MSG_CONNECT 1
22#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
23#define HOST_IF_MSG_KEY 3
24#define HOST_IF_MSG_RCVD_NTWRK_INFO 4
25#define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
26#define HOST_IF_MSG_CFG_PARAMS 6
27#define HOST_IF_MSG_SET_CHANNEL 7
28#define HOST_IF_MSG_DISCONNECT 8
29#define HOST_IF_MSG_GET_RSSI 9
30#define HOST_IF_MSG_GET_CHNL 10
31#define HOST_IF_MSG_ADD_BEACON 11
32#define HOST_IF_MSG_DEL_BEACON 12
33#define HOST_IF_MSG_ADD_STATION 13
34#define HOST_IF_MSG_DEL_STATION 14
35#define HOST_IF_MSG_EDIT_STATION 15
36#define HOST_IF_MSG_SCAN_TIMER_FIRED 16
37#define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
38#define HOST_IF_MSG_POWER_MGMT 18
39#define HOST_IF_MSG_GET_INACTIVETIME 19
40#define HOST_IF_MSG_REMAIN_ON_CHAN 20
41#define HOST_IF_MSG_REGISTER_FRAME 21
42#define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
43#define HOST_IF_MSG_GET_LINKSPEED 23
44#define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
45#define HOST_IF_MSG_SET_MAC_ADDRESS 25
46#define HOST_IF_MSG_GET_MAC_ADDRESS 26
47#define HOST_IF_MSG_SET_OPERATION_MODE 27
48#define HOST_IF_MSG_SET_IPADDRESS 28
49#define HOST_IF_MSG_GET_IPADDRESS 29
50#define HOST_IF_MSG_FLUSH_CONNECT 30
51#define HOST_IF_MSG_GET_STATISTICS 31
52#define HOST_IF_MSG_SET_MULTICAST_FILTER 32
53#define HOST_IF_MSG_ADD_BA_SESSION 33
54#define HOST_IF_MSG_DEL_BA_SESSION 34
55#define HOST_IF_MSG_Q_IDLE 35
56#define HOST_IF_MSG_DEL_ALL_STA 36
57#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
58#define HOST_IF_MSG_EXIT 100
Johnny Kimc5c77ba2015-05-11 14:30:56 +090059
Chaehyun Lime54d5b72015-06-18 22:08:50 +090060#define HOST_IF_SCAN_TIMEOUT 4000
61#define HOST_IF_CONNECT_TIMEOUT 9500
Johnny Kimc5c77ba2015-05-11 14:30:56 +090062
Chaehyun Lime54d5b72015-06-18 22:08:50 +090063#define BA_SESSION_DEFAULT_BUFFER_SIZE 16
64#define BA_SESSION_DEFAULT_TIMEOUT 1000
65#define BLOCK_ACK_REQ_SIZE 0x14
Johnny Kimc5c77ba2015-05-11 14:30:56 +090066/*****************************************************************************/
67/* Type Definitions */
68/*****************************************************************************/
69
70/*!
Tony Cho361ff842015-09-21 12:16:41 +090071 * @struct cfg_param_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +090072 * @brief Structure to hold Host IF CFG Params Attributes
73 * @details
74 * @todo
75 * @sa
76 * @author Mai Daftedar
77 * @date 02 April 2012
78 * @version 1.0
79 */
Tony Cho361ff842015-09-21 12:16:41 +090080struct cfg_param_attr {
Johnny Kimc5c77ba2015-05-11 14:30:56 +090081 tstrCfgParamVal pstrCfgParamVal;
Tony Cho361ff842015-09-21 12:16:41 +090082};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090083
84/*!
85 * @struct tstrHostIFwpaAttr
86 * @brief Structure to hold Host IF Scan Attributes
87 * @details
88 * @todo
89 * @sa
90 * @author Mai Daftedar
91 * @date 25 March 2012
92 * @version 1.0
93 */
94typedef struct _tstrHostIFwpaAttr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090095 u8 *pu8key;
96 const u8 *pu8macaddr;
97 u8 *pu8seq;
98 u8 u8seqlen;
99 u8 u8keyidx;
100 u8 u8Keylen;
101 u8 u8Ciphermode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900102} tstrHostIFwpaAttr;
103
104
105/*!
106 * @struct tstrHostIFwepAttr
107 * @brief Structure to hold Host IF Scan Attributes
108 * @details
109 * @todo
110 * @sa
111 * @author Mai Daftedar
112 * @date 25 March 2012
113 * @version 1.0
114 */
115typedef struct _tstrHostIFwepAttr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900116 u8 *pu8WepKey;
117 u8 u8WepKeylen;
118 u8 u8Wepidx;
119 u8 u8mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900120 AUTHTYPE_T tenuAuth_type;
121
122} tstrHostIFwepAttr;
123
124/*!
125 * @struct tuniHostIFkeyAttr
126 * @brief Structure to hold Host IF Scan Attributes
127 * @details
128 * @todo
129 * @sa
130 * @author Mai Daftedar
131 * @date 25 March 2012
132 * @version 1.0
133 */
134typedef union _tuniHostIFkeyAttr {
135 tstrHostIFwepAttr strHostIFwepAttr;
136 tstrHostIFwpaAttr strHostIFwpaAttr;
137 tstrHostIFpmkidAttr strHostIFpmkidAttr;
138} tuniHostIFkeyAttr;
139
140/*!
Tony Choc98387a2015-09-21 12:16:40 +0900141 * @struct key_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900142 * @brief Structure to hold Host IF Scan Attributes
143 * @details
144 * @todo
145 * @sa
146 * @author Mai Daftedar
147 * @date 25 March 2012
148 * @version 1.0
149 */
Tony Choc98387a2015-09-21 12:16:40 +0900150struct key_attr {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900151 tenuKeyType enuKeyType;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900152 u8 u8KeyAction;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900153 tuniHostIFkeyAttr uniHostIFkeyAttr;
Tony Choc98387a2015-09-21 12:16:40 +0900154};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900155
156
157
158
159/*!
Tony Choc476feb2015-09-21 12:16:36 +0900160 * @struct scan_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900161 * @brief Structure to hold Host IF Scan Attributes
162 * @details
163 * @todo
164 * @sa
165 * @author Mostafa Abu Bakr
166 * @date 25 March 2012
167 * @version 1.0
168 */
Tony Choc476feb2015-09-21 12:16:36 +0900169struct scan_attr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900170 u8 u8ScanSource;
171 u8 u8ScanType;
172 u8 *pu8ChnlFreqList;
173 u8 u8ChnlListLen;
174 u8 *pu8IEs;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900175 size_t IEsLen;
176 tWILCpfScanResult pfScanResult;
177 void *pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900178 tstrHiddenNetwork strHiddenNetwork;
Tony Choc476feb2015-09-21 12:16:36 +0900179};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900180
181/*!
Tony Cho120ae592015-09-21 12:16:37 +0900182 * @struct connect_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900183 * @brief Structure to hold Host IF Connect Attributes
184 * @details
185 * @todo
186 * @sa
187 * @author Mostafa Abu Bakr
188 * @date 25 March 2012
189 * @version 1.0
190 */
Tony Cho120ae592015-09-21 12:16:37 +0900191struct connect_attr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900192 u8 *pu8bssid;
193 u8 *pu8ssid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900194 size_t ssidLen;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900195 u8 *pu8IEs;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900196 size_t IEsLen;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900197 u8 u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900198 tWILCpfConnectResult pfConnectResult;
199 void *pvUserArg;
200 AUTHTYPE_T tenuAuth_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900201 u8 u8channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900202 void *pJoinParams;
Tony Cho120ae592015-09-21 12:16:37 +0900203};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900204
205/*!
Tony Chof23a9ea2015-09-21 12:16:39 +0900206 * @struct rcvd_async_info
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900207 * @brief Structure to hold Received General Asynchronous info
208 * @details
209 * @todo
210 * @sa
211 * @author Mostafa Abu Bakr
212 * @date 25 March 2012
213 * @version 1.0
214 */
Tony Chof23a9ea2015-09-21 12:16:39 +0900215struct rcvd_async_info {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900216 u8 *pu8Buffer;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900217 u32 u32Length;
Tony Chof23a9ea2015-09-21 12:16:39 +0900218};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900219
220/*!
Tony Cho94bdfe42015-09-30 18:44:27 +0900221 * @struct channel_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900222 * @brief Set Channel message body
223 * @details
224 * @todo
225 * @sa
226 * @author Mai Daftedar
227 * @date 25 March 2012
228 * @version 1.0
229 */
Tony Cho94bdfe42015-09-30 18:44:27 +0900230struct channel_attr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900231 u8 u8SetChan;
Tony Cho326b3232015-09-21 12:16:42 +0900232};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900233
234/*!
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900235 * @struct tstrScanComplete
236 * @brief hold received Async. Scan Complete message body
237 * @details
238 * @todo
239 * @sa
240 * @author zsalah
241 * @date 25 March 2012
242 * @version 1.0
243 */
244/*typedef struct _tstrScanComplete
245 * {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900246 * u8* pu8Buffer;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900247 * u32 u32Length;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900248 * } tstrScanComplete;*/
249
250/*!
Tony Cho7f33fec2015-09-30 18:44:30 +0900251 * @struct beacon_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900252 * @brief Set Beacon message body
253 * @details
254 * @todo
255 * @sa
256 * @author Adham Abozaeid
257 * @date 10 July 2012
258 * @version 1.0
259 */
Tony Cho7f33fec2015-09-30 18:44:30 +0900260struct beacon_attr {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900261 u32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */
262 u32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900263 * (including the current frame) appear before the next DTIM */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900264 u32 u32HeadLen; /*!< Length of the head buffer in bytes */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900265 u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900266 * from the beacon's start till the TIM element, NOT including the TIM */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900267 u32 u32TailLen; /*!< Length of the tail buffer in bytes */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900268 u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900269 * after the TIM inormation element */
Tony Cho902362b2015-09-21 12:16:44 +0900270};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900271
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900272/*!
Tony Cho641210a2015-09-21 12:16:52 +0900273 * @struct set_multicast
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900274 * @brief set Multicast filter Address
275 * @details
276 * @todo
277 * @sa
278 * @author Abdelrahman Sobhy
279 * @date 30 August 2013
280 * @version 1.0 Description
281 */
282
Tony Cho641210a2015-09-21 12:16:52 +0900283struct set_multicast {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900284 bool bIsEnabled;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900285 u32 u32count;
Tony Cho641210a2015-09-21 12:16:52 +0900286};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900287
288/*!
Tony Chob4e644e2015-09-21 12:17:00 +0900289 * @struct del_all_sta
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900290 * @brief Deauth station message body
291 * @details
292 * @todo
293 * @sa
294 * @author Mai Daftedar
295 * @date 09 April 2014
296 * @version 1.0 Description
297 */
Tony Chob4e644e2015-09-21 12:17:00 +0900298struct del_all_sta {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900299 u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN];
300 u8 u8Num_AssocSta;
Tony Chob4e644e2015-09-21 12:17:00 +0900301};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900302
303/*!
Tony Chofb93a1e2015-09-21 12:16:57 +0900304 * @struct del_sta
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900305 * @brief Delete station message body
306 * @details
307 * @todo
308 * @sa
309 * @author Adham Abozaeid
310 * @date 15 July 2012
311 * @version 1.0 Description
312 */
Tony Chofb93a1e2015-09-21 12:16:57 +0900313struct del_sta {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900314 u8 au8MacAddr[ETH_ALEN];
Tony Chofb93a1e2015-09-21 12:16:57 +0900315};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900316
317/*!
Tony Cho5a008f12015-09-21 12:16:48 +0900318 * @struct power_mgmt_param
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900319 * @brief Power management message body
320 * @details
321 * @todo
322 * @sa
323 * @author Adham Abozaeid
324 * @date 24 November 2012
325 * @version 1.0
326 */
Tony Cho5a008f12015-09-21 12:16:48 +0900327struct power_mgmt_param {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900328
Dean Lee72ed4dc2015-06-12 14:11:44 +0900329 bool bIsEnabled;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900330 u32 u32Timeout;
Tony Cho5a008f12015-09-21 12:16:48 +0900331};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900332
333/*!
Tony Cho15191ea2015-09-21 12:16:50 +0900334 * @struct set_ip_addr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900335 * @brief set IP Address message body
336 * @details
337 * @todo
338 * @sa
339 * @author Abdelrahman Sobhy
340 * @date 30 August 2013
341 * @version 1.0 Description
342 */
Tony Cho15191ea2015-09-21 12:16:50 +0900343struct set_ip_addr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900344 u8 *au8IPAddr;
345 u8 idx;
Tony Cho15191ea2015-09-21 12:16:50 +0900346};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900347
348/*!
Tony Cho3d1eac02015-09-21 12:16:49 +0900349 * @struct sta_inactive_t
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900350 * @brief Get station message body
351 * @details
352 * @todo
353 * @sa
354 * @author Mai Daftedar
355 * @date 16 April 2013
356 * @version 1.0
357 */
Tony Cho3d1eac02015-09-21 12:16:49 +0900358struct sta_inactive_t {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900359 u8 mac[6];
Tony Cho3d1eac02015-09-21 12:16:49 +0900360};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900361/**/
362/*!
Tony Chodfc76632015-09-21 12:16:34 +0900363 * @union message_body
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900364 * @brief Message body for the Host Interface message_q
365 * @details
366 * @todo
367 * @sa
368 * @author Mostafa Abu Bakr
369 * @date 25 March 2012
370 * @version 1.0
371 */
Tony Chodfc76632015-09-21 12:16:34 +0900372union message_body {
Tony Cho4528bdb2015-09-30 18:44:20 +0900373 struct scan_attr scan_info;
Tony Cho3f501972015-09-30 18:44:21 +0900374 struct connect_attr con_info;
Tony Cho02d19462015-09-30 18:44:22 +0900375 struct rcvd_net_info net_info;
Tony Cho66add622015-09-30 18:44:23 +0900376 struct rcvd_async_info async_info;
Tony Cho18990bf2015-09-30 18:44:24 +0900377 struct key_attr key_info;
Tony Choa2340c32015-09-30 18:44:25 +0900378 struct cfg_param_attr cfg_info;
Tony Choffd6dbc2015-09-30 18:44:28 +0900379 struct channel_attr channel_info;
Tony Choa98491e2015-09-30 18:44:31 +0900380 struct beacon_attr beacon_info;
Tony Choca8f47f2015-09-30 18:44:32 +0900381 struct add_sta_param add_sta_info;
Tony Cho889c25b2015-09-30 18:44:33 +0900382 struct del_sta del_sta_info;
Tony Cho4a930962015-09-30 18:44:34 +0900383 struct add_sta_param edit_sta_info;
Tony Cho49e1f812015-09-30 18:44:36 +0900384 struct power_mgmt_param pwr_mgmt_info;
Tony Cho66bac7f2015-09-30 18:44:37 +0900385 struct sta_inactive_t mac_info;
Tony Chofb2d65e2015-09-30 18:44:39 +0900386 struct set_ip_addr ip_info;
Tony Cho5e4377e2015-09-30 18:44:38 +0900387 struct drv_handler drv;
Tony Choa079cf4d2015-09-30 18:55:05 +0900388 struct set_multicast multicast_info;
Tony Cho00c46302015-09-30 18:55:06 +0900389 struct op_mode mode;
Tony Cho15326e22015-09-30 18:55:07 +0900390 struct set_mac_addr set_mac_info;
Tony Choa5848692015-09-30 18:55:08 +0900391 struct get_mac_addr get_mac_info;
Tony Choc833b472015-09-30 18:55:09 +0900392 struct ba_session_info session_info;
Tony Cho070d3652015-09-30 18:55:10 +0900393 struct remain_ch remain_on_ch;
Tony Chobc37c5d2015-09-21 12:16:59 +0900394 struct reg_frame strHostIfRegisterFrame;
Dean Lee576917a2015-06-15 11:58:57 +0900395 char *pUserData;
Tony Chob4e644e2015-09-21 12:17:00 +0900396 struct del_all_sta strHostIFDelAllSta;
Tony Chodfc76632015-09-21 12:16:34 +0900397};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900398
399/*!
Tony Cho3a8c41b2015-09-18 18:11:04 +0900400 * @struct struct host_if_msg
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900401 * @brief Host Interface message
402 * @details
403 * @todo
404 * @sa
405 * @author Mostafa Abu Bakr
406 * @date 25 March 2012
407 * @version 1.0
408 */
Tony Cho3a8c41b2015-09-18 18:11:04 +0900409struct host_if_msg {
Tony Choa9f812a2015-09-21 12:16:33 +0900410 u16 id; /*!< Message ID */
Tony Cho410c2482015-09-21 12:16:35 +0900411 union message_body body; /*!< Message body */
Johnny Kim11f58c82015-08-13 13:41:20 +0900412 tstrWILC_WFIDrv *drvHandler;
Tony Cho3a8c41b2015-09-18 18:11:04 +0900413};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900414
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900415typedef struct _tstrWidJoinReqExt {
Dean Lee576917a2015-06-15 11:58:57 +0900416 char SSID[MAX_SSID_LEN];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900417 u8 u8channel;
418 u8 BSSID[6];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900419} tstrWidJoinReqExt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900420
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900421/*Struct containg joinParam of each AP*/
422typedef struct _tstrJoinBssParam {
423 BSSTYPE_T bss_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900424 u8 dtim_period;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900425 u16 beacon_period;
426 u16 cap_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900427 u8 au8bssid[6];
Dean Lee576917a2015-06-15 11:58:57 +0900428 char ssid[MAX_SSID_LEN];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900429 u8 ssidLen;
430 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
431 u8 ht_capable;
432 u8 wmm_cap;
433 u8 uapsd_cap;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900434 bool rsn_found;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900435 u8 rsn_grp_policy;
436 u8 mode_802_11i;
437 u8 rsn_pcip_policy[3];
438 u8 rsn_auth_policy[3];
439 u8 rsn_cap[2];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900440 struct _tstrJoinParam *nextJoinBss;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900441 u32 tsf;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900442 u8 u8NoaEnbaled;
443 u8 u8OppEnable;
444 u8 u8CtWindow;
445 u8 u8Count;
446 u8 u8Index;
447 u8 au8Duration[4];
448 u8 au8Interval[4];
449 u8 au8StartTime[4];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900450} tstrJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900451/*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
452typedef struct _tstrBssTable {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900453 u8 u8noBssEntries;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900454 tstrJoinBssParam *head;
455 tstrJoinBssParam *tail;
456} tstrBssTable;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900457
458typedef enum {
459 SCAN_TIMER = 0,
460 CONNECT_TIMER = 1,
461 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
462} tenuScanConnTimer;
463
464/*****************************************************************************/
465/* */
466/* Global Variabls */
467/* */
468/*****************************************************************************/
Johnny Kimd42ab082015-08-20 16:32:52 +0900469/* Zero is not used, because a zero ID means termination */
470static tstrWILC_WFIDrv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
Daniel Machon6fdb3022015-07-06 19:48:04 +0200471tstrWILC_WFIDrv *terminated_handle;
472tstrWILC_WFIDrv *gWFiDrvHandle;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900473bool g_obtainingIP = false;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900474u8 P2P_LISTEN_STATE;
Arnd Bergmann1999bd52015-05-29 22:52:14 +0200475static struct task_struct *HostIFthreadHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900476static WILC_MsgQueueHandle gMsgQHostIF;
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200477static struct semaphore hSemHostIFthrdEnd;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900478
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200479struct semaphore hSemDeinitDrvHandle;
480static struct semaphore hWaitResponse;
481struct semaphore hSemHostIntDeinit;
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -0700482struct timer_list g_hPeriodicRSSI;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900483
484
485
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900486u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900487
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900488static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900489
Dean Lee72ed4dc2015-06-12 14:11:44 +0900490bool gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900491
Chaehyun Limca356ad2015-06-11 14:35:57 +0900492static s8 gs8Rssi;
493static s8 gs8lnkspd;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900494static u8 gu8Chnl;
495static u8 gs8SetIP[2][4];
496static u8 gs8GetIP[2][4];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900497static u32 gu32InactiveTime;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900498static u8 gu8DelBcn;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900499static u32 gu32WidConnRstHack;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900500
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900501u8 *gu8FlushedJoinReq;
502u8 *gu8FlushedInfoElemAsoc;
503u8 gu8Flushed11iMode;
504u8 gu8FlushedAuthType;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900505u32 gu32FlushedJoinReqSize;
506u32 gu32FlushedInfoElemAsocSize;
Johnny Kim8a625ca2015-08-20 16:32:50 +0900507tstrWILC_WFIDrv *gu8FlushedJoinReqDrvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900508#define REAL_JOIN_REQ 0
509#define FLUSHED_JOIN_REQ 1
510#define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
511
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900512static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900513
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900514extern void chip_sleep_manually(u32 u32SleepTime);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900515extern int linux_wlan_get_num_conn_ifcs(void);
516
Johnny Kimd42ab082015-08-20 16:32:52 +0900517static int add_handler_in_list(tstrWILC_WFIDrv *handler)
518{
519 int i;
520
521 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
522 if (!wfidrv_list[i]) {
523 wfidrv_list[i] = handler;
524 return 0;
525 }
526 }
527
528 return -ENOBUFS;
529}
530
531static int remove_handler_in_list(tstrWILC_WFIDrv *handler)
532{
533 int i;
534
535 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
536 if (wfidrv_list[i] == handler) {
537 wfidrv_list[i] = NULL;
538 return 0;
539 }
540 }
541
542 return -EINVAL;
543}
544
545static int get_id_from_handler(tstrWILC_WFIDrv *handler)
546{
547 int i;
548
549 if (!handler)
550 return 0;
551
552 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
553 if (wfidrv_list[i] == handler)
554 return i;
555 }
556
557 return 0;
558}
559
560static tstrWILC_WFIDrv *get_handler_from_id(int id)
561{
Dan Carpenter6ae9ac02015-09-15 09:54:33 +0300562 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
Johnny Kimd42ab082015-08-20 16:32:52 +0900563 return NULL;
564 return wfidrv_list[id];
565}
566
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900567/**
568 * @brief Handle_SetChannel
569 * @details Sending config packet to firmware to set channel
Tony Cho94bdfe42015-09-30 18:44:27 +0900570 * @param[in] struct channel_attr *pstrHostIFSetChan
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900571 * @return Error code.
572 * @author
573 * @date
574 * @version 1.0
575 */
Tony Cho326b3232015-09-21 12:16:42 +0900576static s32 Handle_SetChannel(tstrWILC_WFIDrv *drvHandler,
Tony Cho94bdfe42015-09-30 18:44:27 +0900577 struct channel_attr *pstrHostIFSetChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900578{
579
Leo Kime6e12662015-09-16 18:36:03 +0900580 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900581 tstrWID strWID;
582 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
583
584 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900585 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900586 strWID.enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900587 strWID.ps8WidVal = (char *)&(pstrHostIFSetChan->u8SetChan);
588 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900589
590 PRINT_D(HOSTINF_DBG, "Setting channel\n");
591 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900592 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
593 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900594 if (s32Error) {
595 PRINT_ER("Failed to set channel\n");
Leo Kim24db7132015-09-16 18:36:01 +0900596 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900597 }
598
599 return s32Error;
600}
601/**
602 * @brief Handle_SetWfiDrvHandler
603 * @details Sending config packet to firmware to set driver handler
Tony Cho127f9d92015-09-21 12:16:51 +0900604 * @param[in] void * drvHandler,
605 * struct drv_handler *pstrHostIfSetDrvHandler
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900606 * @return Error code.
607 * @author
608 * @date
609 * @version 1.0
610 */
Johnny Kim53a84402015-08-20 16:32:51 +0900611static s32 Handle_SetWfiDrvHandler(tstrWILC_WFIDrv *drvHandler,
Tony Cho127f9d92015-09-21 12:16:51 +0900612 struct drv_handler *pstrHostIfSetDrvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900613{
614
Leo Kime6e12662015-09-16 18:36:03 +0900615 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900616 tstrWID strWID;
Johnny Kim53a84402015-08-20 16:32:51 +0900617 tstrWILC_WFIDrv *pstrWFIDrv = drvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900618
619
620 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900621 strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900622 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900623 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900624 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900625
626 /*Sending Cfg*/
627
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900628 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
629 pstrHostIfSetDrvHandler->u32Address);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900630
Johnny Kim53a84402015-08-20 16:32:51 +0900631 if (pstrWFIDrv == NULL)
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200632 up(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900633
634
635 if (s32Error) {
636 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900637 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900638 }
639
640 return s32Error;
641}
642
643/**
644 * @brief Handle_SetWfiAPDrvHandler
645 * @details Sending config packet to firmware to set driver handler
646 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
647 * @return Error code.
648 * @author
649 * @date
650 * @version 1.0
651 */
Tony Cho801bee52015-09-21 12:16:53 +0900652static s32 Handle_SetOperationMode(tstrWILC_WFIDrv *drvHandler,
653 struct op_mode *pstrHostIfSetOperationMode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900654{
655
Leo Kime6e12662015-09-16 18:36:03 +0900656 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900657 tstrWID strWID;
658 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
659
660
661 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900662 strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900663 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900664 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900665 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900666
667 /*Sending Cfg*/
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +0200668 PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900669
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900670 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
671 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900672
673
Johnny Kimc590b9a2015-09-08 17:07:59 +0900674 if ((pstrHostIfSetOperationMode->u32Mode) == IDLE_MODE)
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200675 up(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900676
677
678 if (s32Error) {
679 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900680 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900681 }
682
683 return s32Error;
684}
685
686/**
687 * @brief host_int_set_IPAddress
688 * @details Setting IP address params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900689 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900690 * @return Error code.
691 * @author
692 * @date
693 * @version 1.0
694 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900695s32 Handle_set_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900696{
697
Leo Kime6e12662015-09-16 18:36:03 +0900698 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900699 tstrWID strWID;
700 char firmwareIPAddress[4] = {0};
701 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
702
703 if (pu8IPAddr[0] < 192)
704 pu8IPAddr[0] = 0;
705
Luis de Bethencourtb3a02832015-06-26 17:40:25 +0200706 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900707
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900708 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900709
710 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900711 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900712 strWID.enuWIDtype = WID_STR;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900713 strWID.ps8WidVal = (u8 *)pu8IPAddr;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900714 strWID.s32ValueSize = IP_ALEN;
715
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900716 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
717 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900718
719
Johnny Kim218dc402015-08-13 13:41:19 +0900720 host_int_get_ipaddress(drvHandler, firmwareIPAddress, idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900721
722 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +0900723 PRINT_ER("Failed to set IP address\n");
724 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900725 }
726
Leo Kim24db7132015-09-16 18:36:01 +0900727 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900728
729 return s32Error;
730}
731
732
733/**
734 * @brief Handle_get_IPAddress
735 * @details Setting IP address params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900736 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900737 * @return Error code.
738 * @author
739 * @date
740 * @version 1.0
741 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900742s32 Handle_get_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900743{
744
Leo Kime6e12662015-09-16 18:36:03 +0900745 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900746 tstrWID strWID;
747 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
748
749 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900750 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900751 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +0900752 strWID.ps8WidVal = kmalloc(IP_ALEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900753 strWID.s32ValueSize = IP_ALEN;
754
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900755 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
756 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900757
Luis de Bethencourtb3a02832015-06-26 17:40:25 +0200758 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900759
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900760 memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900761
762 /*get the value by searching the local copy*/
Chaehyun Lim49188af2015-08-11 10:32:41 +0900763 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900764
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900765 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
Johnny Kim218dc402015-08-13 13:41:19 +0900766 host_int_setup_ipaddress(pstrWFIDrv, gs8SetIP[idx], idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900767
Leo Kime6e12662015-09-16 18:36:03 +0900768 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900769 PRINT_ER("Failed to get IP address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900770 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900771 }
772
Leo Kim24db7132015-09-16 18:36:01 +0900773 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
774 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
775 PRINT_INFO(HOSTINF_DBG, "\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900776
777 return s32Error;
778}
779
780
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900781/**
782 * @brief Handle_SetMacAddress
783 * @details Setting mac address
784 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
785 * @return Error code.
786 * @author Amr Abdel-Moghny
787 * @date November 2013
788 * @version 7.0
789 */
Tony Chob7611a82015-09-21 12:16:54 +0900790static s32 Handle_SetMacAddress(tstrWILC_WFIDrv *drvHandler,
791 struct set_mac_addr *pstrHostIfSetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900792{
793
Leo Kime6e12662015-09-16 18:36:03 +0900794 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900795 tstrWID strWID;
796 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Glen Leef3052582015-09-10 12:03:04 +0900797 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +0200798
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900799 if (mac_buf == NULL) {
800 PRINT_ER("No buffer to send mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +0900801 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900802 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900803 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900804
805 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900806 strWID.u16WIDid = (u16)WID_MAC_ADDR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900807 strWID.enuWIDtype = WID_STR;
808 strWID.ps8WidVal = mac_buf;
809 strWID.s32ValueSize = ETH_ALEN;
Alexander Kuleshov310a28f2015-09-04 00:48:14 +0600810 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900811 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900812 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
813 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900814 if (s32Error) {
815 PRINT_ER("Failed to set mac address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900816 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900817 }
818
Chaehyun Lim49188af2015-08-11 10:32:41 +0900819 kfree(mac_buf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900820 return s32Error;
821}
822
823
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900824/**
825 * @brief Handle_GetMacAddress
826 * @details Getting mac address
827 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
828 * @return Error code.
829 * @author Amr Abdel-Moghny
830 * @date JAN 2013
831 * @version 8.0
832 */
Tony Chofcd27c52015-09-21 12:16:55 +0900833static s32 Handle_GetMacAddress(tstrWILC_WFIDrv *drvHandler,
834 struct get_mac_addr *pstrHostIfGetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900835{
836
Leo Kime6e12662015-09-16 18:36:03 +0900837 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900838 tstrWID strWID;
839
840 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900841 strWID.u16WIDid = (u16)WID_MAC_ADDR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900842 strWID.enuWIDtype = WID_STR;
843 strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress;
844 strWID.s32ValueSize = ETH_ALEN;
845
846 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900847 s32Error = send_config_pkt(GET_CFG, &strWID, 1, false,
848 get_id_from_handler(drvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900849 if (s32Error) {
850 PRINT_ER("Failed to get mac address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900851 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900852 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200853 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900854
855 return s32Error;
856}
857
858
859/**
860 * @brief Handle_CfgParam
861 * @details Sending config packet to firmware to set CFG params
Tony Cho361ff842015-09-21 12:16:41 +0900862 * @param[in] struct cfg_param_attr *strHostIFCfgParamAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900863 * @return Error code.
864 * @author
865 * @date
866 * @version 1.0
867 */
Tony Cho361ff842015-09-21 12:16:41 +0900868static s32 Handle_CfgParam(tstrWILC_WFIDrv *drvHandler,
869 struct cfg_param_attr *strHostIFCfgParamAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900870{
Leo Kime6e12662015-09-16 18:36:03 +0900871 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900872 tstrWID strWIDList[32];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900873 u8 u8WidCnt = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900874 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
875
876
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200877 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900878
879
880 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
881
882 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) {
883 /*----------------------------------------------------------*/
884 /*Input Value: INFRASTRUCTURE = 1, */
885 /* INDEPENDENT= 2, */
886 /* ANY_BSS= 3 */
887 /*----------------------------------------------------------*/
888 /* validate input then copy>> need to check value 4 and 5 */
889 if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) {
890 strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900891 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900892 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900893 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900894 pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900895 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900896 PRINT_ER("check value 6 over\n");
897 s32Error = -EINVAL;
898 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900899 }
900 u8WidCnt++;
901 }
902 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) {
903 /*------------------------------------------------------*/
904 /*Input Values: OPEN_SYSTEM = 0, */
905 /* SHARED_KEY = 1, */
906 /* ANY = 2 */
907 /*------------------------------------------------------*/
908 /*validate Possible values*/
909 if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) {
910 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900911 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900912 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900913 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900914 pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900915 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900916 PRINT_ER("Impossible value \n");
917 s32Error = -EINVAL;
918 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900919 }
920 u8WidCnt++;
921 }
922 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) {
923 /* range is 1 to 65535. */
924 if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) {
925 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900926 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900927 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900928 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900929 pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
930 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900931 PRINT_ER("Range(1 ~ 65535) over\n");
932 s32Error = -EINVAL;
933 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900934 }
935 u8WidCnt++;
936 }
937 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) {
938 /*-----------------------------------------------------------*/
939 /*Input Values: NO_POWERSAVE = 0, */
940 /* MIN_FAST_PS = 1, */
941 /* MAX_FAST_PS = 2, */
942 /* MIN_PSPOLL_PS = 3, */
943 /* MAX_PSPOLL_PS = 4 */
944 /*----------------------------------------------------------*/
945 if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) {
946 strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900947 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900948 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900949 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900950 pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900951 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900952 PRINT_ER("Invalide power mode\n");
953 s32Error = -EINVAL;
954 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900955 }
956 u8WidCnt++;
957 }
958 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) {
959 /* range from 1 to 256 */
960 if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) {
961 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900962 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900963 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900964 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900965 pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
966 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900967 PRINT_ER("Range(1~256) over\n");
968 s32Error = -EINVAL;
969 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900970 }
971 u8WidCnt++;
972 }
973 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) {
974 /* range from 1 to 256 */
975 if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) {
976 strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900977 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900978
979 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900980 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900981 pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
982 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900983 PRINT_ER("Range(1~256) over\n");
984 s32Error = -EINVAL;
985 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900986 }
987 u8WidCnt++;
988 }
989 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) {
990
991 if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) {
992 strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900993 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900994 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900995 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900996 pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
997 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900998 PRINT_ER("Threshold Range fail\n");
999 s32Error = -EINVAL;
1000 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001001 }
1002 u8WidCnt++;
1003 }
1004 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) {
1005 /* range 256 to 65535 */
1006 if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) {
1007 strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001008 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001009 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001010 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001011 pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1012 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001013 PRINT_ER("Threshold Range fail\n");
1014 s32Error = -EINVAL;
1015 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001016 }
1017 u8WidCnt++;
1018 }
1019 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) {
1020 /*-----------------------------------------------------*/
1021 /*Input Values: Short= 0, */
1022 /* Long= 1, */
1023 /* Auto= 2 */
1024 /*------------------------------------------------------*/
1025 if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) {
1026 strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001027 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001028 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001029 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001030 pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1031 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001032 PRINT_ER("Preamle Range(0~2) over\n");
1033 s32Error = -EINVAL;
1034 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001035 }
1036 u8WidCnt++;
1037 }
1038 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) {
1039 if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) {
1040 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001041 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001042 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001043 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001044 pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001045 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001046 PRINT_ER("Short slot(2) over\n");
1047 s32Error = -EINVAL;
1048 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001049 }
1050 u8WidCnt++;
1051 }
1052 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) {
1053 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1054 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1055 /* this information is useful for external supplicant */
1056 /*Input Values: 1 for enable and 0 for disable. */
1057 if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) {
1058 strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001059 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001060 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001061 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001062 pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001063 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001064 PRINT_ER("TXOP prot disable\n");
1065 s32Error = -EINVAL;
1066 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001067 }
1068 u8WidCnt++;
1069 }
1070 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) {
1071 /* range is 1 to 65535. */
1072 if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) {
1073 strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001074 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001075 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001076 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001077 pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1078 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001079 PRINT_ER("Beacon interval(1~65535) fail\n");
1080 s32Error = -EINVAL;
1081 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001082 }
1083 u8WidCnt++;
1084 }
1085 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) {
1086 /* range is 1 to 255. */
1087 if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) {
1088 strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001089 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001090 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001091 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001092 pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1093 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001094 PRINT_ER("DTIM range(1~255) fail\n");
1095 s32Error = -EINVAL;
1096 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001097 }
1098 u8WidCnt++;
1099 }
1100 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) {
1101 /*----------------------------------------------------------------------*/
1102 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1103 /* SITE_SURVEY_ALL_CH = 1, */
1104 /* SITE_SURVEY_OFF = 2 */
1105 /*----------------------------------------------------------------------*/
1106 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) {
1107 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001108 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001109 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001110 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001111 pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001112 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001113 PRINT_ER("Site survey disable\n");
1114 s32Error = -EINVAL;
1115 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001116 }
1117 u8WidCnt++;
1118 }
1119 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) {
1120 /* range is 1 to 65535. */
1121 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) {
1122 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001123 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001124 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001125 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001126 pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1127 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001128 PRINT_ER("Site survey scan time(1~65535) over\n");
1129 s32Error = -EINVAL;
1130 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001131 }
1132 u8WidCnt++;
1133 }
1134 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) {
1135 /* range is 1 to 65535. */
1136 if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) {
1137 strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001138 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001139 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001140 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001141 pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1142 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001143 PRINT_ER("Active scan time(1~65535) over\n");
1144 s32Error = -EINVAL;
1145 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001146 }
1147 u8WidCnt++;
1148 }
1149 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) {
1150 /* range is 1 to 65535. */
1151 if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) {
1152 strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001153 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001154 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001155 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001156 pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1157 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001158 PRINT_ER("Passive scan time(1~65535) over\n");
1159 s32Error = -EINVAL;
1160 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001161 }
1162 u8WidCnt++;
1163 }
1164 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) {
1165 CURRENT_TX_RATE_T curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate;
1166 /*----------------------------------------------------------------------*/
1167 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1168 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1169 /*----------------------------------------------------------------------*/
1170 /* validate rate */
1171 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
1172 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
1173 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
1174 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
1175 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
1176 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
1177 strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001178 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001179 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001180 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001181 pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001182 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001183 PRINT_ER("out of TX rate\n");
1184 s32Error = -EINVAL;
1185 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001186 }
1187 u8WidCnt++;
1188 }
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001189 s32Error = send_config_pkt(SET_CFG, strWIDList, u8WidCnt, false,
1190 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001191
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001192 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001193 PRINT_ER("Error in setting CFG params\n");
1194
Leo Kim24db7132015-09-16 18:36:01 +09001195ERRORHANDLER:
Arnd Bergmann83383ea2015-06-01 21:06:43 +02001196 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001197 return s32Error;
1198}
1199
1200
1201/**
1202 * @brief Handle_wait_msg_q_empty
1203 * @details this should be the last msg and then the msg Q becomes idle
1204 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1205 * @return Error code.
1206 * @author
1207 * @date
1208 * @version 1.0
1209 */
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001210static s32 Handle_wait_msg_q_empty(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001211{
Leo Kime6e12662015-09-16 18:36:03 +09001212 s32 s32Error = 0;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02001213
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001214 g_wilc_initialized = 0;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02001215 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001216 return s32Error;
1217}
1218
1219/**
1220 * @brief Handle_Scan
1221 * @details Sending config packet to firmware to set the scan params
Tony Choc476feb2015-09-21 12:16:36 +09001222 * @param[in] struct scan_attr *pstrHostIFscanAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001223 * @return Error code.
1224 * @author
1225 * @date
1226 * @version 1.0
1227 */
Tony Choc476feb2015-09-21 12:16:36 +09001228static s32 Handle_Scan(tstrWILC_WFIDrv *drvHandler,
1229 struct scan_attr *pstrHostIFscanAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001230{
Leo Kime6e12662015-09-16 18:36:03 +09001231 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001232 tstrWID strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001233 u32 u32WidsCount = 0;
1234 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001235 u8 *pu8Buffer;
1236 u8 valuesize = 0;
1237 u8 *pu8HdnNtwrksWidVal = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001238 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1239
1240 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001241 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", pstrWFIDrv->enuHostIFstate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001242
1243 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
1244 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
1245
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001246 if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) {
1247 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1248 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate);
Leo Kim24db7132015-09-16 18:36:01 +09001249 PRINT_ER("Already scan\n");
1250 s32Error = -EBUSY;
1251 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001252 }
1253
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001254 if (g_obtainingIP || connecting) {
1255 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +09001256 PRINT_ER("Don't do obss scan\n");
1257 s32Error = -EBUSY;
1258 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001259 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001260
1261 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1262
1263
1264 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0;
1265
Chaehyun Limd85f5322015-06-11 14:35:54 +09001266 strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001267 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1268
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001269 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001270 valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
Glen Leef3052582015-09-10 12:03:04 +09001271 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001272 strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001273 if (strWIDList[u32WidsCount].ps8WidVal != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001274 pu8Buffer = strWIDList[u32WidsCount].ps8WidVal;
1275
1276 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
1277
1278 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
1279
1280 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1281 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001282 memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001283 pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1284 }
1285
1286
1287
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001288 strWIDList[u32WidsCount].s32ValueSize = (s32)(valuesize + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001289 u32WidsCount++;
1290 }
1291
1292 /*filling cfg param array*/
1293
1294 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1295 {
1296 /* IEs to be inserted in Probe Request */
1297 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE;
1298 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1299 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs;
1300 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen;
1301 u32WidsCount++;
1302 }
1303
1304 /*Scan Type*/
1305 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE;
1306 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001307 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001308 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001309 u32WidsCount++;
1310
1311 /*list of channels to be scanned*/
1312 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST;
1313 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1314
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001315 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
1316 int i;
1317
1318 for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001319 if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001320 pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001321 }
1322 }
1323
1324 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList;
1325 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen;
1326 u32WidsCount++;
1327
1328 /*Scan Request*/
1329 strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ;
1330 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001331 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001332 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001333 u32WidsCount++;
1334
1335 /*keep the state as is , no need to change it*/
1336 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1337
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301338 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001339 gbScanWhileConnected = true;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301340 else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001341 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001342
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001343 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount, false,
1344 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001345
Leo Kim24db7132015-09-16 18:36:01 +09001346 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001347 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09001348 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001349 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001350
Leo Kim24db7132015-09-16 18:36:01 +09001351ERRORHANDLER:
1352 if (s32Error) {
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07001353 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001354 /*if there is an ongoing scan request*/
1355 Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED);
1356 }
1357
1358 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1359 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001360 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001361 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1362 }
1363
1364 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1365 if (pstrHostIFscanAttr->pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001366 kfree(pstrHostIFscanAttr->pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001367 pstrHostIFscanAttr->pu8IEs = NULL;
1368 }
1369 if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001370 kfree(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001371 pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
1372 }
1373
1374 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1375 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001376 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001377 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1378 }
1379
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001380 if (pu8HdnNtwrksWidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001381 kfree(pu8HdnNtwrksWidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001382
1383 return s32Error;
1384}
1385
1386/**
1387 * @brief Handle_ScanDone
1388 * @details Call scan notification callback function
1389 * @param[in] NONE
1390 * @return Error code.
1391 * @author
1392 * @date
1393 * @version 1.0
1394 */
Johnny Kim2b05df52015-08-13 13:41:21 +09001395static s32 Handle_ScanDone(tstrWILC_WFIDrv *drvHandler, tenuScanEvent enuEvent)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001396{
Leo Kime6e12662015-09-16 18:36:03 +09001397 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001398
1399 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
1400
1401
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001402 u8 u8abort_running_scan;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001403 tstrWID strWID;
1404
1405
1406 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
1407
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001408 /*Ask FW to abort the running scan, if any*/
1409 if (enuEvent == SCAN_EVENT_ABORTED) {
1410 PRINT_D(GENERIC_DBG, "Abort running scan\n");
1411 u8abort_running_scan = 1;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001412 strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001413 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001414 strWID.ps8WidVal = (s8 *)&u8abort_running_scan;
Dean Lee576917a2015-06-15 11:58:57 +09001415 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001416
1417 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001418 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
1419 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09001420 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001421 PRINT_ER("Failed to set abort running scan\n");
Leo Kim24db7132015-09-16 18:36:01 +09001422 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001423 }
1424 }
1425
1426 if (pstrWFIDrv == NULL) {
1427 PRINT_ER("Driver handler is NULL\n");
1428 return s32Error;
1429 }
1430
1431 /*if there is an ongoing scan request*/
1432 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001433 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001434 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1435 /*delete current scan request*/
1436 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1437 }
1438
1439 return s32Error;
1440}
1441
1442/**
1443 * @brief Handle_Connect
1444 * @details Sending config packet to firmware to starting connection
Tony Cho120ae592015-09-21 12:16:37 +09001445 * @param[in] struct connect_attr *pstrHostIFconnectAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001446 * @return Error code.
1447 * @author
1448 * @date
1449 * @version 1.0
1450 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001451u8 u8ConnectedSSID[6] = {0};
Tony Cho120ae592015-09-21 12:16:37 +09001452static s32 Handle_Connect(tstrWILC_WFIDrv *drvHandler,
1453 struct connect_attr *pstrHostIFconnectAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001454{
1455 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
Leo Kime6e12662015-09-16 18:36:03 +09001456 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001457 tstrWID strWIDList[8];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001458 u32 u32WidsCount = 0, dummyval = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001459 /* char passphrase[] = "12345678"; */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001460 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001461 tstrJoinBssParam *ptstrJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001462
1463 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1464
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001465 /* if we try to connect to an already connected AP then discard the request */
1466
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001467 if (memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001468
Leo Kime6e12662015-09-16 18:36:03 +09001469 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001470 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1471 return s32Error;
1472 }
1473
1474 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1475
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001476 ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams;
1477 if (ptstrJoinBssParam == NULL) {
1478 PRINT_ER("Required BSSID not found\n");
Leo Kim24db7132015-09-16 18:36:01 +09001479 s32Error = -ENOENT;
1480 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001481 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001482
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001483 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001484 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001485 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001486 }
1487
1488 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1489 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001490 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssidLen + 1, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001491 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001492 pstrHostIFconnectAttr->ssidLen);
1493 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1494 }
1495
1496 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1497 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001498 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001499 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001500 pstrHostIFconnectAttr->IEsLen);
1501 }
1502
1503 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1504 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1505 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1506 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1507
1508 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
1509 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001510 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001511 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001512 u32WidsCount++;
1513
1514 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
1515 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001516 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001517 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001518 u32WidsCount++;
1519
1520 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
1521 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001522 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001523 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001524 u32WidsCount++;
1525
1526 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1527 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1528 {
1529 /* IEs to be inserted in Association Request */
1530 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1531 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1532 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1533 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1534 u32WidsCount++;
1535
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001536 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001537
1538 gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001539 gu8FlushedInfoElemAsoc = kmalloc(gu32FlushedInfoElemAsocSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001540 memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1541 gu32FlushedInfoElemAsocSize);
1542 }
1543 }
Chaehyun Limd85f5322015-06-11 14:35:54 +09001544 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001545 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001546 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001547 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001548 u32WidsCount++;
1549
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001550 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001551 gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security;
1552
1553 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1554
1555
Chaehyun Limd85f5322015-06-11 14:35:54 +09001556 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001557 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001558 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001559 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001560 u32WidsCount++;
1561
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001562 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001563 gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001564
1565 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1566 /*
Chaehyun Limd85f5322015-06-11 14:35:54 +09001567 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001568 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1569 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001570 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001571 * u32WidsCount++;
1572 */
1573
1574 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1575 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
1576
Chaehyun Limd85f5322015-06-11 14:35:54 +09001577 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001578 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1579
1580 /*Sending NoA attributes during connection*/
1581 strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */
Glen Leef3052582015-09-10 12:03:04 +09001582 strWIDList[u32WidsCount].ps8WidVal = kmalloc(strWIDList[u32WidsCount].s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001583
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001584 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001585 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize;
Glen Leef3052582015-09-10 12:03:04 +09001586 gu8FlushedJoinReq = kmalloc(gu32FlushedJoinReqSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001587 }
Leo Kim24db7132015-09-16 18:36:01 +09001588 if (strWIDList[u32WidsCount].ps8WidVal == NULL) {
1589 s32Error = -EFAULT;
1590 goto ERRORHANDLER;
1591 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001592
1593 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1594
1595
1596 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001597 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001598 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1599 }
1600 pu8CurrByte += MAX_SSID_LEN;
1601
1602 /* BSS type*/
1603 *(pu8CurrByte++) = INFRASTRUCTURE;
1604 /* Channel*/
1605 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1606 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1607 } else {
1608 PRINT_ER("Channel out of range\n");
1609 *(pu8CurrByte++) = 0xFF;
1610 }
1611 /* Cap Info*/
1612 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1613 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1614 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1615
1616 /* sa*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001617 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001618 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001619 pu8CurrByte += 6;
1620
1621 /* bssid*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001622 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001623 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001624 pu8CurrByte += 6;
1625
1626 /* Beacon Period*/
1627 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1628 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1629 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1630 /* DTIM Period*/
1631 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1632 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1633 /* Supported rates*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001634 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001635 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1636
1637 /* wmm cap*/
1638 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1639 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1640 /* uapsd cap*/
1641 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1642
1643 /* ht cap*/
1644 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1645 /* copy this information to the user request */
1646 pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1647
1648 /* rsn found*/
1649 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1650 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1651 /* rsn group policy*/
1652 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1653 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1654 /* mode_802_11i*/
1655 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1656 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1657 /* rsn pcip policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001658 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001659 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1660
1661 /* rsn auth policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001662 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001663 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1664
1665 /* rsn auth policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001666 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001667 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1668
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001669 *(pu8CurrByte++) = REAL_JOIN_REQ;
1670
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001671 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1672 if (ptstrJoinBssParam->u8NoaEnbaled) {
1673 PRINT_D(HOSTINF_DBG, "NOA present\n");
1674
1675 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1676 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1677 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1678 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1679
1680 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1681
1682 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1683
1684 if (ptstrJoinBssParam->u8OppEnable)
1685 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1686
1687 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1688
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001689 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001690
1691 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1692
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001693 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001694
1695 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1696
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001697 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001698
1699 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1700
1701 } else
1702 PRINT_D(HOSTINF_DBG, "NOA not present\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001703
1704 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1705 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001706 u32WidsCount++;
1707
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001708 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1709 * firmware at chip reset when processing the WIDs of the Connect Request.
1710 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1711 /* ////////////////////// */
1712 gu32WidConnRstHack = 0;
1713 /* ////////////////////// */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001714
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001715 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001716 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
Johnny Kim8a625ca2015-08-20 16:32:50 +09001717 gu8FlushedJoinReqDrvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001718 }
1719
1720 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1721
1722 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001723 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001724
Alexander Kuleshov310a28f2015-09-04 00:48:14 +06001725 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->pu8bssid);
1726 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001727 }
1728
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001729 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount, false,
1730 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001731 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09001732 PRINT_ER("failed to send config packet\n");
1733 s32Error = -EFAULT;
1734 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001735 } else {
1736 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1737 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1738 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001739
Leo Kim24db7132015-09-16 18:36:01 +09001740ERRORHANDLER:
1741 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001742 tstrConnectInfo strConnectInfo;
1743
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07001744 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001745
1746 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1747
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001748 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001749
1750 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001751 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001752 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001753
1754 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1755 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001756 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001757 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001758 pstrHostIFconnectAttr->pu8IEs,
1759 pstrHostIFconnectAttr->IEsLen);
1760 }
1761
1762 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1763 &strConnectInfo,
1764 MAC_DISCONNECTED,
1765 NULL,
1766 pstrHostIFconnectAttr->pvUserArg);
1767 /*Change state to idle*/
1768 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
1769 /* Deallocation */
1770 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001771 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001772 strConnectInfo.pu8ReqIEs = NULL;
1773 }
1774
1775 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001776 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001777 }
1778 }
1779
1780 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
1781 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
1782 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001783 kfree(pstrHostIFconnectAttr->pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001784 pstrHostIFconnectAttr->pu8bssid = NULL;
1785 }
1786
1787 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
1788 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001789 kfree(pstrHostIFconnectAttr->pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001790 pstrHostIFconnectAttr->pu8ssid = NULL;
1791 }
1792
1793 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
1794 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001795 kfree(pstrHostIFconnectAttr->pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001796 pstrHostIFconnectAttr->pu8IEs = NULL;
1797 }
1798
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001799 if (pu8CurrByte != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001800 kfree(pu8CurrByte);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001801 return s32Error;
1802}
1803
1804/**
1805 * @brief Handle_FlushConnect
1806 * @details Sending config packet to firmware to flush an old connection
1807 * after switching FW from station one to hybrid one
1808 * @param[in] void * drvHandler
1809 * @return Error code.
1810 * @author Amr Abdel-Moghny
1811 * @date 19 DEC 2013
1812 * @version 8.0
1813 */
1814
Johnny Kim2b05df52015-08-13 13:41:21 +09001815static s32 Handle_FlushConnect(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001816{
Leo Kime6e12662015-09-16 18:36:03 +09001817 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001818 tstrWID strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001819 u32 u32WidsCount = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001820 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001821
1822
1823 /* IEs to be inserted in Association Request */
1824 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1825 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1826 strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc;
1827 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize;
1828 u32WidsCount++;
1829
Chaehyun Limd85f5322015-06-11 14:35:54 +09001830 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001831 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001832 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001833 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001834 u32WidsCount++;
1835
1836
1837
Chaehyun Limd85f5322015-06-11 14:35:54 +09001838 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001839 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001840 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001841 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001842 u32WidsCount++;
1843
Chaehyun Limd85f5322015-06-11 14:35:54 +09001844 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001845 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1846 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001847 strWIDList[u32WidsCount].ps8WidVal = (s8 *)gu8FlushedJoinReq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001848 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1849
1850 pu8CurrByte += FLUSHED_BYTE_POS;
1851 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1852
1853 u32WidsCount++;
1854
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001855 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount, false,
1856 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001857 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09001858 PRINT_ER("failed to send config packet\n");
1859 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001860 }
1861
1862 return s32Error;
1863}
1864
1865/**
1866 * @brief Handle_ConnectTimeout
1867 * @details Call connect notification callback function indicating connection failure
1868 * @param[in] NONE
1869 * @return Error code.
1870 * @author
1871 * @date
1872 * @version 1.0
1873 */
Johnny Kim2b05df52015-08-13 13:41:21 +09001874static s32 Handle_ConnectTimeout(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001875{
Leo Kime6e12662015-09-16 18:36:03 +09001876 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001877 tstrConnectInfo strConnectInfo;
1878 tstrWID strWID;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001879 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001880 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1881
1882 if (pstrWFIDrv == NULL) {
1883 PRINT_ER("Driver handler is NULL\n");
1884 return s32Error;
1885 }
1886
1887 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
1888
Dean Lee72ed4dc2015-06-12 14:11:44 +09001889 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001890
1891
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001892 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001893
1894
1895 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
1896 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
1897 * WID_DISCONNECT} */
1898 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1899 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001900 memcpy(strConnectInfo.au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001901 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
1902 }
1903
1904 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1905 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001906 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001907 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001908 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1909 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
1910 }
1911
1912 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1913 &strConnectInfo,
1914 MAC_DISCONNECTED,
1915 NULL,
1916 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
1917
1918 /* Deallocation of strConnectInfo.pu8ReqIEs */
1919 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001920 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001921 strConnectInfo.pu8ReqIEs = NULL;
1922 }
1923 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001924 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001925 }
1926
1927 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
1928 * WID_DISCONNECT} */
Chaehyun Limd85f5322015-06-11 14:35:54 +09001929 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001930 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001931 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
Dean Lee576917a2015-06-15 11:58:57 +09001932 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001933
1934 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1935
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001936 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
1937 get_id_from_handler(pstrWFIDrv));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001938 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001939 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001940
1941 /* Deallocation of the Saved Connect Request in the global Handle */
1942 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
1943 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001944 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001945 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
1946 }
1947
1948 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001949 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001950 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
1951 }
1952
1953 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1954 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001955 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001956 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
1957 }
1958
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001959 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001960 /*Freeing flushed join request params on connect timeout*/
Johnny Kim8a625ca2015-08-20 16:32:50 +09001961 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001962 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001963 gu8FlushedJoinReq = NULL;
1964 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09001965 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001966 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001967 gu8FlushedInfoElemAsoc = NULL;
1968 }
1969
1970 return s32Error;
1971}
1972
1973/**
1974 * @brief Handle_RcvdNtwrkInfo
1975 * @details Handling received network information
Tony Cho3bbd59f2015-09-21 12:16:38 +09001976 * @param[in] struct rcvd_net_info *pstrRcvdNetworkInfo
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001977 * @return Error code.
1978 * @author
1979 * @date
1980 * @version 1.0
1981 */
Tony Cho3bbd59f2015-09-21 12:16:38 +09001982static s32 Handle_RcvdNtwrkInfo(tstrWILC_WFIDrv *drvHandler,
1983 struct rcvd_net_info *pstrRcvdNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001984{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001985 u32 i;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001986 bool bNewNtwrkFound;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001987
1988
1989
Leo Kime6e12662015-09-16 18:36:03 +09001990 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001991 tstrNetworkInfo *pstrNetworkInfo = NULL;
1992 void *pJoinParams = NULL;
1993
1994 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
1995
1996
1997
Dean Lee72ed4dc2015-06-12 14:11:44 +09001998 bNewNtwrkFound = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001999 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
2000
2001 /*if there is a an ongoing scan request*/
2002 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2003 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
Chaehyun Lima1f7f642015-09-22 22:47:44 +09002004 parse_network_info(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002005 if ((pstrNetworkInfo == NULL)
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002006 || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
Leo Kim24db7132015-09-16 18:36:01 +09002007 PRINT_ER("driver is null\n");
2008 s32Error = -EINVAL;
2009 goto done;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002010 }
2011
2012 /* check whether this network is discovered before */
2013 for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
2014
2015 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
2016 (pstrNetworkInfo->au8bssid != NULL)) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002017 if (memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002018 pstrNetworkInfo->au8bssid, 6) == 0) {
2019 if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
2020 /*we have already found this network with better rssi, so keep the old cached one and don't
2021 * send anything to the upper layer */
2022 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
2023 goto done;
2024 } else {
2025 /* here the same already found network is found again but with a better rssi, so just update
2026 * the rssi for this cached network and send this updated network to the upper layer but
2027 * don't add a new record for it */
2028 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002029 bNewNtwrkFound = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002030 break;
2031 }
2032 }
2033 }
2034 }
2035
Dean Lee72ed4dc2015-06-12 14:11:44 +09002036 if (bNewNtwrkFound == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002037 /* here it is confirmed that it is a new discovered network,
2038 * so add its record then call the User CallBack function */
2039
2040 PRINT_D(HOSTINF_DBG, "New network found\n");
2041
2042 if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
2043 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
2044
2045 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
2046 && (pstrNetworkInfo->au8bssid != NULL)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002047 memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002048 pstrNetworkInfo->au8bssid, 6);
2049
2050 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++;
2051
Dean Lee72ed4dc2015-06-12 14:11:44 +09002052 pstrNetworkInfo->bNewNetwork = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002053 /* add new BSS to JoinBssTable */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002054 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002055
2056 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2057 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid,
2058 pJoinParams);
2059
2060
2061 }
2062 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002063 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002064 }
2065 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002066 pstrNetworkInfo->bNewNetwork = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002067 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2068 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2069 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2070 }
2071 }
2072
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002073done:
2074 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2075 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002076 kfree(pstrRcvdNetworkInfo->pu8Buffer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002077 pstrRcvdNetworkInfo->pu8Buffer = NULL;
2078 }
2079
2080 /*free structure allocated*/
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002081 if (pstrNetworkInfo != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002082 DeallocateNetworkInfo(pstrNetworkInfo);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002083 pstrNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002084 }
2085
2086 return s32Error;
2087}
2088
2089/**
2090 * @brief Handle_RcvdGnrlAsyncInfo
2091 * @details Handling received asynchrous general network information
Tony Chof23a9ea2015-09-21 12:16:39 +09002092 * @param[in] struct rcvd_async_info *pstrRcvdGnrlAsyncInfo
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002093 * @return Error code.
2094 * @author
2095 * @date
2096 * @version 1.0
2097 */
Tony Chof23a9ea2015-09-21 12:16:39 +09002098static s32 Handle_RcvdGnrlAsyncInfo(tstrWILC_WFIDrv *drvHandler,
2099 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002100{
2101 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2102 /* which carries only 1 WID which have WID ID = WID_STATUS */
Leo Kime6e12662015-09-16 18:36:03 +09002103 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002104 u8 u8MsgType = 0;
2105 u8 u8MsgID = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002106 u16 u16MsgLen = 0;
2107 u16 u16WidID = (u16)WID_NIL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002108 u8 u8WidLen = 0;
2109 u8 u8MacStatus;
2110 u8 u8MacStatusReasonCode;
2111 u8 u8MacStatusAdditionalInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002112 tstrConnectInfo strConnectInfo;
2113 tstrDisconnectNotifInfo strDisconnectNotifInfo;
Leo Kime6e12662015-09-16 18:36:03 +09002114 s32 s32Err = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002115 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002116
Leo Kim234837d2015-09-22 14:34:43 +09002117 if (!pstrWFIDrv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002118 PRINT_ER("Driver handler is NULL\n");
Leo Kim234837d2015-09-22 14:34:43 +09002119 return -ENODEV;
2120 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002121 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
2122 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
2123
2124 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
2125 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) ||
2126 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2127 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002128 (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
Leo Kim24db7132015-09-16 18:36:01 +09002129 PRINT_ER("driver is null\n");
2130 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002131 }
2132
2133 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
2134
2135 /* Check whether the received message type is 'I' */
2136 if ('I' != u8MsgType) {
2137 PRINT_ER("Received Message format incorrect.\n");
Leo Kim24db7132015-09-16 18:36:01 +09002138 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002139 }
2140
2141 /* Extract message ID */
2142 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
2143
2144 /* Extract message Length */
2145 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
2146
2147 /* Extract WID ID [expected to be = WID_STATUS] */
2148 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
2149
2150 /* Extract WID Length [expected to be = 1] */
2151 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
2152
2153 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2154 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
2155 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
2156 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
2157 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2158 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2159 /* 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 +09002160 u32 u32RcvdAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002161 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
2162
2163 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2164
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002165 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002166
2167 if (u8MacStatus == MAC_CONNECTED) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002168 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002169
Johnny Kim218dc402015-08-13 13:41:19 +09002170 host_int_get_assoc_res_info(pstrWFIDrv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002171 gapu8RcvdAssocResp,
2172 MAX_ASSOC_RESP_FRAME_SIZE,
2173 &u32RcvdAssocRespInfoLen);
2174
2175 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
2176
2177 if (u32RcvdAssocRespInfoLen != 0) {
2178
2179 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
2180 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
2181 &pstrConnectRespInfo);
2182 if (s32Err) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002183 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002184 } else {
2185 /* use the necessary parsed Info from the Received Association Response */
2186 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
2187
2188 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
2189 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
2190 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
2191 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
2192
2193
Glen Leef3052582015-09-10 12:03:04 +09002194 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002195 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002196 pstrConnectRespInfo->u16RespIEsLen);
2197 }
2198 }
2199
2200 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2201 if (pstrConnectRespInfo != NULL) {
2202 DeallocateAssocRespInfo(pstrConnectRespInfo);
2203 pstrConnectRespInfo = NULL;
2204 }
2205 }
2206 }
2207 }
2208
2209 /* The station has just received mac status and it also received assoc. response which
2210 * it was waiting for.
2211 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2212 if ((u8MacStatus == MAC_CONNECTED) &&
2213 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002214 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 +09002215 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002216
2217 } else if (u8MacStatus == MAC_DISCONNECTED) {
2218 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002219 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002220 }
2221
2222 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2223 /* through a structure of type tstrConnectRespInfo */
2224 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2225 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002226 memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002227
2228 if ((u8MacStatus == MAC_CONNECTED) &&
2229 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002230 memcpy(pstrWFIDrv->au8AssociatedBSSID,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002231 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
2232 }
2233 }
2234
2235
2236 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2237 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09002238 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002239 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002240 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2241 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2242 }
2243
2244
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002245 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002246 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2247 &strConnectInfo,
2248 u8MacStatus,
2249 NULL,
2250 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2251
2252
2253 /* if received mac status is MAC_CONNECTED and
2254 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2255 * else change state to IDLE */
2256 if ((u8MacStatus == MAC_CONNECTED) &&
2257 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Johnny Kim218dc402015-08-13 13:41:19 +09002258 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002259
2260 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
2261 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED;
2262
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002263 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +09002264 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002265 mod_timer(&hDuringIpTimer,
2266 jiffies + msecs_to_jiffies(10000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002267
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002268 /* open a BA session if possible */
2269 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002270 /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
2271 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2272 } else {
2273 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
2274 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002275 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002276 }
2277
2278 /* Deallocation */
2279 if (strConnectInfo.pu8RespIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002280 kfree(strConnectInfo.pu8RespIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002281 strConnectInfo.pu8RespIEs = NULL;
2282 }
2283
2284 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002285 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002286 strConnectInfo.pu8ReqIEs = NULL;
2287 }
2288
2289
2290 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2291 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002292 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002293 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2294 }
2295
2296 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002297 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002298 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2299 }
2300
2301 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2302 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002303 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002304 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2305 }
2306
2307 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2308 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) {
2309 /* Disassociation or Deauthentication frame has been received */
2310 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
2311
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002312 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002313
2314 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002315 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002316 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002317 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2318 }
2319
2320 strDisconnectNotifInfo.u16reason = 0;
2321 strDisconnectNotifInfo.ie = NULL;
2322 strDisconnectNotifInfo.ie_len = 0;
2323
2324 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002325 g_obtainingIP = false;
Johnny Kim218dc402015-08-13 13:41:19 +09002326 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002327
2328 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2329 NULL,
2330 0,
2331 &strDisconnectNotifInfo,
2332 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2333
2334 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002335 PRINT_ER("Connect result callback function is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002336 }
2337
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002338 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002339
2340
2341 /* Deallocation */
2342
2343 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2344 * should be deallocated here */
2345 /*
2346 * if(strDisconnectNotifInfo.ie != NULL)
2347 * {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002348 * kfree(strDisconnectNotifInfo.ie);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002349 * strDisconnectNotifInfo.ie = NULL;
2350 * }
2351 */
2352
2353 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2354 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002355 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002356 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2357 }
2358
2359 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002360 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002361 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2362 }
2363
2364 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2365 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002366 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002367 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2368 }
2369
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002370 /*Freeing flushed join request params on receiving*/
2371 /*MAC_DISCONNECTED while connected*/
Johnny Kim8a625ca2015-08-20 16:32:50 +09002372 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002373 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002374 gu8FlushedJoinReq = NULL;
2375 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09002376 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002377 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002378 gu8FlushedInfoElemAsoc = NULL;
2379 }
2380
2381 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002382 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002383
2384 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2385 (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
2386 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002387 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002388 /*Abort the running scan*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002389 del_timer(&pstrWFIDrv->hScanTimer);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002390 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult)
Johnny Kim2b05df52015-08-13 13:41:21 +09002391 Handle_ScanDone(pstrWFIDrv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002392
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002393 }
2394
2395 }
2396
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002397 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2398 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002399 kfree(pstrRcvdGnrlAsyncInfo->pu8Buffer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002400 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
2401 }
2402
2403 return s32Error;
2404}
2405
2406/**
2407 * @brief Handle_Key
2408 * @details Sending config packet to firmware to set key
Tony Choc98387a2015-09-21 12:16:40 +09002409 * @param[in] struct key_attr *pstrHostIFkeyAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002410 * @return Error code.
2411 * @author
2412 * @date
2413 * @version 1.0
2414 */
Tony Choc98387a2015-09-21 12:16:40 +09002415static int Handle_Key(tstrWILC_WFIDrv *drvHandler,
2416 struct key_attr *pstrHostIFkeyAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002417{
Leo Kime6e12662015-09-16 18:36:03 +09002418 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002419 tstrWID strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002420 tstrWID strWIDList[5];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002421 u8 i;
2422 u8 *pu8keybuf;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002423 s8 s8idxarray[1];
2424 s8 ret = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002425 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2426
2427
2428 switch (pstrHostIFkeyAttr->enuKeyType) {
2429
2430
2431 case WEP:
2432
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002433 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2434
2435 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2436 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Chaehyun Limd85f5322015-06-11 14:35:54 +09002437 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002438 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002439 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002440 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002441
2442 strWIDList[1].u16WIDid = WID_AUTH_TYPE;
2443 strWIDList[1].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002444 strWIDList[1].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002445 strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002446
Chaehyun Limd85f5322015-06-11 14:35:54 +09002447 strWIDList[2].u16WIDid = (u16)WID_KEY_ID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002448 strWIDList[2].enuWIDtype = WID_CHAR;
2449
Chaehyun Limca356ad2015-06-11 14:35:57 +09002450 strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Dean Lee576917a2015-06-15 11:58:57 +09002451 strWIDList[2].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002452
2453
Glen Leef3052582015-09-10 12:03:04 +09002454 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002455
2456
2457 if (pu8keybuf == NULL) {
2458 PRINT_ER("No buffer to send Key\n");
2459 return -1;
2460 }
2461
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002462 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002463 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2464
2465
Chaehyun Lim49188af2015-08-11 10:32:41 +09002466 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002467
Chaehyun Limd85f5322015-06-11 14:35:54 +09002468 strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002469 strWIDList[3].enuWIDtype = WID_STR;
2470 strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002471 strWIDList[3].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002472
2473
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002474 s32Error = send_config_pkt(SET_CFG, strWIDList, 4, true,
2475 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002476 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002477
2478
2479 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002480
2481 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2482 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Glen Leef3052582015-09-10 12:03:04 +09002483 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002484 if (pu8keybuf == NULL) {
2485 PRINT_ER("No buffer to send Key\n");
2486 return -1;
2487 }
2488 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2489
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002490 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002491
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002492 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002493 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2494
Chaehyun Lim49188af2015-08-11 10:32:41 +09002495 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002496
Chaehyun Limd85f5322015-06-11 14:35:54 +09002497 strWID.u16WIDid = (u16)WID_ADD_WEP_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002498 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002499 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002500 strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2;
2501
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002502 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2503 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002504 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002505 } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) {
2506
2507 PRINT_D(HOSTINF_DBG, "Removing key\n");
Chaehyun Limd85f5322015-06-11 14:35:54 +09002508 strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002509 strWID.enuWIDtype = WID_STR;
2510
Chaehyun Limca356ad2015-06-11 14:35:57 +09002511 s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002512 strWID.ps8WidVal = s8idxarray;
2513 strWID.s32ValueSize = 1;
2514
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002515 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2516 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002517 } else {
Chaehyun Limd85f5322015-06-11 14:35:54 +09002518 strWID.u16WIDid = (u16)WID_KEY_ID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002519 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002520 strWID.ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Dean Lee576917a2015-06-15 11:58:57 +09002521 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002522
2523 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
2524
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002525 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2526 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002527 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002528 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002529 break;
2530
2531 case WPARxGtk:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002532 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
Glen Leef3052582015-09-10 12:03:04 +09002533 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002534 if (pu8keybuf == NULL) {
2535 PRINT_ER("No buffer to send RxGTK Key\n");
2536 ret = -1;
2537 goto _WPARxGtk_end_case_;
2538 }
2539
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002540 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002541
2542
2543 /*|----------------------------------------------------------------------------|
2544 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2545 * |------------|---------|-------|------------|---------------|----------------|
2546 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2547
2548
2549
2550 if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002551 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002552
2553
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002554 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002555
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002556 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002557
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002558 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002559 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2560 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
Chaehyun Limd85f5322015-06-11 14:35:54 +09002561 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002562 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002563 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002564 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002565
Chaehyun Limd85f5322015-06-11 14:35:54 +09002566 strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002567 strWIDList[1].enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002568 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002569 strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN;
2570
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002571 s32Error = send_config_pkt(SET_CFG, strWIDList, 2, true,
2572 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002573
Chaehyun Lim49188af2015-08-11 10:32:41 +09002574 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002575
2576 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002577 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002578 /* ///////////////////////// */
2579 }
2580
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002581 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2582 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
2583
Glen Leef3052582015-09-10 12:03:04 +09002584 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002585 if (pu8keybuf == NULL) {
2586 PRINT_ER("No buffer to send RxGTK Key\n");
2587 ret = -1;
2588 goto _WPARxGtk_end_case_;
2589 }
2590
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002591 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002592
2593
2594 /*|----------------------------------------------------------------------------|
2595 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2596 * |------------|---------|-------|------------|---------------|----------------|
2597 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2598
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302599 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002600 memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302601 else
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002602 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002603
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002604 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002605
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002606 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002607
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002608 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2609 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002610 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2611
Chaehyun Limd85f5322015-06-11 14:35:54 +09002612 strWID.u16WIDid = (u16)WID_ADD_RX_GTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002613 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002614 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002615 strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN;
2616
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002617 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2618 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002619
Chaehyun Lim49188af2015-08-11 10:32:41 +09002620 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002621
2622 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002623 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002624 /* ///////////////////////// */
2625 }
2626_WPARxGtk_end_case_:
Chaehyun Lim49188af2015-08-11 10:32:41 +09002627 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2628 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002629 if (ret == -1)
2630 return ret;
2631
2632 break;
2633
2634 case WPAPtk:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002635 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2636
2637
Glen Leef3052582015-09-10 12:03:04 +09002638 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002639
2640
2641
2642 if (pu8keybuf == NULL) {
2643 PRINT_ER("No buffer to send PTK Key\n");
2644 ret = -1;
2645 goto _WPAPtk_end_case_;
2646
2647 }
2648
2649 /*|-----------------------------------------------------------------------------|
2650 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2651 * |----------------|------------ |--------------|----------------|---------------|
2652 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2653 |-----------------------------------------------------------------------------|*/
2654
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002655 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002656
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002657 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2658 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002659 /*16 byte TK*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002660 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002661 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2662
2663
Chaehyun Limd85f5322015-06-11 14:35:54 +09002664 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002665 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002666 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002667 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002668
Chaehyun Limd85f5322015-06-11 14:35:54 +09002669 strWIDList[1].u16WIDid = (u16)WID_ADD_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002670 strWIDList[1].enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002671 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002672 strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1;
2673
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002674 s32Error = send_config_pkt(SET_CFG, strWIDList, 2, true,
2675 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002676 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002677
2678 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002679 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002680 /* ///////////////////////// */
2681 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002682 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2683
2684
Glen Leef3052582015-09-10 12:03:04 +09002685 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002686
2687
2688
2689 if (pu8keybuf == NULL) {
2690 PRINT_ER("No buffer to send PTK Key\n");
2691 ret = -1;
2692 goto _WPAPtk_end_case_;
2693
2694 }
2695
2696 /*|-----------------------------------------------------------------------------|
2697 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
2698 * |----------------|------------|--------------|----------------|---------------|
2699 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
2700 |-----------------------------------------------------------------------------|*/
2701
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002702 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002703
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002704 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002705 /*16 byte TK*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002706 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002707 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2708
2709
Chaehyun Limd85f5322015-06-11 14:35:54 +09002710 strWID.u16WIDid = (u16)WID_ADD_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002711 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002712 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002713 strWID.s32ValueSize = PTK_KEY_MSG_LEN;
2714
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002715 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2716 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002717 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002718
2719 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002720 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002721 /* ///////////////////////// */
2722 }
2723
2724_WPAPtk_end_case_:
Chaehyun Lim49188af2015-08-11 10:32:41 +09002725 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002726 if (ret == -1)
2727 return ret;
2728
2729 break;
2730
2731
2732 case PMKSA:
2733
2734 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
2735
Glen Leef3052582015-09-10 12:03:04 +09002736 pu8keybuf = kmalloc((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002737 if (pu8keybuf == NULL) {
2738 PRINT_ER("No buffer to send PMKSA Key\n");
2739 return -1;
2740 }
2741
2742 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
2743
2744 for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
2745
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002746 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
2747 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002748 }
2749
Chaehyun Limd85f5322015-06-11 14:35:54 +09002750 strWID.u16WIDid = (u16)WID_PMKID_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002751 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002752 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002753 strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1;
2754
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002755 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2756 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002757
Chaehyun Lim49188af2015-08-11 10:32:41 +09002758 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002759 break;
2760 }
2761
2762 if (s32Error)
2763 PRINT_ER("Failed to send key config packet\n");
2764
2765
2766 return s32Error;
2767}
2768
2769
2770/**
2771 * @brief Handle_Disconnect
2772 * @details Sending config packet to firmware to disconnect
2773 * @param[in] NONE
2774 * @return NONE
2775 * @author
2776 * @date
2777 * @version 1.0
2778 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002779static void Handle_Disconnect(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002780{
2781 tstrWID strWID;
2782
Leo Kime6e12662015-09-16 18:36:03 +09002783 s32 s32Error = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002784 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002785 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2786
2787
Chaehyun Limd85f5322015-06-11 14:35:54 +09002788 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002789 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002790 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
Dean Lee576917a2015-06-15 11:58:57 +09002791 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002792
2793
2794
2795 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2796
Dean Lee72ed4dc2015-06-12 14:11:44 +09002797 g_obtainingIP = false;
Johnny Kim218dc402015-08-13 13:41:19 +09002798 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002799
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002800 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002801
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002802 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
2803 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002804
2805 if (s32Error) {
2806 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002807 } else {
2808 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2809
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002810 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002811
2812 strDisconnectNotifInfo.u16reason = 0;
2813 strDisconnectNotifInfo.ie = NULL;
2814 strDisconnectNotifInfo.ie_len = 0;
2815
2816 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002817 del_timer(&pstrWFIDrv->hScanTimer);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002818 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002819 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2820
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002821 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002822 }
2823
2824 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2825
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002826 /*Stop connect timer, if connection in progress*/
2827 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2828 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002829 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002830 }
2831
2832 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
2833 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2834 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002835 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002836 }
2837
Dean Lee72ed4dc2015-06-12 14:11:44 +09002838 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002839
2840 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2841
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002842 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002843
2844
2845 /* Deallocation */
2846 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2847 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002848 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002849 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2850 }
2851
2852 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002853 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002854 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2855 }
2856
2857 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2858 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002859 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002860 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2861 }
2862
2863
Johnny Kim8a625ca2015-08-20 16:32:50 +09002864 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002865 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002866 gu8FlushedJoinReq = NULL;
2867 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09002868 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002869 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002870 gu8FlushedInfoElemAsoc = NULL;
2871 }
2872
2873 }
2874
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002875 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002876 up(&(pstrWFIDrv->hSemTestDisconnectBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002877 /* ///////////////////////// */
2878
2879}
2880
2881
Johnny Kim2b05df52015-08-13 13:41:21 +09002882void resolve_disconnect_aberration(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002883{
2884 tstrWILC_WFIDrv *pstrWFIDrv;
2885
2886 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002887 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002888 return;
2889 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
2890 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
Johnny Kim218dc402015-08-13 13:41:19 +09002891 host_int_disconnect(pstrWFIDrv, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002892 }
2893}
Johnny Kim2b05df52015-08-13 13:41:21 +09002894static s32 Switch_Log_Terminal(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002895{
2896
2897
Leo Kime6e12662015-09-16 18:36:03 +09002898 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002899 tstrWID strWID;
2900 static char dummy = 9;
2901 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2902
Chaehyun Limd85f5322015-06-11 14:35:54 +09002903 strWID.u16WIDid = (u16)WID_LOGTerminal_Switch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002904 strWID.enuWIDtype = WID_CHAR;
2905 strWID.ps8WidVal = &dummy;
Dean Lee576917a2015-06-15 11:58:57 +09002906 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002907
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002908 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2909 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002910
2911
2912 if (s32Error) {
2913 PRINT_D(HOSTINF_DBG, "Failed to switch log terminal\n");
Leo Kim24db7132015-09-16 18:36:01 +09002914 PRINT_ER("Failed to switch log terminal\n");
2915 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002916 }
2917
Leo Kim24db7132015-09-16 18:36:01 +09002918 PRINT_INFO(HOSTINF_DBG, "MAC address set ::\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002919
2920 return s32Error;
2921}
2922
2923/**
2924 * @brief Handle_GetChnl
2925 * @details Sending config packet to get channel
2926 * @param[in] NONE
2927 * @return NONE
2928 *
2929 * @author
2930 * @date
2931 * @version 1.0
2932 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002933static s32 Handle_GetChnl(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002934{
2935
Leo Kime6e12662015-09-16 18:36:03 +09002936 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002937 tstrWID strWID;
2938 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
2939 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002940
Chaehyun Limd85f5322015-06-11 14:35:54 +09002941 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002942 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002943 strWID.ps8WidVal = (s8 *)&gu8Chnl;
Dean Lee576917a2015-06-15 11:58:57 +09002944 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002945
2946 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2947
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002948 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
2949 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002950 /*get the value by searching the local copy*/
2951 if (s32Error) {
2952 PRINT_ER("Failed to get channel number\n");
Leo Kim24db7132015-09-16 18:36:01 +09002953 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002954 }
2955
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002956 up(&(pstrWFIDrv->hSemGetCHNL));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002957
2958 return s32Error;
2959
2960
2961
2962}
2963
2964
2965/**
2966 * @brief Handle_GetRssi
2967 * @details Sending config packet to get RSSI
2968 * @param[in] NONE
2969 * @return NONE
2970 * @author
2971 * @date
2972 * @version 1.0
2973 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002974static void Handle_GetRssi(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002975{
Leo Kime6e12662015-09-16 18:36:03 +09002976 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002977 tstrWID strWID;
2978 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2979
Chaehyun Limd85f5322015-06-11 14:35:54 +09002980 strWID.u16WIDid = (u16)WID_RSSI;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002981 strWID.enuWIDtype = WID_CHAR;
2982 strWID.ps8WidVal = &gs8Rssi;
Dean Lee576917a2015-06-15 11:58:57 +09002983 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002984
2985 /*Sending Cfg*/
2986 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2987
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002988 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
2989 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002990 if (s32Error) {
2991 PRINT_ER("Failed to get RSSI value\n");
Leo Kim24db7132015-09-16 18:36:01 +09002992 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002993 }
2994
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002995 up(&(pstrWFIDrv->hSemGetRSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002996
2997
2998}
2999
3000
Johnny Kim2b05df52015-08-13 13:41:21 +09003001static void Handle_GetLinkspeed(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003002{
Leo Kime6e12662015-09-16 18:36:03 +09003003 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003004 tstrWID strWID;
3005 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3006
3007 gs8lnkspd = 0;
3008
Chaehyun Limd85f5322015-06-11 14:35:54 +09003009 strWID.u16WIDid = (u16)WID_LINKSPEED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003010 strWID.enuWIDtype = WID_CHAR;
3011 strWID.ps8WidVal = &gs8lnkspd;
Dean Lee576917a2015-06-15 11:58:57 +09003012 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003013 /*Sending Cfg*/
3014 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
3015
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003016 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
3017 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003018 if (s32Error) {
3019 PRINT_ER("Failed to get LINKSPEED value\n");
Leo Kim24db7132015-09-16 18:36:01 +09003020 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003021 }
3022
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003023 up(&(pstrWFIDrv->hSemGetLINKSPEED));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003024
3025
3026}
3027
Johnny Kim2b05df52015-08-13 13:41:21 +09003028s32 Handle_GetStatistics(tstrWILC_WFIDrv *drvHandler, tstrStatistics *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003029{
3030 tstrWID strWIDList[5];
Chaehyun Limfbc2fe12015-09-15 14:06:16 +09003031 u32 u32WidsCount = 0, s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003032
3033 strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED;
3034 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003035 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003036 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003037 u32WidsCount++;
3038
3039 strWIDList[u32WidsCount].u16WIDid = WID_RSSI;
3040 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003041 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003042 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->s8RSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003043 u32WidsCount++;
3044
3045 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
3046 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003047 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003048 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003049 u32WidsCount++;
3050
3051 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
3052 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003053 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003054 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32RxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003055 u32WidsCount++;
3056
3057 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
3058 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003059 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003060 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxFailureCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003061 u32WidsCount++;
3062
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003063 s32Error = send_config_pkt(GET_CFG, strWIDList, u32WidsCount, false,
3064 get_id_from_handler(drvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003065
Leo Kim24db7132015-09-16 18:36:01 +09003066 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003067 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09003068
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003069 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003070 return 0;
3071
3072}
3073
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003074/**
3075 * @brief Handle_Get_InActiveTime
3076 * @details Sending config packet to set mac adddress for station and
3077 * get inactive time
3078 * @param[in] NONE
3079 * @return NONE
3080 *
3081 * @author
3082 * @date
3083 * @version 1.0
3084 */
Tony Cho3d1eac02015-09-21 12:16:49 +09003085static s32 Handle_Get_InActiveTime(tstrWILC_WFIDrv *drvHandler,
3086 struct sta_inactive_t *strHostIfStaInactiveT)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003087{
3088
Leo Kime6e12662015-09-16 18:36:03 +09003089 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003090 u8 *stamac;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003091 tstrWID strWID;
3092 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3093
3094
Chaehyun Limd85f5322015-06-11 14:35:54 +09003095 strWID.u16WIDid = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003096 strWID.enuWIDtype = WID_STR;
3097 strWID.s32ValueSize = ETH_ALEN;
Glen Leef3052582015-09-10 12:03:04 +09003098 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003099
3100
3101 stamac = strWID.ps8WidVal;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003102 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003103
3104
3105 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
3106
3107
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003108 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3109 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003110 /*get the value by searching the local copy*/
3111 if (s32Error) {
3112 PRINT_ER("Failed to SET incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09003113 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003114 }
3115
3116
Chaehyun Limd85f5322015-06-11 14:35:54 +09003117 strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003118 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003119 strWID.ps8WidVal = (s8 *)&gu32InactiveTime;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003120 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003121
3122
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003123 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
3124 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003125 /*get the value by searching the local copy*/
3126 if (s32Error) {
3127 PRINT_ER("Failed to get incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09003128 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003129 }
3130
3131
3132 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
3133
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003134 up(&(pstrWFIDrv->hSemInactiveTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003135
3136 return s32Error;
3137
3138
3139
3140}
3141
3142
3143/**
3144 * @brief Handle_AddBeacon
3145 * @details Sending config packet to add beacon
Tony Cho7f33fec2015-09-30 18:44:30 +09003146 * @param[in] struct beacon_attr *pstrSetBeaconParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003147 * @return NONE
3148 * @author
3149 * @date
3150 * @version 1.0
3151 */
Tony Cho902362b2015-09-21 12:16:44 +09003152static void Handle_AddBeacon(tstrWILC_WFIDrv *drvHandler,
Tony Cho7f33fec2015-09-30 18:44:30 +09003153 struct beacon_attr *pstrSetBeaconParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003154{
Leo Kime6e12662015-09-16 18:36:03 +09003155 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003156 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003157 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003158 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003159
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003160 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
3161
Chaehyun Limd85f5322015-06-11 14:35:54 +09003162 strWID.u16WIDid = (u16)WID_ADD_BEACON;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003163 strWID.enuWIDtype = WID_BIN;
3164 strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
Glen Leef3052582015-09-10 12:03:04 +09003165 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003166 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003167 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003168
3169 pu8CurrByte = strWID.ps8WidVal;
3170 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
3171 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
3172 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
3173 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
3174
3175 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
3176 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
3177 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
3178 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
3179
3180 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
3181 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
3182 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
3183 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
3184
3185 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
3186 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
3187
3188 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
3189 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
3190 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
3191 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
3192
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003193 if (pstrSetBeaconParam->pu8Tail > 0)
3194 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
3195 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
3196
3197
3198
3199 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003200 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3201 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003202 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003203 PRINT_ER("Failed to send add beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003204
Leo Kim24db7132015-09-16 18:36:01 +09003205ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003206 kfree(strWID.ps8WidVal);
3207 kfree(pstrSetBeaconParam->pu8Head);
3208 kfree(pstrSetBeaconParam->pu8Tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003209}
3210
3211
3212/**
3213 * @brief Handle_AddBeacon
3214 * @details Sending config packet to delete beacon
Tony Cho80bf88362015-09-30 18:44:29 +09003215 * @param[in] tstrWILC_WFIDrv *drvHandler
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003216 * @return NONE
3217 * @author
3218 * @date
3219 * @version 1.0
3220 */
Tony Cho80bf88362015-09-30 18:44:29 +09003221static void Handle_DelBeacon(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003222{
Leo Kime6e12662015-09-16 18:36:03 +09003223 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003224 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003225 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003226 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003227
Chaehyun Limd85f5322015-06-11 14:35:54 +09003228 strWID.u16WIDid = (u16)WID_DEL_BEACON;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003229 strWID.enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003230 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003231 strWID.ps8WidVal = &gu8DelBcn;
3232
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003233 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003234 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003235
3236 pu8CurrByte = strWID.ps8WidVal;
3237
3238 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
3239 /* TODO: build del beacon message*/
3240
3241 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003242 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3243 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003244 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003245 PRINT_ER("Failed to send delete beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003246}
3247
3248
3249/**
3250 * @brief WILC_HostIf_PackStaParam
3251 * @details Handling packing of the station params in a buffer
Tony Cho6a89ba92015-09-21 12:16:46 +09003252 * @param[in] u8* pu8Buffer, struct add_sta_param *pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003253 * @return NONE
3254 * @author
3255 * @date
3256 * @version 1.0
3257 */
Tony Cho6a89ba92015-09-21 12:16:46 +09003258static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
3259 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003260{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003261 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003262
3263 pu8CurrByte = pu8Buffer;
3264
3265 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003266 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003267 pu8CurrByte += ETH_ALEN;
3268
3269 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
3270 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
3271
3272 *pu8CurrByte++ = pstrStationParam->u8NumRates;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003273 if (pstrStationParam->u8NumRates > 0)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003274 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003275 pu8CurrByte += pstrStationParam->u8NumRates;
3276
3277 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
3278 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
3279 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
3280
3281 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003282 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003283 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
3284
3285 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
3286 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
3287
3288 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
3289 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
3290 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
3291 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
3292
3293 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
3294
3295 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
3296 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
3297
3298 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
3299 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
3300
3301 return pu8CurrByte - pu8Buffer;
3302}
3303
3304/**
3305 * @brief Handle_AddStation
3306 * @details Sending config packet to add station
Tony Cho6a89ba92015-09-21 12:16:46 +09003307 * @param[in] struct add_sta_param *pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003308 * @return NONE
3309 * @author
3310 * @date
3311 * @version 1.0
3312 */
Tony Cho6a89ba92015-09-21 12:16:46 +09003313static void Handle_AddStation(tstrWILC_WFIDrv *drvHandler,
3314 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003315{
Leo Kime6e12662015-09-16 18:36:03 +09003316 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003317 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003318 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003319 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003320
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003321 PRINT_D(HOSTINF_DBG, "Handling add station\n");
Chaehyun Limd85f5322015-06-11 14:35:54 +09003322 strWID.u16WIDid = (u16)WID_ADD_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003323 strWID.enuWIDtype = WID_BIN;
3324 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3325
Glen Leef3052582015-09-10 12:03:04 +09003326 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003327 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003328 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003329
3330 pu8CurrByte = strWID.ps8WidVal;
3331 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3332
3333 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003334 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3335 get_id_from_handler(pstrWFIDrv));
Leo Kime6e12662015-09-16 18:36:03 +09003336 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003337 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003338
Leo Kim24db7132015-09-16 18:36:01 +09003339ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003340 kfree(pstrStationParam->pu8Rates);
3341 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003342}
3343
3344/**
3345 * @brief Handle_DelAllSta
3346 * @details Sending config packet to delete station
3347 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3348 * @return NONE
3349 * @author
3350 * @date
3351 * @version 1.0
3352 */
Tony Chob4e644e2015-09-21 12:17:00 +09003353static void Handle_DelAllSta(tstrWILC_WFIDrv *drvHandler,
3354 struct del_all_sta *pstrDelAllStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003355{
Leo Kime6e12662015-09-16 18:36:03 +09003356 s32 s32Error = 0;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003357
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003358 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003359 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003360 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003361 u8 i;
Chaehyun Lim37034802015-06-11 14:34:32 +09003362 u8 au8Zero_Buff[6] = {0};
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003363
Chaehyun Limd85f5322015-06-11 14:35:54 +09003364 strWID.u16WIDid = (u16)WID_DEL_ALL_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003365 strWID.enuWIDtype = WID_STR;
3366 strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
3367
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003368 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003369
Glen Leef3052582015-09-10 12:03:04 +09003370 strWID.ps8WidVal = kmalloc((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003371 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003372 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003373
3374 pu8CurrByte = strWID.ps8WidVal;
3375
3376 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
3377
3378 for (i = 0; i < MAX_NUM_STA; i++) {
3379 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003380 memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003381 else
3382 continue;
3383
3384 pu8CurrByte += ETH_ALEN;
3385 }
3386
3387 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003388 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3389 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003390 if (s32Error)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02003391 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003392
Leo Kim24db7132015-09-16 18:36:01 +09003393ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003394 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003395
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003396 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003397}
3398
3399
3400/**
3401 * @brief Handle_DelStation
3402 * @details Sending config packet to delete station
Tony Chofb93a1e2015-09-21 12:16:57 +09003403 * @param[in] struct del_sta *pstrDelStaParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003404 * @return NONE
3405 * @author
3406 * @date
3407 * @version 1.0
3408 */
Tony Chofb93a1e2015-09-21 12:16:57 +09003409static void Handle_DelStation(tstrWILC_WFIDrv *drvHandler,
3410 struct del_sta *pstrDelStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003411{
Leo Kime6e12662015-09-16 18:36:03 +09003412 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003413 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003414 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003415 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3416
Chaehyun Limd85f5322015-06-11 14:35:54 +09003417 strWID.u16WIDid = (u16)WID_REMOVE_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003418 strWID.enuWIDtype = WID_BIN;
3419 strWID.s32ValueSize = ETH_ALEN;
3420
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003421 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003422
Glen Leef3052582015-09-10 12:03:04 +09003423 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003424 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003425 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003426
3427 pu8CurrByte = strWID.ps8WidVal;
3428
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003429 memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003430
3431 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003432 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3433 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003434 if (s32Error)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02003435 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003436
Leo Kim24db7132015-09-16 18:36:01 +09003437ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003438 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003439}
3440
3441
3442/**
3443 * @brief Handle_EditStation
3444 * @details Sending config packet to edit station
Tony Cho6a89ba92015-09-21 12:16:46 +09003445 * @param[in] struct add_sta_param *pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003446 * @return NONE
3447 * @author
3448 * @date
3449 * @version 1.0
3450 */
Tony Cho6a89ba92015-09-21 12:16:46 +09003451static void Handle_EditStation(tstrWILC_WFIDrv *drvHandler,
3452 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003453{
Leo Kime6e12662015-09-16 18:36:03 +09003454 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003455 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003456 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003457 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3458
Chaehyun Limd85f5322015-06-11 14:35:54 +09003459 strWID.u16WIDid = (u16)WID_EDIT_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003460 strWID.enuWIDtype = WID_BIN;
3461 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3462
3463 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
Glen Leef3052582015-09-10 12:03:04 +09003464 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003465 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003466 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003467
3468 pu8CurrByte = strWID.ps8WidVal;
3469 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3470
3471 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003472 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3473 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003474 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003475 PRINT_ER("Failed to send edit station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003476
Leo Kim24db7132015-09-16 18:36:01 +09003477ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003478 kfree(pstrStationParam->pu8Rates);
3479 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003480}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003481
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003482/**
3483 * @brief Handle_RemainOnChan
3484 * @details Sending config packet to edit station
3485 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3486 * @return NONE
3487 * @author
3488 * @date
3489 * @version 1.0
3490 */
Tony Cho2f9c03f2015-09-21 12:16:58 +09003491static int Handle_RemainOnChan(tstrWILC_WFIDrv *drvHandler,
3492 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003493{
Leo Kime6e12662015-09-16 18:36:03 +09003494 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003495 u8 u8remain_on_chan_flag;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003496 tstrWID strWID;
3497 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3498
3499 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3500 if (!pstrWFIDrv->u8RemainOnChan_pendingreq) {
3501 pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
3502 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
3503 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
3504 pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
3505 pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
3506 } else {
3507 /*Set the channel to use it as a wid val*/
3508 pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel;
3509 }
3510
3511 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3512 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
3513 pstrWFIDrv->u8RemainOnChan_pendingreq = 1;
Leo Kim24db7132015-09-16 18:36:01 +09003514 s32Error = -EBUSY;
3515 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003516 }
3517 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3518 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
Leo Kim24db7132015-09-16 18:36:01 +09003519 s32Error = -EBUSY;
3520 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003521 }
3522
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003523 if (g_obtainingIP || connecting) {
3524 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +09003525 s32Error = -EBUSY;
3526 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003527 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003528
3529 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
3530
Dean Lee72ed4dc2015-06-12 14:11:44 +09003531 u8remain_on_chan_flag = true;
Chaehyun Limd85f5322015-06-11 14:35:54 +09003532 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003533 strWID.enuWIDtype = WID_STR;
3534 strWID.s32ValueSize = 2;
Glen Leef3052582015-09-10 12:03:04 +09003535 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003536
Leo Kim24db7132015-09-16 18:36:01 +09003537 if (strWID.ps8WidVal == NULL) {
3538 s32Error = -ENOMEM;
3539 goto ERRORHANDLER;
3540 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003541
3542 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003543 strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003544
3545 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003546 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3547 get_id_from_handler(pstrWFIDrv));
Leo Kime6e12662015-09-16 18:36:03 +09003548 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003549 PRINT_ER("Failed to set remain on channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003550
Leo Kim24db7132015-09-16 18:36:01 +09003551ERRORHANDLER:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003552 {
3553 P2P_LISTEN_STATE = 1;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003554 pstrWFIDrv->hRemainOnChannel.data = (unsigned long)pstrWFIDrv;
3555 mod_timer(&pstrWFIDrv->hRemainOnChannel,
3556 jiffies +
3557 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003558
3559 /*Calling CFG ready_on_channel*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003560 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003561 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003562
3563 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3564 pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
3565 }
3566 return s32Error;
3567}
3568
3569/**
3570 * @brief Handle_RegisterFrame
3571 * @details
3572 * @param[in]
3573 * @return NONE
3574 * @author
3575 * @date
3576 * @version 1.0
3577 */
Tony Chobc37c5d2015-09-21 12:16:59 +09003578static int Handle_RegisterFrame(tstrWILC_WFIDrv *drvHandler,
3579 struct reg_frame *pstrHostIfRegisterFrame)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003580{
Leo Kime6e12662015-09-16 18:36:03 +09003581 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003582 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003583 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003584 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3585
3586 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
3587
3588 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +09003589 strWID.u16WIDid = (u16)WID_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003590 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09003591 strWID.ps8WidVal = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003592 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003593 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003594
3595 pu8CurrByte = strWID.ps8WidVal;
3596
3597 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
3598 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003599 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003600
3601
Chaehyun Limd85f5322015-06-11 14:35:54 +09003602 strWID.s32ValueSize = sizeof(u16) + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003603
3604
3605 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003606 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3607 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003608 if (s32Error) {
3609 PRINT_ER("Failed to frame register config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09003610 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003611 }
3612
3613 return s32Error;
3614
3615}
3616
3617/**
3618 * @brief Handle_ListenStateExpired
3619 * @details Handle of listen state expiration
3620 * @param[in] NONE
3621 * @return Error code.
3622 * @author
3623 * @date
3624 * @version 1.0
3625 */
3626#define FALSE_FRMWR_CHANNEL 100
Tony Cho2f9c03f2015-09-21 12:16:58 +09003627static u32 Handle_ListenStateExpired(tstrWILC_WFIDrv *drvHandler,
3628 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003629{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003630 u8 u8remain_on_chan_flag;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003631 tstrWID strWID;
Leo Kime6e12662015-09-16 18:36:03 +09003632 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003633 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3634
3635 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
3636
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003637 /*Make sure we are already in listen state*/
3638 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
3639 if (P2P_LISTEN_STATE) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003640 u8remain_on_chan_flag = false;
Chaehyun Limd85f5322015-06-11 14:35:54 +09003641 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003642 strWID.enuWIDtype = WID_STR;
3643 strWID.s32ValueSize = 2;
Glen Leef3052582015-09-10 12:03:04 +09003644 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003645
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003646 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003647 PRINT_ER("Failed to allocate memory\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003648
3649 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3650 strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL;
3651
3652 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003653 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3654 get_id_from_handler(pstrWFIDrv));
Leo Kime6e12662015-09-16 18:36:03 +09003655 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003656 PRINT_ER("Failed to set remain on channel\n");
3657 goto _done_;
3658 }
3659
3660 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) {
3661 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid
3662 , pstrHostIfRemainOnChan->u32ListenSessionID);
3663 }
3664 P2P_LISTEN_STATE = 0;
3665 } else {
3666 PRINT_D(GENERIC_DBG, "Not in listen state\n");
Leo Kime6e12662015-09-16 18:36:03 +09003667 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003668 }
3669
3670_done_:
3671 return s32Error;
3672}
3673
3674
3675/**
3676 * @brief ListenTimerCB
3677 * @details Callback function of remain-on-channel timer
3678 * @param[in] NONE
3679 * @return Error code.
3680 * @author
3681 * @date
3682 * @version 1.0
3683 */
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003684static void ListenTimerCB(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003685{
Leo Kime6e12662015-09-16 18:36:03 +09003686 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003687 struct host_if_msg msg;
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003688 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003689 /*Stopping remain-on-channel timer*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07003690 del_timer(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003691
3692 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09003693 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003694 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Cho143eb952015-09-21 12:16:32 +09003695 msg.drvHandler = pstrWFIDrv;
Tony Cho070d3652015-09-30 18:55:10 +09003696 msg.body.remain_on_ch.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003697
3698 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09003699 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003700 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09003701 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003702}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003703
3704/**
3705 * @brief Handle_EditStation
3706 * @details Sending config packet to edit station
3707 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3708 * @return NONE
3709 * @author
3710 * @date
3711 * @version 1.0
3712 */
Tony Cho5a008f12015-09-21 12:16:48 +09003713static void Handle_PowerManagement(tstrWILC_WFIDrv *drvHandler,
3714 struct power_mgmt_param *strPowerMgmtParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003715{
Leo Kime6e12662015-09-16 18:36:03 +09003716 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003717 tstrWID strWID;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003718 s8 s8PowerMode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003719 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003720
Chaehyun Limd85f5322015-06-11 14:35:54 +09003721 strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003722
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05303723 if (strPowerMgmtParam->bIsEnabled == true)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003724 s8PowerMode = MIN_FAST_PS;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05303725 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003726 s8PowerMode = NO_POWERSAVE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003727 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
3728 strWID.ps8WidVal = &s8PowerMode;
Dean Lee576917a2015-06-15 11:58:57 +09003729 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003730
3731 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
3732
3733 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003734 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3735 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003736 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003737 PRINT_ER("Failed to send power management config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003738}
3739
3740/**
3741 * @brief Handle_SetMulticastFilter
3742 * @details Set Multicast filter in firmware
Tony Cho641210a2015-09-21 12:16:52 +09003743 * @param[in] struct set_multicast *strHostIfSetMulti
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003744 * @return NONE
3745 * @author asobhy
3746 * @date
3747 * @version 1.0
3748 */
Tony Cho641210a2015-09-21 12:16:52 +09003749static void Handle_SetMulticastFilter(tstrWILC_WFIDrv *drvHandler,
3750 struct set_multicast *strHostIfSetMulti)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003751{
Leo Kime6e12662015-09-16 18:36:03 +09003752 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003753 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003754 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003755
3756 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
3757
Chaehyun Limd85f5322015-06-11 14:35:54 +09003758 strWID.u16WIDid = (u16)WID_SETUP_MULTICAST_FILTER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003759 strWID.enuWIDtype = WID_BIN;
Tony Cho641210a2015-09-21 12:16:52 +09003760 strWID.s32ValueSize = sizeof(struct set_multicast) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
Glen Leef3052582015-09-10 12:03:04 +09003761 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003762 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003763 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003764
3765 pu8CurrByte = strWID.ps8WidVal;
3766 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
3767 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
3768 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
3769 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
3770
3771 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
3772 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
3773 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
3774 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
3775
3776 if ((strHostIfSetMulti->u32count) > 0)
3777 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
3778
3779 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003780 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3781 get_id_from_handler(drvHandler));
Leo Kim24db7132015-09-16 18:36:01 +09003782 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003783 PRINT_ER("Failed to send setup multicast config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003784
Leo Kim24db7132015-09-16 18:36:01 +09003785ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003786 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003787
3788}
3789
3790
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003791/**
3792 * @brief Handle_AddBASession
3793 * @details Add block ack session
3794 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
3795 * @return NONE
3796 * @author Amr Abdel-Moghny
3797 * @date Feb. 2014
3798 * @version 9.0
3799 */
Tony Cho54265472015-09-21 12:16:56 +09003800static s32 Handle_AddBASession(tstrWILC_WFIDrv *drvHandler,
3801 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003802{
Leo Kime6e12662015-09-16 18:36:03 +09003803 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003804 tstrWID strWID;
3805 int AddbaTimeout = 100;
3806 char *ptr = NULL;
3807 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3808
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003809 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 +09003810 strHostIfBASessionInfo->au8Bssid[0],
3811 strHostIfBASessionInfo->au8Bssid[1],
3812 strHostIfBASessionInfo->au8Bssid[2],
3813 strHostIfBASessionInfo->u16BufferSize,
3814 strHostIfBASessionInfo->u16SessionTimeout,
3815 strHostIfBASessionInfo->u8Ted);
3816
Chaehyun Limd85f5322015-06-11 14:35:54 +09003817 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003818 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09003819 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003820 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
3821 ptr = strWID.ps8WidVal;
3822 /* *ptr++ = 0x14; */
3823 *ptr++ = 0x14;
3824 *ptr++ = 0x3;
3825 *ptr++ = 0x0;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003826 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003827 ptr += ETH_ALEN;
3828 *ptr++ = strHostIfBASessionInfo->u8Ted;
3829 /* BA Policy*/
3830 *ptr++ = 1;
3831 /* Buffer size*/
3832 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
3833 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
3834 /* BA timeout*/
3835 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
3836 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
3837 /* ADDBA timeout*/
3838 *ptr++ = (AddbaTimeout & 0xFF);
3839 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
3840 /* Group Buffer Max Frames*/
3841 *ptr++ = 8;
3842 /* Group Buffer Timeout */
3843 *ptr++ = 0;
3844
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003845 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3846 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003847 if (s32Error)
3848 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
3849
3850
Chaehyun Limd85f5322015-06-11 14:35:54 +09003851 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003852 strWID.enuWIDtype = WID_STR;
3853 strWID.s32ValueSize = 15;
3854 ptr = strWID.ps8WidVal;
3855 /* *ptr++ = 0x14; */
3856 *ptr++ = 15;
3857 *ptr++ = 7;
3858 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003859 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003860 ptr += ETH_ALEN;
3861 /* TID*/
3862 *ptr++ = strHostIfBASessionInfo->u8Ted;
3863 /* Max Num MSDU */
3864 *ptr++ = 8;
3865 /* BA timeout*/
3866 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
3867 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
3868 /*Ack-Policy */
3869 *ptr++ = 3;
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003870 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3871 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003872
3873 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09003874 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003875
3876 return s32Error;
3877
3878}
3879
3880
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003881/**
3882 * @brief Handle_DelBASession
3883 * @details Delete block ack session
3884 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
3885 * @return NONE
3886 * @author Amr Abdel-Moghny
3887 * @date Feb. 2013
3888 * @version 9.0
3889 */
Tony Cho54265472015-09-21 12:16:56 +09003890static s32 Handle_DelBASession(tstrWILC_WFIDrv *drvHandler,
3891 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003892{
Leo Kime6e12662015-09-16 18:36:03 +09003893 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003894 tstrWID strWID;
3895 char *ptr = NULL;
3896 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3897
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003898 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003899 strHostIfBASessionInfo->au8Bssid[0],
3900 strHostIfBASessionInfo->au8Bssid[1],
3901 strHostIfBASessionInfo->au8Bssid[2],
3902 strHostIfBASessionInfo->u8Ted);
3903
Chaehyun Limd85f5322015-06-11 14:35:54 +09003904 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003905 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09003906 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003907 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
3908 ptr = strWID.ps8WidVal;
3909 /* *ptr++ = 0x14; */
3910 *ptr++ = 0x14;
3911 *ptr++ = 0x3;
3912 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003913 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003914 ptr += ETH_ALEN;
3915 *ptr++ = strHostIfBASessionInfo->u8Ted;
3916 /* BA direction = recipent*/
3917 *ptr++ = 0;
3918 /* Delba Reason */
3919 *ptr++ = 32; /* Unspecific QOS reason */
3920
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003921 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3922 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003923 if (s32Error)
3924 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
3925
3926
Chaehyun Limd85f5322015-06-11 14:35:54 +09003927 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003928 strWID.enuWIDtype = WID_STR;
3929 strWID.s32ValueSize = 15;
3930 ptr = strWID.ps8WidVal;
3931 /* *ptr++ = 0x14; */
3932 *ptr++ = 15;
3933 *ptr++ = 7;
3934 *ptr++ = 0x3;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003935 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003936 ptr += ETH_ALEN;
3937 /* TID*/
3938 *ptr++ = strHostIfBASessionInfo->u8Ted;
3939
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003940 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3941 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003942
3943 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09003944 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003945
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003946 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003947
3948 return s32Error;
3949
3950}
3951
3952
3953/**
3954 * @brief Handle_DelAllRxBASessions
3955 * @details Delete all Rx BA sessions
3956 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
3957 * @return NONE
3958 * @author Abdelrahman Sobhy
3959 * @date Feb. 2013
3960 * @version 9.0
3961 */
Tony Cho54265472015-09-21 12:16:56 +09003962static s32 Handle_DelAllRxBASessions(tstrWILC_WFIDrv *drvHandler,
3963 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003964{
Leo Kime6e12662015-09-16 18:36:03 +09003965 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003966 tstrWID strWID;
3967 char *ptr = NULL;
3968 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3969
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003970 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003971 strHostIfBASessionInfo->au8Bssid[0],
3972 strHostIfBASessionInfo->au8Bssid[1],
3973 strHostIfBASessionInfo->au8Bssid[2],
3974 strHostIfBASessionInfo->u8Ted);
3975
Chaehyun Limd85f5322015-06-11 14:35:54 +09003976 strWID.u16WIDid = (u16)WID_DEL_ALL_RX_BA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003977 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09003978 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003979 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
3980 ptr = strWID.ps8WidVal;
3981 *ptr++ = 0x14;
3982 *ptr++ = 0x3;
3983 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003984 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003985 ptr += ETH_ALEN;
3986 *ptr++ = strHostIfBASessionInfo->u8Ted;
3987 /* BA direction = recipent*/
3988 *ptr++ = 0;
3989 /* Delba Reason */
3990 *ptr++ = 32; /* Unspecific QOS reason */
3991
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003992 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3993 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003994 if (s32Error)
3995 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
3996
3997
3998 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09003999 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004000
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004001 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004002
4003 return s32Error;
4004
4005}
4006
4007/**
4008 * @brief hostIFthread
4009 * @details Main thread to handle message queue requests
4010 * @param[in] void* pvArg
4011 * @return NONE
4012 * @author
4013 * @date
4014 * @version 1.0
4015 */
Arnd Bergmann1999bd52015-05-29 22:52:14 +02004016static int hostIFthread(void *pvArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004017{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004018 u32 u32Ret;
Tony Cho143eb952015-09-21 12:16:32 +09004019 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004020 tstrWILC_WFIDrv *pstrWFIDrv;
4021
Tony Cho143eb952015-09-21 12:16:32 +09004022 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004023
4024 while (1) {
Tony Cho143eb952015-09-21 12:16:32 +09004025 wilc_mq_recv(&gMsgQHostIF, &msg, sizeof(struct host_if_msg), &u32Ret);
4026 pstrWFIDrv = (tstrWILC_WFIDrv *)msg.drvHandler;
Tony Choa9f812a2015-09-21 12:16:33 +09004027 if (msg.id == HOST_IF_MSG_EXIT) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004028 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
4029 break;
4030 }
4031
4032
4033 /*Re-Queue HIF message*/
4034 if ((!g_wilc_initialized)) {
4035 PRINT_D(GENERIC_DBG, "--WAIT--");
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07004036 usleep_range(200 * 1000, 200 * 1000);
Tony Cho143eb952015-09-21 12:16:32 +09004037 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004038 continue;
4039 }
4040
Tony Choa9f812a2015-09-21 12:16:33 +09004041 if (msg.id == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004042 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
Tony Cho143eb952015-09-21 12:16:32 +09004043 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07004044 usleep_range(2 * 1000, 2 * 1000);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004045 continue;
4046 }
4047
Tony Choa9f812a2015-09-21 12:16:33 +09004048 switch (msg.id) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004049 case HOST_IF_MSG_Q_IDLE:
4050 Handle_wait_msg_q_empty();
4051 break;
4052
4053 case HOST_IF_MSG_SCAN:
Tony Cho4528bdb2015-09-30 18:44:20 +09004054 Handle_Scan(msg.drvHandler, &msg.body.scan_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004055 break;
4056
4057 case HOST_IF_MSG_CONNECT:
Tony Cho3f501972015-09-30 18:44:21 +09004058 Handle_Connect(msg.drvHandler, &msg.body.con_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004059 break;
4060
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004061 case HOST_IF_MSG_FLUSH_CONNECT:
Tony Cho143eb952015-09-21 12:16:32 +09004062 Handle_FlushConnect(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004063 break;
4064
4065 case HOST_IF_MSG_RCVD_NTWRK_INFO:
Tony Cho02d19462015-09-30 18:44:22 +09004066 Handle_RcvdNtwrkInfo(msg.drvHandler, &msg.body.net_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004067 break;
4068
4069 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
Tony Cho66add622015-09-30 18:44:23 +09004070 Handle_RcvdGnrlAsyncInfo(msg.drvHandler, &msg.body.async_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004071 break;
4072
4073 case HOST_IF_MSG_KEY:
Tony Cho18990bf2015-09-30 18:44:24 +09004074 Handle_Key(msg.drvHandler, &msg.body.key_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004075 break;
4076
4077 case HOST_IF_MSG_CFG_PARAMS:
4078
Tony Choa2340c32015-09-30 18:44:25 +09004079 Handle_CfgParam(msg.drvHandler, &msg.body.cfg_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004080 break;
4081
4082 case HOST_IF_MSG_SET_CHANNEL:
Tony Choffd6dbc2015-09-30 18:44:28 +09004083 Handle_SetChannel(msg.drvHandler, &msg.body.channel_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004084 break;
4085
4086 case HOST_IF_MSG_DISCONNECT:
Tony Cho143eb952015-09-21 12:16:32 +09004087 Handle_Disconnect(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004088 break;
4089
4090 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07004091 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004092 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
4093
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004094 /*Allow chip sleep, only if both interfaces are not connected*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004095 if (!linux_wlan_get_num_conn_ifcs())
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004096 chip_sleep_manually(INFINITE_SLEEP_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004097
Tony Cho143eb952015-09-21 12:16:32 +09004098 Handle_ScanDone(msg.drvHandler, SCAN_EVENT_DONE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004099
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004100 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
Tony Cho070d3652015-09-30 18:55:10 +09004101 Handle_RemainOnChan(msg.drvHandler, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004102
4103 break;
4104
4105 case HOST_IF_MSG_GET_RSSI:
Tony Cho143eb952015-09-21 12:16:32 +09004106 Handle_GetRssi(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004107 break;
4108
4109 case HOST_IF_MSG_GET_LINKSPEED:
Tony Cho143eb952015-09-21 12:16:32 +09004110 Handle_GetLinkspeed(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004111 break;
4112
4113 case HOST_IF_MSG_GET_STATISTICS:
Tony Cho410c2482015-09-21 12:16:35 +09004114 Handle_GetStatistics(msg.drvHandler, (tstrStatistics *)msg.body.pUserData);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004115 break;
4116
4117 case HOST_IF_MSG_GET_CHNL:
Tony Cho143eb952015-09-21 12:16:32 +09004118 Handle_GetChnl(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004119 break;
4120
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004121 case HOST_IF_MSG_ADD_BEACON:
Tony Choa98491e2015-09-30 18:44:31 +09004122 Handle_AddBeacon(msg.drvHandler, &msg.body.beacon_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004123 break;
4124
4125 case HOST_IF_MSG_DEL_BEACON:
Tony Cho80bf88362015-09-30 18:44:29 +09004126 Handle_DelBeacon(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004127 break;
4128
4129 case HOST_IF_MSG_ADD_STATION:
Tony Choca8f47f2015-09-30 18:44:32 +09004130 Handle_AddStation(msg.drvHandler, &msg.body.add_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004131 break;
4132
4133 case HOST_IF_MSG_DEL_STATION:
Tony Cho889c25b2015-09-30 18:44:33 +09004134 Handle_DelStation(msg.drvHandler, &msg.body.del_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004135 break;
4136
4137 case HOST_IF_MSG_EDIT_STATION:
Tony Cho4a930962015-09-30 18:44:34 +09004138 Handle_EditStation(msg.drvHandler, &msg.body.edit_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004139 break;
4140
4141 case HOST_IF_MSG_GET_INACTIVETIME:
Tony Cho66bac7f2015-09-30 18:44:37 +09004142 Handle_Get_InActiveTime(msg.drvHandler, &msg.body.mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004143 break;
4144
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004145 case HOST_IF_MSG_SCAN_TIMER_FIRED:
4146 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
4147
Tony Cho143eb952015-09-21 12:16:32 +09004148 Handle_ScanDone(msg.drvHandler, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004149 break;
4150
4151 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004152 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
Tony Cho143eb952015-09-21 12:16:32 +09004153 Handle_ConnectTimeout(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004154 break;
4155
4156 case HOST_IF_MSG_POWER_MGMT:
Tony Cho49e1f812015-09-30 18:44:36 +09004157 Handle_PowerManagement(msg.drvHandler, &msg.body.pwr_mgmt_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004158 break;
4159
4160 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
Tony Cho143eb952015-09-21 12:16:32 +09004161 Handle_SetWfiDrvHandler(msg.drvHandler,
Tony Cho5e4377e2015-09-30 18:44:38 +09004162 &msg.body.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004163 break;
4164
4165 case HOST_IF_MSG_SET_OPERATION_MODE:
Tony Cho00c46302015-09-30 18:55:06 +09004166 Handle_SetOperationMode(msg.drvHandler, &msg.body.mode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004167 break;
4168
4169 case HOST_IF_MSG_SET_IPADDRESS:
4170 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Tony Chofb2d65e2015-09-30 18:44:39 +09004171 Handle_set_IPAddress(msg.drvHandler, msg.body.ip_info.au8IPAddr, msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004172 break;
4173
4174 case HOST_IF_MSG_GET_IPADDRESS:
4175 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Tony Chofb2d65e2015-09-30 18:44:39 +09004176 Handle_get_IPAddress(msg.drvHandler, msg.body.ip_info.au8IPAddr, msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004177 break;
4178
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004179 case HOST_IF_MSG_SET_MAC_ADDRESS:
Tony Cho15326e22015-09-30 18:55:07 +09004180 Handle_SetMacAddress(msg.drvHandler, &msg.body.set_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004181 break;
4182
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004183 case HOST_IF_MSG_GET_MAC_ADDRESS:
Tony Choa5848692015-09-30 18:55:08 +09004184 Handle_GetMacAddress(msg.drvHandler, &msg.body.get_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004185 break;
4186
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004187 case HOST_IF_MSG_REMAIN_ON_CHAN:
4188 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
Tony Cho070d3652015-09-30 18:55:10 +09004189 Handle_RemainOnChan(msg.drvHandler, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004190 break;
4191
4192 case HOST_IF_MSG_REGISTER_FRAME:
4193 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
Tony Cho410c2482015-09-21 12:16:35 +09004194 Handle_RegisterFrame(msg.drvHandler, &msg.body.strHostIfRegisterFrame);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004195 break;
4196
4197 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
Tony Cho070d3652015-09-30 18:55:10 +09004198 Handle_ListenStateExpired(msg.drvHandler, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004199 break;
4200
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004201 case HOST_IF_MSG_SET_MULTICAST_FILTER:
4202 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
Tony Choa079cf4d2015-09-30 18:55:05 +09004203 Handle_SetMulticastFilter(msg.drvHandler, &msg.body.multicast_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004204 break;
4205
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004206 case HOST_IF_MSG_ADD_BA_SESSION:
Tony Choc833b472015-09-30 18:55:09 +09004207 Handle_AddBASession(msg.drvHandler, &msg.body.session_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004208 break;
4209
4210 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
Tony Choc833b472015-09-30 18:55:09 +09004211 Handle_DelAllRxBASessions(msg.drvHandler, &msg.body.session_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004212 break;
4213
4214 case HOST_IF_MSG_DEL_ALL_STA:
Tony Cho410c2482015-09-21 12:16:35 +09004215 Handle_DelAllSta(msg.drvHandler, &msg.body.strHostIFDelAllSta);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004216 break;
4217
4218 default:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004219 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004220 break;
4221 }
4222 }
4223
4224 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004225 up(&hSemHostIFthrdEnd);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02004226 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004227}
4228
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004229static void TimerCB_Scan(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004230{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004231 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09004232 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004233
4234 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09004235 memset(&msg, 0, sizeof(struct host_if_msg));
4236 msg.drvHandler = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09004237 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004238
4239 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004240 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004241}
4242
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004243static void TimerCB_Connect(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004244{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004245 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09004246 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004247
4248 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09004249 memset(&msg, 0, sizeof(struct host_if_msg));
4250 msg.drvHandler = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09004251 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004252
4253 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004254 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004255}
4256
4257
4258/**
4259 * @brief removes wpa/wpa2 keys
4260 * @details only in BSS STA mode if External Supplicant support is enabled.
4261 * removes all WPA/WPA2 station key entries from MAC hardware.
4262 * @param[in,out] handle to the wifi driver
4263 * @param[in] 6 bytes of Station Adress in the station entry table
4264 * @return Error code indicating success/failure
4265 * @note
4266 * @author zsalah
4267 * @date 8 March 2012
4268 * @version 1.0
4269 */
4270/* Check implementation in core adding 9 bytes to the input! */
Johnny Kim218dc402015-08-13 13:41:19 +09004271s32 host_int_remove_key(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8StaAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004272{
Leo Kime6e12662015-09-16 18:36:03 +09004273 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004274 tstrWID strWID;
4275 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4276
Chaehyun Limd85f5322015-06-11 14:35:54 +09004277 strWID.u16WIDid = (u16)WID_REMOVE_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004278 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09004279 strWID.ps8WidVal = (s8 *)pu8StaAddress;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004280 strWID.s32ValueSize = 6;
4281
4282 return s32Error;
4283
4284}
4285
4286/**
4287 * @brief removes WEP key
4288 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4289 * remove a WEP key entry from MAC HW.
4290 * The BSS Station automatically finds the index of the entry using its
4291 * BSS ID and removes that entry from the MAC hardware.
4292 * @param[in,out] handle to the wifi driver
4293 * @param[in] 6 bytes of Station Adress in the station entry table
4294 * @return Error code indicating success/failure
4295 * @note NO need for the STA add since it is not used for processing
4296 * @author zsalah
4297 * @date 8 March 2012
4298 * @version 1.0
4299 */
Johnny Kim218dc402015-08-13 13:41:19 +09004300s32 host_int_remove_wep_key(tstrWILC_WFIDrv *hWFIDrv, u8 u8keyIdx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004301{
Leo Kime6e12662015-09-16 18:36:03 +09004302 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004303 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004304 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004305
4306
Leo Kim24db7132015-09-16 18:36:01 +09004307 if (pstrWFIDrv == NULL) {
4308 s32Error = -EFAULT;
4309 PRINT_ER("Failed to send setup multicast config packet\n");
4310 return s32Error;
4311 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004312
4313 /* prepare the Remove Wep Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004314 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004315
4316
Tony Choa9f812a2015-09-21 12:16:33 +09004317 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004318 msg.body.key_info.enuKeyType = WEP;
4319 msg.body.key_info.u8KeyAction = REMOVEKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004320 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004321
4322
4323
Tony Cho18990bf2015-09-30 18:44:24 +09004324 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004325 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8keyIdx;
4326
4327 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004328 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004329 if (s32Error)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004330 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004331 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004332
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004333 return s32Error;
4334}
4335
4336/**
4337 * @brief sets WEP default key
4338 * @details Sets the index of the WEP encryption key in use,
4339 * in the key table
4340 * @param[in,out] handle to the wifi driver
4341 * @param[in] key index ( 0, 1, 2, 3)
4342 * @return Error code indicating success/failure
4343 * @note
4344 * @author zsalah
4345 * @date 8 March 2012
4346 * @version 1.0
4347 */
Johnny Kim218dc402015-08-13 13:41:19 +09004348s32 host_int_set_WEPDefaultKeyID(tstrWILC_WFIDrv *hWFIDrv, u8 u8Index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004349{
Leo Kime6e12662015-09-16 18:36:03 +09004350 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004351 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004352 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004353
4354
Leo Kim24db7132015-09-16 18:36:01 +09004355 if (pstrWFIDrv == NULL) {
4356 s32Error = -EFAULT;
4357 PRINT_ER("driver is null\n");
4358 return s32Error;
4359 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004360
4361 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004362 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004363
4364
Tony Choa9f812a2015-09-21 12:16:33 +09004365 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004366 msg.body.key_info.enuKeyType = WEP;
4367 msg.body.key_info.u8KeyAction = DEFAULTKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004368 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004369
4370
Tony Cho18990bf2015-09-30 18:44:24 +09004371 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004372 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
4373
4374 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004375 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004376 if (s32Error)
4377 PRINT_ER("Error in sending message queue : Default key index\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004378 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004379
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004380 return s32Error;
4381}
4382
4383/**
4384 * @brief sets WEP deafault key
4385 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4386 * sets WEP key entry into MAC hardware when it receives the
4387 * corresponding request from NDIS.
4388 * @param[in,out] handle to the wifi driver
4389 * @param[in] message containing WEP Key in the following format
4390 *|---------------------------------------|
4391 *|Key ID Value | Key Length | Key |
4392 *|-------------|------------|------------|
4393 | 1byte | 1byte | Key Length |
4394 ||---------------------------------------|
4395 |
4396 * @return Error code indicating success/failure
4397 * @note
4398 * @author zsalah
4399 * @date 8 March 2012
4400 * @version 1.0
4401 */
Johnny Kim218dc402015-08-13 13:41:19 +09004402s32 host_int_add_wep_key_bss_sta(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004403{
4404
Leo Kime6e12662015-09-16 18:36:03 +09004405 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004406 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004407 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004408
Leo Kim24db7132015-09-16 18:36:01 +09004409 if (pstrWFIDrv == NULL) {
4410 s32Error = -EFAULT;
4411 PRINT_ER("driver is null\n");
4412 return s32Error;
4413 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004414
4415 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004416 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004417
4418
Tony Choa9f812a2015-09-21 12:16:33 +09004419 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004420 msg.body.key_info.enuKeyType = WEP;
4421 msg.body.key_info.u8KeyAction = ADDKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004422 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004423
4424
Tony Cho18990bf2015-09-30 18:44:24 +09004425 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004426 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004427
Tony Cho18990bf2015-09-30 18:44:24 +09004428 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004429 pu8WepKey, u8WepKeylen);
4430
4431
Tony Cho18990bf2015-09-30 18:44:24 +09004432 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004433 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4434
Tony Cho18990bf2015-09-30 18:44:24 +09004435 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004436 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4437
4438 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004439 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004440 if (s32Error)
4441 PRINT_ER("Error in sending message queue :WEP Key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004442 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004443
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004444 return s32Error;
4445
4446}
4447
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004448/**
4449 *
4450 * @brief host_int_add_wep_key_bss_ap
4451 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4452 * sets WEP key entry into MAC hardware when it receives the
4453 *
4454 * corresponding request from NDIS.
4455 * @param[in,out] handle to the wifi driver
4456 *
4457 *
4458 * @return Error code indicating success/failure
4459 * @note
4460 * @author mdaftedar
4461 * @date 28 FEB 2013
4462 * @version 1.0
4463 */
Johnny Kim218dc402015-08-13 13:41:19 +09004464s32 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 +09004465{
4466
Leo Kime6e12662015-09-16 18:36:03 +09004467 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004468 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004469 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004470 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004471
Leo Kim24db7132015-09-16 18:36:01 +09004472 if (pstrWFIDrv == NULL) {
4473 s32Error = -EFAULT;
4474 PRINT_ER("driver is null\n");
4475 return s32Error;
4476 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004477
4478 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004479 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004480
4481 if (INFO) {
4482 for (i = 0; i < u8WepKeylen; i++)
4483 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4484 }
Tony Choa9f812a2015-09-21 12:16:33 +09004485 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004486 msg.body.key_info.enuKeyType = WEP;
4487 msg.body.key_info.u8KeyAction = ADDKEY_AP;
Tony Cho143eb952015-09-21 12:16:32 +09004488 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004489
4490
Tony Cho18990bf2015-09-30 18:44:24 +09004491 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004492 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004493
4494
Tony Cho18990bf2015-09-30 18:44:24 +09004495 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004496 pu8WepKey, (u8WepKeylen));
4497
4498
Tony Cho18990bf2015-09-30 18:44:24 +09004499 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004500 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4501
Tony Cho18990bf2015-09-30 18:44:24 +09004502 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004503 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4504
Tony Cho18990bf2015-09-30 18:44:24 +09004505 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004506 uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
4507
Tony Cho18990bf2015-09-30 18:44:24 +09004508 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004509 uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
4510 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004511 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004512
4513 if (s32Error)
4514 PRINT_ER("Error in sending message queue :WEP Key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004515 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004516
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004517 return s32Error;
4518
4519}
Glen Lee108b3432015-09-16 18:53:20 +09004520
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004521/**
4522 * @brief adds ptk Key
4523 * @details
4524 * @param[in,out] handle to the wifi driver
4525 * @param[in] message containing PTK Key in the following format
4526 *|-----------------------------------------------------------------------------|
4527 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4528 *|----------------|------------|--------------|----------------|---------------|
4529 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4530 ||-----------------------------------------------------------------------------|
4531 * @return Error code indicating success/failure
4532 * @note
4533 * @author zsalah
4534 * @date 8 March 2012
4535 * @version 1.0
4536 */
Johnny Kim218dc402015-08-13 13:41:19 +09004537s32 host_int_add_ptk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004538 const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004539{
Leo Kime6e12662015-09-16 18:36:03 +09004540 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004541 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004542 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004543 u8 u8KeyLen = u8PtkKeylen;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004544 u32 i;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004545
Leo Kim24db7132015-09-16 18:36:01 +09004546 if (pstrWFIDrv == NULL) {
4547 s32Error = -EFAULT;
4548 PRINT_ER("driver is null\n");
4549 return s32Error;
4550 }
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004551 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004552 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004553 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004554 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004555
4556 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004557 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004558
4559
Tony Choa9f812a2015-09-21 12:16:33 +09004560 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004561 msg.body.key_info.enuKeyType = WPAPtk;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004562 if (mode == AP_MODE) {
Tony Cho18990bf2015-09-30 18:44:24 +09004563 msg.body.key_info.u8KeyAction = ADDKEY_AP;
4564 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004565 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
4566 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004567 if (mode == STATION_MODE)
Tony Cho18990bf2015-09-30 18:44:24 +09004568 msg.body.key_info.u8KeyAction = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004569
4570
Tony Cho18990bf2015-09-30 18:44:24 +09004571 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004572 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8PtkKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004573
4574
Tony Cho18990bf2015-09-30 18:44:24 +09004575 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004576 pu8Ptk, u8PtkKeylen);
4577
4578 if (pu8RxMic != NULL) {
4579
Tony Cho18990bf2015-09-30 18:44:24 +09004580 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004581 pu8RxMic, RX_MIC_KEY_LEN);
4582 if (INFO) {
4583 for (i = 0; i < RX_MIC_KEY_LEN; i++)
4584 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
4585 }
4586 }
4587 if (pu8TxMic != NULL) {
4588
Tony Cho18990bf2015-09-30 18:44:24 +09004589 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004590 pu8TxMic, TX_MIC_KEY_LEN);
4591 if (INFO) {
4592 for (i = 0; i < TX_MIC_KEY_LEN; i++)
4593 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
4594 }
4595 }
4596
Tony Cho18990bf2015-09-30 18:44:24 +09004597 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004598 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4599
Tony Cho18990bf2015-09-30 18:44:24 +09004600 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004601 uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
Tony Cho18990bf2015-09-30 18:44:24 +09004602 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004603 uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
Tony Cho143eb952015-09-21 12:16:32 +09004604 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004605
4606 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004607 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004608
4609 if (s32Error)
4610 PRINT_ER("Error in sending message queue: PTK Key\n");
4611
4612 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004613 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004614 /* /////// */
4615
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004616 return s32Error;
4617}
4618
4619/**
4620 * @brief adds Rx GTk Key
4621 * @details
4622 * @param[in,out] handle to the wifi driver
4623 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
4624 * u8GtkKeylen :The total key length
4625 *
4626 * @return Error code indicating success/failure
4627 * @note
4628 * @author zsalah
4629 * @date 8 March 2012
4630 * @version 1.0
4631 */
Johnny Kim218dc402015-08-13 13:41:19 +09004632s32 host_int_add_rx_gtk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004633 u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004634 const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004635{
Leo Kime6e12662015-09-16 18:36:03 +09004636 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004637 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004638 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004639 u8 u8KeyLen = u8GtkKeylen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004640
Leo Kim24db7132015-09-16 18:36:01 +09004641 if (pstrWFIDrv == NULL) {
4642 s32Error = -EFAULT;
4643 PRINT_ER("driver is null\n");
4644 return s32Error;
4645 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004646 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004647 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004648
4649
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004650 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004651 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004652 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004653 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004654 if (KeyRSC != NULL) {
Tony Cho18990bf2015-09-30 18:44:24 +09004655 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004656 uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004657
Tony Cho18990bf2015-09-30 18:44:24 +09004658 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004659 KeyRSC, u32KeyRSClen);
4660 }
4661
4662
Tony Choa9f812a2015-09-21 12:16:33 +09004663 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004664 msg.body.key_info.enuKeyType = WPARxGtk;
Tony Cho143eb952015-09-21 12:16:32 +09004665 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004666
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004667 if (mode == AP_MODE) {
Tony Cho18990bf2015-09-30 18:44:24 +09004668 msg.body.key_info.u8KeyAction = ADDKEY_AP;
4669 msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004670 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004671 if (mode == STATION_MODE)
Tony Cho18990bf2015-09-30 18:44:24 +09004672 msg.body.key_info.u8KeyAction = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004673
4674
Tony Cho18990bf2015-09-30 18:44:24 +09004675 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004676 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8KeyLen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004677
Tony Cho18990bf2015-09-30 18:44:24 +09004678 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004679 pu8RxGtk, u8GtkKeylen);
4680
4681 if (pu8RxMic != NULL) {
4682
Tony Cho18990bf2015-09-30 18:44:24 +09004683 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004684 pu8RxMic, RX_MIC_KEY_LEN);
4685
4686 }
4687 if (pu8TxMic != NULL) {
4688
Tony Cho18990bf2015-09-30 18:44:24 +09004689 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004690 pu8TxMic, TX_MIC_KEY_LEN);
4691
4692 }
4693
Tony Cho18990bf2015-09-30 18:44:24 +09004694 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004695 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
Tony Cho18990bf2015-09-30 18:44:24 +09004696 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004697 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4698
Tony Cho18990bf2015-09-30 18:44:24 +09004699 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004700 uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
4701
4702
4703
4704 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004705 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004706 if (s32Error)
4707 PRINT_ER("Error in sending message queue: RX GTK\n");
4708 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004709 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004710 /* /////// */
4711
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004712 return s32Error;
4713}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004714
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004715/**
4716 * @brief host_int_set_pmkid_info
4717 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
4718 * support is enabled. This Function sets the PMKID in firmware
4719 * when host drivr receives the corresponding request from NDIS.
4720 * The firmware then includes theset PMKID in the appropriate
4721 * management frames
4722 * @param[in,out] handle to the wifi driver
4723 * @param[in] message containing PMKID Info in the following format
4724 *|-----------------------------------------------------------------|
4725 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
4726 *|-----------|------------|----------|-------|----------|----------|
4727 | 1 | 6 | 16 | ... | 6 | 16 |
4728 ||-----------------------------------------------------------------|
4729 * @return Error code indicating success/failure
4730 * @note
4731 * @author zsalah
4732 * @date 8 March 2012
4733 * @version 1.0
4734 */
Johnny Kim218dc402015-08-13 13:41:19 +09004735s32 host_int_set_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004736{
Leo Kime6e12662015-09-16 18:36:03 +09004737 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004738 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004739 struct host_if_msg msg;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004740 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004741
4742
Leo Kim24db7132015-09-16 18:36:01 +09004743 if (pstrWFIDrv == NULL) {
4744 s32Error = -EFAULT;
4745 PRINT_ER("driver is null\n");
4746 return s32Error;
4747 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004748
4749 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004750 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004751
Tony Choa9f812a2015-09-21 12:16:33 +09004752 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004753 msg.body.key_info.enuKeyType = PMKSA;
4754 msg.body.key_info.u8KeyAction = ADDKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004755 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004756
4757 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
4758
Tony Cho18990bf2015-09-30 18:44:24 +09004759 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004760 ETH_ALEN);
4761
Tony Cho18990bf2015-09-30 18:44:24 +09004762 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004763 PMKID_LEN);
4764 }
4765
4766 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004767 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004768 if (s32Error)
4769 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
4770
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004771 return s32Error;
4772}
4773
4774/**
4775 * @brief gets the cached the pmkid info
4776 * @details valid only in BSS STA mode if External Supplicant
4777 * support is enabled. This Function sets the PMKID in firmware
4778 * when host drivr receives the corresponding request from NDIS.
4779 * The firmware then includes theset PMKID in the appropriate
4780 * management frames
4781 * @param[in,out] handle to the wifi driver,
4782 * message containing PMKID Info in the following format
4783 *|-----------------------------------------------------------------|
4784 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
4785 *|-----------|------------|----------|-------|----------|----------|
4786 | 1 | 6 | 16 | ... | 6 | 16 |
4787 ||-----------------------------------------------------------------|
4788 * @param[in]
4789 * @return Error code indicating success/failure
4790 * @note
4791 * @author zsalah
4792 * @date 8 March 2012
4793 * @version 1.0
4794 */
Johnny Kim218dc402015-08-13 13:41:19 +09004795s32 host_int_get_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PmkidInfoArray,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004796 u32 u32PmkidInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004797{
Leo Kime6e12662015-09-16 18:36:03 +09004798 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004799 tstrWID strWID;
4800 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4801
Chaehyun Limd85f5322015-06-11 14:35:54 +09004802 strWID.u16WIDid = (u16)WID_PMKID_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004803 strWID.enuWIDtype = WID_STR;
4804 strWID.s32ValueSize = u32PmkidInfoLen;
4805 strWID.ps8WidVal = pu8PmkidInfoArray;
4806
4807 return s32Error;
4808}
4809
4810/**
4811 * @brief sets the pass phrase
4812 * @details AP/STA mode. This function gives the pass phrase used to
4813 * generate the Pre-Shared Key when WPA/WPA2 is enabled
4814 * The length of the field can vary from 8 to 64 bytes,
4815 * the lower layer should get the
4816 * @param[in,out] handle to the wifi driver,
4817 * @param[in] String containing PSK
4818 * @return Error code indicating success/failure
4819 * @note
4820 * @author zsalah
4821 * @date 8 March 2012
4822 * @version 1.0
4823 */
Johnny Kim218dc402015-08-13 13:41:19 +09004824s32 host_int_set_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PassPhrase,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004825 u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004826{
Leo Kime6e12662015-09-16 18:36:03 +09004827 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004828 tstrWID strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004829
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004830 /*validating psk length*/
4831 if ((u8Psklength > 7) && (u8Psklength < 65)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09004832 strWID.u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004833 strWID.enuWIDtype = WID_STR;
4834 strWID.ps8WidVal = pu8PassPhrase;
4835 strWID.s32ValueSize = u8Psklength;
4836 }
4837
4838 return s32Error;
4839}
4840/**
4841 * @brief host_int_get_MacAddress
4842 * @details gets mac address
4843 * @param[in,out] handle to the wifi driver,
4844 *
4845 * @return Error code indicating success/failure
4846 * @note
4847 * @author mdaftedar
4848 * @date 19 April 2012
4849 * @version 1.0
4850 */
Johnny Kim218dc402015-08-13 13:41:19 +09004851s32 host_int_get_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004852{
Leo Kime6e12662015-09-16 18:36:03 +09004853 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004854 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004855
4856
4857 /* prepare the Message */
Tony Cho143eb952015-09-21 12:16:32 +09004858 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004859
Tony Choa9f812a2015-09-21 12:16:33 +09004860 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
Tony Choa5848692015-09-30 18:55:08 +09004861 msg.body.get_mac_info.u8MacAddress = pu8MacAddress;
Tony Cho143eb952015-09-21 12:16:32 +09004862 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004863 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004864 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004865 if (s32Error) {
4866 PRINT_ER("Failed to send get mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +09004867 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004868 }
4869
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004870 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004871 return s32Error;
4872}
4873
4874/**
4875 * @brief host_int_set_MacAddress
4876 * @details sets mac address
4877 * @param[in,out] handle to the wifi driver,
4878 *
4879 * @return Error code indicating success/failure
4880 * @note
4881 * @author mabubakr
4882 * @date 16 July 2012
4883 * @version 1.0
4884 */
Johnny Kim218dc402015-08-13 13:41:19 +09004885s32 host_int_set_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004886{
Leo Kime6e12662015-09-16 18:36:03 +09004887 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004888 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004889
4890 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
4891
4892 /* prepare setting mac address message */
Tony Cho143eb952015-09-21 12:16:32 +09004893 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09004894 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
Tony Cho15326e22015-09-30 18:55:07 +09004895 memcpy(msg.body.set_mac_info.u8MacAddress, pu8MacAddress, ETH_ALEN);
Tony Cho143eb952015-09-21 12:16:32 +09004896 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004897
Tony Cho143eb952015-09-21 12:16:32 +09004898 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09004899 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004900 PRINT_ER("Failed to send message queue: Set mac address\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004901
4902 return s32Error;
4903
4904}
4905
4906/**
4907 * @brief host_int_get_RSNAConfigPSKPassPhrase
4908 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
4909 * generate the Pre-Shared Key when WPA/WPA2 is enabled
4910 * The length of the field can vary from 8 to 64 bytes,
4911 * the lower layer should get the
4912 * @param[in,out] handle to the wifi driver,
4913 * String containing PSK
4914 * @return Error code indicating success/failure
4915 * @note
4916 * @author zsalah
4917 * @date 8 March 2012
4918 * @version 1.0
4919 */
Johnny Kim218dc402015-08-13 13:41:19 +09004920s32 host_int_get_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004921 u8 *pu8PassPhrase, u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004922{
Leo Kime6e12662015-09-16 18:36:03 +09004923 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004924 tstrWID strWID;
4925 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4926
Chaehyun Limd85f5322015-06-11 14:35:54 +09004927 strWID.u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004928 strWID.enuWIDtype = WID_STR;
4929 strWID.s32ValueSize = u8Psklength;
4930 strWID.ps8WidVal = pu8PassPhrase;
4931
4932 return s32Error;
4933}
4934
4935/**
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004936 * @brief sets a start scan request
4937 * @details
4938 * @param[in,out] handle to the wifi driver,
4939 * @param[in] Scan Source one of the following values
4940 * DEFAULT_SCAN 0
4941 * USER_SCAN BIT0
4942 * OBSS_PERIODIC_SCAN BIT1
4943 * OBSS_ONETIME_SCAN BIT2
4944 * @return Error code indicating success/failure
4945 * @note
4946 * @author zsalah
4947 * @date 8 March 2012
4948 * @version 1.0
4949 */
Johnny Kim218dc402015-08-13 13:41:19 +09004950s32 host_int_set_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 scanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004951{
Leo Kime6e12662015-09-16 18:36:03 +09004952 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004953 tstrWID strWID;
4954 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4955
Chaehyun Limd85f5322015-06-11 14:35:54 +09004956 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004957 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09004958 strWID.ps8WidVal = (s8 *)&scanSource;
Dean Lee576917a2015-06-15 11:58:57 +09004959 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004960
4961 return s32Error;
4962}
4963
4964/**
4965 * @brief host_int_get_start_scan_req
4966 * @details gets a start scan request
4967 * @param[in,out] handle to the wifi driver,
4968 * @param[in] Scan Source one of the following values
4969 * DEFAULT_SCAN 0
4970 * USER_SCAN BIT0
4971 * OBSS_PERIODIC_SCAN BIT1
4972 * OBSS_ONETIME_SCAN BIT2
4973 * @return Error code indicating success/failure
4974 * @note
4975 * @author zsalah
4976 * @date 8 March 2012
4977 * @version 1.0
4978 */
4979
Johnny Kim218dc402015-08-13 13:41:19 +09004980s32 host_int_get_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ScanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004981{
Leo Kime6e12662015-09-16 18:36:03 +09004982 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004983 tstrWID strWID;
4984 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4985
Chaehyun Limd85f5322015-06-11 14:35:54 +09004986 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004987 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09004988 strWID.ps8WidVal = (s8 *)pu8ScanSource;
Dean Lee576917a2015-06-15 11:58:57 +09004989 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004990
4991 return s32Error;
4992}
4993
4994/**
4995 * @brief host_int_set_join_req
4996 * @details sets a join request
4997 * @param[in,out] handle to the wifi driver,
4998 * @param[in] Index of the bss descriptor
4999 * @return Error code indicating success/failure
5000 * @note
5001 * @author zsalah
5002 * @date 8 March 2012
5003 * @version 1.0
5004 */
Johnny Kim218dc402015-08-13 13:41:19 +09005005s32 host_int_set_join_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8bssid,
Arnd Bergmann057d1e92015-06-01 21:06:44 +02005006 const u8 *pu8ssid, size_t ssidLen,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005007 const u8 *pu8IEs, size_t IEsLen,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005008 tWILCpfConnectResult pfConnectResult, void *pvUserArg,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005009 u8 u8security, AUTHTYPE_T tenuAuth_type,
5010 u8 u8channel,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005011 void *pJoinParams)
5012{
Leo Kime6e12662015-09-16 18:36:03 +09005013 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005014 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005015 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005016 tenuScanConnTimer enuScanConnTimer;
5017
Leo Kim24db7132015-09-16 18:36:01 +09005018 if (pstrWFIDrv == NULL || pfConnectResult == NULL) {
5019 s32Error = -EFAULT;
5020 PRINT_ER("Driver is null\n");
5021 return s32Error;
5022 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005023
5024 if (hWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005025 PRINT_ER("Driver is null\n");
5026 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005027 }
5028
5029 if (pJoinParams == NULL) {
5030 PRINT_ER("Unable to Join - JoinParams is NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09005031 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005032 }
Leo Kim24db7132015-09-16 18:36:01 +09005033
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005034 /* prepare the Connect Message */
Tony Cho143eb952015-09-21 12:16:32 +09005035 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005036
Tony Choa9f812a2015-09-21 12:16:33 +09005037 msg.id = HOST_IF_MSG_CONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005038
Tony Cho3f501972015-09-30 18:44:21 +09005039 msg.body.con_info.u8security = u8security;
5040 msg.body.con_info.tenuAuth_type = tenuAuth_type;
5041 msg.body.con_info.u8channel = u8channel;
5042 msg.body.con_info.pfConnectResult = pfConnectResult;
5043 msg.body.con_info.pvUserArg = pvUserArg;
5044 msg.body.con_info.pJoinParams = pJoinParams;
Tony Cho143eb952015-09-21 12:16:32 +09005045 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005046
5047 if (pu8bssid != NULL) {
Tony Cho3f501972015-09-30 18:44:21 +09005048 msg.body.con_info.pu8bssid = kmalloc(6, GFP_KERNEL); /* will be deallocated by the receiving thread */
5049 memcpy(msg.body.con_info.pu8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005050 pu8bssid, 6);
5051 }
5052
5053 if (pu8ssid != NULL) {
Tony Cho3f501972015-09-30 18:44:21 +09005054 msg.body.con_info.ssidLen = ssidLen;
5055 msg.body.con_info.pu8ssid = kmalloc(ssidLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5056 memcpy(msg.body.con_info.pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005057
5058 pu8ssid, ssidLen);
5059 }
5060
5061 if (pu8IEs != NULL) {
Tony Cho3f501972015-09-30 18:44:21 +09005062 msg.body.con_info.IEsLen = IEsLen;
5063 msg.body.con_info.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5064 memcpy(msg.body.con_info.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005065 pu8IEs, IEsLen);
5066 }
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05305067 if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005068 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05305069 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005070 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate);
5071
5072 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005073 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005074 if (s32Error) {
5075 PRINT_ER("Failed to send message queue: Set join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09005076 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005077 }
5078
5079 enuScanConnTimer = CONNECT_TIMER;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005080 pstrWFIDrv->hConnectTimer.data = (unsigned long)hWFIDrv;
5081 mod_timer(&pstrWFIDrv->hConnectTimer,
5082 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005083
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005084 return s32Error;
5085}
5086
5087/**
5088 * @brief Flush a join request parameters to FW, but actual connection
5089 * @details The function is called in situation where WILC is connected to AP and
5090 * required to switch to hybrid FW for P2P connection
5091 * @param[in] handle to the wifi driver,
5092 * @return Error code indicating success/failure
5093 * @note
5094 * @author Amr Abdel-Moghny
5095 * @date 19 DEC 2013
5096 * @version 8.0
5097 */
5098
Johnny Kim218dc402015-08-13 13:41:19 +09005099s32 host_int_flush_join_req(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005100{
Leo Kime6e12662015-09-16 18:36:03 +09005101 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005102 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005103
5104 if (!gu8FlushedJoinReq) {
Leo Kime6e12662015-09-16 18:36:03 +09005105 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005106 return s32Error;
5107 }
5108
5109
Leo Kim24db7132015-09-16 18:36:01 +09005110 if (hWFIDrv == NULL) {
5111 s32Error = -EFAULT;
5112 PRINT_ER("Driver is null\n");
5113 return s32Error;
5114 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005115
Tony Choa9f812a2015-09-21 12:16:33 +09005116 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
Tony Cho143eb952015-09-21 12:16:32 +09005117 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005118
5119 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005120 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005121 if (s32Error) {
5122 PRINT_ER("Failed to send message queue: Flush join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09005123 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005124 }
5125
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005126 return s32Error;
5127}
5128
5129/**
5130 * @brief host_int_disconnect
5131 * @details disconnects from the currently associated network
5132 * @param[in,out] handle to the wifi driver,
5133 * @param[in] Reason Code of the Disconnection
5134 * @return Error code indicating success/failure
5135 * @note
5136 * @author zsalah
5137 * @date 8 March 2012
5138 * @version 1.0
5139 */
Johnny Kim218dc402015-08-13 13:41:19 +09005140s32 host_int_disconnect(tstrWILC_WFIDrv *hWFIDrv, u16 u16ReasonCode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005141{
Leo Kime6e12662015-09-16 18:36:03 +09005142 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005143 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005144 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5145
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005146 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005147 PRINT_ER("Driver is null\n");
5148 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005149 }
5150
5151 /* prepare the Disconnect Message */
Tony Cho143eb952015-09-21 12:16:32 +09005152 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005153
Tony Choa9f812a2015-09-21 12:16:33 +09005154 msg.id = HOST_IF_MSG_DISCONNECT;
Tony Cho143eb952015-09-21 12:16:32 +09005155 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005156
5157 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005158 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005159 if (s32Error)
5160 PRINT_ER("Failed to send message queue: disconnect\n");
5161 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005162 down(&(pstrWFIDrv->hSemTestDisconnectBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005163 /* /////// */
5164
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005165 return s32Error;
5166}
5167
5168/**
5169 * @brief host_int_disconnect_station
5170 * @details disconnects a sta
5171 * @param[in,out] handle to the wifi driver,
5172 * @param[in] Association Id of the station to be disconnected
5173 * @return Error code indicating success/failure
5174 * @note
5175 * @author zsalah
5176 * @date 8 March 2012
5177 * @version 1.0
5178 */
Johnny Kim218dc402015-08-13 13:41:19 +09005179s32 host_int_disconnect_station(tstrWILC_WFIDrv *hWFIDrv, u8 assoc_id)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005180{
Leo Kime6e12662015-09-16 18:36:03 +09005181 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005182 tstrWID strWID;
5183 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5184
Chaehyun Limd85f5322015-06-11 14:35:54 +09005185 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005186 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005187 strWID.ps8WidVal = (s8 *)&assoc_id;
Dean Lee576917a2015-06-15 11:58:57 +09005188 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005189
5190 return s32Error;
5191}
5192
5193/**
5194 * @brief host_int_get_assoc_req_info
5195 * @details gets a Association request info
5196 * @param[in,out] handle to the wifi driver,
5197 * Message containg assoc. req info in the following format
5198 * ------------------------------------------------------------------------
5199 | Management Frame Format |
5200 ||-------------------------------------------------------------------|
5201 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5202 ||-------------|--------|--|--|-----|----------------|----------|----|
5203 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5204 ||-------------------------------------------------------------------|
5205 | |
5206 | Association Request Frame - Frame Body |
5207 ||-------------------------------------------------------------------|
5208 | Capability Information | Listen Interval | SSID | Supported Rates |
5209 ||------------------------|-----------------|------|-----------------|
5210 | 2 | 2 | 2-34 | 3-10 |
5211 | ---------------------------------------------------------------------
5212 * @return Error code indicating success/failure
5213 * @note
5214 * @author zsalah
5215 * @date 8 March 2012
5216 * @version 1.0
5217 */
5218
Johnny Kim218dc402015-08-13 13:41:19 +09005219s32 host_int_get_assoc_req_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocReqInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005220 u32 u32AssocReqInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005221{
Leo Kime6e12662015-09-16 18:36:03 +09005222 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005223 tstrWID strWID;
5224 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5225
Chaehyun Limd85f5322015-06-11 14:35:54 +09005226 strWID.u16WIDid = (u16)WID_ASSOC_REQ_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005227 strWID.enuWIDtype = WID_STR;
5228 strWID.ps8WidVal = pu8AssocReqInfo;
5229 strWID.s32ValueSize = u32AssocReqInfoLen;
5230
5231
5232 return s32Error;
5233}
5234
5235/**
5236 * @brief gets a Association Response info
5237 * @details
5238 * @param[in,out] handle to the wifi driver,
5239 * Message containg assoc. resp info
5240 * @return Error code indicating success/failure
5241 * @note
5242 * @author zsalah
5243 * @date 8 March 2012
5244 * @version 1.0
5245 */
Johnny Kim218dc402015-08-13 13:41:19 +09005246s32 host_int_get_assoc_res_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocRespInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005247 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005248{
Leo Kime6e12662015-09-16 18:36:03 +09005249 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005250 tstrWID strWID;
5251 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5252
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005253 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005254 PRINT_ER("Driver is null\n");
5255 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005256 }
5257
Chaehyun Limd85f5322015-06-11 14:35:54 +09005258 strWID.u16WIDid = (u16)WID_ASSOC_RES_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005259 strWID.enuWIDtype = WID_STR;
5260 strWID.ps8WidVal = pu8AssocRespInfo;
5261 strWID.s32ValueSize = u32MaxAssocRespInfoLen;
5262
5263
5264 /* Sending Configuration packet */
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09005265 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
5266 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005267 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005268 *pu32RcvdAssocRespInfoLen = 0;
Leo Kim24db7132015-09-16 18:36:01 +09005269 PRINT_ER("Failed to send association response config packet\n");
5270 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005271 } else {
5272 *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize;
5273 }
5274
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005275 return s32Error;
5276}
5277
5278/**
5279 * @brief gets a Association Response info
5280 * @details Valid only in STA mode. This function gives the RSSI
5281 * values observed in all the channels at the time of scanning.
5282 * The length of the field is 1 greater that the total number of
5283 * channels supported. Byte 0 contains the number of channels while
5284 * each of Byte N contains the observed RSSI value for the channel index N.
5285 * @param[in,out] handle to the wifi driver,
5286 * array of scanned channels' RSSI
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_get_rx_power_level(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8RxPowerLevel,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005294 u32 u32RxPowerLevelLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005295{
Leo Kime6e12662015-09-16 18:36:03 +09005296 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005297 tstrWID strWID;
5298 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5299
Chaehyun Limd85f5322015-06-11 14:35:54 +09005300 strWID.u16WIDid = (u16)WID_RX_POWER_LEVEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005301 strWID.enuWIDtype = WID_STR;
5302 strWID.ps8WidVal = pu8RxPowerLevel;
5303 strWID.s32ValueSize = u32RxPowerLevelLen;
5304
5305
5306 return s32Error;
5307}
5308
5309/**
5310 * @brief sets a channel
5311 * @details
5312 * @param[in,out] handle to the wifi driver,
5313 * @param[in] Index of the channel to be set
5314 *|-------------------------------------------------------------------|
5315 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5316 | Input: 1 2 14 |
5317 ||-------------------------------------------------------------------|
5318 * @return Error code indicating success/failure
5319 * @note
5320 * @author zsalah
5321 * @date 8 March 2012
5322 * @version 1.0
5323 */
Johnny Kim218dc402015-08-13 13:41:19 +09005324s32 host_int_set_mac_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 u8ChNum)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005325{
Leo Kime6e12662015-09-16 18:36:03 +09005326 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005327 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005328 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005329
Leo Kim24db7132015-09-16 18:36:01 +09005330 if (pstrWFIDrv == NULL) {
5331 PRINT_ER("driver is null\n");
5332 return -EFAULT;
5333 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005334
5335 /* prepare the set channel message */
Tony Cho143eb952015-09-21 12:16:32 +09005336 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005337 msg.id = HOST_IF_MSG_SET_CHANNEL;
Tony Choffd6dbc2015-09-30 18:44:28 +09005338 msg.body.channel_info.u8SetChan = u8ChNum;
Tony Cho143eb952015-09-21 12:16:32 +09005339 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005340
Tony Cho143eb952015-09-21 12:16:32 +09005341 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005342 if (s32Error) {
5343 PRINT_ER("wilc mq send fail\n");
5344 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005345 }
5346
5347 return s32Error;
5348}
5349
5350
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005351s32 host_int_wait_msg_queue_idle(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005352{
Leo Kime6e12662015-09-16 18:36:03 +09005353 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005354
Tony Cho143eb952015-09-21 12:16:32 +09005355 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005356
5357 /* prepare the set driver handler message */
5358
Tony Cho143eb952015-09-21 12:16:32 +09005359 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005360 msg.id = HOST_IF_MSG_Q_IDLE;
Tony Cho143eb952015-09-21 12:16:32 +09005361 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005362 if (s32Error) {
5363 PRINT_ER("wilc mq send fail\n");
5364 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005365 }
5366
5367 /* wait untill MSG Q is empty */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005368 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005369
5370 return s32Error;
5371
5372}
5373
Johnny Kim218dc402015-08-13 13:41:19 +09005374s32 host_int_set_wfi_drv_handler(tstrWILC_WFIDrv *u32address)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005375{
Leo Kime6e12662015-09-16 18:36:03 +09005376 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005377
Tony Cho143eb952015-09-21 12:16:32 +09005378 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005379
5380
5381 /* prepare the set driver handler message */
5382
Tony Cho143eb952015-09-21 12:16:32 +09005383 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005384 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
Tony Cho5e4377e2015-09-30 18:44:38 +09005385 msg.body.drv.u32Address = get_id_from_handler(u32address);
Tony Cho143eb952015-09-21 12:16:32 +09005386 msg.drvHandler = u32address;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005387
Tony Cho143eb952015-09-21 12:16:32 +09005388 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005389 if (s32Error) {
5390 PRINT_ER("wilc mq send fail\n");
5391 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005392 }
5393
5394 return s32Error;
5395}
5396
5397
5398
Johnny Kim218dc402015-08-13 13:41:19 +09005399s32 host_int_set_operation_mode(tstrWILC_WFIDrv *hWFIDrv, u32 u32mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005400{
Leo Kime6e12662015-09-16 18:36:03 +09005401 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005402
Tony Cho143eb952015-09-21 12:16:32 +09005403 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005404
5405
5406 /* prepare the set driver handler message */
5407
Tony Cho143eb952015-09-21 12:16:32 +09005408 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005409 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
Tony Cho00c46302015-09-30 18:55:06 +09005410 msg.body.mode.u32Mode = u32mode;
Tony Cho143eb952015-09-21 12:16:32 +09005411 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005412
Tony Cho143eb952015-09-21 12:16:32 +09005413 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005414 if (s32Error) {
5415 PRINT_ER("wilc mq send fail\n");
5416 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005417 }
5418
5419 return s32Error;
5420}
5421
5422/**
5423 * @brief gets the current channel index
5424 * @details
5425 * @param[in,out] handle to the wifi driver,
5426 * current channel index
5427 *|-----------------------------------------------------------------------|
5428 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5429 | Input: 1 2 14 |
5430 ||-----------------------------------------------------------------------|
5431 * @return Error code indicating success/failure
5432 * @note
5433 * @author zsalah
5434 * @date 8 March 2012
5435 * @version 1.0
5436 */
Johnny Kim218dc402015-08-13 13:41:19 +09005437s32 host_int_get_host_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ChNo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005438{
Leo Kime6e12662015-09-16 18:36:03 +09005439 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005440 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005441 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005442
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005443 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005444 PRINT_ER("driver is null\n");
5445 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005446 }
5447
5448 /* prepare the Get Channel Message */
Tony Cho143eb952015-09-21 12:16:32 +09005449 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005450
Tony Choa9f812a2015-09-21 12:16:33 +09005451 msg.id = HOST_IF_MSG_GET_CHNL;
Tony Cho143eb952015-09-21 12:16:32 +09005452 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005453
5454 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005455 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005456 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09005457 PRINT_ER("wilc mq send fail\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005458 down(&(pstrWFIDrv->hSemGetCHNL));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005459 /* gu8Chnl = 11; */
5460
5461 *pu8ChNo = gu8Chnl;
5462
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005463 return s32Error;
5464
5465
5466}
5467
5468
5469/**
5470 * @brief host_int_test_set_int_wid
5471 * @details Test function for setting wids
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005472 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005473 * @return Error code indicating success/failure
5474 * @note
5475 * @author zsalah
5476 * @date 8 March 2012
5477 * @version 1.0
5478 */
Johnny Kim218dc402015-08-13 13:41:19 +09005479s32 host_int_test_set_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 u32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005480{
Leo Kime6e12662015-09-16 18:36:03 +09005481 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005482 tstrWID strWID;
5483 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5484
5485
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005486 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005487 PRINT_ER("driver is null\n");
5488 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005489 }
5490
5491 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +09005492 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005493 strWID.enuWIDtype = WID_INT;
Dean Lee576917a2015-06-15 11:58:57 +09005494 strWID.ps8WidVal = (char *)&u32TestMemAddr;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005495 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005496
5497 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09005498 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
5499 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005500 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09005501 PRINT_ER("Failed to set wid value\n");
5502 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005503 } else {
5504 PRINT_D(HOSTINF_DBG, "Successfully set wid value\n");
5505
5506 }
5507
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005508 return s32Error;
5509}
5510
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005511/**
5512 * @brief host_int_get_inactive_time
5513 * @details
5514 * @param[in,out] handle to the wifi driver,
5515 * current sta macaddress, inactive_time
5516 * @return
5517 * @note
5518 * @author
5519 * @date
5520 * @version 1.0
5521 */
Johnny Kim218dc402015-08-13 13:41:19 +09005522s32 host_int_get_inactive_time(tstrWILC_WFIDrv *hWFIDrv, const u8 *mac, u32 *pu32InactiveTime)
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 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005526 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005527
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005528 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005529 PRINT_ER("driver is null\n");
5530 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005531 }
5532
Tony Cho143eb952015-09-21 12:16:32 +09005533 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005534
5535
Tony Cho66bac7f2015-09-30 18:44:37 +09005536 memcpy(msg.body.mac_info.mac,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005537 mac, ETH_ALEN);
5538
Tony Choa9f812a2015-09-21 12:16:33 +09005539 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
Tony Cho143eb952015-09-21 12:16:32 +09005540 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005541
5542 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005543 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005544 if (s32Error)
5545 PRINT_ER("Failed to send get host channel param's message queue ");
5546
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005547 down(&(pstrWFIDrv->hSemInactiveTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005548
5549 *pu32InactiveTime = gu32InactiveTime;
5550
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005551 return s32Error;
5552}
Glen Lee108b3432015-09-16 18:53:20 +09005553
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005554/**
5555 * @brief host_int_test_get_int_wid
5556 * @details Test function for getting wids
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005557 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005558 * @return Error code indicating success/failure
5559 * @note
5560 * @author zsalah
5561 * @date 8 March 2012
5562 * @version 1.0
5563 */
Johnny Kim218dc402015-08-13 13:41:19 +09005564s32 host_int_test_get_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 *pu32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005565{
5566
Leo Kime6e12662015-09-16 18:36:03 +09005567 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005568 tstrWID strWID;
5569 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5570
5571
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005572 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005573 PRINT_ER("driver is null\n");
5574 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005575 }
5576
Chaehyun Limd85f5322015-06-11 14:35:54 +09005577 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005578 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005579 strWID.ps8WidVal = (s8 *)pu32TestMemAddr;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005580 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005581
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09005582 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
5583 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005584 /*get the value by searching the local copy*/
5585 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09005586 PRINT_ER("Failed to get wid value\n");
5587 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005588 } else {
5589 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
5590
5591 }
5592
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005593 return s32Error;
5594}
5595
5596
5597/**
5598 * @brief host_int_get_rssi
5599 * @details gets the currently maintained RSSI value for the station.
5600 * The received signal strength value in dB.
5601 * The range of valid values is -128 to 0.
5602 * @param[in,out] handle to the wifi driver,
5603 * rssi value in dB
5604 * @return Error code indicating success/failure
5605 * @note
5606 * @author zsalah
5607 * @date 8 March 2012
5608 * @version 1.0
5609 */
Johnny Kim218dc402015-08-13 13:41:19 +09005610s32 host_int_get_rssi(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005611{
Leo Kime6e12662015-09-16 18:36:03 +09005612 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005613 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005614 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5615
5616
5617 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09005618 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005619
Tony Choa9f812a2015-09-21 12:16:33 +09005620 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Cho143eb952015-09-21 12:16:32 +09005621 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005622
5623 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005624 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005625 if (s32Error) {
5626 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005627 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005628 }
5629
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005630 down(&(pstrWFIDrv->hSemGetRSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005631
5632
5633 if (ps8Rssi == NULL) {
5634 PRINT_ER("RSS pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09005635 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005636 }
5637
5638
5639 *ps8Rssi = gs8Rssi;
5640
5641
5642 return s32Error;
5643}
5644
Johnny Kim218dc402015-08-13 13:41:19 +09005645s32 host_int_get_link_speed(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8lnkspd)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005646{
Tony Cho143eb952015-09-21 12:16:32 +09005647 struct host_if_msg msg;
Leo Kime6e12662015-09-16 18:36:03 +09005648 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005649
5650 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5651
5652
5653
5654 /* prepare the Get LINKSPEED Message */
Tony Cho143eb952015-09-21 12:16:32 +09005655 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005656
Tony Choa9f812a2015-09-21 12:16:33 +09005657 msg.id = HOST_IF_MSG_GET_LINKSPEED;
Tony Cho143eb952015-09-21 12:16:32 +09005658 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005659
5660 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005661 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005662 if (s32Error) {
5663 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005664 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005665 }
5666
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005667 down(&(pstrWFIDrv->hSemGetLINKSPEED));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005668
5669
5670 if (ps8lnkspd == NULL) {
5671 PRINT_ER("LINKSPEED pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09005672 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005673 }
5674
5675
5676 *ps8lnkspd = gs8lnkspd;
5677
5678
5679 return s32Error;
5680}
5681
Johnny Kim218dc402015-08-13 13:41:19 +09005682s32 host_int_get_statistics(tstrWILC_WFIDrv *hWFIDrv, tstrStatistics *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005683{
Leo Kime6e12662015-09-16 18:36:03 +09005684 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005685 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005686
5687
5688 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09005689 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005690
Tony Choa9f812a2015-09-21 12:16:33 +09005691 msg.id = HOST_IF_MSG_GET_STATISTICS;
Tony Cho410c2482015-09-21 12:16:35 +09005692 msg.body.pUserData = (char *)pstrStatistics;
Tony Cho143eb952015-09-21 12:16:32 +09005693 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005694 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005695 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005696 if (s32Error) {
5697 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005698 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005699 }
5700
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005701 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005702 return s32Error;
5703}
5704
5705
5706/**
5707 * @brief host_int_scan
5708 * @details scans a set of channels
5709 * @param[in,out] handle to the wifi driver,
5710 * @param[in] Scan source
5711 * Scan Type PASSIVE_SCAN = 0,
5712 * ACTIVE_SCAN = 1
5713 * Channels Array
5714 * Channels Array length
5715 * Scan Callback function
5716 * @return Error code indicating success/failure
5717 * @note
5718 * @author zsalah
5719 * @date 8 March 2012
5720 * @version 1.0
5721 */
Johnny Kim218dc402015-08-13 13:41:19 +09005722s32 host_int_scan(tstrWILC_WFIDrv *hWFIDrv, u8 u8ScanSource,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005723 u8 u8ScanType, u8 *pu8ChnlFreqList,
5724 u8 u8ChnlListLen, const u8 *pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005725 size_t IEsLen, tWILCpfScanResult ScanResult,
5726 void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork)
5727{
Leo Kime6e12662015-09-16 18:36:03 +09005728 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005729 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005730 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005731 tenuScanConnTimer enuScanConnTimer;
5732
Leo Kim24db7132015-09-16 18:36:01 +09005733 if (pstrWFIDrv == NULL || ScanResult == NULL) {
5734 PRINT_ER("pstrWFIDrv or ScanResult = NULL\n");
5735 return -EFAULT;
5736 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005737
5738 /* prepare the Scan Message */
Tony Cho143eb952015-09-21 12:16:32 +09005739 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005740
Tony Choa9f812a2015-09-21 12:16:33 +09005741 msg.id = HOST_IF_MSG_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005742
5743 if (pstrHiddenNetwork != NULL) {
Tony Cho4528bdb2015-09-30 18:44:20 +09005744 msg.body.scan_info.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
5745 msg.body.scan_info.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005746
5747 } else
5748 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
5749
Tony Cho143eb952015-09-21 12:16:32 +09005750 msg.drvHandler = hWFIDrv;
Tony Cho4528bdb2015-09-30 18:44:20 +09005751 msg.body.scan_info.u8ScanSource = u8ScanSource;
5752 msg.body.scan_info.u8ScanType = u8ScanType;
5753 msg.body.scan_info.pfScanResult = ScanResult;
5754 msg.body.scan_info.pvUserArg = pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005755
Tony Cho4528bdb2015-09-30 18:44:20 +09005756 msg.body.scan_info.u8ChnlListLen = u8ChnlListLen;
5757 msg.body.scan_info.pu8ChnlFreqList = kmalloc(u8ChnlListLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5758 memcpy(msg.body.scan_info.pu8ChnlFreqList,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005759 pu8ChnlFreqList, u8ChnlListLen);
5760
Tony Cho4528bdb2015-09-30 18:44:20 +09005761 msg.body.scan_info.IEsLen = IEsLen;
5762 msg.body.scan_info.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5763 memcpy(msg.body.scan_info.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005764 pu8IEs, IEsLen);
5765
5766 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005767 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005768 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09005769 PRINT_ER("Error in sending message queue\n");
5770 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005771 }
5772
5773 enuScanConnTimer = SCAN_TIMER;
5774 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005775 pstrWFIDrv->hScanTimer.data = (unsigned long)hWFIDrv;
5776 mod_timer(&pstrWFIDrv->hScanTimer,
5777 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005778
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005779 return s32Error;
5780
5781}
5782/**
5783 * @brief hif_set_cfg
5784 * @details sets configuration wids values
5785 * @param[in,out] handle to the wifi driver,
5786 * @param[in] WID, WID value
5787 * @return Error code indicating success/failure
5788 * @note
5789 * @author zsalah
5790 * @date 8 March 2012
5791 * @version 1.0
5792 */
Johnny Kim218dc402015-08-13 13:41:19 +09005793s32 hif_set_cfg(tstrWILC_WFIDrv *hWFIDrv, tstrCfgParamVal *pstrCfgParamVal)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005794{
5795
Leo Kime6e12662015-09-16 18:36:03 +09005796 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005797 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5798
Tony Cho143eb952015-09-21 12:16:32 +09005799 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005800
5801
Leo Kim24db7132015-09-16 18:36:01 +09005802 if (pstrWFIDrv == NULL) {
5803 PRINT_ER("pstrWFIDrv NULL\n");
5804 return -EFAULT;
5805 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005806 /* prepare the WiphyParams Message */
Tony Cho143eb952015-09-21 12:16:32 +09005807 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005808 msg.id = HOST_IF_MSG_CFG_PARAMS;
Tony Choa2340c32015-09-30 18:44:25 +09005809 msg.body.cfg_info.pstrCfgParamVal = *pstrCfgParamVal;
Tony Cho143eb952015-09-21 12:16:32 +09005810 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005811
Tony Cho143eb952015-09-21 12:16:32 +09005812 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005813
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005814 return s32Error;
5815
5816}
5817
5818
5819/**
5820 * @brief hif_get_cfg
5821 * @details gets configuration wids values
5822 * @param[in,out] handle to the wifi driver,
5823 * WID value
5824 * @param[in] WID,
5825 * @return Error code indicating success/failure
5826 * @note
5827 * @author zsalah
5828 *
5829 * @date 8 March 2012
5830 * @version 1.0
5831 */
Johnny Kim218dc402015-08-13 13:41:19 +09005832s32 hif_get_cfg(tstrWILC_WFIDrv *hWFIDrv, u16 u16WID, u16 *pu16WID_Value)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005833{
Leo Kime6e12662015-09-16 18:36:03 +09005834 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005835 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5836
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005837 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005838
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005839 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005840 PRINT_ER("pstrWFIDrv NULL\n");
5841 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005842 }
5843 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
5844 switch (u16WID) {
5845
5846 case WID_BSS_TYPE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005847 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005848 break;
5849
5850 case WID_AUTH_TYPE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005851 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005852 break;
5853
5854 case WID_AUTH_TIMEOUT:
5855 *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout;
5856 break;
5857
5858 case WID_POWER_MANAGEMENT:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005859 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005860 break;
5861
5862 case WID_SHORT_RETRY_LIMIT:
5863 *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit;
5864 break;
5865
5866 case WID_LONG_RETRY_LIMIT:
5867 *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit;
5868 break;
5869
5870 case WID_FRAG_THRESHOLD:
5871 *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold;
5872 break;
5873
5874 case WID_RTS_THRESHOLD:
5875 *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold;
5876 break;
5877
5878 case WID_PREAMBLE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005879 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005880 break;
5881
5882 case WID_SHORT_SLOT_ALLOWED:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005883 *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005884 break;
5885
5886 case WID_11N_TXOP_PROT_DISABLE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005887 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005888 break;
5889
5890 case WID_BEACON_INTERVAL:
5891 *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval;
5892 break;
5893
5894 case WID_DTIM_PERIOD:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005895 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005896 break;
5897
5898 case WID_SITE_SURVEY:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005899 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005900 break;
5901
5902 case WID_SITE_SURVEY_SCAN_TIME:
5903 *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time;
5904 break;
5905
5906 case WID_ACTIVE_SCAN_TIME:
5907 *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time;
5908 break;
5909
5910 case WID_PASSIVE_SCAN_TIME:
5911 *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time;
5912 break;
5913
5914 case WID_CURRENT_TX_RATE:
5915 *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate;
5916 break;
5917
5918 default:
5919 break;
5920 }
5921
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005922 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005923
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005924 return s32Error;
5925
5926}
5927
5928/*****************************************************************************/
5929/* Notification Functions */
5930/*****************************************************************************/
5931/**
5932 * @brief notifies host with join and leave requests
5933 * @details This function prepares an Information frame having the
5934 * information about a joining/leaving station.
5935 * @param[in,out] handle to the wifi driver,
5936 * @param[in] 6 byte Sta Adress
5937 * Join or leave flag:
5938 * Join = 1,
5939 * Leave =0
5940 * @return Error code indicating success/failure
5941 * @note
5942 * @author zsalah
5943 * @date 8 March 2012
5944 * @version 1.0
5945 */
5946void host_int_send_join_leave_info_to_host
Dean Lee72ed4dc2015-06-12 14:11:44 +09005947 (u16 assocId, u8 *stationAddr, bool joining)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005948{
5949}
5950/**
5951 * @brief notifies host with stations found in scan
5952 * @details sends the beacon/probe response from scan
5953 * @param[in,out] handle to the wifi driver,
5954 * @param[in] Sta Address,
5955 * Frame length,
5956 * Rssi of the Station found
5957 * @return Error code indicating success/failure
5958 * @note
5959 * @author zsalah
5960 * @date 8 March 2012
5961 * @version 1.0
5962 */
5963
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07005964static void GetPeriodicRSSI(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005965{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07005966 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02005967
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005968 if (pstrWFIDrv == NULL) {
5969 PRINT_ER("Driver handler is NULL\n");
5970 return;
5971 }
5972
5973 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
Leo Kime6e12662015-09-16 18:36:03 +09005974 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005975 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005976
5977 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09005978 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005979
Tony Choa9f812a2015-09-21 12:16:33 +09005980 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Cho143eb952015-09-21 12:16:32 +09005981 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005982
5983 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005984 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005985 if (s32Error) {
5986 PRINT_ER("Failed to send get host channel param's message queue ");
5987 return;
5988 }
5989 }
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005990 g_hPeriodicRSSI.data = (unsigned long)pstrWFIDrv;
5991 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005992}
5993
5994
5995void host_int_send_network_info_to_host
Chaehyun Limca356ad2015-06-11 14:35:57 +09005996 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005997{
5998}
5999/**
6000 * @brief host_int_init
6001 * @details host interface initialization function
6002 * @param[in,out] handle to the wifi driver,
6003 * @note
6004 * @author zsalah
6005 * @date 8 March 2012
6006 * @version 1.0
6007 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006008static u32 clients_count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006009
Johnny Kim218dc402015-08-13 13:41:19 +09006010s32 host_int_init(tstrWILC_WFIDrv **phWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006011{
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006012 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006013 tstrWILC_WFIDrv *pstrWFIDrv;
Johnny Kimd42ab082015-08-20 16:32:52 +09006014 int err;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006015
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006016 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
6017
Dean Lee72ed4dc2015-06-12 14:11:44 +09006018 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006019
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006020 sema_init(&hWaitResponse, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006021
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006022 /*Allocate host interface private structure*/
Chaehyun Lim27a82eb2015-09-22 18:34:55 +09006023 pstrWFIDrv = kzalloc(sizeof(tstrWILC_WFIDrv), GFP_KERNEL);
Chaehyun Lim16042962015-09-22 18:34:56 +09006024 if (!pstrWFIDrv) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006025 result = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006026 goto _fail_timer_2;
6027 }
Johnny Kim218dc402015-08-13 13:41:19 +09006028 *phWFIDrv = pstrWFIDrv;
Johnny Kimd42ab082015-08-20 16:32:52 +09006029 err = add_handler_in_list(pstrWFIDrv);
6030 if (err) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006031 result = -EFAULT;
Johnny Kimd42ab082015-08-20 16:32:52 +09006032 goto _fail_timer_2;
6033 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006034
Dean Lee72ed4dc2015-06-12 14:11:44 +09006035 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006036
Johnny Kim8a143302015-06-10 17:06:46 +09006037 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006038 if (clients_count == 0) {
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006039 sema_init(&hSemHostIFthrdEnd, 0);
6040 sema_init(&hSemDeinitDrvHandle, 0);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006041 sema_init(&hSemHostIntDeinit, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006042 }
6043
Chaehyun Limdddaba12015-09-22 18:35:01 +09006044 sema_init(&pstrWFIDrv->hSemTestKeyBlock, 0);
6045 sema_init(&pstrWFIDrv->hSemTestDisconnectBlock, 0);
6046 sema_init(&pstrWFIDrv->hSemGetRSSI, 0);
6047 sema_init(&pstrWFIDrv->hSemGetLINKSPEED, 0);
6048 sema_init(&pstrWFIDrv->hSemGetCHNL, 0);
6049 sema_init(&pstrWFIDrv->hSemInactiveTime, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006050
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006051 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
6052
6053 if (clients_count == 0) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006054 result = wilc_mq_create(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006055
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006056 if (result < 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006057 PRINT_ER("Failed to creat MQ\n");
6058 goto _fail_;
6059 }
Arnd Bergmann1999bd52015-05-29 22:52:14 +02006060 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
6061 if (IS_ERR(HostIFthreadHandler)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006062 PRINT_ER("Failed to creat Thread\n");
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006063 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006064 goto _fail_mq_;
6065 }
Greg Kroah-Hartman507d7fc2015-08-17 12:59:42 -07006066 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
6067 (unsigned long)pstrWFIDrv);
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07006068 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006069 }
6070
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006071 setup_timer(&pstrWFIDrv->hScanTimer, TimerCB_Scan, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006072
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006073 setup_timer(&pstrWFIDrv->hConnectTimer, TimerCB_Connect, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006074
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006075 /*Remain on channel timer*/
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006076 setup_timer(&pstrWFIDrv->hRemainOnChannel, ListenTimerCB, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006077
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006078 sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1);
Chaehyun Limdddaba12015-09-22 18:35:01 +09006079 down(&pstrWFIDrv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006080
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006081 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006082
6083 /*Initialize CFG WIDS Defualt Values*/
6084
6085 pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
6086 pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN;
6087 pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
6088 pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
6089 pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE;
6090
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006091 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
6092
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006093 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",
6094
6095 pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source,
6096 pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time,
6097 pstrWFIDrv->strCfgValues.curr_tx_rate);
6098
Chaehyun Limdddaba12015-09-22 18:35:01 +09006099 up(&pstrWFIDrv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006100
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006101 clients_count++; /* increase number of created entities */
6102
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006103 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006104
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006105_fail_timer_2:
Chaehyun Limdddaba12015-09-22 18:35:01 +09006106 up(&pstrWFIDrv->gtOsCfgValuesSem);
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006107 del_timer_sync(&pstrWFIDrv->hConnectTimer);
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006108 del_timer_sync(&pstrWFIDrv->hScanTimer);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02006109 kthread_stop(HostIFthreadHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006110_fail_mq_:
Chaehyun Lim1b128f62015-08-19 15:59:08 +09006111 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006112_fail_:
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006113 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006114}
6115/**
6116 * @brief host_int_deinit
6117 * @details host interface initialization function
6118 * @param[in,out] handle to the wifi driver,
6119 * @note
6120 * @author zsalah
6121 * @date 8 March 2012
6122 * @version 1.0
6123 */
6124
Johnny Kim218dc402015-08-13 13:41:19 +09006125s32 host_int_deinit(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006126{
Leo Kime6e12662015-09-16 18:36:03 +09006127 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006128 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006129 int ret;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006130
6131 /*obtain driver handle*/
6132 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006133
6134 if (pstrWFIDrv == NULL) {
6135 PRINT_ER("pstrWFIDrv = NULL\n");
6136 return 0;
6137 }
6138
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006139 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006140
6141 terminated_handle = pstrWFIDrv;
6142 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
6143
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006144 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
6145 /*to guarantee handling all messages befor proceeding*/
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006146 if (del_timer_sync(&pstrWFIDrv->hScanTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006147 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006148 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
6149 }
6150
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006151 if (del_timer_sync(&pstrWFIDrv->hConnectTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006152 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006153 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6154 }
6155
6156
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006157 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006158 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006159 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6160 }
6161
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006162 /*Destroy Remain-onchannel Timer*/
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006163 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006164
Johnny Kim218dc402015-08-13 13:41:19 +09006165 host_int_set_wfi_drv_handler(NULL);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006166 down(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006167
6168
6169 /*Calling the CFG80211 scan done function with the abort flag set to true*/
6170 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006171 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006172 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
6173
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006174 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006175 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006176
6177 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6178
Dean Lee72ed4dc2015-06-12 14:11:44 +09006179 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006180
Tony Cho143eb952015-09-21 12:16:32 +09006181 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006182
6183 if (clients_count == 1) {
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006184 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006185 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006186 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6187 }
Tony Choa9f812a2015-09-21 12:16:33 +09006188 msg.id = HOST_IF_MSG_EXIT;
Tony Cho143eb952015-09-21 12:16:32 +09006189 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006190
6191
Tony Cho143eb952015-09-21 12:16:32 +09006192 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kime6e12662015-09-16 18:36:03 +09006193 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006194 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006195
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006196 down(&hSemHostIFthrdEnd);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006197
Chaehyun Lim1b128f62015-08-19 15:59:08 +09006198 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006199 }
6200
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006201 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006202
6203 /*Setting the gloabl driver handler with NULL*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006204 /* gWFiDrvHandle = NULL; */
Johnny Kimd42ab082015-08-20 16:32:52 +09006205 ret = remove_handler_in_list(pstrWFIDrv);
6206 if (ret)
Leo Kime6e12662015-09-16 18:36:03 +09006207 s32Error = -ENOENT;
Johnny Kimd42ab082015-08-20 16:32:52 +09006208
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006209 if (pstrWFIDrv != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09006210 kfree(pstrWFIDrv);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006211 /* pstrWFIDrv=NULL; */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006212
6213 }
6214
6215 clients_count--; /* Decrease number of created entities */
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006216 terminated_handle = NULL;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006217 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006218 return s32Error;
6219}
6220
6221
6222/**
6223 * @brief NetworkInfoReceived
6224 * @details function to to be called when network info packet is received
6225 * @param[in] pu8Buffer the received packet
6226 * @param[in] u32Length length of the received packet
6227 * @return none
6228 * @note
6229 * @author
6230 * @date 1 Mar 2012
6231 * @version 1.0
6232 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006233void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006234{
Leo Kime6e12662015-09-16 18:36:03 +09006235 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006236 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006237 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006238 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006239
Johnny Kimd42ab082015-08-20 16:32:52 +09006240 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6241 pstrWFIDrv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006242
6243
6244
6245
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006246 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
Johnny Kim8a143302015-06-10 17:06:46 +09006247 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006248 return;
6249 }
6250
6251 /* prepare the Asynchronous Network Info message */
Tony Cho143eb952015-09-21 12:16:32 +09006252 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006253
Tony Choa9f812a2015-09-21 12:16:33 +09006254 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
Tony Cho143eb952015-09-21 12:16:32 +09006255 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006256
Tony Cho02d19462015-09-30 18:44:22 +09006257 msg.body.net_info.u32Length = u32Length;
6258 msg.body.net_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
6259 memcpy(msg.body.net_info.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006260 pu8Buffer, u32Length);
6261
6262 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006263 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006264 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006265 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006266}
6267
6268/**
6269 * @brief GnrlAsyncInfoReceived
6270 * @details function to be called when general Asynchronous info packet is received
6271 * @param[in] pu8Buffer the received packet
6272 * @param[in] u32Length length of the received packet
6273 * @return none
6274 * @note
6275 * @author
6276 * @date 15 Mar 2012
6277 * @version 1.0
6278 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006279void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006280{
Leo Kime6e12662015-09-16 18:36:03 +09006281 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006282 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006283 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006284 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006285
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006286 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006287
Johnny Kimd42ab082015-08-20 16:32:52 +09006288 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6289 pstrWFIDrv = get_handler_from_id(id);
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006290 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006291
6292
6293 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6294 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006295 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006296 return;
6297 }
6298
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006299 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006300 /* received mac status is not needed when there is no current Connect Request */
6301 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006302 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006303 return;
6304 }
6305
6306 /* prepare the General Asynchronous Info message */
Tony Cho143eb952015-09-21 12:16:32 +09006307 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006308
6309
Tony Choa9f812a2015-09-21 12:16:33 +09006310 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
Tony Cho143eb952015-09-21 12:16:32 +09006311 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006312
6313
Tony Cho66add622015-09-30 18:44:23 +09006314 msg.body.async_info.u32Length = u32Length;
6315 msg.body.async_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
6316 memcpy(msg.body.async_info.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006317 pu8Buffer, u32Length);
6318
6319 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006320 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006321 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006322 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006323
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006324 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006325}
6326
6327/**
6328 * @brief host_int_ScanCompleteReceived
6329 * @details Setting scan complete received notifcation in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006330 * @param[in] u8* pu8Buffer, u32 u32Length
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006331 * @return Error code.
6332 * @author
6333 * @date
6334 * @version 1.0
6335 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006336void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006337{
Leo Kime6e12662015-09-16 18:36:03 +09006338 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006339 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006340 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006341 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006342
Johnny Kimd42ab082015-08-20 16:32:52 +09006343 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6344 pstrWFIDrv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006345
6346
Johnny Kim8a143302015-06-10 17:06:46 +09006347 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006348
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006349 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006350 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006351
6352 /*if there is an ongoing scan request*/
6353 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6354 /* prepare theScan Done message */
Tony Cho143eb952015-09-21 12:16:32 +09006355 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006356
Tony Choa9f812a2015-09-21 12:16:33 +09006357 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
Tony Cho143eb952015-09-21 12:16:32 +09006358 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006359
6360
6361 /* will be deallocated by the receiving thread */
6362 /*no need to send message body*/
6363
Tony Cho410c2482015-09-21 12:16:35 +09006364 /*msg.body.strScanComplete.u32Length = u32Length;
6365 * msg.body.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
6366 * memcpy(msg.body.strScanComplete.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006367 * pu8Buffer, u32Length); */
6368
6369 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006370 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006371 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006372 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006373 }
6374
6375
6376 return;
6377
6378}
6379
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006380/**
6381 * @brief host_int_remain_on_channel
6382 * @details
6383 * @param[in] Handle to wifi driver
6384 * Duration to remain on channel
6385 * Channel to remain on
6386 * Pointer to fn to be called on receive frames in listen state
6387 * Pointer to remain-on-channel expired fn
6388 * Priv
6389 * @return Error code.
6390 * @author
6391 * @date
6392 * @version 1.0
6393 */
Johnny Kim218dc402015-08-13 13:41:19 +09006394s32 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 +09006395{
Leo Kime6e12662015-09-16 18:36:03 +09006396 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006397 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006398 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006399
Leo Kim24db7132015-09-16 18:36:01 +09006400 if (pstrWFIDrv == NULL) {
6401 PRINT_ER("driver is null\n");
6402 return -EFAULT;
6403 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006404
6405 /* prepare the remainonchan Message */
Tony Cho143eb952015-09-21 12:16:32 +09006406 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006407
6408 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006409 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
Tony Cho070d3652015-09-30 18:55:10 +09006410 msg.body.remain_on_ch.u16Channel = chan;
6411 msg.body.remain_on_ch.pRemainOnChanExpired = RemainOnChanExpired;
6412 msg.body.remain_on_ch.pRemainOnChanReady = RemainOnChanReady;
6413 msg.body.remain_on_ch.pVoid = pvUserArg;
6414 msg.body.remain_on_ch.u32duration = u32duration;
6415 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
Tony Cho143eb952015-09-21 12:16:32 +09006416 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006417
Tony Cho143eb952015-09-21 12:16:32 +09006418 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006419 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006420 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006421
6422 return s32Error;
6423}
6424
6425/**
6426 * @brief host_int_ListenStateExpired
6427 * @details
6428 * @param[in] Handle to wifi driver
6429 * Duration to remain on channel
6430 * Channel to remain on
6431 * Pointer to fn to be called on receive frames in listen state
6432 * Pointer to remain-on-channel expired fn
6433 * Priv
6434 * @return Error code.
6435 * @author
6436 * @date
6437 * @version 1.0
6438 */
Johnny Kim218dc402015-08-13 13:41:19 +09006439s32 host_int_ListenStateExpired(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006440{
Leo Kime6e12662015-09-16 18:36:03 +09006441 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006442 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006443 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006444
Leo Kim24db7132015-09-16 18:36:01 +09006445 if (pstrWFIDrv == NULL) {
6446 PRINT_ER("driver is null\n");
6447 return -EFAULT;
6448 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006449
6450 /*Stopping remain-on-channel timer*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07006451 del_timer(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006452
6453 /* prepare the timer fire Message */
Tony Cho143eb952015-09-21 12:16:32 +09006454 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09006455 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Cho143eb952015-09-21 12:16:32 +09006456 msg.drvHandler = hWFIDrv;
Tony Cho070d3652015-09-30 18:55:10 +09006457 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006458
Tony Cho143eb952015-09-21 12:16:32 +09006459 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006460 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006461 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006462
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006463 return s32Error;
6464}
6465
6466/**
6467 * @brief host_int_frame_register
6468 * @details
6469 * @param[in] Handle to wifi driver
6470 * @return Error code.
6471 * @author
6472 * @date
6473 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09006474s32 host_int_frame_register(tstrWILC_WFIDrv *hWFIDrv, u16 u16FrameType, bool bReg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006475{
Leo Kime6e12662015-09-16 18:36:03 +09006476 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006477 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006478 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006479
Leo Kim24db7132015-09-16 18:36:01 +09006480 if (pstrWFIDrv == NULL) {
6481 PRINT_ER("driver is null\n");
6482 return -EFAULT;
6483 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006484
Tony Cho143eb952015-09-21 12:16:32 +09006485 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006486
6487 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006488 msg.id = HOST_IF_MSG_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006489 switch (u16FrameType) {
6490 case ACTION:
6491 PRINT_D(HOSTINF_DBG, "ACTION\n");
Tony Cho410c2482015-09-21 12:16:35 +09006492 msg.body.strHostIfRegisterFrame.u8Regid = ACTION_FRM_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006493 break;
6494
6495 case PROBE_REQ:
6496 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
Tony Cho410c2482015-09-21 12:16:35 +09006497 msg.body.strHostIfRegisterFrame.u8Regid = PROBE_REQ_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006498 break;
6499
6500 default:
6501 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
6502 break;
6503 }
Tony Cho410c2482015-09-21 12:16:35 +09006504 msg.body.strHostIfRegisterFrame.u16FrameType = u16FrameType;
6505 msg.body.strHostIfRegisterFrame.bReg = bReg;
Tony Cho143eb952015-09-21 12:16:32 +09006506 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006507
Tony Cho143eb952015-09-21 12:16:32 +09006508 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006509 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006510 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006511
6512 return s32Error;
6513
6514
6515}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006516
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006517/**
6518 * @brief host_int_add_beacon
6519 * @details Setting add beacon params in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006520 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
6521 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
6522 * u32 u32TailLen, u8* pu8Tail
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006523 * @return Error code.
6524 * @author
6525 * @date
6526 * @version 1.0
6527 */
Johnny Kim218dc402015-08-13 13:41:19 +09006528s32 host_int_add_beacon(tstrWILC_WFIDrv *hWFIDrv, u32 u32Interval,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006529 u32 u32DTIMPeriod,
6530 u32 u32HeadLen, u8 *pu8Head,
6531 u32 u32TailLen, u8 *pu8Tail)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006532{
Leo Kime6e12662015-09-16 18:36:03 +09006533 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006534 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006535 struct host_if_msg msg;
Tony Choa98491e2015-09-30 18:44:31 +09006536 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006537
Leo Kim24db7132015-09-16 18:36:01 +09006538 if (pstrWFIDrv == NULL) {
6539 PRINT_ER("driver is null\n");
6540 return -EFAULT;
6541 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006542
Tony Cho143eb952015-09-21 12:16:32 +09006543 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006544
6545 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
6546
6547
6548 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006549 msg.id = HOST_IF_MSG_ADD_BEACON;
Tony Cho143eb952015-09-21 12:16:32 +09006550 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006551 pstrSetBeaconParam->u32Interval = u32Interval;
6552 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
6553 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
Glen Leef3052582015-09-10 12:03:04 +09006554 pstrSetBeaconParam->pu8Head = kmalloc(u32HeadLen, GFP_KERNEL);
Leo Kim24db7132015-09-16 18:36:01 +09006555 if (pstrSetBeaconParam->pu8Head == NULL) {
6556 s32Error = -ENOMEM;
6557 goto ERRORHANDLER;
6558 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006559 memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006560 pstrSetBeaconParam->u32TailLen = u32TailLen;
6561
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006562 if (u32TailLen > 0) {
Glen Leef3052582015-09-10 12:03:04 +09006563 pstrSetBeaconParam->pu8Tail = kmalloc(u32TailLen, GFP_KERNEL);
Leo Kim24db7132015-09-16 18:36:01 +09006564 if (pstrSetBeaconParam->pu8Tail == NULL) {
6565 s32Error = -ENOMEM;
6566 goto ERRORHANDLER;
6567 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006568 memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006569 } else {
6570 pstrSetBeaconParam->pu8Tail = NULL;
6571 }
6572
Tony Cho143eb952015-09-21 12:16:32 +09006573 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006574 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006575 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006576
Leo Kim24db7132015-09-16 18:36:01 +09006577ERRORHANDLER:
6578 if (s32Error) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006579 if (pstrSetBeaconParam->pu8Head != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006580 kfree(pstrSetBeaconParam->pu8Head);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006581
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006582 if (pstrSetBeaconParam->pu8Tail != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006583 kfree(pstrSetBeaconParam->pu8Tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006584 }
6585
6586 return s32Error;
6587
6588}
6589
6590
6591/**
6592 * @brief host_int_del_beacon
6593 * @details Setting add beacon params in message queue
6594 * @param[in] WILC_WFIDrvHandle hWFIDrv
6595 * @return Error code.
6596 * @author
6597 * @date
6598 * @version 1.0
6599 */
Johnny Kim218dc402015-08-13 13:41:19 +09006600s32 host_int_del_beacon(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006601{
Leo Kime6e12662015-09-16 18:36:03 +09006602 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006603 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006604 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006605
Leo Kim24db7132015-09-16 18:36:01 +09006606 if (pstrWFIDrv == NULL) {
6607 PRINT_ER("driver is null\n");
6608 return -EFAULT;
6609 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006610
6611 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006612 msg.id = HOST_IF_MSG_DEL_BEACON;
Tony Cho143eb952015-09-21 12:16:32 +09006613 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006614 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
6615
Tony Cho143eb952015-09-21 12:16:32 +09006616 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim7dc1d0c2015-09-16 18:36:00 +09006617 if (s32Error)
6618 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006619
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006620 return s32Error;
6621}
6622
6623
6624/**
6625 * @brief host_int_add_station
6626 * @details Setting add station params in message queue
Tony Cho6a89ba92015-09-21 12:16:46 +09006627 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006628 * @return Error code.
6629 * @author
6630 * @date
6631 * @version 1.0
6632 */
Tony Cho6a89ba92015-09-21 12:16:46 +09006633s32 host_int_add_station(tstrWILC_WFIDrv *hWFIDrv,
6634 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006635{
Leo Kime6e12662015-09-16 18:36:03 +09006636 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006637 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006638 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09006639 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006640
6641
Leo Kim24db7132015-09-16 18:36:01 +09006642 if (pstrWFIDrv == NULL) {
6643 PRINT_ER("driver is null\n");
6644 return -EFAULT;
6645 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006646
Tony Cho143eb952015-09-21 12:16:32 +09006647 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006648
6649 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
6650
6651
6652 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006653 msg.id = HOST_IF_MSG_ADD_STATION;
Tony Cho143eb952015-09-21 12:16:32 +09006654 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006655
Tony Cho6a89ba92015-09-21 12:16:46 +09006656 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006657 if (pstrAddStationMsg->u8NumRates > 0) {
Glen Leef3052582015-09-10 12:03:04 +09006658 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006659
Leo Kim7ae43362015-09-16 18:35:59 +09006660 if (!rates)
6661 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006662
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006663 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02006664 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006665 }
6666
6667
Tony Cho143eb952015-09-21 12:16:32 +09006668 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006669 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006670 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006671 return s32Error;
6672}
6673
6674/**
6675 * @brief host_int_del_station
6676 * @details Setting delete station params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006677 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006678 * @return Error code.
6679 * @author
6680 * @date
6681 * @version 1.0
6682 */
Johnny Kim218dc402015-08-13 13:41:19 +09006683s32 host_int_del_station(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8MacAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006684{
Leo Kime6e12662015-09-16 18:36:03 +09006685 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006686 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006687 struct host_if_msg msg;
Tony Cho889c25b2015-09-30 18:44:33 +09006688 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006689
Leo Kim24db7132015-09-16 18:36:01 +09006690 if (pstrWFIDrv == NULL) {
6691 PRINT_ER("driver is null\n");
6692 return -EFAULT;
6693 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006694
Tony Cho143eb952015-09-21 12:16:32 +09006695 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006696
6697 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
6698
6699
6700
6701 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006702 msg.id = HOST_IF_MSG_DEL_STATION;
Tony Cho143eb952015-09-21 12:16:32 +09006703 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006704
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006705 if (pu8MacAddr == NULL)
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006706 memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006707 else
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006708 memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006709
Tony Cho143eb952015-09-21 12:16:32 +09006710 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006711 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006712 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006713 return s32Error;
6714}
6715/**
6716 * @brief host_int_del_allstation
6717 * @details Setting del station params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006718 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006719 * @return Error code.
6720 * @author
6721 * @date
6722 * @version 1.0
6723 */
Johnny Kim218dc402015-08-13 13:41:19 +09006724s32 host_int_del_allstation(tstrWILC_WFIDrv *hWFIDrv, u8 pu8MacAddr[][ETH_ALEN])
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006725{
Leo Kime6e12662015-09-16 18:36:03 +09006726 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006727 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006728 struct host_if_msg msg;
Tony Chob4e644e2015-09-21 12:17:00 +09006729 struct del_all_sta *pstrDelAllStationMsg = &msg.body.strHostIFDelAllSta;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006730 u8 au8Zero_Buff[ETH_ALEN] = {0};
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006731 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006732 u8 u8AssocNumb = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006733
6734
Leo Kim24db7132015-09-16 18:36:01 +09006735 if (pstrWFIDrv == NULL) {
6736 PRINT_ER("driver is null\n");
6737 return -EFAULT;
6738 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006739
Tony Cho143eb952015-09-21 12:16:32 +09006740 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006741
6742 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
6743
6744 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006745 msg.id = HOST_IF_MSG_DEL_ALL_STA;
Tony Cho143eb952015-09-21 12:16:32 +09006746 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006747
6748 /* Handling situation of deauthenticing all associated stations*/
6749 for (i = 0; i < MAX_NUM_STA; i++) {
6750 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006751 memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006752 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],
6753 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
6754 u8AssocNumb++;
6755 }
6756 }
6757 if (!u8AssocNumb) {
6758 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
6759 return s32Error;
6760 }
6761
6762 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
Tony Cho143eb952015-09-21 12:16:32 +09006763 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006764
6765
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006766 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006767 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006768
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006769 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006770
6771 return s32Error;
6772
6773}
6774
6775/**
6776 * @brief host_int_edit_station
6777 * @details Setting edit station params in message queue
Tony Cho6a89ba92015-09-21 12:16:46 +09006778 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006779 * @return Error code.
6780 * @author
6781 * @date
6782 * @version 1.0
6783 */
Tony Cho6a89ba92015-09-21 12:16:46 +09006784s32 host_int_edit_station(tstrWILC_WFIDrv *hWFIDrv,
6785 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006786{
Leo Kime6e12662015-09-16 18:36:03 +09006787 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006788 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006789 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09006790 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006791
Leo Kim24db7132015-09-16 18:36:01 +09006792 if (pstrWFIDrv == NULL) {
6793 PRINT_ER("driver is null\n");
6794 return -EFAULT;
6795 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006796
6797 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
6798
Tony Cho143eb952015-09-21 12:16:32 +09006799 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006800
6801
6802 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006803 msg.id = HOST_IF_MSG_EDIT_STATION;
Tony Cho143eb952015-09-21 12:16:32 +09006804 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006805
Tony Cho6a89ba92015-09-21 12:16:46 +09006806 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006807 if (pstrAddStationMsg->u8NumRates > 0) {
Glen Leef3052582015-09-10 12:03:04 +09006808 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006809
Leo Kim7ae43362015-09-16 18:35:59 +09006810 if (!rates)
6811 return -ENOMEM;
6812
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006813 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02006814 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006815 }
6816
Tony Cho143eb952015-09-21 12:16:32 +09006817 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006818 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006819 PRINT_ER("wilc_mq_send fail\n");
6820
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006821 return s32Error;
6822}
Glen Lee108b3432015-09-16 18:53:20 +09006823
Johnny Kim218dc402015-08-13 13:41:19 +09006824s32 host_int_set_power_mgmt(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32Timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006825{
Leo Kime6e12662015-09-16 18:36:03 +09006826 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006827 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006828 struct host_if_msg msg;
Tony Cho49e1f812015-09-30 18:44:36 +09006829 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006830
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006831 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006832
Leo Kim24db7132015-09-16 18:36:01 +09006833 if (pstrWFIDrv == NULL) {
6834 PRINT_ER("driver is null\n");
6835 return -EFAULT;
6836 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006837
6838 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
6839
Tony Cho143eb952015-09-21 12:16:32 +09006840 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006841
6842
6843 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006844 msg.id = HOST_IF_MSG_POWER_MGMT;
Tony Cho143eb952015-09-21 12:16:32 +09006845 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006846
6847 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
6848 pstrPowerMgmtParam->u32Timeout = u32Timeout;
6849
6850
Tony Cho143eb952015-09-21 12:16:32 +09006851 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006852 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006853 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006854 return s32Error;
6855}
6856
Johnny Kim218dc402015-08-13 13:41:19 +09006857s32 host_int_setup_multicast_filter(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32count)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006858{
Leo Kime6e12662015-09-16 18:36:03 +09006859 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006860
6861 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006862 struct host_if_msg msg;
Tony Choa079cf4d2015-09-30 18:55:05 +09006863 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006864
6865
Leo Kim24db7132015-09-16 18:36:01 +09006866 if (pstrWFIDrv == NULL) {
6867 PRINT_ER("driver is null\n");
6868 return -EFAULT;
6869 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006870
6871 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
6872
Tony Cho143eb952015-09-21 12:16:32 +09006873 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006874
6875
6876 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006877 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
Tony Cho143eb952015-09-21 12:16:32 +09006878 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006879
6880 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
6881 pstrMulticastFilterParam->u32count = u32count;
6882
Tony Cho143eb952015-09-21 12:16:32 +09006883 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006884 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006885 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006886 return s32Error;
6887}
6888
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006889/**
6890 * @brief host_int_ParseJoinBssParam
6891 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
6892 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
6893 * @return
6894 * @author zsalah
6895 * @date
6896 * @version 1.0**/
6897static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
6898{
6899 tstrJoinBssParam *pNewJoinBssParam = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006900 u8 *pu8IEs;
Chaehyun Limd85f5322015-06-11 14:35:54 +09006901 u16 u16IEsLen;
6902 u16 index = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006903 u8 suppRatesNo = 0;
6904 u8 extSuppRatesNo;
Chaehyun Limd85f5322015-06-11 14:35:54 +09006905 u16 jumpOffset;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006906 u8 pcipherCount;
6907 u8 authCount;
6908 u8 pcipherTotalCount = 0;
6909 u8 authTotalCount = 0;
6910 u8 i, j;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006911
6912 pu8IEs = ptstrNetworkInfo->pu8IEs;
6913 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
6914
Glen Leef3052582015-09-10 12:03:04 +09006915 pNewJoinBssParam = kmalloc(sizeof(tstrJoinBssParam), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006916 if (pNewJoinBssParam != NULL) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006917 memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006918 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
6919 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
6920 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006921 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006922 /*for(i=0; i<6;i++)
6923 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006924 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006925 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006926 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
6927 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006928 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
6929 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
6930
6931 /* parse supported rates: */
6932 while (index < u16IEsLen) {
6933 /* supportedRates IE */
6934 if (pu8IEs[index] == SUPP_RATES_IE) {
6935 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
6936 suppRatesNo = pu8IEs[index + 1];
6937 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
6938 index += 2; /* skipping ID and length bytes; */
6939
6940 for (i = 0; i < suppRatesNo; i++) {
6941 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
6942 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
6943 }
6944 index += suppRatesNo;
6945 continue;
6946 }
6947 /* Ext SupportedRates IE */
6948 else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
6949 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
6950 /* checking if no of ext. supp and supp rates < max limit */
6951 extSuppRatesNo = pu8IEs[index + 1];
6952 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
6953 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
6954 else
6955 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
6956 index += 2;
6957 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
6958 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
6959 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
6960 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
6961 }
6962 index += extSuppRatesNo;
6963 continue;
6964 }
6965 /* HT Cap. IE */
6966 else if (pu8IEs[index] == HT_CAPABILITY_IE) {
6967 /* if IE found set the flag */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09006968 pNewJoinBssParam->ht_capable = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006969 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6970 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
6971 continue;
6972 } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
6973 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
6974 (pu8IEs[index + 4] == 0xF2) && /* OUI */
6975 (pu8IEs[index + 5] == 0x02) && /* OUI Type */
6976 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
6977 (pu8IEs[index + 7] == 0x01)) {
6978 /* Presence of WMM Info/Param element indicates WMM capability */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09006979 pNewJoinBssParam->wmm_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006980
6981 /* Check if Bit 7 is set indicating U-APSD capability */
Anish Bhattffda2032015-09-29 12:15:49 -07006982 if (pu8IEs[index + 8] & BIT(7))
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09006983 pNewJoinBssParam->uapsd_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006984 index += pu8IEs[index + 1] + 2;
6985 continue;
6986 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006987 else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
6988 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
6989 (pu8IEs[index + 4] == 0x9a) && /* OUI */
6990 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
Chaehyun Limd85f5322015-06-11 14:35:54 +09006991 u16 u16P2P_count;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006992
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006993 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
6994 pNewJoinBssParam->u8NoaEnbaled = 1;
6995 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
6996
6997 /* Check if Bit 7 is set indicating Opss capability */
Anish Bhattffda2032015-09-29 12:15:49 -07006998 if (pu8IEs[index + 10] & BIT(7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006999 pNewJoinBssParam->u8OppEnable = 1;
7000 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
7001 } else
7002 pNewJoinBssParam->u8OppEnable = 0;
7003 /* HOSTINF_DBG */
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007004 PRINT_D(GENERIC_DBG, "P2P Dump\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007005 for (i = 0; i < pu8IEs[index + 7]; i++)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007006 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007007
7008 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
7009 u16P2P_count = index + 12;
7010
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007011 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007012 u16P2P_count += 4;
7013
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007014 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007015 u16P2P_count += 4;
7016
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007017 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007018
7019 index += pu8IEs[index + 1] + 2;
7020 continue;
7021
7022 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007023 else if ((pu8IEs[index] == RSN_IE) ||
7024 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
7025 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
7026 (pu8IEs[index + 5] == 0x01))) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09007027 u16 rsnIndex = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007028 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
7029 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
7030 * {
7031 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
7032 * }*/
7033 if (pu8IEs[rsnIndex] == RSN_IE) {
7034 pNewJoinBssParam->mode_802_11i = 2;
7035 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
7036 } else { /* check if rsn was previously parsed */
7037 if (pNewJoinBssParam->mode_802_11i == 0)
7038 pNewJoinBssParam->mode_802_11i = 1;
7039 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
7040 rsnIndex += 4;
7041 }
7042 rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
7043 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
7044 rsnIndex++;
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007045 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007046 /* initialize policies with invalid values */
7047
7048 jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
7049
7050 /*parsing pairwise cipher*/
7051
7052 /* saving 3 pcipher max. */
7053 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7054 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7055
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007056 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007057 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
7058 /* each count corresponds to 4 bytes, only last byte is saved */
7059 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7060 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
7061 }
7062 pcipherTotalCount += pcipherCount;
7063 rsnIndex += jumpOffset;
7064
7065 jumpOffset = pu8IEs[rsnIndex] * 4;
7066
7067 /*parsing AKM suite (auth_policy)*/
7068 /* saving 3 auth policies max. */
7069 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7070 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7071
7072 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
7073 /* each count corresponds to 4 bytes, only last byte is saved */
7074 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7075 }
7076 authTotalCount += authCount;
7077 rsnIndex += jumpOffset;
7078 /*pasring rsn cap. only if rsn IE*/
7079 if (pu8IEs[index] == RSN_IE) {
7080 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
7081 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
7082 rsnIndex += 2;
7083 }
Abdul Hussainf717c0eb2015-06-16 09:49:49 +00007084 pNewJoinBssParam->rsn_found = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007085 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7086 continue;
7087 } else
7088 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7089
7090 }
7091
7092
7093 }
7094
7095 return (void *)pNewJoinBssParam;
7096
7097}
7098
7099void host_int_freeJoinParams(void *pJoinParams)
7100{
7101 if ((tstrJoinBssParam *)pJoinParams != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09007102 kfree((tstrJoinBssParam *)pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007103 else
7104 PRINT_ER("Unable to FREE null pointer\n");
7105}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007106
7107/**
7108 * @brief host_int_addBASession
7109 * @details Open a block Ack session with the given parameters
7110 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7111 * @return
7112 * @author anoureldin
7113 * @date
7114 * @version 1.0**/
7115
Johnny Kim2b05df52015-08-13 13:41:21 +09007116static int host_int_addBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID, short int BufferSize,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007117 short int SessionTimeout, void *drvHandler)
7118{
Leo Kime6e12662015-09-16 18:36:03 +09007119 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007120 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007121 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09007122 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007123
Leo Kim24db7132015-09-16 18:36:01 +09007124 if (pstrWFIDrv == NULL) {
7125 PRINT_ER("driver is null\n");
7126 return -EFAULT;
7127 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007128
Tony Cho143eb952015-09-21 12:16:32 +09007129 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007130
7131 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007132 msg.id = HOST_IF_MSG_ADD_BA_SESSION;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007133
7134 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7135 pBASessionInfo->u8Ted = TID;
7136 pBASessionInfo->u16BufferSize = BufferSize;
7137 pBASessionInfo->u16SessionTimeout = SessionTimeout;
Tony Cho143eb952015-09-21 12:16:32 +09007138 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007139
Tony Cho143eb952015-09-21 12:16:32 +09007140 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007141 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007142 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007143
7144 return s32Error;
7145}
7146
7147
Johnny Kim218dc402015-08-13 13:41:19 +09007148s32 host_int_delBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007149{
Leo Kime6e12662015-09-16 18:36:03 +09007150 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007151 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007152 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09007153 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007154
Leo Kim24db7132015-09-16 18:36:01 +09007155 if (pstrWFIDrv == NULL) {
7156 PRINT_ER("driver is null\n");
7157 return -EFAULT;
7158 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007159
Tony Cho143eb952015-09-21 12:16:32 +09007160 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007161
7162 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007163 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007164
7165 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7166 pBASessionInfo->u8Ted = TID;
Tony Cho143eb952015-09-21 12:16:32 +09007167 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007168
Tony Cho143eb952015-09-21 12:16:32 +09007169 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007170 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007171 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007172
Arnd Bergmann83383ea2015-06-01 21:06:43 +02007173 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007174
7175 return s32Error;
7176}
7177
Johnny Kim218dc402015-08-13 13:41:19 +09007178s32 host_int_del_All_Rx_BASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007179{
Leo Kime6e12662015-09-16 18:36:03 +09007180 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007181 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007182 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09007183 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007184
Leo Kim24db7132015-09-16 18:36:01 +09007185 if (pstrWFIDrv == NULL) {
7186 PRINT_ER("driver is null\n");
7187 return -EFAULT;
7188 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007189
Tony Cho143eb952015-09-21 12:16:32 +09007190 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007191
7192 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007193 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007194
7195 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7196 pBASessionInfo->u8Ted = TID;
Tony Cho143eb952015-09-21 12:16:32 +09007197 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007198
Tony Cho143eb952015-09-21 12:16:32 +09007199 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007200 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007201 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007202
Arnd Bergmann83383ea2015-06-01 21:06:43 +02007203 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007204
7205 return s32Error;
7206}
7207
7208/**
7209 * @brief host_int_setup_ipaddress
7210 * @details setup IP in firmware
7211 * @param[in] Handle to wifi driver
7212 * @return Error code.
7213 * @author Abdelrahman Sobhy
7214 * @date
7215 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09007216s32 host_int_setup_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007217{
Leo Kime6e12662015-09-16 18:36:03 +09007218 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007219 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007220 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007221
7222 /* TODO: Enable This feature on softap firmware */
7223 return 0;
7224
Leo Kim24db7132015-09-16 18:36:01 +09007225 if (pstrWFIDrv == NULL) {
7226 PRINT_ER("driver is null\n");
7227 return -EFAULT;
7228 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007229
Tony Cho143eb952015-09-21 12:16:32 +09007230 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007231
7232 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007233 msg.id = HOST_IF_MSG_SET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007234
Tony Chofb2d65e2015-09-30 18:44:39 +09007235 msg.body.ip_info.au8IPAddr = u16ipadd;
Tony Cho143eb952015-09-21 12:16:32 +09007236 msg.drvHandler = hWFIDrv;
Tony Chofb2d65e2015-09-30 18:44:39 +09007237 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007238
Tony Cho143eb952015-09-21 12:16:32 +09007239 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007240 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007241 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007242
7243 return s32Error;
7244
7245
7246}
7247
7248/**
7249 * @brief host_int_get_ipaddress
7250 * @details Get IP from firmware
7251 * @param[in] Handle to wifi driver
7252 * @return Error code.
7253 * @author Abdelrahman Sobhy
7254 * @date
7255 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09007256s32 host_int_get_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007257{
Leo Kime6e12662015-09-16 18:36:03 +09007258 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007259 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007260 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007261
Leo Kim24db7132015-09-16 18:36:01 +09007262 if (pstrWFIDrv == NULL) {
7263 PRINT_ER("driver is null\n");
7264 return -EFAULT;
7265 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007266
Tony Cho143eb952015-09-21 12:16:32 +09007267 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007268
7269 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007270 msg.id = HOST_IF_MSG_GET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007271
Tony Chofb2d65e2015-09-30 18:44:39 +09007272 msg.body.ip_info.au8IPAddr = u16ipadd;
Tony Cho143eb952015-09-21 12:16:32 +09007273 msg.drvHandler = hWFIDrv;
Tony Chofb2d65e2015-09-30 18:44:39 +09007274 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007275
Tony Cho143eb952015-09-21 12:16:32 +09007276 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007277 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007278 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007279
7280 return s32Error;
7281
7282
7283}