blob: 47ccaa81b660a3ba456ba1b4c64fa72441aedbe8 [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/* Message types of the Host IF Message Queue*/
Chaehyun Lim9eac3a12015-06-18 22:08:51 +090017#define HOST_IF_MSG_SCAN 0
18#define HOST_IF_MSG_CONNECT 1
19#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
20#define HOST_IF_MSG_KEY 3
21#define HOST_IF_MSG_RCVD_NTWRK_INFO 4
22#define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
23#define HOST_IF_MSG_CFG_PARAMS 6
24#define HOST_IF_MSG_SET_CHANNEL 7
25#define HOST_IF_MSG_DISCONNECT 8
26#define HOST_IF_MSG_GET_RSSI 9
27#define HOST_IF_MSG_GET_CHNL 10
28#define HOST_IF_MSG_ADD_BEACON 11
29#define HOST_IF_MSG_DEL_BEACON 12
30#define HOST_IF_MSG_ADD_STATION 13
31#define HOST_IF_MSG_DEL_STATION 14
32#define HOST_IF_MSG_EDIT_STATION 15
33#define HOST_IF_MSG_SCAN_TIMER_FIRED 16
34#define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
35#define HOST_IF_MSG_POWER_MGMT 18
36#define HOST_IF_MSG_GET_INACTIVETIME 19
37#define HOST_IF_MSG_REMAIN_ON_CHAN 20
38#define HOST_IF_MSG_REGISTER_FRAME 21
39#define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
40#define HOST_IF_MSG_GET_LINKSPEED 23
41#define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
42#define HOST_IF_MSG_SET_MAC_ADDRESS 25
43#define HOST_IF_MSG_GET_MAC_ADDRESS 26
44#define HOST_IF_MSG_SET_OPERATION_MODE 27
45#define HOST_IF_MSG_SET_IPADDRESS 28
46#define HOST_IF_MSG_GET_IPADDRESS 29
47#define HOST_IF_MSG_FLUSH_CONNECT 30
48#define HOST_IF_MSG_GET_STATISTICS 31
49#define HOST_IF_MSG_SET_MULTICAST_FILTER 32
50#define HOST_IF_MSG_ADD_BA_SESSION 33
51#define HOST_IF_MSG_DEL_BA_SESSION 34
52#define HOST_IF_MSG_Q_IDLE 35
53#define HOST_IF_MSG_DEL_ALL_STA 36
54#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
55#define HOST_IF_MSG_EXIT 100
Johnny Kimc5c77ba2015-05-11 14:30:56 +090056
Chaehyun Lime54d5b72015-06-18 22:08:50 +090057#define HOST_IF_SCAN_TIMEOUT 4000
58#define HOST_IF_CONNECT_TIMEOUT 9500
Johnny Kimc5c77ba2015-05-11 14:30:56 +090059
Chaehyun Lime54d5b72015-06-18 22:08:50 +090060#define BA_SESSION_DEFAULT_BUFFER_SIZE 16
61#define BA_SESSION_DEFAULT_TIMEOUT 1000
62#define BLOCK_ACK_REQ_SIZE 0x14
Johnny Kimc5c77ba2015-05-11 14:30:56 +090063
64/*!
Tony Cho361ff842015-09-21 12:16:41 +090065 * @struct cfg_param_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +090066 * @brief Structure to hold Host IF CFG Params Attributes
67 * @details
68 * @todo
69 * @sa
70 * @author Mai Daftedar
71 * @date 02 April 2012
72 * @version 1.0
73 */
Tony Cho361ff842015-09-21 12:16:41 +090074struct cfg_param_attr {
Johnny Kimc5c77ba2015-05-11 14:30:56 +090075 tstrCfgParamVal pstrCfgParamVal;
Tony Cho361ff842015-09-21 12:16:41 +090076};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090077
78/*!
79 * @struct tstrHostIFwpaAttr
80 * @brief Structure to hold Host IF Scan Attributes
81 * @details
82 * @todo
83 * @sa
84 * @author Mai Daftedar
85 * @date 25 March 2012
86 * @version 1.0
87 */
88typedef struct _tstrHostIFwpaAttr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090089 u8 *pu8key;
90 const u8 *pu8macaddr;
91 u8 *pu8seq;
92 u8 u8seqlen;
93 u8 u8keyidx;
94 u8 u8Keylen;
95 u8 u8Ciphermode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090096} tstrHostIFwpaAttr;
97
98
99/*!
100 * @struct tstrHostIFwepAttr
101 * @brief Structure to hold Host IF Scan Attributes
102 * @details
103 * @todo
104 * @sa
105 * @author Mai Daftedar
106 * @date 25 March 2012
107 * @version 1.0
108 */
109typedef struct _tstrHostIFwepAttr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900110 u8 *pu8WepKey;
111 u8 u8WepKeylen;
112 u8 u8Wepidx;
113 u8 u8mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900114 AUTHTYPE_T tenuAuth_type;
115
116} tstrHostIFwepAttr;
117
118/*!
119 * @struct tuniHostIFkeyAttr
120 * @brief Structure to hold Host IF Scan Attributes
121 * @details
122 * @todo
123 * @sa
124 * @author Mai Daftedar
125 * @date 25 March 2012
126 * @version 1.0
127 */
128typedef union _tuniHostIFkeyAttr {
129 tstrHostIFwepAttr strHostIFwepAttr;
130 tstrHostIFwpaAttr strHostIFwpaAttr;
131 tstrHostIFpmkidAttr strHostIFpmkidAttr;
132} tuniHostIFkeyAttr;
133
134/*!
Tony Choc98387a2015-09-21 12:16:40 +0900135 * @struct key_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900136 * @brief Structure to hold Host IF Scan Attributes
137 * @details
138 * @todo
139 * @sa
140 * @author Mai Daftedar
141 * @date 25 March 2012
142 * @version 1.0
143 */
Tony Choc98387a2015-09-21 12:16:40 +0900144struct key_attr {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900145 tenuKeyType enuKeyType;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900146 u8 u8KeyAction;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900147 tuniHostIFkeyAttr uniHostIFkeyAttr;
Tony Choc98387a2015-09-21 12:16:40 +0900148};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900149
150
151
152
153/*!
Tony Choc476feb2015-09-21 12:16:36 +0900154 * @struct scan_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900155 * @brief Structure to hold Host IF Scan Attributes
156 * @details
157 * @todo
158 * @sa
159 * @author Mostafa Abu Bakr
160 * @date 25 March 2012
161 * @version 1.0
162 */
Tony Choc476feb2015-09-21 12:16:36 +0900163struct scan_attr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900164 u8 u8ScanSource;
165 u8 u8ScanType;
166 u8 *pu8ChnlFreqList;
167 u8 u8ChnlListLen;
168 u8 *pu8IEs;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900169 size_t IEsLen;
170 tWILCpfScanResult pfScanResult;
171 void *pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900172 tstrHiddenNetwork strHiddenNetwork;
Tony Choc476feb2015-09-21 12:16:36 +0900173};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900174
175/*!
Tony Cho120ae592015-09-21 12:16:37 +0900176 * @struct connect_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900177 * @brief Structure to hold Host IF Connect Attributes
178 * @details
179 * @todo
180 * @sa
181 * @author Mostafa Abu Bakr
182 * @date 25 March 2012
183 * @version 1.0
184 */
Tony Cho120ae592015-09-21 12:16:37 +0900185struct connect_attr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900186 u8 *pu8bssid;
187 u8 *pu8ssid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900188 size_t ssidLen;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900189 u8 *pu8IEs;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900190 size_t IEsLen;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900191 u8 u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900192 tWILCpfConnectResult pfConnectResult;
193 void *pvUserArg;
194 AUTHTYPE_T tenuAuth_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900195 u8 u8channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900196 void *pJoinParams;
Tony Cho120ae592015-09-21 12:16:37 +0900197};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900198
199/*!
Tony Chof23a9ea2015-09-21 12:16:39 +0900200 * @struct rcvd_async_info
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900201 * @brief Structure to hold Received General Asynchronous info
202 * @details
203 * @todo
204 * @sa
205 * @author Mostafa Abu Bakr
206 * @date 25 March 2012
207 * @version 1.0
208 */
Tony Chof23a9ea2015-09-21 12:16:39 +0900209struct rcvd_async_info {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900210 u8 *pu8Buffer;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900211 u32 u32Length;
Tony Chof23a9ea2015-09-21 12:16:39 +0900212};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900213
214/*!
Tony Cho94bdfe42015-09-30 18:44:27 +0900215 * @struct channel_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900216 * @brief Set Channel message body
217 * @details
218 * @todo
219 * @sa
220 * @author Mai Daftedar
221 * @date 25 March 2012
222 * @version 1.0
223 */
Tony Cho94bdfe42015-09-30 18:44:27 +0900224struct channel_attr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900225 u8 u8SetChan;
Tony Cho326b3232015-09-21 12:16:42 +0900226};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900227
228/*!
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900229 * @struct tstrScanComplete
230 * @brief hold received Async. Scan Complete message body
231 * @details
232 * @todo
233 * @sa
234 * @author zsalah
235 * @date 25 March 2012
236 * @version 1.0
237 */
238/*typedef struct _tstrScanComplete
239 * {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900240 * u8* pu8Buffer;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900241 * u32 u32Length;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900242 * } tstrScanComplete;*/
243
244/*!
Tony Cho7f33fec2015-09-30 18:44:30 +0900245 * @struct beacon_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900246 * @brief Set Beacon message body
247 * @details
248 * @todo
249 * @sa
250 * @author Adham Abozaeid
251 * @date 10 July 2012
252 * @version 1.0
253 */
Tony Cho7f33fec2015-09-30 18:44:30 +0900254struct beacon_attr {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900255 u32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */
256 u32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900257 * (including the current frame) appear before the next DTIM */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900258 u32 u32HeadLen; /*!< Length of the head buffer in bytes */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900259 u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900260 * from the beacon's start till the TIM element, NOT including the TIM */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900261 u32 u32TailLen; /*!< Length of the tail buffer in bytes */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900262 u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900263 * after the TIM inormation element */
Tony Cho902362b2015-09-21 12:16:44 +0900264};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900265
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900266/*!
Tony Cho641210a2015-09-21 12:16:52 +0900267 * @struct set_multicast
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900268 * @brief set Multicast filter Address
269 * @details
270 * @todo
271 * @sa
272 * @author Abdelrahman Sobhy
273 * @date 30 August 2013
274 * @version 1.0 Description
275 */
276
Tony Cho641210a2015-09-21 12:16:52 +0900277struct set_multicast {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900278 bool bIsEnabled;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900279 u32 u32count;
Tony Cho641210a2015-09-21 12:16:52 +0900280};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900281
282/*!
Tony Chob4e644e2015-09-21 12:17:00 +0900283 * @struct del_all_sta
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900284 * @brief Deauth station message body
285 * @details
286 * @todo
287 * @sa
288 * @author Mai Daftedar
289 * @date 09 April 2014
290 * @version 1.0 Description
291 */
Tony Chob4e644e2015-09-21 12:17:00 +0900292struct del_all_sta {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900293 u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN];
294 u8 u8Num_AssocSta;
Tony Chob4e644e2015-09-21 12:17:00 +0900295};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900296
297/*!
Tony Chofb93a1e2015-09-21 12:16:57 +0900298 * @struct del_sta
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900299 * @brief Delete station message body
300 * @details
301 * @todo
302 * @sa
303 * @author Adham Abozaeid
304 * @date 15 July 2012
305 * @version 1.0 Description
306 */
Tony Chofb93a1e2015-09-21 12:16:57 +0900307struct del_sta {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900308 u8 au8MacAddr[ETH_ALEN];
Tony Chofb93a1e2015-09-21 12:16:57 +0900309};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900310
311/*!
Tony Cho5a008f12015-09-21 12:16:48 +0900312 * @struct power_mgmt_param
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900313 * @brief Power management message body
314 * @details
315 * @todo
316 * @sa
317 * @author Adham Abozaeid
318 * @date 24 November 2012
319 * @version 1.0
320 */
Tony Cho5a008f12015-09-21 12:16:48 +0900321struct power_mgmt_param {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900322
Dean Lee72ed4dc2015-06-12 14:11:44 +0900323 bool bIsEnabled;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900324 u32 u32Timeout;
Tony Cho5a008f12015-09-21 12:16:48 +0900325};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900326
327/*!
Tony Cho15191ea2015-09-21 12:16:50 +0900328 * @struct set_ip_addr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900329 * @brief set IP Address message body
330 * @details
331 * @todo
332 * @sa
333 * @author Abdelrahman Sobhy
334 * @date 30 August 2013
335 * @version 1.0 Description
336 */
Tony Cho15191ea2015-09-21 12:16:50 +0900337struct set_ip_addr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900338 u8 *au8IPAddr;
339 u8 idx;
Tony Cho15191ea2015-09-21 12:16:50 +0900340};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900341
342/*!
Tony Cho3d1eac02015-09-21 12:16:49 +0900343 * @struct sta_inactive_t
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900344 * @brief Get station message body
345 * @details
346 * @todo
347 * @sa
348 * @author Mai Daftedar
349 * @date 16 April 2013
350 * @version 1.0
351 */
Tony Cho3d1eac02015-09-21 12:16:49 +0900352struct sta_inactive_t {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900353 u8 mac[6];
Tony Cho3d1eac02015-09-21 12:16:49 +0900354};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900355/**/
356/*!
Tony Chodfc76632015-09-21 12:16:34 +0900357 * @union message_body
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900358 * @brief Message body for the Host Interface message_q
359 * @details
360 * @todo
361 * @sa
362 * @author Mostafa Abu Bakr
363 * @date 25 March 2012
364 * @version 1.0
365 */
Tony Chodfc76632015-09-21 12:16:34 +0900366union message_body {
Tony Cho4528bdb2015-09-30 18:44:20 +0900367 struct scan_attr scan_info;
Tony Cho3f501972015-09-30 18:44:21 +0900368 struct connect_attr con_info;
Tony Cho02d19462015-09-30 18:44:22 +0900369 struct rcvd_net_info net_info;
Tony Cho66add622015-09-30 18:44:23 +0900370 struct rcvd_async_info async_info;
Tony Cho18990bf2015-09-30 18:44:24 +0900371 struct key_attr key_info;
Tony Choa2340c32015-09-30 18:44:25 +0900372 struct cfg_param_attr cfg_info;
Tony Choffd6dbc2015-09-30 18:44:28 +0900373 struct channel_attr channel_info;
Tony Choa98491e2015-09-30 18:44:31 +0900374 struct beacon_attr beacon_info;
Tony Choca8f47f2015-09-30 18:44:32 +0900375 struct add_sta_param add_sta_info;
Tony Cho889c25b2015-09-30 18:44:33 +0900376 struct del_sta del_sta_info;
Tony Cho4a930962015-09-30 18:44:34 +0900377 struct add_sta_param edit_sta_info;
Tony Cho49e1f812015-09-30 18:44:36 +0900378 struct power_mgmt_param pwr_mgmt_info;
Tony Cho66bac7f2015-09-30 18:44:37 +0900379 struct sta_inactive_t mac_info;
Tony Chofb2d65e2015-09-30 18:44:39 +0900380 struct set_ip_addr ip_info;
Tony Cho5e4377e2015-09-30 18:44:38 +0900381 struct drv_handler drv;
Tony Choa079cf4d2015-09-30 18:55:05 +0900382 struct set_multicast multicast_info;
Tony Cho00c46302015-09-30 18:55:06 +0900383 struct op_mode mode;
Tony Cho15326e22015-09-30 18:55:07 +0900384 struct set_mac_addr set_mac_info;
Tony Choa5848692015-09-30 18:55:08 +0900385 struct get_mac_addr get_mac_info;
Tony Choc833b472015-09-30 18:55:09 +0900386 struct ba_session_info session_info;
Tony Cho070d3652015-09-30 18:55:10 +0900387 struct remain_ch remain_on_ch;
Tony Chobc37c5d2015-09-21 12:16:59 +0900388 struct reg_frame strHostIfRegisterFrame;
Dean Lee576917a2015-06-15 11:58:57 +0900389 char *pUserData;
Tony Chob4e644e2015-09-21 12:17:00 +0900390 struct del_all_sta strHostIFDelAllSta;
Tony Chodfc76632015-09-21 12:16:34 +0900391};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900392
393/*!
Tony Cho3a8c41b2015-09-18 18:11:04 +0900394 * @struct struct host_if_msg
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900395 * @brief Host Interface message
396 * @details
397 * @todo
398 * @sa
399 * @author Mostafa Abu Bakr
400 * @date 25 March 2012
401 * @version 1.0
402 */
Tony Cho3a8c41b2015-09-18 18:11:04 +0900403struct host_if_msg {
Tony Choa9f812a2015-09-21 12:16:33 +0900404 u16 id; /*!< Message ID */
Tony Cho410c2482015-09-21 12:16:35 +0900405 union message_body body; /*!< Message body */
Johnny Kim11f58c82015-08-13 13:41:20 +0900406 tstrWILC_WFIDrv *drvHandler;
Tony Cho3a8c41b2015-09-18 18:11:04 +0900407};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900408
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900409typedef struct _tstrWidJoinReqExt {
Dean Lee576917a2015-06-15 11:58:57 +0900410 char SSID[MAX_SSID_LEN];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900411 u8 u8channel;
412 u8 BSSID[6];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900413} tstrWidJoinReqExt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900414
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900415/*Struct containg joinParam of each AP*/
416typedef struct _tstrJoinBssParam {
417 BSSTYPE_T bss_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900418 u8 dtim_period;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900419 u16 beacon_period;
420 u16 cap_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900421 u8 au8bssid[6];
Dean Lee576917a2015-06-15 11:58:57 +0900422 char ssid[MAX_SSID_LEN];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900423 u8 ssidLen;
424 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
425 u8 ht_capable;
426 u8 wmm_cap;
427 u8 uapsd_cap;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900428 bool rsn_found;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900429 u8 rsn_grp_policy;
430 u8 mode_802_11i;
431 u8 rsn_pcip_policy[3];
432 u8 rsn_auth_policy[3];
433 u8 rsn_cap[2];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900434 struct _tstrJoinParam *nextJoinBss;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900435 u32 tsf;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900436 u8 u8NoaEnbaled;
437 u8 u8OppEnable;
438 u8 u8CtWindow;
439 u8 u8Count;
440 u8 u8Index;
441 u8 au8Duration[4];
442 u8 au8Interval[4];
443 u8 au8StartTime[4];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900444} tstrJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900445/*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
446typedef struct _tstrBssTable {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900447 u8 u8noBssEntries;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900448 tstrJoinBssParam *head;
449 tstrJoinBssParam *tail;
450} tstrBssTable;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900451
452typedef enum {
453 SCAN_TIMER = 0,
454 CONNECT_TIMER = 1,
455 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
456} tenuScanConnTimer;
457
458/*****************************************************************************/
459/* */
460/* Global Variabls */
461/* */
462/*****************************************************************************/
Johnny Kimd42ab082015-08-20 16:32:52 +0900463/* Zero is not used, because a zero ID means termination */
464static tstrWILC_WFIDrv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
Daniel Machon6fdb3022015-07-06 19:48:04 +0200465tstrWILC_WFIDrv *terminated_handle;
466tstrWILC_WFIDrv *gWFiDrvHandle;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900467bool g_obtainingIP = false;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900468u8 P2P_LISTEN_STATE;
Arnd Bergmann1999bd52015-05-29 22:52:14 +0200469static struct task_struct *HostIFthreadHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900470static WILC_MsgQueueHandle gMsgQHostIF;
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200471static struct semaphore hSemHostIFthrdEnd;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900472
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200473struct semaphore hSemDeinitDrvHandle;
474static struct semaphore hWaitResponse;
475struct semaphore hSemHostIntDeinit;
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -0700476struct timer_list g_hPeriodicRSSI;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900477
478
479
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900480u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900481
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900482static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900483
Dean Lee72ed4dc2015-06-12 14:11:44 +0900484bool gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900485
Chaehyun Limca356ad2015-06-11 14:35:57 +0900486static s8 gs8Rssi;
487static s8 gs8lnkspd;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900488static u8 gu8Chnl;
489static u8 gs8SetIP[2][4];
490static u8 gs8GetIP[2][4];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900491static u32 gu32InactiveTime;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900492static u8 gu8DelBcn;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900493static u32 gu32WidConnRstHack;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900494
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900495u8 *gu8FlushedJoinReq;
496u8 *gu8FlushedInfoElemAsoc;
497u8 gu8Flushed11iMode;
498u8 gu8FlushedAuthType;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900499u32 gu32FlushedJoinReqSize;
500u32 gu32FlushedInfoElemAsocSize;
Johnny Kim8a625ca2015-08-20 16:32:50 +0900501tstrWILC_WFIDrv *gu8FlushedJoinReqDrvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900502#define REAL_JOIN_REQ 0
503#define FLUSHED_JOIN_REQ 1
504#define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
505
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900506static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900507
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900508extern void chip_sleep_manually(u32 u32SleepTime);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900509extern int linux_wlan_get_num_conn_ifcs(void);
510
Johnny Kimd42ab082015-08-20 16:32:52 +0900511static int add_handler_in_list(tstrWILC_WFIDrv *handler)
512{
513 int i;
514
515 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
516 if (!wfidrv_list[i]) {
517 wfidrv_list[i] = handler;
518 return 0;
519 }
520 }
521
522 return -ENOBUFS;
523}
524
525static int remove_handler_in_list(tstrWILC_WFIDrv *handler)
526{
527 int i;
528
529 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
530 if (wfidrv_list[i] == handler) {
531 wfidrv_list[i] = NULL;
532 return 0;
533 }
534 }
535
536 return -EINVAL;
537}
538
539static int get_id_from_handler(tstrWILC_WFIDrv *handler)
540{
541 int i;
542
543 if (!handler)
544 return 0;
545
546 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
547 if (wfidrv_list[i] == handler)
548 return i;
549 }
550
551 return 0;
552}
553
554static tstrWILC_WFIDrv *get_handler_from_id(int id)
555{
Dan Carpenter6ae9ac02015-09-15 09:54:33 +0300556 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
Johnny Kimd42ab082015-08-20 16:32:52 +0900557 return NULL;
558 return wfidrv_list[id];
559}
560
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900561/**
562 * @brief Handle_SetChannel
563 * @details Sending config packet to firmware to set channel
Tony Cho94bdfe42015-09-30 18:44:27 +0900564 * @param[in] struct channel_attr *pstrHostIFSetChan
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900565 * @return Error code.
566 * @author
567 * @date
568 * @version 1.0
569 */
Tony Cho326b3232015-09-21 12:16:42 +0900570static s32 Handle_SetChannel(tstrWILC_WFIDrv *drvHandler,
Tony Cho94bdfe42015-09-30 18:44:27 +0900571 struct channel_attr *pstrHostIFSetChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900572{
573
Leo Kime6e12662015-09-16 18:36:03 +0900574 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900575 tstrWID strWID;
576 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
577
578 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900579 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900580 strWID.enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900581 strWID.ps8WidVal = (char *)&(pstrHostIFSetChan->u8SetChan);
582 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900583
584 PRINT_D(HOSTINF_DBG, "Setting channel\n");
585 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900586 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
587 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900588 if (s32Error) {
589 PRINT_ER("Failed to set channel\n");
Leo Kim24db7132015-09-16 18:36:01 +0900590 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900591 }
592
593 return s32Error;
594}
595/**
596 * @brief Handle_SetWfiDrvHandler
597 * @details Sending config packet to firmware to set driver handler
Tony Cho127f9d92015-09-21 12:16:51 +0900598 * @param[in] void * drvHandler,
599 * struct drv_handler *pstrHostIfSetDrvHandler
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900600 * @return Error code.
601 * @author
602 * @date
603 * @version 1.0
604 */
Johnny Kim53a84402015-08-20 16:32:51 +0900605static s32 Handle_SetWfiDrvHandler(tstrWILC_WFIDrv *drvHandler,
Tony Cho127f9d92015-09-21 12:16:51 +0900606 struct drv_handler *pstrHostIfSetDrvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900607{
608
Leo Kime6e12662015-09-16 18:36:03 +0900609 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900610 tstrWID strWID;
Johnny Kim53a84402015-08-20 16:32:51 +0900611 tstrWILC_WFIDrv *pstrWFIDrv = drvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900612
613
614 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900615 strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900616 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900617 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900618 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900619
620 /*Sending Cfg*/
621
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900622 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
623 pstrHostIfSetDrvHandler->u32Address);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900624
Johnny Kim53a84402015-08-20 16:32:51 +0900625 if (pstrWFIDrv == NULL)
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200626 up(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900627
628
629 if (s32Error) {
630 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900631 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900632 }
633
634 return s32Error;
635}
636
637/**
638 * @brief Handle_SetWfiAPDrvHandler
639 * @details Sending config packet to firmware to set driver handler
640 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
641 * @return Error code.
642 * @author
643 * @date
644 * @version 1.0
645 */
Tony Cho801bee52015-09-21 12:16:53 +0900646static s32 Handle_SetOperationMode(tstrWILC_WFIDrv *drvHandler,
647 struct op_mode *pstrHostIfSetOperationMode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900648{
649
Leo Kime6e12662015-09-16 18:36:03 +0900650 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900651 tstrWID strWID;
652 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
653
654
655 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900656 strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900657 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900658 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900659 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900660
661 /*Sending Cfg*/
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +0200662 PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900663
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900664 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
665 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900666
667
Johnny Kimc590b9a2015-09-08 17:07:59 +0900668 if ((pstrHostIfSetOperationMode->u32Mode) == IDLE_MODE)
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200669 up(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900670
671
672 if (s32Error) {
673 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900674 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900675 }
676
677 return s32Error;
678}
679
680/**
681 * @brief host_int_set_IPAddress
682 * @details Setting IP address params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900683 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900684 * @return Error code.
685 * @author
686 * @date
687 * @version 1.0
688 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900689s32 Handle_set_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900690{
691
Leo Kime6e12662015-09-16 18:36:03 +0900692 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900693 tstrWID strWID;
694 char firmwareIPAddress[4] = {0};
695 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
696
697 if (pu8IPAddr[0] < 192)
698 pu8IPAddr[0] = 0;
699
Luis de Bethencourtb3a02832015-06-26 17:40:25 +0200700 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900701
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900702 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900703
704 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900705 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900706 strWID.enuWIDtype = WID_STR;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900707 strWID.ps8WidVal = (u8 *)pu8IPAddr;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900708 strWID.s32ValueSize = IP_ALEN;
709
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900710 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
711 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900712
713
Johnny Kim218dc402015-08-13 13:41:19 +0900714 host_int_get_ipaddress(drvHandler, firmwareIPAddress, idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900715
716 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +0900717 PRINT_ER("Failed to set IP address\n");
718 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900719 }
720
Leo Kim24db7132015-09-16 18:36:01 +0900721 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900722
723 return s32Error;
724}
725
726
727/**
728 * @brief Handle_get_IPAddress
729 * @details Setting IP address params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900730 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900731 * @return Error code.
732 * @author
733 * @date
734 * @version 1.0
735 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900736s32 Handle_get_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900737{
738
Leo Kime6e12662015-09-16 18:36:03 +0900739 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900740 tstrWID strWID;
741 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
742
743 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900744 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900745 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +0900746 strWID.ps8WidVal = kmalloc(IP_ALEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900747 strWID.s32ValueSize = IP_ALEN;
748
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900749 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
750 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900751
Luis de Bethencourtb3a02832015-06-26 17:40:25 +0200752 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900753
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900754 memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900755
756 /*get the value by searching the local copy*/
Chaehyun Lim49188af2015-08-11 10:32:41 +0900757 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900758
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900759 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
Johnny Kim218dc402015-08-13 13:41:19 +0900760 host_int_setup_ipaddress(pstrWFIDrv, gs8SetIP[idx], idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900761
Leo Kime6e12662015-09-16 18:36:03 +0900762 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900763 PRINT_ER("Failed to get IP address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900764 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900765 }
766
Leo Kim24db7132015-09-16 18:36:01 +0900767 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
768 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
769 PRINT_INFO(HOSTINF_DBG, "\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900770
771 return s32Error;
772}
773
774
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900775/**
776 * @brief Handle_SetMacAddress
777 * @details Setting mac address
778 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
779 * @return Error code.
780 * @author Amr Abdel-Moghny
781 * @date November 2013
782 * @version 7.0
783 */
Tony Chob7611a82015-09-21 12:16:54 +0900784static s32 Handle_SetMacAddress(tstrWILC_WFIDrv *drvHandler,
785 struct set_mac_addr *pstrHostIfSetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900786{
787
Leo Kime6e12662015-09-16 18:36:03 +0900788 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900789 tstrWID strWID;
790 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Glen Leef3052582015-09-10 12:03:04 +0900791 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +0200792
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900793 if (mac_buf == NULL) {
794 PRINT_ER("No buffer to send mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +0900795 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900796 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900797 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900798
799 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900800 strWID.u16WIDid = (u16)WID_MAC_ADDR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900801 strWID.enuWIDtype = WID_STR;
802 strWID.ps8WidVal = mac_buf;
803 strWID.s32ValueSize = ETH_ALEN;
Alexander Kuleshov310a28f2015-09-04 00:48:14 +0600804 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900805 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900806 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
807 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900808 if (s32Error) {
809 PRINT_ER("Failed to set mac address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900810 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900811 }
812
Chaehyun Lim49188af2015-08-11 10:32:41 +0900813 kfree(mac_buf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900814 return s32Error;
815}
816
817
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900818/**
819 * @brief Handle_GetMacAddress
820 * @details Getting mac address
821 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
822 * @return Error code.
823 * @author Amr Abdel-Moghny
824 * @date JAN 2013
825 * @version 8.0
826 */
Tony Chofcd27c52015-09-21 12:16:55 +0900827static s32 Handle_GetMacAddress(tstrWILC_WFIDrv *drvHandler,
828 struct get_mac_addr *pstrHostIfGetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900829{
830
Leo Kime6e12662015-09-16 18:36:03 +0900831 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900832 tstrWID strWID;
833
834 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900835 strWID.u16WIDid = (u16)WID_MAC_ADDR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900836 strWID.enuWIDtype = WID_STR;
837 strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress;
838 strWID.s32ValueSize = ETH_ALEN;
839
840 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900841 s32Error = send_config_pkt(GET_CFG, &strWID, 1, false,
842 get_id_from_handler(drvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900843 if (s32Error) {
844 PRINT_ER("Failed to get mac address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900845 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900846 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200847 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900848
849 return s32Error;
850}
851
852
853/**
854 * @brief Handle_CfgParam
855 * @details Sending config packet to firmware to set CFG params
Tony Cho361ff842015-09-21 12:16:41 +0900856 * @param[in] struct cfg_param_attr *strHostIFCfgParamAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900857 * @return Error code.
858 * @author
859 * @date
860 * @version 1.0
861 */
Tony Cho361ff842015-09-21 12:16:41 +0900862static s32 Handle_CfgParam(tstrWILC_WFIDrv *drvHandler,
863 struct cfg_param_attr *strHostIFCfgParamAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900864{
Leo Kime6e12662015-09-16 18:36:03 +0900865 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900866 tstrWID strWIDList[32];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900867 u8 u8WidCnt = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900868 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
869
870
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200871 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900872
873
874 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
875
876 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) {
877 /*----------------------------------------------------------*/
878 /*Input Value: INFRASTRUCTURE = 1, */
879 /* INDEPENDENT= 2, */
880 /* ANY_BSS= 3 */
881 /*----------------------------------------------------------*/
882 /* validate input then copy>> need to check value 4 and 5 */
883 if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) {
884 strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900885 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900886 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900887 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900888 pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900889 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900890 PRINT_ER("check value 6 over\n");
891 s32Error = -EINVAL;
892 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900893 }
894 u8WidCnt++;
895 }
896 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) {
897 /*------------------------------------------------------*/
898 /*Input Values: OPEN_SYSTEM = 0, */
899 /* SHARED_KEY = 1, */
900 /* ANY = 2 */
901 /*------------------------------------------------------*/
902 /*validate Possible values*/
903 if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) {
904 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900905 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900906 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900907 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900908 pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900909 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900910 PRINT_ER("Impossible value \n");
911 s32Error = -EINVAL;
912 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900913 }
914 u8WidCnt++;
915 }
916 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) {
917 /* range is 1 to 65535. */
918 if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) {
919 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900920 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900921 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900922 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900923 pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
924 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900925 PRINT_ER("Range(1 ~ 65535) over\n");
926 s32Error = -EINVAL;
927 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900928 }
929 u8WidCnt++;
930 }
931 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) {
932 /*-----------------------------------------------------------*/
933 /*Input Values: NO_POWERSAVE = 0, */
934 /* MIN_FAST_PS = 1, */
935 /* MAX_FAST_PS = 2, */
936 /* MIN_PSPOLL_PS = 3, */
937 /* MAX_PSPOLL_PS = 4 */
938 /*----------------------------------------------------------*/
939 if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) {
940 strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900941 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900942 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900943 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900944 pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900945 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900946 PRINT_ER("Invalide power mode\n");
947 s32Error = -EINVAL;
948 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900949 }
950 u8WidCnt++;
951 }
952 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) {
953 /* range from 1 to 256 */
954 if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) {
955 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900956 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900957 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900958 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900959 pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
960 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900961 PRINT_ER("Range(1~256) over\n");
962 s32Error = -EINVAL;
963 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900964 }
965 u8WidCnt++;
966 }
967 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) {
968 /* range from 1 to 256 */
969 if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) {
970 strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900971 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900972
973 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900974 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900975 pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
976 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900977 PRINT_ER("Range(1~256) over\n");
978 s32Error = -EINVAL;
979 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900980 }
981 u8WidCnt++;
982 }
983 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) {
984
985 if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) {
986 strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900987 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900988 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900989 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900990 pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
991 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900992 PRINT_ER("Threshold Range fail\n");
993 s32Error = -EINVAL;
994 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900995 }
996 u8WidCnt++;
997 }
998 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) {
999 /* range 256 to 65535 */
1000 if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) {
1001 strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001002 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001003 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001004 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001005 pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1006 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001007 PRINT_ER("Threshold Range fail\n");
1008 s32Error = -EINVAL;
1009 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001010 }
1011 u8WidCnt++;
1012 }
1013 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) {
1014 /*-----------------------------------------------------*/
1015 /*Input Values: Short= 0, */
1016 /* Long= 1, */
1017 /* Auto= 2 */
1018 /*------------------------------------------------------*/
1019 if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) {
1020 strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001021 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001022 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001023 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001024 pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1025 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001026 PRINT_ER("Preamle Range(0~2) over\n");
1027 s32Error = -EINVAL;
1028 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001029 }
1030 u8WidCnt++;
1031 }
1032 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) {
1033 if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) {
1034 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001035 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001036 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001037 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001038 pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001039 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001040 PRINT_ER("Short slot(2) over\n");
1041 s32Error = -EINVAL;
1042 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001043 }
1044 u8WidCnt++;
1045 }
1046 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) {
1047 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1048 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1049 /* this information is useful for external supplicant */
1050 /*Input Values: 1 for enable and 0 for disable. */
1051 if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) {
1052 strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001053 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001054 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001055 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001056 pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001057 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001058 PRINT_ER("TXOP prot disable\n");
1059 s32Error = -EINVAL;
1060 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001061 }
1062 u8WidCnt++;
1063 }
1064 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) {
1065 /* range is 1 to 65535. */
1066 if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) {
1067 strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001068 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001069 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001070 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001071 pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1072 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001073 PRINT_ER("Beacon interval(1~65535) fail\n");
1074 s32Error = -EINVAL;
1075 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001076 }
1077 u8WidCnt++;
1078 }
1079 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) {
1080 /* range is 1 to 255. */
1081 if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) {
1082 strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001083 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001084 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001085 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001086 pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1087 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001088 PRINT_ER("DTIM range(1~255) fail\n");
1089 s32Error = -EINVAL;
1090 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001091 }
1092 u8WidCnt++;
1093 }
1094 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) {
1095 /*----------------------------------------------------------------------*/
1096 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1097 /* SITE_SURVEY_ALL_CH = 1, */
1098 /* SITE_SURVEY_OFF = 2 */
1099 /*----------------------------------------------------------------------*/
1100 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) {
1101 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001102 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001103 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001104 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001105 pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001106 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001107 PRINT_ER("Site survey disable\n");
1108 s32Error = -EINVAL;
1109 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001110 }
1111 u8WidCnt++;
1112 }
1113 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) {
1114 /* range is 1 to 65535. */
1115 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) {
1116 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001117 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001118 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001119 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001120 pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1121 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001122 PRINT_ER("Site survey scan time(1~65535) over\n");
1123 s32Error = -EINVAL;
1124 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001125 }
1126 u8WidCnt++;
1127 }
1128 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) {
1129 /* range is 1 to 65535. */
1130 if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) {
1131 strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001132 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001133 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001134 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001135 pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1136 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001137 PRINT_ER("Active scan time(1~65535) over\n");
1138 s32Error = -EINVAL;
1139 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001140 }
1141 u8WidCnt++;
1142 }
1143 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) {
1144 /* range is 1 to 65535. */
1145 if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) {
1146 strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001147 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001148 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001149 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001150 pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1151 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001152 PRINT_ER("Passive scan time(1~65535) over\n");
1153 s32Error = -EINVAL;
1154 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001155 }
1156 u8WidCnt++;
1157 }
1158 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) {
1159 CURRENT_TX_RATE_T curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate;
1160 /*----------------------------------------------------------------------*/
1161 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1162 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1163 /*----------------------------------------------------------------------*/
1164 /* validate rate */
1165 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
1166 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
1167 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
1168 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
1169 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
1170 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
1171 strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001172 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001173 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001174 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001175 pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001176 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001177 PRINT_ER("out of TX rate\n");
1178 s32Error = -EINVAL;
1179 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001180 }
1181 u8WidCnt++;
1182 }
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001183 s32Error = send_config_pkt(SET_CFG, strWIDList, u8WidCnt, false,
1184 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001185
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001186 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001187 PRINT_ER("Error in setting CFG params\n");
1188
Leo Kim24db7132015-09-16 18:36:01 +09001189ERRORHANDLER:
Arnd Bergmann83383ea2015-06-01 21:06:43 +02001190 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001191 return s32Error;
1192}
1193
1194
1195/**
1196 * @brief Handle_wait_msg_q_empty
1197 * @details this should be the last msg and then the msg Q becomes idle
1198 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1199 * @return Error code.
1200 * @author
1201 * @date
1202 * @version 1.0
1203 */
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001204static s32 Handle_wait_msg_q_empty(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001205{
Leo Kime6e12662015-09-16 18:36:03 +09001206 s32 s32Error = 0;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02001207
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001208 g_wilc_initialized = 0;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02001209 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001210 return s32Error;
1211}
1212
1213/**
1214 * @brief Handle_Scan
1215 * @details Sending config packet to firmware to set the scan params
Tony Choc476feb2015-09-21 12:16:36 +09001216 * @param[in] struct scan_attr *pstrHostIFscanAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001217 * @return Error code.
1218 * @author
1219 * @date
1220 * @version 1.0
1221 */
Tony Choc476feb2015-09-21 12:16:36 +09001222static s32 Handle_Scan(tstrWILC_WFIDrv *drvHandler,
1223 struct scan_attr *pstrHostIFscanAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001224{
Leo Kime6e12662015-09-16 18:36:03 +09001225 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001226 tstrWID strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001227 u32 u32WidsCount = 0;
1228 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001229 u8 *pu8Buffer;
1230 u8 valuesize = 0;
1231 u8 *pu8HdnNtwrksWidVal = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001232 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1233
1234 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001235 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", pstrWFIDrv->enuHostIFstate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001236
1237 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
1238 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
1239
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001240 if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) {
1241 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1242 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate);
Leo Kim24db7132015-09-16 18:36:01 +09001243 PRINT_ER("Already scan\n");
1244 s32Error = -EBUSY;
1245 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001246 }
1247
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001248 if (g_obtainingIP || connecting) {
1249 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +09001250 PRINT_ER("Don't do obss scan\n");
1251 s32Error = -EBUSY;
1252 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001253 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001254
1255 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1256
1257
1258 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0;
1259
Chaehyun Limd85f5322015-06-11 14:35:54 +09001260 strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001261 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1262
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001263 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001264 valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
Glen Leef3052582015-09-10 12:03:04 +09001265 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001266 strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001267 if (strWIDList[u32WidsCount].ps8WidVal != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001268 pu8Buffer = strWIDList[u32WidsCount].ps8WidVal;
1269
1270 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
1271
1272 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
1273
1274 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1275 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001276 memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001277 pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1278 }
1279
1280
1281
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001282 strWIDList[u32WidsCount].s32ValueSize = (s32)(valuesize + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001283 u32WidsCount++;
1284 }
1285
1286 /*filling cfg param array*/
1287
1288 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1289 {
1290 /* IEs to be inserted in Probe Request */
1291 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE;
1292 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1293 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs;
1294 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen;
1295 u32WidsCount++;
1296 }
1297
1298 /*Scan Type*/
1299 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE;
1300 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001301 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001302 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001303 u32WidsCount++;
1304
1305 /*list of channels to be scanned*/
1306 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST;
1307 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1308
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001309 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
1310 int i;
1311
1312 for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001313 if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001314 pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001315 }
1316 }
1317
1318 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList;
1319 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen;
1320 u32WidsCount++;
1321
1322 /*Scan Request*/
1323 strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ;
1324 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001325 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001326 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001327 u32WidsCount++;
1328
1329 /*keep the state as is , no need to change it*/
1330 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1331
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301332 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001333 gbScanWhileConnected = true;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301334 else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001335 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001336
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001337 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount, false,
1338 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001339
Leo Kim24db7132015-09-16 18:36:01 +09001340 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001341 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09001342 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001343 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001344
Leo Kim24db7132015-09-16 18:36:01 +09001345ERRORHANDLER:
1346 if (s32Error) {
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07001347 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001348 /*if there is an ongoing scan request*/
1349 Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED);
1350 }
1351
1352 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1353 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001354 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001355 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1356 }
1357
1358 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1359 if (pstrHostIFscanAttr->pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001360 kfree(pstrHostIFscanAttr->pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001361 pstrHostIFscanAttr->pu8IEs = NULL;
1362 }
1363 if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001364 kfree(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001365 pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
1366 }
1367
1368 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1369 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001370 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001371 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1372 }
1373
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001374 if (pu8HdnNtwrksWidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001375 kfree(pu8HdnNtwrksWidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001376
1377 return s32Error;
1378}
1379
1380/**
1381 * @brief Handle_ScanDone
1382 * @details Call scan notification callback function
1383 * @param[in] NONE
1384 * @return Error code.
1385 * @author
1386 * @date
1387 * @version 1.0
1388 */
Johnny Kim2b05df52015-08-13 13:41:21 +09001389static s32 Handle_ScanDone(tstrWILC_WFIDrv *drvHandler, tenuScanEvent enuEvent)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001390{
Leo Kime6e12662015-09-16 18:36:03 +09001391 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001392
1393 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
1394
1395
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001396 u8 u8abort_running_scan;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001397 tstrWID strWID;
1398
1399
1400 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
1401
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001402 /*Ask FW to abort the running scan, if any*/
1403 if (enuEvent == SCAN_EVENT_ABORTED) {
1404 PRINT_D(GENERIC_DBG, "Abort running scan\n");
1405 u8abort_running_scan = 1;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001406 strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001407 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001408 strWID.ps8WidVal = (s8 *)&u8abort_running_scan;
Dean Lee576917a2015-06-15 11:58:57 +09001409 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001410
1411 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001412 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
1413 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09001414 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001415 PRINT_ER("Failed to set abort running scan\n");
Leo Kim24db7132015-09-16 18:36:01 +09001416 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001417 }
1418 }
1419
1420 if (pstrWFIDrv == NULL) {
1421 PRINT_ER("Driver handler is NULL\n");
1422 return s32Error;
1423 }
1424
1425 /*if there is an ongoing scan request*/
1426 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001427 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001428 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1429 /*delete current scan request*/
1430 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1431 }
1432
1433 return s32Error;
1434}
1435
1436/**
1437 * @brief Handle_Connect
1438 * @details Sending config packet to firmware to starting connection
Tony Cho120ae592015-09-21 12:16:37 +09001439 * @param[in] struct connect_attr *pstrHostIFconnectAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001440 * @return Error code.
1441 * @author
1442 * @date
1443 * @version 1.0
1444 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001445u8 u8ConnectedSSID[6] = {0};
Tony Cho120ae592015-09-21 12:16:37 +09001446static s32 Handle_Connect(tstrWILC_WFIDrv *drvHandler,
1447 struct connect_attr *pstrHostIFconnectAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001448{
1449 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
Leo Kime6e12662015-09-16 18:36:03 +09001450 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001451 tstrWID strWIDList[8];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001452 u32 u32WidsCount = 0, dummyval = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001453 /* char passphrase[] = "12345678"; */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001454 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001455 tstrJoinBssParam *ptstrJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001456
1457 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1458
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001459 /* if we try to connect to an already connected AP then discard the request */
1460
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001461 if (memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001462
Leo Kime6e12662015-09-16 18:36:03 +09001463 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001464 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1465 return s32Error;
1466 }
1467
1468 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1469
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001470 ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams;
1471 if (ptstrJoinBssParam == NULL) {
1472 PRINT_ER("Required BSSID not found\n");
Leo Kim24db7132015-09-16 18:36:01 +09001473 s32Error = -ENOENT;
1474 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001475 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001476
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001477 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001478 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001479 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001480 }
1481
1482 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1483 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001484 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssidLen + 1, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001485 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001486 pstrHostIFconnectAttr->ssidLen);
1487 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1488 }
1489
1490 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1491 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001492 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001493 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001494 pstrHostIFconnectAttr->IEsLen);
1495 }
1496
1497 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1498 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1499 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1500 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1501
1502 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
1503 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001504 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001505 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001506 u32WidsCount++;
1507
1508 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_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_FAILED_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 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1521 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1522 {
1523 /* IEs to be inserted in Association Request */
1524 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1525 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1526 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1527 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1528 u32WidsCount++;
1529
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001530 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001531
1532 gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001533 gu8FlushedInfoElemAsoc = kmalloc(gu32FlushedInfoElemAsocSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001534 memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1535 gu32FlushedInfoElemAsocSize);
1536 }
1537 }
Chaehyun Limd85f5322015-06-11 14:35:54 +09001538 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001539 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001540 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001541 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001542 u32WidsCount++;
1543
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001544 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001545 gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security;
1546
1547 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1548
1549
Chaehyun Limd85f5322015-06-11 14:35:54 +09001550 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001551 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001552 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001553 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001554 u32WidsCount++;
1555
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001556 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001557 gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001558
1559 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1560 /*
Chaehyun Limd85f5322015-06-11 14:35:54 +09001561 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001562 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1563 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001564 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001565 * u32WidsCount++;
1566 */
1567
1568 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1569 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
1570
Chaehyun Limd85f5322015-06-11 14:35:54 +09001571 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001572 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1573
1574 /*Sending NoA attributes during connection*/
1575 strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */
Glen Leef3052582015-09-10 12:03:04 +09001576 strWIDList[u32WidsCount].ps8WidVal = kmalloc(strWIDList[u32WidsCount].s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001577
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001578 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001579 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize;
Glen Leef3052582015-09-10 12:03:04 +09001580 gu8FlushedJoinReq = kmalloc(gu32FlushedJoinReqSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001581 }
Leo Kim24db7132015-09-16 18:36:01 +09001582 if (strWIDList[u32WidsCount].ps8WidVal == NULL) {
1583 s32Error = -EFAULT;
1584 goto ERRORHANDLER;
1585 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001586
1587 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1588
1589
1590 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001591 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001592 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1593 }
1594 pu8CurrByte += MAX_SSID_LEN;
1595
1596 /* BSS type*/
1597 *(pu8CurrByte++) = INFRASTRUCTURE;
1598 /* Channel*/
1599 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1600 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1601 } else {
1602 PRINT_ER("Channel out of range\n");
1603 *(pu8CurrByte++) = 0xFF;
1604 }
1605 /* Cap Info*/
1606 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1607 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1608 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1609
1610 /* sa*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001611 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001612 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001613 pu8CurrByte += 6;
1614
1615 /* bssid*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001616 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001617 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001618 pu8CurrByte += 6;
1619
1620 /* Beacon Period*/
1621 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1622 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1623 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1624 /* DTIM Period*/
1625 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1626 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1627 /* Supported rates*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001628 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001629 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1630
1631 /* wmm cap*/
1632 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1633 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1634 /* uapsd cap*/
1635 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1636
1637 /* ht cap*/
1638 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1639 /* copy this information to the user request */
1640 pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1641
1642 /* rsn found*/
1643 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1644 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1645 /* rsn group policy*/
1646 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1647 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1648 /* mode_802_11i*/
1649 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1650 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1651 /* rsn pcip policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001652 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001653 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1654
1655 /* rsn auth policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001656 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001657 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1658
1659 /* rsn auth policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001660 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001661 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1662
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001663 *(pu8CurrByte++) = REAL_JOIN_REQ;
1664
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001665 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1666 if (ptstrJoinBssParam->u8NoaEnbaled) {
1667 PRINT_D(HOSTINF_DBG, "NOA present\n");
1668
1669 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1670 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1671 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1672 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1673
1674 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1675
1676 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1677
1678 if (ptstrJoinBssParam->u8OppEnable)
1679 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1680
1681 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1682
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001683 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001684
1685 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1686
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001687 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001688
1689 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1690
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001691 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001692
1693 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1694
1695 } else
1696 PRINT_D(HOSTINF_DBG, "NOA not present\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001697
1698 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1699 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001700 u32WidsCount++;
1701
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001702 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1703 * firmware at chip reset when processing the WIDs of the Connect Request.
1704 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1705 /* ////////////////////// */
1706 gu32WidConnRstHack = 0;
1707 /* ////////////////////// */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001708
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001709 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001710 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
Johnny Kim8a625ca2015-08-20 16:32:50 +09001711 gu8FlushedJoinReqDrvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001712 }
1713
1714 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1715
1716 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001717 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001718
Alexander Kuleshov310a28f2015-09-04 00:48:14 +06001719 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->pu8bssid);
1720 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001721 }
1722
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001723 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount, false,
1724 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001725 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09001726 PRINT_ER("failed to send config packet\n");
1727 s32Error = -EFAULT;
1728 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001729 } else {
1730 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1731 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1732 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001733
Leo Kim24db7132015-09-16 18:36:01 +09001734ERRORHANDLER:
1735 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001736 tstrConnectInfo strConnectInfo;
1737
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07001738 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001739
1740 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1741
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001742 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001743
1744 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001745 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001746 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001747
1748 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1749 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001750 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001751 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001752 pstrHostIFconnectAttr->pu8IEs,
1753 pstrHostIFconnectAttr->IEsLen);
1754 }
1755
1756 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1757 &strConnectInfo,
1758 MAC_DISCONNECTED,
1759 NULL,
1760 pstrHostIFconnectAttr->pvUserArg);
1761 /*Change state to idle*/
1762 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
1763 /* Deallocation */
1764 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001765 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001766 strConnectInfo.pu8ReqIEs = NULL;
1767 }
1768
1769 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001770 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001771 }
1772 }
1773
1774 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
1775 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
1776 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001777 kfree(pstrHostIFconnectAttr->pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001778 pstrHostIFconnectAttr->pu8bssid = NULL;
1779 }
1780
1781 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
1782 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001783 kfree(pstrHostIFconnectAttr->pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001784 pstrHostIFconnectAttr->pu8ssid = NULL;
1785 }
1786
1787 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
1788 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001789 kfree(pstrHostIFconnectAttr->pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001790 pstrHostIFconnectAttr->pu8IEs = NULL;
1791 }
1792
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001793 if (pu8CurrByte != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001794 kfree(pu8CurrByte);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001795 return s32Error;
1796}
1797
1798/**
1799 * @brief Handle_FlushConnect
1800 * @details Sending config packet to firmware to flush an old connection
1801 * after switching FW from station one to hybrid one
1802 * @param[in] void * drvHandler
1803 * @return Error code.
1804 * @author Amr Abdel-Moghny
1805 * @date 19 DEC 2013
1806 * @version 8.0
1807 */
1808
Johnny Kim2b05df52015-08-13 13:41:21 +09001809static s32 Handle_FlushConnect(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001810{
Leo Kime6e12662015-09-16 18:36:03 +09001811 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001812 tstrWID strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001813 u32 u32WidsCount = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001814 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001815
1816
1817 /* IEs to be inserted in Association Request */
1818 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1819 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1820 strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc;
1821 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize;
1822 u32WidsCount++;
1823
Chaehyun Limd85f5322015-06-11 14:35:54 +09001824 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001825 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001826 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001827 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001828 u32WidsCount++;
1829
1830
1831
Chaehyun Limd85f5322015-06-11 14:35:54 +09001832 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001833 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001834 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001835 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001836 u32WidsCount++;
1837
Chaehyun Limd85f5322015-06-11 14:35:54 +09001838 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001839 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1840 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001841 strWIDList[u32WidsCount].ps8WidVal = (s8 *)gu8FlushedJoinReq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001842 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1843
1844 pu8CurrByte += FLUSHED_BYTE_POS;
1845 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1846
1847 u32WidsCount++;
1848
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001849 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount, false,
1850 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001851 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09001852 PRINT_ER("failed to send config packet\n");
1853 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001854 }
1855
1856 return s32Error;
1857}
1858
1859/**
1860 * @brief Handle_ConnectTimeout
1861 * @details Call connect notification callback function indicating connection failure
1862 * @param[in] NONE
1863 * @return Error code.
1864 * @author
1865 * @date
1866 * @version 1.0
1867 */
Johnny Kim2b05df52015-08-13 13:41:21 +09001868static s32 Handle_ConnectTimeout(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001869{
Leo Kime6e12662015-09-16 18:36:03 +09001870 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001871 tstrConnectInfo strConnectInfo;
1872 tstrWID strWID;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001873 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001874 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1875
1876 if (pstrWFIDrv == NULL) {
1877 PRINT_ER("Driver handler is NULL\n");
1878 return s32Error;
1879 }
1880
1881 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
1882
Dean Lee72ed4dc2015-06-12 14:11:44 +09001883 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001884
1885
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001886 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001887
1888
1889 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
1890 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
1891 * WID_DISCONNECT} */
1892 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1893 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001894 memcpy(strConnectInfo.au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001895 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
1896 }
1897
1898 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1899 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001900 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001901 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001902 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1903 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
1904 }
1905
1906 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1907 &strConnectInfo,
1908 MAC_DISCONNECTED,
1909 NULL,
1910 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
1911
1912 /* Deallocation of strConnectInfo.pu8ReqIEs */
1913 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001914 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001915 strConnectInfo.pu8ReqIEs = NULL;
1916 }
1917 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001918 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001919 }
1920
1921 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
1922 * WID_DISCONNECT} */
Chaehyun Limd85f5322015-06-11 14:35:54 +09001923 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001924 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001925 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
Dean Lee576917a2015-06-15 11:58:57 +09001926 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001927
1928 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1929
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001930 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
1931 get_id_from_handler(pstrWFIDrv));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001932 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001933 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001934
1935 /* Deallocation of the Saved Connect Request in the global Handle */
1936 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
1937 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001938 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001939 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
1940 }
1941
1942 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001943 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001944 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
1945 }
1946
1947 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1948 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001949 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001950 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
1951 }
1952
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001953 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001954 /*Freeing flushed join request params on connect timeout*/
Johnny Kim8a625ca2015-08-20 16:32:50 +09001955 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001956 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001957 gu8FlushedJoinReq = NULL;
1958 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09001959 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001960 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001961 gu8FlushedInfoElemAsoc = NULL;
1962 }
1963
1964 return s32Error;
1965}
1966
1967/**
1968 * @brief Handle_RcvdNtwrkInfo
1969 * @details Handling received network information
Tony Cho3bbd59f2015-09-21 12:16:38 +09001970 * @param[in] struct rcvd_net_info *pstrRcvdNetworkInfo
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001971 * @return Error code.
1972 * @author
1973 * @date
1974 * @version 1.0
1975 */
Tony Cho3bbd59f2015-09-21 12:16:38 +09001976static s32 Handle_RcvdNtwrkInfo(tstrWILC_WFIDrv *drvHandler,
1977 struct rcvd_net_info *pstrRcvdNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001978{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001979 u32 i;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001980 bool bNewNtwrkFound;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001981
1982
1983
Leo Kime6e12662015-09-16 18:36:03 +09001984 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001985 tstrNetworkInfo *pstrNetworkInfo = NULL;
1986 void *pJoinParams = NULL;
1987
1988 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
1989
1990
1991
Dean Lee72ed4dc2015-06-12 14:11:44 +09001992 bNewNtwrkFound = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001993 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1994
1995 /*if there is a an ongoing scan request*/
1996 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
1997 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
Chaehyun Lima1f7f642015-09-22 22:47:44 +09001998 parse_network_info(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001999 if ((pstrNetworkInfo == NULL)
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002000 || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
Leo Kim24db7132015-09-16 18:36:01 +09002001 PRINT_ER("driver is null\n");
2002 s32Error = -EINVAL;
2003 goto done;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002004 }
2005
2006 /* check whether this network is discovered before */
2007 for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
2008
2009 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
2010 (pstrNetworkInfo->au8bssid != NULL)) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002011 if (memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002012 pstrNetworkInfo->au8bssid, 6) == 0) {
2013 if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
2014 /*we have already found this network with better rssi, so keep the old cached one and don't
2015 * send anything to the upper layer */
2016 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
2017 goto done;
2018 } else {
2019 /* here the same already found network is found again but with a better rssi, so just update
2020 * the rssi for this cached network and send this updated network to the upper layer but
2021 * don't add a new record for it */
2022 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002023 bNewNtwrkFound = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002024 break;
2025 }
2026 }
2027 }
2028 }
2029
Dean Lee72ed4dc2015-06-12 14:11:44 +09002030 if (bNewNtwrkFound == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002031 /* here it is confirmed that it is a new discovered network,
2032 * so add its record then call the User CallBack function */
2033
2034 PRINT_D(HOSTINF_DBG, "New network found\n");
2035
2036 if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
2037 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
2038
2039 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
2040 && (pstrNetworkInfo->au8bssid != NULL)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002041 memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002042 pstrNetworkInfo->au8bssid, 6);
2043
2044 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++;
2045
Dean Lee72ed4dc2015-06-12 14:11:44 +09002046 pstrNetworkInfo->bNewNetwork = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002047 /* add new BSS to JoinBssTable */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002048 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002049
2050 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2051 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid,
2052 pJoinParams);
2053
2054
2055 }
2056 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002057 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002058 }
2059 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002060 pstrNetworkInfo->bNewNetwork = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002061 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2062 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2063 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2064 }
2065 }
2066
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002067done:
2068 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2069 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002070 kfree(pstrRcvdNetworkInfo->pu8Buffer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002071 pstrRcvdNetworkInfo->pu8Buffer = NULL;
2072 }
2073
2074 /*free structure allocated*/
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002075 if (pstrNetworkInfo != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002076 DeallocateNetworkInfo(pstrNetworkInfo);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002077 pstrNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002078 }
2079
2080 return s32Error;
2081}
2082
2083/**
2084 * @brief Handle_RcvdGnrlAsyncInfo
2085 * @details Handling received asynchrous general network information
Tony Chof23a9ea2015-09-21 12:16:39 +09002086 * @param[in] struct rcvd_async_info *pstrRcvdGnrlAsyncInfo
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002087 * @return Error code.
2088 * @author
2089 * @date
2090 * @version 1.0
2091 */
Tony Chof23a9ea2015-09-21 12:16:39 +09002092static s32 Handle_RcvdGnrlAsyncInfo(tstrWILC_WFIDrv *drvHandler,
2093 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002094{
2095 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2096 /* which carries only 1 WID which have WID ID = WID_STATUS */
Leo Kime6e12662015-09-16 18:36:03 +09002097 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002098 u8 u8MsgType = 0;
2099 u8 u8MsgID = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002100 u16 u16MsgLen = 0;
2101 u16 u16WidID = (u16)WID_NIL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002102 u8 u8WidLen = 0;
2103 u8 u8MacStatus;
2104 u8 u8MacStatusReasonCode;
2105 u8 u8MacStatusAdditionalInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002106 tstrConnectInfo strConnectInfo;
2107 tstrDisconnectNotifInfo strDisconnectNotifInfo;
Leo Kime6e12662015-09-16 18:36:03 +09002108 s32 s32Err = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002109 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002110
Leo Kim234837d2015-09-22 14:34:43 +09002111 if (!pstrWFIDrv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002112 PRINT_ER("Driver handler is NULL\n");
Leo Kim234837d2015-09-22 14:34:43 +09002113 return -ENODEV;
2114 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002115 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
2116 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
2117
2118 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
2119 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) ||
2120 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2121 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002122 (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
Leo Kim24db7132015-09-16 18:36:01 +09002123 PRINT_ER("driver is null\n");
2124 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002125 }
2126
2127 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
2128
2129 /* Check whether the received message type is 'I' */
2130 if ('I' != u8MsgType) {
2131 PRINT_ER("Received Message format incorrect.\n");
Leo Kim24db7132015-09-16 18:36:01 +09002132 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002133 }
2134
2135 /* Extract message ID */
2136 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
2137
2138 /* Extract message Length */
2139 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
2140
2141 /* Extract WID ID [expected to be = WID_STATUS] */
2142 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
2143
2144 /* Extract WID Length [expected to be = 1] */
2145 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
2146
2147 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2148 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
2149 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
2150 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
2151 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2152 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2153 /* 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 +09002154 u32 u32RcvdAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002155 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
2156
2157 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2158
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002159 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002160
2161 if (u8MacStatus == MAC_CONNECTED) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002162 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002163
Johnny Kim218dc402015-08-13 13:41:19 +09002164 host_int_get_assoc_res_info(pstrWFIDrv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002165 gapu8RcvdAssocResp,
2166 MAX_ASSOC_RESP_FRAME_SIZE,
2167 &u32RcvdAssocRespInfoLen);
2168
2169 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
2170
2171 if (u32RcvdAssocRespInfoLen != 0) {
2172
2173 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
2174 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
2175 &pstrConnectRespInfo);
2176 if (s32Err) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002177 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002178 } else {
2179 /* use the necessary parsed Info from the Received Association Response */
2180 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
2181
2182 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
2183 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
2184 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
2185 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
2186
2187
Glen Leef3052582015-09-10 12:03:04 +09002188 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002189 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002190 pstrConnectRespInfo->u16RespIEsLen);
2191 }
2192 }
2193
2194 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2195 if (pstrConnectRespInfo != NULL) {
2196 DeallocateAssocRespInfo(pstrConnectRespInfo);
2197 pstrConnectRespInfo = NULL;
2198 }
2199 }
2200 }
2201 }
2202
2203 /* The station has just received mac status and it also received assoc. response which
2204 * it was waiting for.
2205 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2206 if ((u8MacStatus == MAC_CONNECTED) &&
2207 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002208 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 +09002209 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002210
2211 } else if (u8MacStatus == MAC_DISCONNECTED) {
2212 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002213 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002214 }
2215
2216 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2217 /* through a structure of type tstrConnectRespInfo */
2218 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2219 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002220 memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002221
2222 if ((u8MacStatus == MAC_CONNECTED) &&
2223 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002224 memcpy(pstrWFIDrv->au8AssociatedBSSID,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002225 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
2226 }
2227 }
2228
2229
2230 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2231 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09002232 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002233 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002234 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2235 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2236 }
2237
2238
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002239 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002240 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2241 &strConnectInfo,
2242 u8MacStatus,
2243 NULL,
2244 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2245
2246
2247 /* if received mac status is MAC_CONNECTED and
2248 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2249 * else change state to IDLE */
2250 if ((u8MacStatus == MAC_CONNECTED) &&
2251 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Johnny Kim218dc402015-08-13 13:41:19 +09002252 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002253
2254 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
2255 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED;
2256
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002257 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +09002258 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002259 mod_timer(&hDuringIpTimer,
2260 jiffies + msecs_to_jiffies(10000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002261
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002262 /* open a BA session if possible */
2263 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002264 /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
2265 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2266 } else {
2267 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
2268 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002269 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002270 }
2271
2272 /* Deallocation */
2273 if (strConnectInfo.pu8RespIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002274 kfree(strConnectInfo.pu8RespIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002275 strConnectInfo.pu8RespIEs = NULL;
2276 }
2277
2278 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002279 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002280 strConnectInfo.pu8ReqIEs = NULL;
2281 }
2282
2283
2284 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2285 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002286 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002287 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2288 }
2289
2290 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002291 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002292 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2293 }
2294
2295 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2296 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002297 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002298 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2299 }
2300
2301 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2302 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) {
2303 /* Disassociation or Deauthentication frame has been received */
2304 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
2305
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002306 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002307
2308 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002309 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002310 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002311 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2312 }
2313
2314 strDisconnectNotifInfo.u16reason = 0;
2315 strDisconnectNotifInfo.ie = NULL;
2316 strDisconnectNotifInfo.ie_len = 0;
2317
2318 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002319 g_obtainingIP = false;
Johnny Kim218dc402015-08-13 13:41:19 +09002320 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002321
2322 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2323 NULL,
2324 0,
2325 &strDisconnectNotifInfo,
2326 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2327
2328 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002329 PRINT_ER("Connect result callback function is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002330 }
2331
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002332 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002333
2334
2335 /* Deallocation */
2336
2337 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2338 * should be deallocated here */
2339 /*
2340 * if(strDisconnectNotifInfo.ie != NULL)
2341 * {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002342 * kfree(strDisconnectNotifInfo.ie);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002343 * strDisconnectNotifInfo.ie = NULL;
2344 * }
2345 */
2346
2347 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2348 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002349 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002350 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2351 }
2352
2353 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002354 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002355 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2356 }
2357
2358 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2359 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002360 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002361 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2362 }
2363
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002364 /*Freeing flushed join request params on receiving*/
2365 /*MAC_DISCONNECTED while connected*/
Johnny Kim8a625ca2015-08-20 16:32:50 +09002366 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002367 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002368 gu8FlushedJoinReq = NULL;
2369 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09002370 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002371 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002372 gu8FlushedInfoElemAsoc = NULL;
2373 }
2374
2375 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002376 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002377
2378 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2379 (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
2380 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002381 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002382 /*Abort the running scan*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002383 del_timer(&pstrWFIDrv->hScanTimer);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002384 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult)
Johnny Kim2b05df52015-08-13 13:41:21 +09002385 Handle_ScanDone(pstrWFIDrv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002386
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002387 }
2388
2389 }
2390
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002391 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2392 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002393 kfree(pstrRcvdGnrlAsyncInfo->pu8Buffer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002394 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
2395 }
2396
2397 return s32Error;
2398}
2399
2400/**
2401 * @brief Handle_Key
2402 * @details Sending config packet to firmware to set key
Tony Choc98387a2015-09-21 12:16:40 +09002403 * @param[in] struct key_attr *pstrHostIFkeyAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002404 * @return Error code.
2405 * @author
2406 * @date
2407 * @version 1.0
2408 */
Tony Choc98387a2015-09-21 12:16:40 +09002409static int Handle_Key(tstrWILC_WFIDrv *drvHandler,
2410 struct key_attr *pstrHostIFkeyAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002411{
Leo Kime6e12662015-09-16 18:36:03 +09002412 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002413 tstrWID strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002414 tstrWID strWIDList[5];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002415 u8 i;
2416 u8 *pu8keybuf;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002417 s8 s8idxarray[1];
2418 s8 ret = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002419 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2420
2421
2422 switch (pstrHostIFkeyAttr->enuKeyType) {
2423
2424
2425 case WEP:
2426
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002427 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2428
2429 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2430 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Chaehyun Limd85f5322015-06-11 14:35:54 +09002431 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002432 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002433 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002434 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002435
2436 strWIDList[1].u16WIDid = WID_AUTH_TYPE;
2437 strWIDList[1].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002438 strWIDList[1].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002439 strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002440
Chaehyun Limd85f5322015-06-11 14:35:54 +09002441 strWIDList[2].u16WIDid = (u16)WID_KEY_ID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002442 strWIDList[2].enuWIDtype = WID_CHAR;
2443
Chaehyun Limca356ad2015-06-11 14:35:57 +09002444 strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Dean Lee576917a2015-06-15 11:58:57 +09002445 strWIDList[2].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002446
2447
Glen Leef3052582015-09-10 12:03:04 +09002448 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002449
2450
2451 if (pu8keybuf == NULL) {
2452 PRINT_ER("No buffer to send Key\n");
2453 return -1;
2454 }
2455
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002456 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002457 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2458
2459
Chaehyun Lim49188af2015-08-11 10:32:41 +09002460 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002461
Chaehyun Limd85f5322015-06-11 14:35:54 +09002462 strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002463 strWIDList[3].enuWIDtype = WID_STR;
2464 strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002465 strWIDList[3].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002466
2467
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002468 s32Error = send_config_pkt(SET_CFG, strWIDList, 4, true,
2469 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002470 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002471
2472
2473 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002474
2475 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2476 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Glen Leef3052582015-09-10 12:03:04 +09002477 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002478 if (pu8keybuf == NULL) {
2479 PRINT_ER("No buffer to send Key\n");
2480 return -1;
2481 }
2482 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2483
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002484 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002485
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002486 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002487 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2488
Chaehyun Lim49188af2015-08-11 10:32:41 +09002489 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002490
Chaehyun Limd85f5322015-06-11 14:35:54 +09002491 strWID.u16WIDid = (u16)WID_ADD_WEP_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002492 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002493 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002494 strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2;
2495
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002496 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2497 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002498 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002499 } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) {
2500
2501 PRINT_D(HOSTINF_DBG, "Removing key\n");
Chaehyun Limd85f5322015-06-11 14:35:54 +09002502 strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002503 strWID.enuWIDtype = WID_STR;
2504
Chaehyun Limca356ad2015-06-11 14:35:57 +09002505 s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002506 strWID.ps8WidVal = s8idxarray;
2507 strWID.s32ValueSize = 1;
2508
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002509 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2510 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002511 } else {
Chaehyun Limd85f5322015-06-11 14:35:54 +09002512 strWID.u16WIDid = (u16)WID_KEY_ID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002513 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002514 strWID.ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Dean Lee576917a2015-06-15 11:58:57 +09002515 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002516
2517 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
2518
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002519 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2520 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002521 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002522 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002523 break;
2524
2525 case WPARxGtk:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002526 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
Glen Leef3052582015-09-10 12:03:04 +09002527 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002528 if (pu8keybuf == NULL) {
2529 PRINT_ER("No buffer to send RxGTK Key\n");
2530 ret = -1;
2531 goto _WPARxGtk_end_case_;
2532 }
2533
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002534 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002535
2536
2537 /*|----------------------------------------------------------------------------|
2538 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2539 * |------------|---------|-------|------------|---------------|----------------|
2540 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2541
2542
2543
2544 if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002545 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002546
2547
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002548 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002549
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002550 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002551
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002552 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002553 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2554 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
Chaehyun Limd85f5322015-06-11 14:35:54 +09002555 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002556 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002557 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002558 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002559
Chaehyun Limd85f5322015-06-11 14:35:54 +09002560 strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002561 strWIDList[1].enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002562 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002563 strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN;
2564
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002565 s32Error = send_config_pkt(SET_CFG, strWIDList, 2, true,
2566 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002567
Chaehyun Lim49188af2015-08-11 10:32:41 +09002568 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002569
2570 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002571 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002572 /* ///////////////////////// */
2573 }
2574
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002575 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2576 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
2577
Glen Leef3052582015-09-10 12:03:04 +09002578 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002579 if (pu8keybuf == NULL) {
2580 PRINT_ER("No buffer to send RxGTK Key\n");
2581 ret = -1;
2582 goto _WPARxGtk_end_case_;
2583 }
2584
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002585 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002586
2587
2588 /*|----------------------------------------------------------------------------|
2589 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2590 * |------------|---------|-------|------------|---------------|----------------|
2591 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2592
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302593 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002594 memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302595 else
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002596 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002597
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002598 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002599
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002600 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002601
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002602 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2603 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002604 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2605
Chaehyun Limd85f5322015-06-11 14:35:54 +09002606 strWID.u16WIDid = (u16)WID_ADD_RX_GTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002607 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002608 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002609 strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN;
2610
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002611 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2612 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002613
Chaehyun Lim49188af2015-08-11 10:32:41 +09002614 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002615
2616 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002617 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002618 /* ///////////////////////// */
2619 }
2620_WPARxGtk_end_case_:
Chaehyun Lim49188af2015-08-11 10:32:41 +09002621 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2622 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002623 if (ret == -1)
2624 return ret;
2625
2626 break;
2627
2628 case WPAPtk:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002629 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2630
2631
Glen Leef3052582015-09-10 12:03:04 +09002632 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002633
2634
2635
2636 if (pu8keybuf == NULL) {
2637 PRINT_ER("No buffer to send PTK Key\n");
2638 ret = -1;
2639 goto _WPAPtk_end_case_;
2640
2641 }
2642
2643 /*|-----------------------------------------------------------------------------|
2644 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2645 * |----------------|------------ |--------------|----------------|---------------|
2646 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2647 |-----------------------------------------------------------------------------|*/
2648
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002649 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002650
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002651 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2652 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002653 /*16 byte TK*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002654 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002655 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2656
2657
Chaehyun Limd85f5322015-06-11 14:35:54 +09002658 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002659 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002660 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002661 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002662
Chaehyun Limd85f5322015-06-11 14:35:54 +09002663 strWIDList[1].u16WIDid = (u16)WID_ADD_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002664 strWIDList[1].enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002665 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002666 strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1;
2667
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002668 s32Error = send_config_pkt(SET_CFG, strWIDList, 2, true,
2669 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002670 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002671
2672 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002673 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002674 /* ///////////////////////// */
2675 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002676 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2677
2678
Glen Leef3052582015-09-10 12:03:04 +09002679 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002680
2681
2682
2683 if (pu8keybuf == NULL) {
2684 PRINT_ER("No buffer to send PTK Key\n");
2685 ret = -1;
2686 goto _WPAPtk_end_case_;
2687
2688 }
2689
2690 /*|-----------------------------------------------------------------------------|
2691 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
2692 * |----------------|------------|--------------|----------------|---------------|
2693 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
2694 |-----------------------------------------------------------------------------|*/
2695
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002696 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002697
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002698 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002699 /*16 byte TK*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002700 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002701 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2702
2703
Chaehyun Limd85f5322015-06-11 14:35:54 +09002704 strWID.u16WIDid = (u16)WID_ADD_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002705 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002706 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002707 strWID.s32ValueSize = PTK_KEY_MSG_LEN;
2708
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002709 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2710 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002711 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002712
2713 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002714 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002715 /* ///////////////////////// */
2716 }
2717
2718_WPAPtk_end_case_:
Chaehyun Lim49188af2015-08-11 10:32:41 +09002719 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002720 if (ret == -1)
2721 return ret;
2722
2723 break;
2724
2725
2726 case PMKSA:
2727
2728 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
2729
Glen Leef3052582015-09-10 12:03:04 +09002730 pu8keybuf = kmalloc((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002731 if (pu8keybuf == NULL) {
2732 PRINT_ER("No buffer to send PMKSA Key\n");
2733 return -1;
2734 }
2735
2736 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
2737
2738 for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
2739
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002740 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
2741 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002742 }
2743
Chaehyun Limd85f5322015-06-11 14:35:54 +09002744 strWID.u16WIDid = (u16)WID_PMKID_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002745 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002746 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002747 strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1;
2748
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002749 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2750 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002751
Chaehyun Lim49188af2015-08-11 10:32:41 +09002752 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002753 break;
2754 }
2755
2756 if (s32Error)
2757 PRINT_ER("Failed to send key config packet\n");
2758
2759
2760 return s32Error;
2761}
2762
2763
2764/**
2765 * @brief Handle_Disconnect
2766 * @details Sending config packet to firmware to disconnect
2767 * @param[in] NONE
2768 * @return NONE
2769 * @author
2770 * @date
2771 * @version 1.0
2772 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002773static void Handle_Disconnect(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002774{
2775 tstrWID strWID;
2776
Leo Kime6e12662015-09-16 18:36:03 +09002777 s32 s32Error = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002778 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002779 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2780
2781
Chaehyun Limd85f5322015-06-11 14:35:54 +09002782 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002783 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002784 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
Dean Lee576917a2015-06-15 11:58:57 +09002785 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002786
2787
2788
2789 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2790
Dean Lee72ed4dc2015-06-12 14:11:44 +09002791 g_obtainingIP = false;
Johnny Kim218dc402015-08-13 13:41:19 +09002792 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002793
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002794 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002795
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002796 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
2797 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002798
2799 if (s32Error) {
2800 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002801 } else {
2802 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2803
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002804 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002805
2806 strDisconnectNotifInfo.u16reason = 0;
2807 strDisconnectNotifInfo.ie = NULL;
2808 strDisconnectNotifInfo.ie_len = 0;
2809
2810 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002811 del_timer(&pstrWFIDrv->hScanTimer);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002812 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002813 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2814
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002815 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002816 }
2817
2818 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2819
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002820 /*Stop connect timer, if connection in progress*/
2821 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2822 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002823 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002824 }
2825
2826 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
2827 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2828 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002829 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002830 }
2831
Dean Lee72ed4dc2015-06-12 14:11:44 +09002832 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002833
2834 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2835
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002836 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002837
2838
2839 /* Deallocation */
2840 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2841 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002842 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002843 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2844 }
2845
2846 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002847 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002848 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2849 }
2850
2851 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2852 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002853 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002854 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2855 }
2856
2857
Johnny Kim8a625ca2015-08-20 16:32:50 +09002858 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002859 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002860 gu8FlushedJoinReq = NULL;
2861 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09002862 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002863 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002864 gu8FlushedInfoElemAsoc = NULL;
2865 }
2866
2867 }
2868
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002869 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002870 up(&(pstrWFIDrv->hSemTestDisconnectBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002871 /* ///////////////////////// */
2872
2873}
2874
2875
Johnny Kim2b05df52015-08-13 13:41:21 +09002876void resolve_disconnect_aberration(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002877{
2878 tstrWILC_WFIDrv *pstrWFIDrv;
2879
2880 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002881 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002882 return;
2883 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
2884 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
Johnny Kim218dc402015-08-13 13:41:19 +09002885 host_int_disconnect(pstrWFIDrv, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002886 }
2887}
Johnny Kim2b05df52015-08-13 13:41:21 +09002888static s32 Switch_Log_Terminal(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002889{
2890
2891
Leo Kime6e12662015-09-16 18:36:03 +09002892 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002893 tstrWID strWID;
2894 static char dummy = 9;
2895 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2896
Chaehyun Limd85f5322015-06-11 14:35:54 +09002897 strWID.u16WIDid = (u16)WID_LOGTerminal_Switch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002898 strWID.enuWIDtype = WID_CHAR;
2899 strWID.ps8WidVal = &dummy;
Dean Lee576917a2015-06-15 11:58:57 +09002900 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002901
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002902 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2903 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002904
2905
2906 if (s32Error) {
2907 PRINT_D(HOSTINF_DBG, "Failed to switch log terminal\n");
Leo Kim24db7132015-09-16 18:36:01 +09002908 PRINT_ER("Failed to switch log terminal\n");
2909 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002910 }
2911
Leo Kim24db7132015-09-16 18:36:01 +09002912 PRINT_INFO(HOSTINF_DBG, "MAC address set ::\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002913
2914 return s32Error;
2915}
2916
2917/**
2918 * @brief Handle_GetChnl
2919 * @details Sending config packet to get channel
2920 * @param[in] NONE
2921 * @return NONE
2922 *
2923 * @author
2924 * @date
2925 * @version 1.0
2926 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002927static s32 Handle_GetChnl(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002928{
2929
Leo Kime6e12662015-09-16 18:36:03 +09002930 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002931 tstrWID strWID;
2932 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
2933 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002934
Chaehyun Limd85f5322015-06-11 14:35:54 +09002935 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002936 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002937 strWID.ps8WidVal = (s8 *)&gu8Chnl;
Dean Lee576917a2015-06-15 11:58:57 +09002938 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002939
2940 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2941
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002942 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
2943 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002944 /*get the value by searching the local copy*/
2945 if (s32Error) {
2946 PRINT_ER("Failed to get channel number\n");
Leo Kim24db7132015-09-16 18:36:01 +09002947 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002948 }
2949
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002950 up(&(pstrWFIDrv->hSemGetCHNL));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002951
2952 return s32Error;
2953
2954
2955
2956}
2957
2958
2959/**
2960 * @brief Handle_GetRssi
2961 * @details Sending config packet to get RSSI
2962 * @param[in] NONE
2963 * @return NONE
2964 * @author
2965 * @date
2966 * @version 1.0
2967 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002968static void Handle_GetRssi(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002969{
Leo Kime6e12662015-09-16 18:36:03 +09002970 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002971 tstrWID strWID;
2972 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2973
Chaehyun Limd85f5322015-06-11 14:35:54 +09002974 strWID.u16WIDid = (u16)WID_RSSI;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002975 strWID.enuWIDtype = WID_CHAR;
2976 strWID.ps8WidVal = &gs8Rssi;
Dean Lee576917a2015-06-15 11:58:57 +09002977 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002978
2979 /*Sending Cfg*/
2980 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2981
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002982 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
2983 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002984 if (s32Error) {
2985 PRINT_ER("Failed to get RSSI value\n");
Leo Kim24db7132015-09-16 18:36:01 +09002986 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002987 }
2988
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002989 up(&(pstrWFIDrv->hSemGetRSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002990
2991
2992}
2993
2994
Johnny Kim2b05df52015-08-13 13:41:21 +09002995static void Handle_GetLinkspeed(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002996{
Leo Kime6e12662015-09-16 18:36:03 +09002997 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002998 tstrWID strWID;
2999 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3000
3001 gs8lnkspd = 0;
3002
Chaehyun Limd85f5322015-06-11 14:35:54 +09003003 strWID.u16WIDid = (u16)WID_LINKSPEED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003004 strWID.enuWIDtype = WID_CHAR;
3005 strWID.ps8WidVal = &gs8lnkspd;
Dean Lee576917a2015-06-15 11:58:57 +09003006 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003007 /*Sending Cfg*/
3008 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
3009
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003010 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
3011 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003012 if (s32Error) {
3013 PRINT_ER("Failed to get LINKSPEED value\n");
Leo Kim24db7132015-09-16 18:36:01 +09003014 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003015 }
3016
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003017 up(&(pstrWFIDrv->hSemGetLINKSPEED));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003018
3019
3020}
3021
Johnny Kim2b05df52015-08-13 13:41:21 +09003022s32 Handle_GetStatistics(tstrWILC_WFIDrv *drvHandler, tstrStatistics *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003023{
3024 tstrWID strWIDList[5];
Chaehyun Limfbc2fe12015-09-15 14:06:16 +09003025 u32 u32WidsCount = 0, s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003026
3027 strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED;
3028 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003029 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003030 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003031 u32WidsCount++;
3032
3033 strWIDList[u32WidsCount].u16WIDid = WID_RSSI;
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->s8RSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003037 u32WidsCount++;
3038
3039 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
3040 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003041 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003042 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003043 u32WidsCount++;
3044
3045 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_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->u32RxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003049 u32WidsCount++;
3050
3051 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_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->u32TxFailureCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003055 u32WidsCount++;
3056
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003057 s32Error = send_config_pkt(GET_CFG, strWIDList, u32WidsCount, false,
3058 get_id_from_handler(drvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003059
Leo Kim24db7132015-09-16 18:36:01 +09003060 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003061 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09003062
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003063 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003064 return 0;
3065
3066}
3067
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003068/**
3069 * @brief Handle_Get_InActiveTime
3070 * @details Sending config packet to set mac adddress for station and
3071 * get inactive time
3072 * @param[in] NONE
3073 * @return NONE
3074 *
3075 * @author
3076 * @date
3077 * @version 1.0
3078 */
Tony Cho3d1eac02015-09-21 12:16:49 +09003079static s32 Handle_Get_InActiveTime(tstrWILC_WFIDrv *drvHandler,
3080 struct sta_inactive_t *strHostIfStaInactiveT)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003081{
3082
Leo Kime6e12662015-09-16 18:36:03 +09003083 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003084 u8 *stamac;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003085 tstrWID strWID;
3086 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3087
3088
Chaehyun Limd85f5322015-06-11 14:35:54 +09003089 strWID.u16WIDid = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003090 strWID.enuWIDtype = WID_STR;
3091 strWID.s32ValueSize = ETH_ALEN;
Glen Leef3052582015-09-10 12:03:04 +09003092 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003093
3094
3095 stamac = strWID.ps8WidVal;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003096 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003097
3098
3099 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
3100
3101
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003102 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3103 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003104 /*get the value by searching the local copy*/
3105 if (s32Error) {
3106 PRINT_ER("Failed to SET incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09003107 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003108 }
3109
3110
Chaehyun Limd85f5322015-06-11 14:35:54 +09003111 strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003112 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003113 strWID.ps8WidVal = (s8 *)&gu32InactiveTime;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003114 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003115
3116
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003117 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
3118 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003119 /*get the value by searching the local copy*/
3120 if (s32Error) {
3121 PRINT_ER("Failed to get incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09003122 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003123 }
3124
3125
3126 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
3127
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003128 up(&(pstrWFIDrv->hSemInactiveTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003129
3130 return s32Error;
3131
3132
3133
3134}
3135
3136
3137/**
3138 * @brief Handle_AddBeacon
3139 * @details Sending config packet to add beacon
Tony Cho7f33fec2015-09-30 18:44:30 +09003140 * @param[in] struct beacon_attr *pstrSetBeaconParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003141 * @return NONE
3142 * @author
3143 * @date
3144 * @version 1.0
3145 */
Tony Cho902362b2015-09-21 12:16:44 +09003146static void Handle_AddBeacon(tstrWILC_WFIDrv *drvHandler,
Tony Cho7f33fec2015-09-30 18:44:30 +09003147 struct beacon_attr *pstrSetBeaconParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003148{
Leo Kime6e12662015-09-16 18:36:03 +09003149 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003150 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003151 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003152 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003153
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003154 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
3155
Chaehyun Limd85f5322015-06-11 14:35:54 +09003156 strWID.u16WIDid = (u16)WID_ADD_BEACON;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003157 strWID.enuWIDtype = WID_BIN;
3158 strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
Glen Leef3052582015-09-10 12:03:04 +09003159 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003160 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003161 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003162
3163 pu8CurrByte = strWID.ps8WidVal;
3164 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
3165 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
3166 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
3167 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
3168
3169 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
3170 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
3171 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
3172 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
3173
3174 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
3175 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
3176 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
3177 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
3178
3179 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
3180 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
3181
3182 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
3183 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
3184 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
3185 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
3186
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003187 if (pstrSetBeaconParam->pu8Tail > 0)
3188 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
3189 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
3190
3191
3192
3193 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003194 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3195 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003196 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003197 PRINT_ER("Failed to send add beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003198
Leo Kim24db7132015-09-16 18:36:01 +09003199ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003200 kfree(strWID.ps8WidVal);
3201 kfree(pstrSetBeaconParam->pu8Head);
3202 kfree(pstrSetBeaconParam->pu8Tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003203}
3204
3205
3206/**
3207 * @brief Handle_AddBeacon
3208 * @details Sending config packet to delete beacon
Tony Cho80bf88362015-09-30 18:44:29 +09003209 * @param[in] tstrWILC_WFIDrv *drvHandler
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003210 * @return NONE
3211 * @author
3212 * @date
3213 * @version 1.0
3214 */
Tony Cho80bf88362015-09-30 18:44:29 +09003215static void Handle_DelBeacon(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003216{
Leo Kime6e12662015-09-16 18:36:03 +09003217 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003218 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003219 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003220 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003221
Chaehyun Limd85f5322015-06-11 14:35:54 +09003222 strWID.u16WIDid = (u16)WID_DEL_BEACON;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003223 strWID.enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003224 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003225 strWID.ps8WidVal = &gu8DelBcn;
3226
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003227 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003228 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003229
3230 pu8CurrByte = strWID.ps8WidVal;
3231
3232 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
3233 /* TODO: build del beacon message*/
3234
3235 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003236 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3237 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003238 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003239 PRINT_ER("Failed to send delete beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003240}
3241
3242
3243/**
3244 * @brief WILC_HostIf_PackStaParam
3245 * @details Handling packing of the station params in a buffer
Tony Cho6a89ba92015-09-21 12:16:46 +09003246 * @param[in] u8* pu8Buffer, struct add_sta_param *pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003247 * @return NONE
3248 * @author
3249 * @date
3250 * @version 1.0
3251 */
Tony Cho6a89ba92015-09-21 12:16:46 +09003252static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
3253 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003254{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003255 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003256
3257 pu8CurrByte = pu8Buffer;
3258
3259 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003260 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003261 pu8CurrByte += ETH_ALEN;
3262
3263 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
3264 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
3265
3266 *pu8CurrByte++ = pstrStationParam->u8NumRates;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003267 if (pstrStationParam->u8NumRates > 0)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003268 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003269 pu8CurrByte += pstrStationParam->u8NumRates;
3270
3271 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
3272 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
3273 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
3274
3275 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003276 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003277 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
3278
3279 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
3280 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
3281
3282 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
3283 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
3284 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
3285 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
3286
3287 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
3288
3289 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
3290 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
3291
3292 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
3293 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
3294
3295 return pu8CurrByte - pu8Buffer;
3296}
3297
3298/**
3299 * @brief Handle_AddStation
3300 * @details Sending config packet to add station
Tony Cho6a89ba92015-09-21 12:16:46 +09003301 * @param[in] struct add_sta_param *pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003302 * @return NONE
3303 * @author
3304 * @date
3305 * @version 1.0
3306 */
Tony Cho6a89ba92015-09-21 12:16:46 +09003307static void Handle_AddStation(tstrWILC_WFIDrv *drvHandler,
3308 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003309{
Leo Kime6e12662015-09-16 18:36:03 +09003310 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003311 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003312 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003313 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003314
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003315 PRINT_D(HOSTINF_DBG, "Handling add station\n");
Chaehyun Limd85f5322015-06-11 14:35:54 +09003316 strWID.u16WIDid = (u16)WID_ADD_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003317 strWID.enuWIDtype = WID_BIN;
3318 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3319
Glen Leef3052582015-09-10 12:03:04 +09003320 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003321 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003322 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003323
3324 pu8CurrByte = strWID.ps8WidVal;
3325 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3326
3327 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003328 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3329 get_id_from_handler(pstrWFIDrv));
Leo Kime6e12662015-09-16 18:36:03 +09003330 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003331 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003332
Leo Kim24db7132015-09-16 18:36:01 +09003333ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003334 kfree(pstrStationParam->pu8Rates);
3335 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003336}
3337
3338/**
3339 * @brief Handle_DelAllSta
3340 * @details Sending config packet to delete station
3341 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3342 * @return NONE
3343 * @author
3344 * @date
3345 * @version 1.0
3346 */
Tony Chob4e644e2015-09-21 12:17:00 +09003347static void Handle_DelAllSta(tstrWILC_WFIDrv *drvHandler,
3348 struct del_all_sta *pstrDelAllStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003349{
Leo Kime6e12662015-09-16 18:36:03 +09003350 s32 s32Error = 0;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003351
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003352 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003353 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003354 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003355 u8 i;
Chaehyun Lim37034802015-06-11 14:34:32 +09003356 u8 au8Zero_Buff[6] = {0};
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003357
Chaehyun Limd85f5322015-06-11 14:35:54 +09003358 strWID.u16WIDid = (u16)WID_DEL_ALL_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003359 strWID.enuWIDtype = WID_STR;
3360 strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
3361
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003362 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003363
Glen Leef3052582015-09-10 12:03:04 +09003364 strWID.ps8WidVal = kmalloc((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003365 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003366 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003367
3368 pu8CurrByte = strWID.ps8WidVal;
3369
3370 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
3371
3372 for (i = 0; i < MAX_NUM_STA; i++) {
3373 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003374 memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003375 else
3376 continue;
3377
3378 pu8CurrByte += ETH_ALEN;
3379 }
3380
3381 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003382 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3383 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003384 if (s32Error)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02003385 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003386
Leo Kim24db7132015-09-16 18:36:01 +09003387ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003388 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003389
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003390 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003391}
3392
3393
3394/**
3395 * @brief Handle_DelStation
3396 * @details Sending config packet to delete station
Tony Chofb93a1e2015-09-21 12:16:57 +09003397 * @param[in] struct del_sta *pstrDelStaParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003398 * @return NONE
3399 * @author
3400 * @date
3401 * @version 1.0
3402 */
Tony Chofb93a1e2015-09-21 12:16:57 +09003403static void Handle_DelStation(tstrWILC_WFIDrv *drvHandler,
3404 struct del_sta *pstrDelStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003405{
Leo Kime6e12662015-09-16 18:36:03 +09003406 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003407 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003408 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003409 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3410
Chaehyun Limd85f5322015-06-11 14:35:54 +09003411 strWID.u16WIDid = (u16)WID_REMOVE_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003412 strWID.enuWIDtype = WID_BIN;
3413 strWID.s32ValueSize = ETH_ALEN;
3414
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003415 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003416
Glen Leef3052582015-09-10 12:03:04 +09003417 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003418 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003419 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003420
3421 pu8CurrByte = strWID.ps8WidVal;
3422
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003423 memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003424
3425 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003426 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3427 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003428 if (s32Error)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02003429 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003430
Leo Kim24db7132015-09-16 18:36:01 +09003431ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003432 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003433}
3434
3435
3436/**
3437 * @brief Handle_EditStation
3438 * @details Sending config packet to edit station
Tony Cho6a89ba92015-09-21 12:16:46 +09003439 * @param[in] struct add_sta_param *pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003440 * @return NONE
3441 * @author
3442 * @date
3443 * @version 1.0
3444 */
Tony Cho6a89ba92015-09-21 12:16:46 +09003445static void Handle_EditStation(tstrWILC_WFIDrv *drvHandler,
3446 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003447{
Leo Kime6e12662015-09-16 18:36:03 +09003448 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003449 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003450 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003451 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3452
Chaehyun Limd85f5322015-06-11 14:35:54 +09003453 strWID.u16WIDid = (u16)WID_EDIT_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003454 strWID.enuWIDtype = WID_BIN;
3455 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3456
3457 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
Glen Leef3052582015-09-10 12:03:04 +09003458 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003459 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003460 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003461
3462 pu8CurrByte = strWID.ps8WidVal;
3463 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3464
3465 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003466 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3467 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003468 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003469 PRINT_ER("Failed to send edit station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003470
Leo Kim24db7132015-09-16 18:36:01 +09003471ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003472 kfree(pstrStationParam->pu8Rates);
3473 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003474}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003475
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003476/**
3477 * @brief Handle_RemainOnChan
3478 * @details Sending config packet to edit station
3479 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3480 * @return NONE
3481 * @author
3482 * @date
3483 * @version 1.0
3484 */
Tony Cho2f9c03f2015-09-21 12:16:58 +09003485static int Handle_RemainOnChan(tstrWILC_WFIDrv *drvHandler,
3486 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003487{
Leo Kime6e12662015-09-16 18:36:03 +09003488 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003489 u8 u8remain_on_chan_flag;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003490 tstrWID strWID;
3491 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3492
3493 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3494 if (!pstrWFIDrv->u8RemainOnChan_pendingreq) {
3495 pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
3496 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
3497 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
3498 pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
3499 pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
3500 } else {
3501 /*Set the channel to use it as a wid val*/
3502 pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel;
3503 }
3504
3505 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3506 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
3507 pstrWFIDrv->u8RemainOnChan_pendingreq = 1;
Leo Kim24db7132015-09-16 18:36:01 +09003508 s32Error = -EBUSY;
3509 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003510 }
3511 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3512 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
Leo Kim24db7132015-09-16 18:36:01 +09003513 s32Error = -EBUSY;
3514 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003515 }
3516
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003517 if (g_obtainingIP || connecting) {
3518 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +09003519 s32Error = -EBUSY;
3520 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003521 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003522
3523 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
3524
Dean Lee72ed4dc2015-06-12 14:11:44 +09003525 u8remain_on_chan_flag = true;
Chaehyun Limd85f5322015-06-11 14:35:54 +09003526 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003527 strWID.enuWIDtype = WID_STR;
3528 strWID.s32ValueSize = 2;
Glen Leef3052582015-09-10 12:03:04 +09003529 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003530
Leo Kim24db7132015-09-16 18:36:01 +09003531 if (strWID.ps8WidVal == NULL) {
3532 s32Error = -ENOMEM;
3533 goto ERRORHANDLER;
3534 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003535
3536 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003537 strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003538
3539 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003540 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3541 get_id_from_handler(pstrWFIDrv));
Leo Kime6e12662015-09-16 18:36:03 +09003542 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003543 PRINT_ER("Failed to set remain on channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003544
Leo Kim24db7132015-09-16 18:36:01 +09003545ERRORHANDLER:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003546 {
3547 P2P_LISTEN_STATE = 1;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003548 pstrWFIDrv->hRemainOnChannel.data = (unsigned long)pstrWFIDrv;
3549 mod_timer(&pstrWFIDrv->hRemainOnChannel,
3550 jiffies +
3551 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003552
3553 /*Calling CFG ready_on_channel*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003554 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003555 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003556
3557 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3558 pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
3559 }
3560 return s32Error;
3561}
3562
3563/**
3564 * @brief Handle_RegisterFrame
3565 * @details
3566 * @param[in]
3567 * @return NONE
3568 * @author
3569 * @date
3570 * @version 1.0
3571 */
Tony Chobc37c5d2015-09-21 12:16:59 +09003572static int Handle_RegisterFrame(tstrWILC_WFIDrv *drvHandler,
3573 struct reg_frame *pstrHostIfRegisterFrame)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003574{
Leo Kime6e12662015-09-16 18:36:03 +09003575 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003576 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003577 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003578 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3579
3580 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
3581
3582 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +09003583 strWID.u16WIDid = (u16)WID_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003584 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09003585 strWID.ps8WidVal = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003586 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003587 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003588
3589 pu8CurrByte = strWID.ps8WidVal;
3590
3591 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
3592 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003593 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003594
3595
Chaehyun Limd85f5322015-06-11 14:35:54 +09003596 strWID.s32ValueSize = sizeof(u16) + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003597
3598
3599 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003600 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3601 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003602 if (s32Error) {
3603 PRINT_ER("Failed to frame register config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09003604 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003605 }
3606
3607 return s32Error;
3608
3609}
3610
3611/**
3612 * @brief Handle_ListenStateExpired
3613 * @details Handle of listen state expiration
3614 * @param[in] NONE
3615 * @return Error code.
3616 * @author
3617 * @date
3618 * @version 1.0
3619 */
3620#define FALSE_FRMWR_CHANNEL 100
Tony Cho2f9c03f2015-09-21 12:16:58 +09003621static u32 Handle_ListenStateExpired(tstrWILC_WFIDrv *drvHandler,
3622 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003623{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003624 u8 u8remain_on_chan_flag;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003625 tstrWID strWID;
Leo Kime6e12662015-09-16 18:36:03 +09003626 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003627 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3628
3629 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
3630
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003631 /*Make sure we are already in listen state*/
3632 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
3633 if (P2P_LISTEN_STATE) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003634 u8remain_on_chan_flag = false;
Chaehyun Limd85f5322015-06-11 14:35:54 +09003635 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003636 strWID.enuWIDtype = WID_STR;
3637 strWID.s32ValueSize = 2;
Glen Leef3052582015-09-10 12:03:04 +09003638 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003639
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003640 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003641 PRINT_ER("Failed to allocate memory\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003642
3643 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3644 strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL;
3645
3646 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003647 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3648 get_id_from_handler(pstrWFIDrv));
Leo Kime6e12662015-09-16 18:36:03 +09003649 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003650 PRINT_ER("Failed to set remain on channel\n");
3651 goto _done_;
3652 }
3653
3654 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) {
3655 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid
3656 , pstrHostIfRemainOnChan->u32ListenSessionID);
3657 }
3658 P2P_LISTEN_STATE = 0;
3659 } else {
3660 PRINT_D(GENERIC_DBG, "Not in listen state\n");
Leo Kime6e12662015-09-16 18:36:03 +09003661 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003662 }
3663
3664_done_:
3665 return s32Error;
3666}
3667
3668
3669/**
3670 * @brief ListenTimerCB
3671 * @details Callback function of remain-on-channel timer
3672 * @param[in] NONE
3673 * @return Error code.
3674 * @author
3675 * @date
3676 * @version 1.0
3677 */
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003678static void ListenTimerCB(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003679{
Leo Kime6e12662015-09-16 18:36:03 +09003680 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003681 struct host_if_msg msg;
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003682 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003683 /*Stopping remain-on-channel timer*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07003684 del_timer(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003685
3686 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09003687 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003688 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Cho143eb952015-09-21 12:16:32 +09003689 msg.drvHandler = pstrWFIDrv;
Tony Cho070d3652015-09-30 18:55:10 +09003690 msg.body.remain_on_ch.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003691
3692 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09003693 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003694 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09003695 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003696}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003697
3698/**
3699 * @brief Handle_EditStation
3700 * @details Sending config packet to edit station
3701 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3702 * @return NONE
3703 * @author
3704 * @date
3705 * @version 1.0
3706 */
Tony Cho5a008f12015-09-21 12:16:48 +09003707static void Handle_PowerManagement(tstrWILC_WFIDrv *drvHandler,
3708 struct power_mgmt_param *strPowerMgmtParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003709{
Leo Kime6e12662015-09-16 18:36:03 +09003710 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003711 tstrWID strWID;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003712 s8 s8PowerMode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003713 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003714
Chaehyun Limd85f5322015-06-11 14:35:54 +09003715 strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003716
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05303717 if (strPowerMgmtParam->bIsEnabled == true)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003718 s8PowerMode = MIN_FAST_PS;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05303719 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003720 s8PowerMode = NO_POWERSAVE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003721 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
3722 strWID.ps8WidVal = &s8PowerMode;
Dean Lee576917a2015-06-15 11:58:57 +09003723 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003724
3725 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
3726
3727 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003728 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3729 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003730 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003731 PRINT_ER("Failed to send power management config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003732}
3733
3734/**
3735 * @brief Handle_SetMulticastFilter
3736 * @details Set Multicast filter in firmware
Tony Cho641210a2015-09-21 12:16:52 +09003737 * @param[in] struct set_multicast *strHostIfSetMulti
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003738 * @return NONE
3739 * @author asobhy
3740 * @date
3741 * @version 1.0
3742 */
Tony Cho641210a2015-09-21 12:16:52 +09003743static void Handle_SetMulticastFilter(tstrWILC_WFIDrv *drvHandler,
3744 struct set_multicast *strHostIfSetMulti)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003745{
Leo Kime6e12662015-09-16 18:36:03 +09003746 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003747 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003748 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003749
3750 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
3751
Chaehyun Limd85f5322015-06-11 14:35:54 +09003752 strWID.u16WIDid = (u16)WID_SETUP_MULTICAST_FILTER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003753 strWID.enuWIDtype = WID_BIN;
Tony Cho641210a2015-09-21 12:16:52 +09003754 strWID.s32ValueSize = sizeof(struct set_multicast) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
Glen Leef3052582015-09-10 12:03:04 +09003755 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003756 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003757 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003758
3759 pu8CurrByte = strWID.ps8WidVal;
3760 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
3761 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
3762 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
3763 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
3764
3765 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
3766 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
3767 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
3768 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
3769
3770 if ((strHostIfSetMulti->u32count) > 0)
3771 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
3772
3773 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003774 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3775 get_id_from_handler(drvHandler));
Leo Kim24db7132015-09-16 18:36:01 +09003776 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003777 PRINT_ER("Failed to send setup multicast config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003778
Leo Kim24db7132015-09-16 18:36:01 +09003779ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003780 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003781
3782}
3783
3784
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003785/**
3786 * @brief Handle_AddBASession
3787 * @details Add block ack session
3788 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
3789 * @return NONE
3790 * @author Amr Abdel-Moghny
3791 * @date Feb. 2014
3792 * @version 9.0
3793 */
Tony Cho54265472015-09-21 12:16:56 +09003794static s32 Handle_AddBASession(tstrWILC_WFIDrv *drvHandler,
3795 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003796{
Leo Kime6e12662015-09-16 18:36:03 +09003797 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003798 tstrWID strWID;
3799 int AddbaTimeout = 100;
3800 char *ptr = NULL;
3801 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3802
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003803 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 +09003804 strHostIfBASessionInfo->au8Bssid[0],
3805 strHostIfBASessionInfo->au8Bssid[1],
3806 strHostIfBASessionInfo->au8Bssid[2],
3807 strHostIfBASessionInfo->u16BufferSize,
3808 strHostIfBASessionInfo->u16SessionTimeout,
3809 strHostIfBASessionInfo->u8Ted);
3810
Chaehyun Limd85f5322015-06-11 14:35:54 +09003811 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003812 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09003813 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003814 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
3815 ptr = strWID.ps8WidVal;
3816 /* *ptr++ = 0x14; */
3817 *ptr++ = 0x14;
3818 *ptr++ = 0x3;
3819 *ptr++ = 0x0;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003820 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003821 ptr += ETH_ALEN;
3822 *ptr++ = strHostIfBASessionInfo->u8Ted;
3823 /* BA Policy*/
3824 *ptr++ = 1;
3825 /* Buffer size*/
3826 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
3827 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
3828 /* BA timeout*/
3829 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
3830 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
3831 /* ADDBA timeout*/
3832 *ptr++ = (AddbaTimeout & 0xFF);
3833 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
3834 /* Group Buffer Max Frames*/
3835 *ptr++ = 8;
3836 /* Group Buffer Timeout */
3837 *ptr++ = 0;
3838
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003839 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3840 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003841 if (s32Error)
3842 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
3843
3844
Chaehyun Limd85f5322015-06-11 14:35:54 +09003845 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003846 strWID.enuWIDtype = WID_STR;
3847 strWID.s32ValueSize = 15;
3848 ptr = strWID.ps8WidVal;
3849 /* *ptr++ = 0x14; */
3850 *ptr++ = 15;
3851 *ptr++ = 7;
3852 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003853 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003854 ptr += ETH_ALEN;
3855 /* TID*/
3856 *ptr++ = strHostIfBASessionInfo->u8Ted;
3857 /* Max Num MSDU */
3858 *ptr++ = 8;
3859 /* BA timeout*/
3860 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
3861 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
3862 /*Ack-Policy */
3863 *ptr++ = 3;
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003864 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3865 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003866
3867 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09003868 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003869
3870 return s32Error;
3871
3872}
3873
3874
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003875/**
3876 * @brief Handle_DelBASession
3877 * @details Delete block ack session
3878 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
3879 * @return NONE
3880 * @author Amr Abdel-Moghny
3881 * @date Feb. 2013
3882 * @version 9.0
3883 */
Tony Cho54265472015-09-21 12:16:56 +09003884static s32 Handle_DelBASession(tstrWILC_WFIDrv *drvHandler,
3885 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003886{
Leo Kime6e12662015-09-16 18:36:03 +09003887 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003888 tstrWID strWID;
3889 char *ptr = NULL;
3890 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3891
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003892 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003893 strHostIfBASessionInfo->au8Bssid[0],
3894 strHostIfBASessionInfo->au8Bssid[1],
3895 strHostIfBASessionInfo->au8Bssid[2],
3896 strHostIfBASessionInfo->u8Ted);
3897
Chaehyun Limd85f5322015-06-11 14:35:54 +09003898 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003899 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09003900 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003901 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
3902 ptr = strWID.ps8WidVal;
3903 /* *ptr++ = 0x14; */
3904 *ptr++ = 0x14;
3905 *ptr++ = 0x3;
3906 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003907 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003908 ptr += ETH_ALEN;
3909 *ptr++ = strHostIfBASessionInfo->u8Ted;
3910 /* BA direction = recipent*/
3911 *ptr++ = 0;
3912 /* Delba Reason */
3913 *ptr++ = 32; /* Unspecific QOS reason */
3914
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003915 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3916 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003917 if (s32Error)
3918 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
3919
3920
Chaehyun Limd85f5322015-06-11 14:35:54 +09003921 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003922 strWID.enuWIDtype = WID_STR;
3923 strWID.s32ValueSize = 15;
3924 ptr = strWID.ps8WidVal;
3925 /* *ptr++ = 0x14; */
3926 *ptr++ = 15;
3927 *ptr++ = 7;
3928 *ptr++ = 0x3;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003929 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003930 ptr += ETH_ALEN;
3931 /* TID*/
3932 *ptr++ = strHostIfBASessionInfo->u8Ted;
3933
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003934 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3935 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003936
3937 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09003938 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003939
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003940 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003941
3942 return s32Error;
3943
3944}
3945
3946
3947/**
3948 * @brief Handle_DelAllRxBASessions
3949 * @details Delete all Rx BA sessions
3950 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
3951 * @return NONE
3952 * @author Abdelrahman Sobhy
3953 * @date Feb. 2013
3954 * @version 9.0
3955 */
Tony Cho54265472015-09-21 12:16:56 +09003956static s32 Handle_DelAllRxBASessions(tstrWILC_WFIDrv *drvHandler,
3957 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003958{
Leo Kime6e12662015-09-16 18:36:03 +09003959 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003960 tstrWID strWID;
3961 char *ptr = NULL;
3962 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3963
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003964 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003965 strHostIfBASessionInfo->au8Bssid[0],
3966 strHostIfBASessionInfo->au8Bssid[1],
3967 strHostIfBASessionInfo->au8Bssid[2],
3968 strHostIfBASessionInfo->u8Ted);
3969
Chaehyun Limd85f5322015-06-11 14:35:54 +09003970 strWID.u16WIDid = (u16)WID_DEL_ALL_RX_BA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003971 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09003972 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003973 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
3974 ptr = strWID.ps8WidVal;
3975 *ptr++ = 0x14;
3976 *ptr++ = 0x3;
3977 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003978 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003979 ptr += ETH_ALEN;
3980 *ptr++ = strHostIfBASessionInfo->u8Ted;
3981 /* BA direction = recipent*/
3982 *ptr++ = 0;
3983 /* Delba Reason */
3984 *ptr++ = 32; /* Unspecific QOS reason */
3985
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003986 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3987 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003988 if (s32Error)
3989 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
3990
3991
3992 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09003993 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003994
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003995 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003996
3997 return s32Error;
3998
3999}
4000
4001/**
4002 * @brief hostIFthread
4003 * @details Main thread to handle message queue requests
4004 * @param[in] void* pvArg
4005 * @return NONE
4006 * @author
4007 * @date
4008 * @version 1.0
4009 */
Arnd Bergmann1999bd52015-05-29 22:52:14 +02004010static int hostIFthread(void *pvArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004011{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004012 u32 u32Ret;
Tony Cho143eb952015-09-21 12:16:32 +09004013 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004014 tstrWILC_WFIDrv *pstrWFIDrv;
4015
Tony Cho143eb952015-09-21 12:16:32 +09004016 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004017
4018 while (1) {
Tony Cho143eb952015-09-21 12:16:32 +09004019 wilc_mq_recv(&gMsgQHostIF, &msg, sizeof(struct host_if_msg), &u32Ret);
4020 pstrWFIDrv = (tstrWILC_WFIDrv *)msg.drvHandler;
Tony Choa9f812a2015-09-21 12:16:33 +09004021 if (msg.id == HOST_IF_MSG_EXIT) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004022 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
4023 break;
4024 }
4025
4026
4027 /*Re-Queue HIF message*/
4028 if ((!g_wilc_initialized)) {
4029 PRINT_D(GENERIC_DBG, "--WAIT--");
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07004030 usleep_range(200 * 1000, 200 * 1000);
Tony Cho143eb952015-09-21 12:16:32 +09004031 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004032 continue;
4033 }
4034
Tony Choa9f812a2015-09-21 12:16:33 +09004035 if (msg.id == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004036 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
Tony Cho143eb952015-09-21 12:16:32 +09004037 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07004038 usleep_range(2 * 1000, 2 * 1000);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004039 continue;
4040 }
4041
Tony Choa9f812a2015-09-21 12:16:33 +09004042 switch (msg.id) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004043 case HOST_IF_MSG_Q_IDLE:
4044 Handle_wait_msg_q_empty();
4045 break;
4046
4047 case HOST_IF_MSG_SCAN:
Tony Cho4528bdb2015-09-30 18:44:20 +09004048 Handle_Scan(msg.drvHandler, &msg.body.scan_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004049 break;
4050
4051 case HOST_IF_MSG_CONNECT:
Tony Cho3f501972015-09-30 18:44:21 +09004052 Handle_Connect(msg.drvHandler, &msg.body.con_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004053 break;
4054
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004055 case HOST_IF_MSG_FLUSH_CONNECT:
Tony Cho143eb952015-09-21 12:16:32 +09004056 Handle_FlushConnect(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004057 break;
4058
4059 case HOST_IF_MSG_RCVD_NTWRK_INFO:
Tony Cho02d19462015-09-30 18:44:22 +09004060 Handle_RcvdNtwrkInfo(msg.drvHandler, &msg.body.net_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004061 break;
4062
4063 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
Tony Cho66add622015-09-30 18:44:23 +09004064 Handle_RcvdGnrlAsyncInfo(msg.drvHandler, &msg.body.async_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004065 break;
4066
4067 case HOST_IF_MSG_KEY:
Tony Cho18990bf2015-09-30 18:44:24 +09004068 Handle_Key(msg.drvHandler, &msg.body.key_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004069 break;
4070
4071 case HOST_IF_MSG_CFG_PARAMS:
4072
Tony Choa2340c32015-09-30 18:44:25 +09004073 Handle_CfgParam(msg.drvHandler, &msg.body.cfg_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004074 break;
4075
4076 case HOST_IF_MSG_SET_CHANNEL:
Tony Choffd6dbc2015-09-30 18:44:28 +09004077 Handle_SetChannel(msg.drvHandler, &msg.body.channel_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004078 break;
4079
4080 case HOST_IF_MSG_DISCONNECT:
Tony Cho143eb952015-09-21 12:16:32 +09004081 Handle_Disconnect(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004082 break;
4083
4084 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07004085 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004086 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
4087
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004088 /*Allow chip sleep, only if both interfaces are not connected*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004089 if (!linux_wlan_get_num_conn_ifcs())
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004090 chip_sleep_manually(INFINITE_SLEEP_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004091
Tony Cho143eb952015-09-21 12:16:32 +09004092 Handle_ScanDone(msg.drvHandler, SCAN_EVENT_DONE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004093
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004094 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
Tony Cho070d3652015-09-30 18:55:10 +09004095 Handle_RemainOnChan(msg.drvHandler, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004096
4097 break;
4098
4099 case HOST_IF_MSG_GET_RSSI:
Tony Cho143eb952015-09-21 12:16:32 +09004100 Handle_GetRssi(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004101 break;
4102
4103 case HOST_IF_MSG_GET_LINKSPEED:
Tony Cho143eb952015-09-21 12:16:32 +09004104 Handle_GetLinkspeed(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004105 break;
4106
4107 case HOST_IF_MSG_GET_STATISTICS:
Tony Cho410c2482015-09-21 12:16:35 +09004108 Handle_GetStatistics(msg.drvHandler, (tstrStatistics *)msg.body.pUserData);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004109 break;
4110
4111 case HOST_IF_MSG_GET_CHNL:
Tony Cho143eb952015-09-21 12:16:32 +09004112 Handle_GetChnl(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004113 break;
4114
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004115 case HOST_IF_MSG_ADD_BEACON:
Tony Choa98491e2015-09-30 18:44:31 +09004116 Handle_AddBeacon(msg.drvHandler, &msg.body.beacon_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004117 break;
4118
4119 case HOST_IF_MSG_DEL_BEACON:
Tony Cho80bf88362015-09-30 18:44:29 +09004120 Handle_DelBeacon(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004121 break;
4122
4123 case HOST_IF_MSG_ADD_STATION:
Tony Choca8f47f2015-09-30 18:44:32 +09004124 Handle_AddStation(msg.drvHandler, &msg.body.add_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004125 break;
4126
4127 case HOST_IF_MSG_DEL_STATION:
Tony Cho889c25b2015-09-30 18:44:33 +09004128 Handle_DelStation(msg.drvHandler, &msg.body.del_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004129 break;
4130
4131 case HOST_IF_MSG_EDIT_STATION:
Tony Cho4a930962015-09-30 18:44:34 +09004132 Handle_EditStation(msg.drvHandler, &msg.body.edit_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004133 break;
4134
4135 case HOST_IF_MSG_GET_INACTIVETIME:
Tony Cho66bac7f2015-09-30 18:44:37 +09004136 Handle_Get_InActiveTime(msg.drvHandler, &msg.body.mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004137 break;
4138
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004139 case HOST_IF_MSG_SCAN_TIMER_FIRED:
4140 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
4141
Tony Cho143eb952015-09-21 12:16:32 +09004142 Handle_ScanDone(msg.drvHandler, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004143 break;
4144
4145 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004146 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
Tony Cho143eb952015-09-21 12:16:32 +09004147 Handle_ConnectTimeout(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004148 break;
4149
4150 case HOST_IF_MSG_POWER_MGMT:
Tony Cho49e1f812015-09-30 18:44:36 +09004151 Handle_PowerManagement(msg.drvHandler, &msg.body.pwr_mgmt_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004152 break;
4153
4154 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
Tony Cho143eb952015-09-21 12:16:32 +09004155 Handle_SetWfiDrvHandler(msg.drvHandler,
Tony Cho5e4377e2015-09-30 18:44:38 +09004156 &msg.body.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004157 break;
4158
4159 case HOST_IF_MSG_SET_OPERATION_MODE:
Tony Cho00c46302015-09-30 18:55:06 +09004160 Handle_SetOperationMode(msg.drvHandler, &msg.body.mode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004161 break;
4162
4163 case HOST_IF_MSG_SET_IPADDRESS:
4164 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Tony Chofb2d65e2015-09-30 18:44:39 +09004165 Handle_set_IPAddress(msg.drvHandler, msg.body.ip_info.au8IPAddr, msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004166 break;
4167
4168 case HOST_IF_MSG_GET_IPADDRESS:
4169 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Tony Chofb2d65e2015-09-30 18:44:39 +09004170 Handle_get_IPAddress(msg.drvHandler, msg.body.ip_info.au8IPAddr, msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004171 break;
4172
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004173 case HOST_IF_MSG_SET_MAC_ADDRESS:
Tony Cho15326e22015-09-30 18:55:07 +09004174 Handle_SetMacAddress(msg.drvHandler, &msg.body.set_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004175 break;
4176
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004177 case HOST_IF_MSG_GET_MAC_ADDRESS:
Tony Choa5848692015-09-30 18:55:08 +09004178 Handle_GetMacAddress(msg.drvHandler, &msg.body.get_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004179 break;
4180
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004181 case HOST_IF_MSG_REMAIN_ON_CHAN:
4182 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
Tony Cho070d3652015-09-30 18:55:10 +09004183 Handle_RemainOnChan(msg.drvHandler, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004184 break;
4185
4186 case HOST_IF_MSG_REGISTER_FRAME:
4187 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
Tony Cho410c2482015-09-21 12:16:35 +09004188 Handle_RegisterFrame(msg.drvHandler, &msg.body.strHostIfRegisterFrame);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004189 break;
4190
4191 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
Tony Cho070d3652015-09-30 18:55:10 +09004192 Handle_ListenStateExpired(msg.drvHandler, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004193 break;
4194
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004195 case HOST_IF_MSG_SET_MULTICAST_FILTER:
4196 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
Tony Choa079cf4d2015-09-30 18:55:05 +09004197 Handle_SetMulticastFilter(msg.drvHandler, &msg.body.multicast_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004198 break;
4199
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004200 case HOST_IF_MSG_ADD_BA_SESSION:
Tony Choc833b472015-09-30 18:55:09 +09004201 Handle_AddBASession(msg.drvHandler, &msg.body.session_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004202 break;
4203
4204 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
Tony Choc833b472015-09-30 18:55:09 +09004205 Handle_DelAllRxBASessions(msg.drvHandler, &msg.body.session_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004206 break;
4207
4208 case HOST_IF_MSG_DEL_ALL_STA:
Tony Cho410c2482015-09-21 12:16:35 +09004209 Handle_DelAllSta(msg.drvHandler, &msg.body.strHostIFDelAllSta);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004210 break;
4211
4212 default:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004213 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004214 break;
4215 }
4216 }
4217
4218 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004219 up(&hSemHostIFthrdEnd);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02004220 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004221}
4222
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004223static void TimerCB_Scan(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004224{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004225 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09004226 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004227
4228 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09004229 memset(&msg, 0, sizeof(struct host_if_msg));
4230 msg.drvHandler = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09004231 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004232
4233 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004234 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004235}
4236
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004237static void TimerCB_Connect(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004238{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004239 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09004240 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004241
4242 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09004243 memset(&msg, 0, sizeof(struct host_if_msg));
4244 msg.drvHandler = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09004245 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004246
4247 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004248 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004249}
4250
4251
4252/**
4253 * @brief removes wpa/wpa2 keys
4254 * @details only in BSS STA mode if External Supplicant support is enabled.
4255 * removes all WPA/WPA2 station key entries from MAC hardware.
4256 * @param[in,out] handle to the wifi driver
4257 * @param[in] 6 bytes of Station Adress in the station entry table
4258 * @return Error code indicating success/failure
4259 * @note
4260 * @author zsalah
4261 * @date 8 March 2012
4262 * @version 1.0
4263 */
4264/* Check implementation in core adding 9 bytes to the input! */
Johnny Kim218dc402015-08-13 13:41:19 +09004265s32 host_int_remove_key(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8StaAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004266{
Leo Kime6e12662015-09-16 18:36:03 +09004267 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004268 tstrWID strWID;
4269 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4270
Chaehyun Limd85f5322015-06-11 14:35:54 +09004271 strWID.u16WIDid = (u16)WID_REMOVE_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004272 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09004273 strWID.ps8WidVal = (s8 *)pu8StaAddress;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004274 strWID.s32ValueSize = 6;
4275
4276 return s32Error;
4277
4278}
4279
4280/**
4281 * @brief removes WEP key
4282 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4283 * remove a WEP key entry from MAC HW.
4284 * The BSS Station automatically finds the index of the entry using its
4285 * BSS ID and removes that entry from the MAC hardware.
4286 * @param[in,out] handle to the wifi driver
4287 * @param[in] 6 bytes of Station Adress in the station entry table
4288 * @return Error code indicating success/failure
4289 * @note NO need for the STA add since it is not used for processing
4290 * @author zsalah
4291 * @date 8 March 2012
4292 * @version 1.0
4293 */
Johnny Kim218dc402015-08-13 13:41:19 +09004294s32 host_int_remove_wep_key(tstrWILC_WFIDrv *hWFIDrv, u8 u8keyIdx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004295{
Leo Kime6e12662015-09-16 18:36:03 +09004296 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004297 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004298 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004299
4300
Leo Kim24db7132015-09-16 18:36:01 +09004301 if (pstrWFIDrv == NULL) {
4302 s32Error = -EFAULT;
4303 PRINT_ER("Failed to send setup multicast config packet\n");
4304 return s32Error;
4305 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004306
4307 /* prepare the Remove Wep Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004308 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004309
4310
Tony Choa9f812a2015-09-21 12:16:33 +09004311 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004312 msg.body.key_info.enuKeyType = WEP;
4313 msg.body.key_info.u8KeyAction = REMOVEKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004314 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004315
4316
4317
Tony Cho18990bf2015-09-30 18:44:24 +09004318 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004319 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8keyIdx;
4320
4321 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004322 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004323 if (s32Error)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004324 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004325 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004326
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004327 return s32Error;
4328}
4329
4330/**
4331 * @brief sets WEP default key
4332 * @details Sets the index of the WEP encryption key in use,
4333 * in the key table
4334 * @param[in,out] handle to the wifi driver
4335 * @param[in] key index ( 0, 1, 2, 3)
4336 * @return Error code indicating success/failure
4337 * @note
4338 * @author zsalah
4339 * @date 8 March 2012
4340 * @version 1.0
4341 */
Johnny Kim218dc402015-08-13 13:41:19 +09004342s32 host_int_set_WEPDefaultKeyID(tstrWILC_WFIDrv *hWFIDrv, u8 u8Index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004343{
Leo Kime6e12662015-09-16 18:36:03 +09004344 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004345 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004346 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004347
4348
Leo Kim24db7132015-09-16 18:36:01 +09004349 if (pstrWFIDrv == NULL) {
4350 s32Error = -EFAULT;
4351 PRINT_ER("driver is null\n");
4352 return s32Error;
4353 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004354
4355 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004356 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004357
4358
Tony Choa9f812a2015-09-21 12:16:33 +09004359 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004360 msg.body.key_info.enuKeyType = WEP;
4361 msg.body.key_info.u8KeyAction = DEFAULTKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004362 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004363
4364
Tony Cho18990bf2015-09-30 18:44:24 +09004365 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004366 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
4367
4368 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004369 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004370 if (s32Error)
4371 PRINT_ER("Error in sending message queue : Default key index\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004372 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004373
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004374 return s32Error;
4375}
4376
4377/**
4378 * @brief sets WEP deafault key
4379 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4380 * sets WEP key entry into MAC hardware when it receives the
4381 * corresponding request from NDIS.
4382 * @param[in,out] handle to the wifi driver
4383 * @param[in] message containing WEP Key in the following format
4384 *|---------------------------------------|
4385 *|Key ID Value | Key Length | Key |
4386 *|-------------|------------|------------|
4387 | 1byte | 1byte | Key Length |
4388 ||---------------------------------------|
4389 |
4390 * @return Error code indicating success/failure
4391 * @note
4392 * @author zsalah
4393 * @date 8 March 2012
4394 * @version 1.0
4395 */
Johnny Kim218dc402015-08-13 13:41:19 +09004396s32 host_int_add_wep_key_bss_sta(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004397{
4398
Leo Kime6e12662015-09-16 18:36:03 +09004399 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004400 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004401 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004402
Leo Kim24db7132015-09-16 18:36:01 +09004403 if (pstrWFIDrv == NULL) {
4404 s32Error = -EFAULT;
4405 PRINT_ER("driver is null\n");
4406 return s32Error;
4407 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004408
4409 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004410 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004411
4412
Tony Choa9f812a2015-09-21 12:16:33 +09004413 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004414 msg.body.key_info.enuKeyType = WEP;
4415 msg.body.key_info.u8KeyAction = ADDKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004416 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004417
4418
Tony Cho18990bf2015-09-30 18:44:24 +09004419 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004420 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004421
Tony Cho18990bf2015-09-30 18:44:24 +09004422 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004423 pu8WepKey, u8WepKeylen);
4424
4425
Tony Cho18990bf2015-09-30 18:44:24 +09004426 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004427 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4428
Tony Cho18990bf2015-09-30 18:44:24 +09004429 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004430 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4431
4432 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004433 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004434 if (s32Error)
4435 PRINT_ER("Error in sending message queue :WEP Key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004436 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004437
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004438 return s32Error;
4439
4440}
4441
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004442/**
4443 *
4444 * @brief host_int_add_wep_key_bss_ap
4445 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4446 * sets WEP key entry into MAC hardware when it receives the
4447 *
4448 * corresponding request from NDIS.
4449 * @param[in,out] handle to the wifi driver
4450 *
4451 *
4452 * @return Error code indicating success/failure
4453 * @note
4454 * @author mdaftedar
4455 * @date 28 FEB 2013
4456 * @version 1.0
4457 */
Johnny Kim218dc402015-08-13 13:41:19 +09004458s32 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 +09004459{
4460
Leo Kime6e12662015-09-16 18:36:03 +09004461 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004462 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004463 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004464 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004465
Leo Kim24db7132015-09-16 18:36:01 +09004466 if (pstrWFIDrv == NULL) {
4467 s32Error = -EFAULT;
4468 PRINT_ER("driver is null\n");
4469 return s32Error;
4470 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004471
4472 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004473 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004474
4475 if (INFO) {
4476 for (i = 0; i < u8WepKeylen; i++)
4477 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4478 }
Tony Choa9f812a2015-09-21 12:16:33 +09004479 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004480 msg.body.key_info.enuKeyType = WEP;
4481 msg.body.key_info.u8KeyAction = ADDKEY_AP;
Tony Cho143eb952015-09-21 12:16:32 +09004482 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004483
4484
Tony Cho18990bf2015-09-30 18:44:24 +09004485 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004486 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004487
4488
Tony Cho18990bf2015-09-30 18:44:24 +09004489 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004490 pu8WepKey, (u8WepKeylen));
4491
4492
Tony Cho18990bf2015-09-30 18:44:24 +09004493 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004494 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4495
Tony Cho18990bf2015-09-30 18:44:24 +09004496 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004497 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4498
Tony Cho18990bf2015-09-30 18:44:24 +09004499 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004500 uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
4501
Tony Cho18990bf2015-09-30 18:44:24 +09004502 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004503 uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
4504 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004505 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004506
4507 if (s32Error)
4508 PRINT_ER("Error in sending message queue :WEP Key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004509 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004510
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004511 return s32Error;
4512
4513}
Glen Lee108b3432015-09-16 18:53:20 +09004514
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004515/**
4516 * @brief adds ptk Key
4517 * @details
4518 * @param[in,out] handle to the wifi driver
4519 * @param[in] message containing PTK Key in the following format
4520 *|-----------------------------------------------------------------------------|
4521 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4522 *|----------------|------------|--------------|----------------|---------------|
4523 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4524 ||-----------------------------------------------------------------------------|
4525 * @return Error code indicating success/failure
4526 * @note
4527 * @author zsalah
4528 * @date 8 March 2012
4529 * @version 1.0
4530 */
Johnny Kim218dc402015-08-13 13:41:19 +09004531s32 host_int_add_ptk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004532 const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004533{
Leo Kime6e12662015-09-16 18:36:03 +09004534 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004535 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004536 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004537 u8 u8KeyLen = u8PtkKeylen;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004538 u32 i;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004539
Leo Kim24db7132015-09-16 18:36:01 +09004540 if (pstrWFIDrv == NULL) {
4541 s32Error = -EFAULT;
4542 PRINT_ER("driver is null\n");
4543 return s32Error;
4544 }
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004545 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004546 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004547 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004548 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004549
4550 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004551 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004552
4553
Tony Choa9f812a2015-09-21 12:16:33 +09004554 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004555 msg.body.key_info.enuKeyType = WPAPtk;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004556 if (mode == AP_MODE) {
Tony Cho18990bf2015-09-30 18:44:24 +09004557 msg.body.key_info.u8KeyAction = ADDKEY_AP;
4558 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004559 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
4560 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004561 if (mode == STATION_MODE)
Tony Cho18990bf2015-09-30 18:44:24 +09004562 msg.body.key_info.u8KeyAction = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004563
4564
Tony Cho18990bf2015-09-30 18:44:24 +09004565 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004566 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8PtkKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004567
4568
Tony Cho18990bf2015-09-30 18:44:24 +09004569 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004570 pu8Ptk, u8PtkKeylen);
4571
4572 if (pu8RxMic != NULL) {
4573
Tony Cho18990bf2015-09-30 18:44:24 +09004574 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004575 pu8RxMic, RX_MIC_KEY_LEN);
4576 if (INFO) {
4577 for (i = 0; i < RX_MIC_KEY_LEN; i++)
4578 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
4579 }
4580 }
4581 if (pu8TxMic != NULL) {
4582
Tony Cho18990bf2015-09-30 18:44:24 +09004583 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004584 pu8TxMic, TX_MIC_KEY_LEN);
4585 if (INFO) {
4586 for (i = 0; i < TX_MIC_KEY_LEN; i++)
4587 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
4588 }
4589 }
4590
Tony Cho18990bf2015-09-30 18:44:24 +09004591 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004592 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4593
Tony Cho18990bf2015-09-30 18:44:24 +09004594 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004595 uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
Tony Cho18990bf2015-09-30 18:44:24 +09004596 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004597 uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
Tony Cho143eb952015-09-21 12:16:32 +09004598 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004599
4600 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004601 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004602
4603 if (s32Error)
4604 PRINT_ER("Error in sending message queue: PTK Key\n");
4605
4606 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004607 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004608 /* /////// */
4609
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004610 return s32Error;
4611}
4612
4613/**
4614 * @brief adds Rx GTk Key
4615 * @details
4616 * @param[in,out] handle to the wifi driver
4617 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
4618 * u8GtkKeylen :The total key length
4619 *
4620 * @return Error code indicating success/failure
4621 * @note
4622 * @author zsalah
4623 * @date 8 March 2012
4624 * @version 1.0
4625 */
Johnny Kim218dc402015-08-13 13:41:19 +09004626s32 host_int_add_rx_gtk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004627 u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004628 const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004629{
Leo Kime6e12662015-09-16 18:36:03 +09004630 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004631 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004632 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004633 u8 u8KeyLen = u8GtkKeylen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004634
Leo Kim24db7132015-09-16 18:36:01 +09004635 if (pstrWFIDrv == NULL) {
4636 s32Error = -EFAULT;
4637 PRINT_ER("driver is null\n");
4638 return s32Error;
4639 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004640 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004641 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004642
4643
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004644 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004645 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004646 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004647 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004648 if (KeyRSC != NULL) {
Tony Cho18990bf2015-09-30 18:44:24 +09004649 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004650 uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004651
Tony Cho18990bf2015-09-30 18:44:24 +09004652 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004653 KeyRSC, u32KeyRSClen);
4654 }
4655
4656
Tony Choa9f812a2015-09-21 12:16:33 +09004657 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004658 msg.body.key_info.enuKeyType = WPARxGtk;
Tony Cho143eb952015-09-21 12:16:32 +09004659 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004660
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004661 if (mode == AP_MODE) {
Tony Cho18990bf2015-09-30 18:44:24 +09004662 msg.body.key_info.u8KeyAction = ADDKEY_AP;
4663 msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004664 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004665 if (mode == STATION_MODE)
Tony Cho18990bf2015-09-30 18:44:24 +09004666 msg.body.key_info.u8KeyAction = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004667
4668
Tony Cho18990bf2015-09-30 18:44:24 +09004669 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004670 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8KeyLen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004671
Tony Cho18990bf2015-09-30 18:44:24 +09004672 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004673 pu8RxGtk, u8GtkKeylen);
4674
4675 if (pu8RxMic != NULL) {
4676
Tony Cho18990bf2015-09-30 18:44:24 +09004677 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004678 pu8RxMic, RX_MIC_KEY_LEN);
4679
4680 }
4681 if (pu8TxMic != NULL) {
4682
Tony Cho18990bf2015-09-30 18:44:24 +09004683 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004684 pu8TxMic, TX_MIC_KEY_LEN);
4685
4686 }
4687
Tony Cho18990bf2015-09-30 18:44:24 +09004688 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004689 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
Tony Cho18990bf2015-09-30 18:44:24 +09004690 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004691 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4692
Tony Cho18990bf2015-09-30 18:44:24 +09004693 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004694 uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
4695
4696
4697
4698 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004699 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004700 if (s32Error)
4701 PRINT_ER("Error in sending message queue: RX GTK\n");
4702 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004703 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004704 /* /////// */
4705
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004706 return s32Error;
4707}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004708
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004709/**
4710 * @brief host_int_set_pmkid_info
4711 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
4712 * support is enabled. This Function sets the PMKID in firmware
4713 * when host drivr receives the corresponding request from NDIS.
4714 * The firmware then includes theset PMKID in the appropriate
4715 * management frames
4716 * @param[in,out] handle to the wifi driver
4717 * @param[in] message containing PMKID Info in the following format
4718 *|-----------------------------------------------------------------|
4719 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
4720 *|-----------|------------|----------|-------|----------|----------|
4721 | 1 | 6 | 16 | ... | 6 | 16 |
4722 ||-----------------------------------------------------------------|
4723 * @return Error code indicating success/failure
4724 * @note
4725 * @author zsalah
4726 * @date 8 March 2012
4727 * @version 1.0
4728 */
Johnny Kim218dc402015-08-13 13:41:19 +09004729s32 host_int_set_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004730{
Leo Kime6e12662015-09-16 18:36:03 +09004731 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004732 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004733 struct host_if_msg msg;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004734 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004735
4736
Leo Kim24db7132015-09-16 18:36:01 +09004737 if (pstrWFIDrv == NULL) {
4738 s32Error = -EFAULT;
4739 PRINT_ER("driver is null\n");
4740 return s32Error;
4741 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004742
4743 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004744 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004745
Tony Choa9f812a2015-09-21 12:16:33 +09004746 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004747 msg.body.key_info.enuKeyType = PMKSA;
4748 msg.body.key_info.u8KeyAction = ADDKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004749 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004750
4751 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
4752
Tony Cho18990bf2015-09-30 18:44:24 +09004753 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004754 ETH_ALEN);
4755
Tony Cho18990bf2015-09-30 18:44:24 +09004756 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004757 PMKID_LEN);
4758 }
4759
4760 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004761 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004762 if (s32Error)
4763 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
4764
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004765 return s32Error;
4766}
4767
4768/**
4769 * @brief gets the cached the pmkid info
4770 * @details valid only in BSS STA mode if External Supplicant
4771 * support is enabled. This Function sets the PMKID in firmware
4772 * when host drivr receives the corresponding request from NDIS.
4773 * The firmware then includes theset PMKID in the appropriate
4774 * management frames
4775 * @param[in,out] handle to the wifi driver,
4776 * message containing PMKID Info in the following format
4777 *|-----------------------------------------------------------------|
4778 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
4779 *|-----------|------------|----------|-------|----------|----------|
4780 | 1 | 6 | 16 | ... | 6 | 16 |
4781 ||-----------------------------------------------------------------|
4782 * @param[in]
4783 * @return Error code indicating success/failure
4784 * @note
4785 * @author zsalah
4786 * @date 8 March 2012
4787 * @version 1.0
4788 */
Johnny Kim218dc402015-08-13 13:41:19 +09004789s32 host_int_get_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PmkidInfoArray,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004790 u32 u32PmkidInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004791{
Leo Kime6e12662015-09-16 18:36:03 +09004792 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004793 tstrWID strWID;
4794 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4795
Chaehyun Limd85f5322015-06-11 14:35:54 +09004796 strWID.u16WIDid = (u16)WID_PMKID_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004797 strWID.enuWIDtype = WID_STR;
4798 strWID.s32ValueSize = u32PmkidInfoLen;
4799 strWID.ps8WidVal = pu8PmkidInfoArray;
4800
4801 return s32Error;
4802}
4803
4804/**
4805 * @brief sets the pass phrase
4806 * @details AP/STA mode. This function gives the pass phrase used to
4807 * generate the Pre-Shared Key when WPA/WPA2 is enabled
4808 * The length of the field can vary from 8 to 64 bytes,
4809 * the lower layer should get the
4810 * @param[in,out] handle to the wifi driver,
4811 * @param[in] String containing PSK
4812 * @return Error code indicating success/failure
4813 * @note
4814 * @author zsalah
4815 * @date 8 March 2012
4816 * @version 1.0
4817 */
Johnny Kim218dc402015-08-13 13:41:19 +09004818s32 host_int_set_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PassPhrase,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004819 u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004820{
Leo Kime6e12662015-09-16 18:36:03 +09004821 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004822 tstrWID strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004823
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004824 /*validating psk length*/
4825 if ((u8Psklength > 7) && (u8Psklength < 65)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09004826 strWID.u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004827 strWID.enuWIDtype = WID_STR;
4828 strWID.ps8WidVal = pu8PassPhrase;
4829 strWID.s32ValueSize = u8Psklength;
4830 }
4831
4832 return s32Error;
4833}
4834/**
4835 * @brief host_int_get_MacAddress
4836 * @details gets mac address
4837 * @param[in,out] handle to the wifi driver,
4838 *
4839 * @return Error code indicating success/failure
4840 * @note
4841 * @author mdaftedar
4842 * @date 19 April 2012
4843 * @version 1.0
4844 */
Johnny Kim218dc402015-08-13 13:41:19 +09004845s32 host_int_get_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004846{
Leo Kime6e12662015-09-16 18:36:03 +09004847 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004848 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004849
4850
4851 /* prepare the Message */
Tony Cho143eb952015-09-21 12:16:32 +09004852 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004853
Tony Choa9f812a2015-09-21 12:16:33 +09004854 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
Tony Choa5848692015-09-30 18:55:08 +09004855 msg.body.get_mac_info.u8MacAddress = pu8MacAddress;
Tony Cho143eb952015-09-21 12:16:32 +09004856 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004857 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004858 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004859 if (s32Error) {
4860 PRINT_ER("Failed to send get mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +09004861 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004862 }
4863
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004864 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004865 return s32Error;
4866}
4867
4868/**
4869 * @brief host_int_set_MacAddress
4870 * @details sets mac address
4871 * @param[in,out] handle to the wifi driver,
4872 *
4873 * @return Error code indicating success/failure
4874 * @note
4875 * @author mabubakr
4876 * @date 16 July 2012
4877 * @version 1.0
4878 */
Johnny Kim218dc402015-08-13 13:41:19 +09004879s32 host_int_set_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004880{
Leo Kime6e12662015-09-16 18:36:03 +09004881 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004882 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004883
4884 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
4885
4886 /* prepare setting mac address message */
Tony Cho143eb952015-09-21 12:16:32 +09004887 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09004888 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
Tony Cho15326e22015-09-30 18:55:07 +09004889 memcpy(msg.body.set_mac_info.u8MacAddress, pu8MacAddress, ETH_ALEN);
Tony Cho143eb952015-09-21 12:16:32 +09004890 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004891
Tony Cho143eb952015-09-21 12:16:32 +09004892 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09004893 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004894 PRINT_ER("Failed to send message queue: Set mac address\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004895
4896 return s32Error;
4897
4898}
4899
4900/**
4901 * @brief host_int_get_RSNAConfigPSKPassPhrase
4902 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
4903 * generate the Pre-Shared Key when WPA/WPA2 is enabled
4904 * The length of the field can vary from 8 to 64 bytes,
4905 * the lower layer should get the
4906 * @param[in,out] handle to the wifi driver,
4907 * String containing PSK
4908 * @return Error code indicating success/failure
4909 * @note
4910 * @author zsalah
4911 * @date 8 March 2012
4912 * @version 1.0
4913 */
Johnny Kim218dc402015-08-13 13:41:19 +09004914s32 host_int_get_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004915 u8 *pu8PassPhrase, u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004916{
Leo Kime6e12662015-09-16 18:36:03 +09004917 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004918 tstrWID strWID;
4919 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4920
Chaehyun Limd85f5322015-06-11 14:35:54 +09004921 strWID.u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004922 strWID.enuWIDtype = WID_STR;
4923 strWID.s32ValueSize = u8Psklength;
4924 strWID.ps8WidVal = pu8PassPhrase;
4925
4926 return s32Error;
4927}
4928
4929/**
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004930 * @brief sets a start scan request
4931 * @details
4932 * @param[in,out] handle to the wifi driver,
4933 * @param[in] Scan Source one of the following values
4934 * DEFAULT_SCAN 0
4935 * USER_SCAN BIT0
4936 * OBSS_PERIODIC_SCAN BIT1
4937 * OBSS_ONETIME_SCAN BIT2
4938 * @return Error code indicating success/failure
4939 * @note
4940 * @author zsalah
4941 * @date 8 March 2012
4942 * @version 1.0
4943 */
Johnny Kim218dc402015-08-13 13:41:19 +09004944s32 host_int_set_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 scanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004945{
Leo Kime6e12662015-09-16 18:36:03 +09004946 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004947 tstrWID strWID;
4948 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4949
Chaehyun Limd85f5322015-06-11 14:35:54 +09004950 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004951 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09004952 strWID.ps8WidVal = (s8 *)&scanSource;
Dean Lee576917a2015-06-15 11:58:57 +09004953 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004954
4955 return s32Error;
4956}
4957
4958/**
4959 * @brief host_int_get_start_scan_req
4960 * @details gets a start scan request
4961 * @param[in,out] handle to the wifi driver,
4962 * @param[in] Scan Source one of the following values
4963 * DEFAULT_SCAN 0
4964 * USER_SCAN BIT0
4965 * OBSS_PERIODIC_SCAN BIT1
4966 * OBSS_ONETIME_SCAN BIT2
4967 * @return Error code indicating success/failure
4968 * @note
4969 * @author zsalah
4970 * @date 8 March 2012
4971 * @version 1.0
4972 */
4973
Johnny Kim218dc402015-08-13 13:41:19 +09004974s32 host_int_get_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ScanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004975{
Leo Kime6e12662015-09-16 18:36:03 +09004976 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004977 tstrWID strWID;
4978 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4979
Chaehyun Limd85f5322015-06-11 14:35:54 +09004980 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004981 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09004982 strWID.ps8WidVal = (s8 *)pu8ScanSource;
Dean Lee576917a2015-06-15 11:58:57 +09004983 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004984
4985 return s32Error;
4986}
4987
4988/**
4989 * @brief host_int_set_join_req
4990 * @details sets a join request
4991 * @param[in,out] handle to the wifi driver,
4992 * @param[in] Index of the bss descriptor
4993 * @return Error code indicating success/failure
4994 * @note
4995 * @author zsalah
4996 * @date 8 March 2012
4997 * @version 1.0
4998 */
Johnny Kim218dc402015-08-13 13:41:19 +09004999s32 host_int_set_join_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8bssid,
Arnd Bergmann057d1e92015-06-01 21:06:44 +02005000 const u8 *pu8ssid, size_t ssidLen,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005001 const u8 *pu8IEs, size_t IEsLen,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005002 tWILCpfConnectResult pfConnectResult, void *pvUserArg,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005003 u8 u8security, AUTHTYPE_T tenuAuth_type,
5004 u8 u8channel,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005005 void *pJoinParams)
5006{
Leo Kime6e12662015-09-16 18:36:03 +09005007 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005008 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005009 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005010 tenuScanConnTimer enuScanConnTimer;
5011
Leo Kim24db7132015-09-16 18:36:01 +09005012 if (pstrWFIDrv == NULL || pfConnectResult == NULL) {
5013 s32Error = -EFAULT;
5014 PRINT_ER("Driver is null\n");
5015 return s32Error;
5016 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005017
5018 if (hWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005019 PRINT_ER("Driver is null\n");
5020 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005021 }
5022
5023 if (pJoinParams == NULL) {
5024 PRINT_ER("Unable to Join - JoinParams is NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09005025 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005026 }
Leo Kim24db7132015-09-16 18:36:01 +09005027
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005028 /* prepare the Connect Message */
Tony Cho143eb952015-09-21 12:16:32 +09005029 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005030
Tony Choa9f812a2015-09-21 12:16:33 +09005031 msg.id = HOST_IF_MSG_CONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005032
Tony Cho3f501972015-09-30 18:44:21 +09005033 msg.body.con_info.u8security = u8security;
5034 msg.body.con_info.tenuAuth_type = tenuAuth_type;
5035 msg.body.con_info.u8channel = u8channel;
5036 msg.body.con_info.pfConnectResult = pfConnectResult;
5037 msg.body.con_info.pvUserArg = pvUserArg;
5038 msg.body.con_info.pJoinParams = pJoinParams;
Tony Cho143eb952015-09-21 12:16:32 +09005039 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005040
5041 if (pu8bssid != NULL) {
Tony Cho3f501972015-09-30 18:44:21 +09005042 msg.body.con_info.pu8bssid = kmalloc(6, GFP_KERNEL); /* will be deallocated by the receiving thread */
5043 memcpy(msg.body.con_info.pu8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005044 pu8bssid, 6);
5045 }
5046
5047 if (pu8ssid != NULL) {
Tony Cho3f501972015-09-30 18:44:21 +09005048 msg.body.con_info.ssidLen = ssidLen;
5049 msg.body.con_info.pu8ssid = kmalloc(ssidLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5050 memcpy(msg.body.con_info.pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005051
5052 pu8ssid, ssidLen);
5053 }
5054
5055 if (pu8IEs != NULL) {
Tony Cho3f501972015-09-30 18:44:21 +09005056 msg.body.con_info.IEsLen = IEsLen;
5057 msg.body.con_info.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5058 memcpy(msg.body.con_info.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005059 pu8IEs, IEsLen);
5060 }
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05305061 if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005062 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05305063 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005064 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate);
5065
5066 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005067 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005068 if (s32Error) {
5069 PRINT_ER("Failed to send message queue: Set join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09005070 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005071 }
5072
5073 enuScanConnTimer = CONNECT_TIMER;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005074 pstrWFIDrv->hConnectTimer.data = (unsigned long)hWFIDrv;
5075 mod_timer(&pstrWFIDrv->hConnectTimer,
5076 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005077
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005078 return s32Error;
5079}
5080
5081/**
5082 * @brief Flush a join request parameters to FW, but actual connection
5083 * @details The function is called in situation where WILC is connected to AP and
5084 * required to switch to hybrid FW for P2P connection
5085 * @param[in] handle to the wifi driver,
5086 * @return Error code indicating success/failure
5087 * @note
5088 * @author Amr Abdel-Moghny
5089 * @date 19 DEC 2013
5090 * @version 8.0
5091 */
5092
Johnny Kim218dc402015-08-13 13:41:19 +09005093s32 host_int_flush_join_req(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005094{
Leo Kime6e12662015-09-16 18:36:03 +09005095 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005096 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005097
5098 if (!gu8FlushedJoinReq) {
Leo Kime6e12662015-09-16 18:36:03 +09005099 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005100 return s32Error;
5101 }
5102
5103
Leo Kim24db7132015-09-16 18:36:01 +09005104 if (hWFIDrv == NULL) {
5105 s32Error = -EFAULT;
5106 PRINT_ER("Driver is null\n");
5107 return s32Error;
5108 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005109
Tony Choa9f812a2015-09-21 12:16:33 +09005110 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
Tony Cho143eb952015-09-21 12:16:32 +09005111 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005112
5113 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005114 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005115 if (s32Error) {
5116 PRINT_ER("Failed to send message queue: Flush join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09005117 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005118 }
5119
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005120 return s32Error;
5121}
5122
5123/**
5124 * @brief host_int_disconnect
5125 * @details disconnects from the currently associated network
5126 * @param[in,out] handle to the wifi driver,
5127 * @param[in] Reason Code of the Disconnection
5128 * @return Error code indicating success/failure
5129 * @note
5130 * @author zsalah
5131 * @date 8 March 2012
5132 * @version 1.0
5133 */
Johnny Kim218dc402015-08-13 13:41:19 +09005134s32 host_int_disconnect(tstrWILC_WFIDrv *hWFIDrv, u16 u16ReasonCode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005135{
Leo Kime6e12662015-09-16 18:36:03 +09005136 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005137 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005138 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5139
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005140 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005141 PRINT_ER("Driver is null\n");
5142 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005143 }
5144
5145 /* prepare the Disconnect Message */
Tony Cho143eb952015-09-21 12:16:32 +09005146 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005147
Tony Choa9f812a2015-09-21 12:16:33 +09005148 msg.id = HOST_IF_MSG_DISCONNECT;
Tony Cho143eb952015-09-21 12:16:32 +09005149 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005150
5151 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005152 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005153 if (s32Error)
5154 PRINT_ER("Failed to send message queue: disconnect\n");
5155 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005156 down(&(pstrWFIDrv->hSemTestDisconnectBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005157 /* /////// */
5158
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005159 return s32Error;
5160}
5161
5162/**
5163 * @brief host_int_disconnect_station
5164 * @details disconnects a sta
5165 * @param[in,out] handle to the wifi driver,
5166 * @param[in] Association Id of the station to be disconnected
5167 * @return Error code indicating success/failure
5168 * @note
5169 * @author zsalah
5170 * @date 8 March 2012
5171 * @version 1.0
5172 */
Johnny Kim218dc402015-08-13 13:41:19 +09005173s32 host_int_disconnect_station(tstrWILC_WFIDrv *hWFIDrv, u8 assoc_id)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005174{
Leo Kime6e12662015-09-16 18:36:03 +09005175 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005176 tstrWID strWID;
5177 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5178
Chaehyun Limd85f5322015-06-11 14:35:54 +09005179 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005180 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005181 strWID.ps8WidVal = (s8 *)&assoc_id;
Dean Lee576917a2015-06-15 11:58:57 +09005182 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005183
5184 return s32Error;
5185}
5186
5187/**
5188 * @brief host_int_get_assoc_req_info
5189 * @details gets a Association request info
5190 * @param[in,out] handle to the wifi driver,
5191 * Message containg assoc. req info in the following format
5192 * ------------------------------------------------------------------------
5193 | Management Frame Format |
5194 ||-------------------------------------------------------------------|
5195 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5196 ||-------------|--------|--|--|-----|----------------|----------|----|
5197 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5198 ||-------------------------------------------------------------------|
5199 | |
5200 | Association Request Frame - Frame Body |
5201 ||-------------------------------------------------------------------|
5202 | Capability Information | Listen Interval | SSID | Supported Rates |
5203 ||------------------------|-----------------|------|-----------------|
5204 | 2 | 2 | 2-34 | 3-10 |
5205 | ---------------------------------------------------------------------
5206 * @return Error code indicating success/failure
5207 * @note
5208 * @author zsalah
5209 * @date 8 March 2012
5210 * @version 1.0
5211 */
5212
Johnny Kim218dc402015-08-13 13:41:19 +09005213s32 host_int_get_assoc_req_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocReqInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005214 u32 u32AssocReqInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005215{
Leo Kime6e12662015-09-16 18:36:03 +09005216 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005217 tstrWID strWID;
5218 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5219
Chaehyun Limd85f5322015-06-11 14:35:54 +09005220 strWID.u16WIDid = (u16)WID_ASSOC_REQ_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005221 strWID.enuWIDtype = WID_STR;
5222 strWID.ps8WidVal = pu8AssocReqInfo;
5223 strWID.s32ValueSize = u32AssocReqInfoLen;
5224
5225
5226 return s32Error;
5227}
5228
5229/**
5230 * @brief gets a Association Response info
5231 * @details
5232 * @param[in,out] handle to the wifi driver,
5233 * Message containg assoc. resp info
5234 * @return Error code indicating success/failure
5235 * @note
5236 * @author zsalah
5237 * @date 8 March 2012
5238 * @version 1.0
5239 */
Johnny Kim218dc402015-08-13 13:41:19 +09005240s32 host_int_get_assoc_res_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocRespInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005241 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005242{
Leo Kime6e12662015-09-16 18:36:03 +09005243 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005244 tstrWID strWID;
5245 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5246
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005247 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005248 PRINT_ER("Driver is null\n");
5249 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005250 }
5251
Chaehyun Limd85f5322015-06-11 14:35:54 +09005252 strWID.u16WIDid = (u16)WID_ASSOC_RES_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005253 strWID.enuWIDtype = WID_STR;
5254 strWID.ps8WidVal = pu8AssocRespInfo;
5255 strWID.s32ValueSize = u32MaxAssocRespInfoLen;
5256
5257
5258 /* Sending Configuration packet */
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09005259 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
5260 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005261 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005262 *pu32RcvdAssocRespInfoLen = 0;
Leo Kim24db7132015-09-16 18:36:01 +09005263 PRINT_ER("Failed to send association response config packet\n");
5264 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005265 } else {
5266 *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize;
5267 }
5268
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005269 return s32Error;
5270}
5271
5272/**
5273 * @brief gets a Association Response info
5274 * @details Valid only in STA mode. This function gives the RSSI
5275 * values observed in all the channels at the time of scanning.
5276 * The length of the field is 1 greater that the total number of
5277 * channels supported. Byte 0 contains the number of channels while
5278 * each of Byte N contains the observed RSSI value for the channel index N.
5279 * @param[in,out] handle to the wifi driver,
5280 * array of scanned channels' RSSI
5281 * @return Error code indicating success/failure
5282 * @note
5283 * @author zsalah
5284 * @date 8 March 2012
5285 * @version 1.0
5286 */
Johnny Kim218dc402015-08-13 13:41:19 +09005287s32 host_int_get_rx_power_level(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8RxPowerLevel,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005288 u32 u32RxPowerLevelLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005289{
Leo Kime6e12662015-09-16 18:36:03 +09005290 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005291 tstrWID strWID;
5292 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5293
Chaehyun Limd85f5322015-06-11 14:35:54 +09005294 strWID.u16WIDid = (u16)WID_RX_POWER_LEVEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005295 strWID.enuWIDtype = WID_STR;
5296 strWID.ps8WidVal = pu8RxPowerLevel;
5297 strWID.s32ValueSize = u32RxPowerLevelLen;
5298
5299
5300 return s32Error;
5301}
5302
5303/**
5304 * @brief sets a channel
5305 * @details
5306 * @param[in,out] handle to the wifi driver,
5307 * @param[in] Index of the channel to be set
5308 *|-------------------------------------------------------------------|
5309 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5310 | Input: 1 2 14 |
5311 ||-------------------------------------------------------------------|
5312 * @return Error code indicating success/failure
5313 * @note
5314 * @author zsalah
5315 * @date 8 March 2012
5316 * @version 1.0
5317 */
Chaehyun Lim5ba48ec2015-10-02 21:44:52 +09005318int host_int_set_mac_chnl_num(tstrWILC_WFIDrv *wfi_drv, u8 channel)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005319{
Chaehyun Lim1ef58e42015-10-02 21:44:49 +09005320 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005321 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005322
Chaehyun Lim157da212015-10-05 11:07:21 +09005323 if (!wfi_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005324 PRINT_ER("driver is null\n");
5325 return -EFAULT;
5326 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005327
5328 /* prepare the set channel message */
Tony Cho143eb952015-09-21 12:16:32 +09005329 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005330 msg.id = HOST_IF_MSG_SET_CHANNEL;
Chaehyun Lim1c5833c2015-10-02 21:44:51 +09005331 msg.body.channel_info.u8SetChan = channel;
Chaehyun Lim5ba48ec2015-10-02 21:44:52 +09005332 msg.drvHandler = wfi_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005333
Chaehyun Lim1ef58e42015-10-02 21:44:49 +09005334 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5335 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09005336 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim1ef58e42015-10-02 21:44:49 +09005337 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005338 }
5339
Chaehyun Lim1ef58e42015-10-02 21:44:49 +09005340 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005341}
5342
5343
Chaehyun Lim244efb12015-10-02 21:44:53 +09005344int host_int_wait_msg_queue_idle(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005345{
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09005346 int result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005347
Tony Cho143eb952015-09-21 12:16:32 +09005348 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005349
5350 /* prepare the set driver handler message */
5351
Tony Cho143eb952015-09-21 12:16:32 +09005352 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005353 msg.id = HOST_IF_MSG_Q_IDLE;
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09005354 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5355 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09005356 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09005357 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005358 }
5359
5360 /* wait untill MSG Q is empty */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005361 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005362
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09005363 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005364}
5365
Johnny Kim218dc402015-08-13 13:41:19 +09005366s32 host_int_set_wfi_drv_handler(tstrWILC_WFIDrv *u32address)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005367{
Leo Kime6e12662015-09-16 18:36:03 +09005368 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005369
Tony Cho143eb952015-09-21 12:16:32 +09005370 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005371
5372
5373 /* prepare the set driver handler message */
5374
Tony Cho143eb952015-09-21 12:16:32 +09005375 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005376 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
Tony Cho5e4377e2015-09-30 18:44:38 +09005377 msg.body.drv.u32Address = get_id_from_handler(u32address);
Tony Cho143eb952015-09-21 12:16:32 +09005378 msg.drvHandler = u32address;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005379
Tony Cho143eb952015-09-21 12:16:32 +09005380 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005381 if (s32Error) {
5382 PRINT_ER("wilc mq send fail\n");
5383 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005384 }
5385
5386 return s32Error;
5387}
5388
5389
5390
Johnny Kim218dc402015-08-13 13:41:19 +09005391s32 host_int_set_operation_mode(tstrWILC_WFIDrv *hWFIDrv, u32 u32mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005392{
Leo Kime6e12662015-09-16 18:36:03 +09005393 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005394
Tony Cho143eb952015-09-21 12:16:32 +09005395 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005396
5397
5398 /* prepare the set driver handler message */
5399
Tony Cho143eb952015-09-21 12:16:32 +09005400 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005401 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
Tony Cho00c46302015-09-30 18:55:06 +09005402 msg.body.mode.u32Mode = u32mode;
Tony Cho143eb952015-09-21 12:16:32 +09005403 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005404
Tony Cho143eb952015-09-21 12:16:32 +09005405 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005406 if (s32Error) {
5407 PRINT_ER("wilc mq send fail\n");
5408 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005409 }
5410
5411 return s32Error;
5412}
5413
5414/**
5415 * @brief gets the current channel index
5416 * @details
5417 * @param[in,out] handle to the wifi driver,
5418 * current channel index
5419 *|-----------------------------------------------------------------------|
5420 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5421 | Input: 1 2 14 |
5422 ||-----------------------------------------------------------------------|
5423 * @return Error code indicating success/failure
5424 * @note
5425 * @author zsalah
5426 * @date 8 March 2012
5427 * @version 1.0
5428 */
Johnny Kim218dc402015-08-13 13:41:19 +09005429s32 host_int_get_host_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ChNo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005430{
Leo Kime6e12662015-09-16 18:36:03 +09005431 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005432 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005433 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005434
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005435 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005436 PRINT_ER("driver is null\n");
5437 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005438 }
5439
5440 /* prepare the Get Channel Message */
Tony Cho143eb952015-09-21 12:16:32 +09005441 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005442
Tony Choa9f812a2015-09-21 12:16:33 +09005443 msg.id = HOST_IF_MSG_GET_CHNL;
Tony Cho143eb952015-09-21 12:16:32 +09005444 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005445
5446 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005447 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005448 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09005449 PRINT_ER("wilc mq send fail\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005450 down(&(pstrWFIDrv->hSemGetCHNL));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005451 /* gu8Chnl = 11; */
5452
5453 *pu8ChNo = gu8Chnl;
5454
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005455 return s32Error;
5456
5457
5458}
5459
5460
5461/**
5462 * @brief host_int_test_set_int_wid
5463 * @details Test function for setting wids
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005464 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005465 * @return Error code indicating success/failure
5466 * @note
5467 * @author zsalah
5468 * @date 8 March 2012
5469 * @version 1.0
5470 */
Johnny Kim218dc402015-08-13 13:41:19 +09005471s32 host_int_test_set_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 u32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005472{
Leo Kime6e12662015-09-16 18:36:03 +09005473 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005474 tstrWID strWID;
5475 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5476
5477
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005478 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005479 PRINT_ER("driver is null\n");
5480 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005481 }
5482
5483 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +09005484 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005485 strWID.enuWIDtype = WID_INT;
Dean Lee576917a2015-06-15 11:58:57 +09005486 strWID.ps8WidVal = (char *)&u32TestMemAddr;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005487 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005488
5489 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09005490 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
5491 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005492 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09005493 PRINT_ER("Failed to set wid value\n");
5494 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005495 } else {
5496 PRINT_D(HOSTINF_DBG, "Successfully set wid value\n");
5497
5498 }
5499
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005500 return s32Error;
5501}
5502
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005503/**
5504 * @brief host_int_get_inactive_time
5505 * @details
5506 * @param[in,out] handle to the wifi driver,
5507 * current sta macaddress, inactive_time
5508 * @return
5509 * @note
5510 * @author
5511 * @date
5512 * @version 1.0
5513 */
Johnny Kim218dc402015-08-13 13:41:19 +09005514s32 host_int_get_inactive_time(tstrWILC_WFIDrv *hWFIDrv, const u8 *mac, u32 *pu32InactiveTime)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005515{
Leo Kime6e12662015-09-16 18:36:03 +09005516 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005517 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005518 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005519
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005520 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005521 PRINT_ER("driver is null\n");
5522 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005523 }
5524
Tony Cho143eb952015-09-21 12:16:32 +09005525 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005526
5527
Tony Cho66bac7f2015-09-30 18:44:37 +09005528 memcpy(msg.body.mac_info.mac,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005529 mac, ETH_ALEN);
5530
Tony Choa9f812a2015-09-21 12:16:33 +09005531 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
Tony Cho143eb952015-09-21 12:16:32 +09005532 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005533
5534 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005535 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005536 if (s32Error)
5537 PRINT_ER("Failed to send get host channel param's message queue ");
5538
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005539 down(&(pstrWFIDrv->hSemInactiveTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005540
5541 *pu32InactiveTime = gu32InactiveTime;
5542
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005543 return s32Error;
5544}
Glen Lee108b3432015-09-16 18:53:20 +09005545
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005546/**
5547 * @brief host_int_test_get_int_wid
5548 * @details Test function for getting wids
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005549 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005550 * @return Error code indicating success/failure
5551 * @note
5552 * @author zsalah
5553 * @date 8 March 2012
5554 * @version 1.0
5555 */
Johnny Kim218dc402015-08-13 13:41:19 +09005556s32 host_int_test_get_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 *pu32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005557{
5558
Leo Kime6e12662015-09-16 18:36:03 +09005559 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005560 tstrWID strWID;
5561 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5562
5563
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005564 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005565 PRINT_ER("driver is null\n");
5566 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005567 }
5568
Chaehyun Limd85f5322015-06-11 14:35:54 +09005569 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005570 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005571 strWID.ps8WidVal = (s8 *)pu32TestMemAddr;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005572 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005573
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09005574 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
5575 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005576 /*get the value by searching the local copy*/
5577 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09005578 PRINT_ER("Failed to get wid value\n");
5579 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005580 } else {
5581 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
5582
5583 }
5584
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005585 return s32Error;
5586}
5587
5588
5589/**
5590 * @brief host_int_get_rssi
5591 * @details gets the currently maintained RSSI value for the station.
5592 * The received signal strength value in dB.
5593 * The range of valid values is -128 to 0.
5594 * @param[in,out] handle to the wifi driver,
5595 * rssi value in dB
5596 * @return Error code indicating success/failure
5597 * @note
5598 * @author zsalah
5599 * @date 8 March 2012
5600 * @version 1.0
5601 */
Johnny Kim218dc402015-08-13 13:41:19 +09005602s32 host_int_get_rssi(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005603{
Leo Kime6e12662015-09-16 18:36:03 +09005604 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005605 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005606 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5607
5608
5609 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09005610 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005611
Tony Choa9f812a2015-09-21 12:16:33 +09005612 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Cho143eb952015-09-21 12:16:32 +09005613 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005614
5615 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005616 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005617 if (s32Error) {
5618 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005619 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005620 }
5621
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005622 down(&(pstrWFIDrv->hSemGetRSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005623
5624
5625 if (ps8Rssi == NULL) {
5626 PRINT_ER("RSS pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09005627 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005628 }
5629
5630
5631 *ps8Rssi = gs8Rssi;
5632
5633
5634 return s32Error;
5635}
5636
Johnny Kim218dc402015-08-13 13:41:19 +09005637s32 host_int_get_link_speed(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8lnkspd)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005638{
Tony Cho143eb952015-09-21 12:16:32 +09005639 struct host_if_msg msg;
Leo Kime6e12662015-09-16 18:36:03 +09005640 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005641
5642 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5643
5644
5645
5646 /* prepare the Get LINKSPEED Message */
Tony Cho143eb952015-09-21 12:16:32 +09005647 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005648
Tony Choa9f812a2015-09-21 12:16:33 +09005649 msg.id = HOST_IF_MSG_GET_LINKSPEED;
Tony Cho143eb952015-09-21 12:16:32 +09005650 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005651
5652 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005653 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005654 if (s32Error) {
5655 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005656 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005657 }
5658
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005659 down(&(pstrWFIDrv->hSemGetLINKSPEED));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005660
5661
5662 if (ps8lnkspd == NULL) {
5663 PRINT_ER("LINKSPEED pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09005664 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005665 }
5666
5667
5668 *ps8lnkspd = gs8lnkspd;
5669
5670
5671 return s32Error;
5672}
5673
Johnny Kim218dc402015-08-13 13:41:19 +09005674s32 host_int_get_statistics(tstrWILC_WFIDrv *hWFIDrv, tstrStatistics *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005675{
Leo Kime6e12662015-09-16 18:36:03 +09005676 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005677 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005678
5679
5680 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09005681 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005682
Tony Choa9f812a2015-09-21 12:16:33 +09005683 msg.id = HOST_IF_MSG_GET_STATISTICS;
Tony Cho410c2482015-09-21 12:16:35 +09005684 msg.body.pUserData = (char *)pstrStatistics;
Tony Cho143eb952015-09-21 12:16:32 +09005685 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005686 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005687 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005688 if (s32Error) {
5689 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005690 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005691 }
5692
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005693 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005694 return s32Error;
5695}
5696
5697
5698/**
5699 * @brief host_int_scan
5700 * @details scans a set of channels
5701 * @param[in,out] handle to the wifi driver,
5702 * @param[in] Scan source
5703 * Scan Type PASSIVE_SCAN = 0,
5704 * ACTIVE_SCAN = 1
5705 * Channels Array
5706 * Channels Array length
5707 * Scan Callback function
5708 * @return Error code indicating success/failure
5709 * @note
5710 * @author zsalah
5711 * @date 8 March 2012
5712 * @version 1.0
5713 */
Johnny Kim218dc402015-08-13 13:41:19 +09005714s32 host_int_scan(tstrWILC_WFIDrv *hWFIDrv, u8 u8ScanSource,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005715 u8 u8ScanType, u8 *pu8ChnlFreqList,
5716 u8 u8ChnlListLen, const u8 *pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005717 size_t IEsLen, tWILCpfScanResult ScanResult,
5718 void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork)
5719{
Leo Kime6e12662015-09-16 18:36:03 +09005720 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005721 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005722 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005723 tenuScanConnTimer enuScanConnTimer;
5724
Leo Kim24db7132015-09-16 18:36:01 +09005725 if (pstrWFIDrv == NULL || ScanResult == NULL) {
5726 PRINT_ER("pstrWFIDrv or ScanResult = NULL\n");
5727 return -EFAULT;
5728 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005729
5730 /* prepare the Scan Message */
Tony Cho143eb952015-09-21 12:16:32 +09005731 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005732
Tony Choa9f812a2015-09-21 12:16:33 +09005733 msg.id = HOST_IF_MSG_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005734
5735 if (pstrHiddenNetwork != NULL) {
Tony Cho4528bdb2015-09-30 18:44:20 +09005736 msg.body.scan_info.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
5737 msg.body.scan_info.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005738
5739 } else
5740 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
5741
Tony Cho143eb952015-09-21 12:16:32 +09005742 msg.drvHandler = hWFIDrv;
Tony Cho4528bdb2015-09-30 18:44:20 +09005743 msg.body.scan_info.u8ScanSource = u8ScanSource;
5744 msg.body.scan_info.u8ScanType = u8ScanType;
5745 msg.body.scan_info.pfScanResult = ScanResult;
5746 msg.body.scan_info.pvUserArg = pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005747
Tony Cho4528bdb2015-09-30 18:44:20 +09005748 msg.body.scan_info.u8ChnlListLen = u8ChnlListLen;
5749 msg.body.scan_info.pu8ChnlFreqList = kmalloc(u8ChnlListLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5750 memcpy(msg.body.scan_info.pu8ChnlFreqList,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005751 pu8ChnlFreqList, u8ChnlListLen);
5752
Tony Cho4528bdb2015-09-30 18:44:20 +09005753 msg.body.scan_info.IEsLen = IEsLen;
5754 msg.body.scan_info.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5755 memcpy(msg.body.scan_info.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005756 pu8IEs, IEsLen);
5757
5758 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005759 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005760 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09005761 PRINT_ER("Error in sending message queue\n");
5762 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005763 }
5764
5765 enuScanConnTimer = SCAN_TIMER;
5766 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005767 pstrWFIDrv->hScanTimer.data = (unsigned long)hWFIDrv;
5768 mod_timer(&pstrWFIDrv->hScanTimer,
5769 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005770
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005771 return s32Error;
5772
5773}
5774/**
5775 * @brief hif_set_cfg
5776 * @details sets configuration wids values
5777 * @param[in,out] handle to the wifi driver,
5778 * @param[in] WID, WID value
5779 * @return Error code indicating success/failure
5780 * @note
5781 * @author zsalah
5782 * @date 8 March 2012
5783 * @version 1.0
5784 */
Johnny Kim218dc402015-08-13 13:41:19 +09005785s32 hif_set_cfg(tstrWILC_WFIDrv *hWFIDrv, tstrCfgParamVal *pstrCfgParamVal)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005786{
5787
Leo Kime6e12662015-09-16 18:36:03 +09005788 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005789 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5790
Tony Cho143eb952015-09-21 12:16:32 +09005791 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005792
5793
Leo Kim24db7132015-09-16 18:36:01 +09005794 if (pstrWFIDrv == NULL) {
5795 PRINT_ER("pstrWFIDrv NULL\n");
5796 return -EFAULT;
5797 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005798 /* prepare the WiphyParams Message */
Tony Cho143eb952015-09-21 12:16:32 +09005799 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005800 msg.id = HOST_IF_MSG_CFG_PARAMS;
Tony Choa2340c32015-09-30 18:44:25 +09005801 msg.body.cfg_info.pstrCfgParamVal = *pstrCfgParamVal;
Tony Cho143eb952015-09-21 12:16:32 +09005802 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005803
Tony Cho143eb952015-09-21 12:16:32 +09005804 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005805
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005806 return s32Error;
5807
5808}
5809
5810
5811/**
5812 * @brief hif_get_cfg
5813 * @details gets configuration wids values
5814 * @param[in,out] handle to the wifi driver,
5815 * WID value
5816 * @param[in] WID,
5817 * @return Error code indicating success/failure
5818 * @note
5819 * @author zsalah
5820 *
5821 * @date 8 March 2012
5822 * @version 1.0
5823 */
Johnny Kim218dc402015-08-13 13:41:19 +09005824s32 hif_get_cfg(tstrWILC_WFIDrv *hWFIDrv, u16 u16WID, u16 *pu16WID_Value)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005825{
Leo Kime6e12662015-09-16 18:36:03 +09005826 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005827 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5828
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005829 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005830
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005831 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005832 PRINT_ER("pstrWFIDrv NULL\n");
5833 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005834 }
5835 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
5836 switch (u16WID) {
5837
5838 case WID_BSS_TYPE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005839 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005840 break;
5841
5842 case WID_AUTH_TYPE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005843 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005844 break;
5845
5846 case WID_AUTH_TIMEOUT:
5847 *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout;
5848 break;
5849
5850 case WID_POWER_MANAGEMENT:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005851 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005852 break;
5853
5854 case WID_SHORT_RETRY_LIMIT:
5855 *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit;
5856 break;
5857
5858 case WID_LONG_RETRY_LIMIT:
5859 *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit;
5860 break;
5861
5862 case WID_FRAG_THRESHOLD:
5863 *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold;
5864 break;
5865
5866 case WID_RTS_THRESHOLD:
5867 *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold;
5868 break;
5869
5870 case WID_PREAMBLE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005871 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005872 break;
5873
5874 case WID_SHORT_SLOT_ALLOWED:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005875 *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005876 break;
5877
5878 case WID_11N_TXOP_PROT_DISABLE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005879 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005880 break;
5881
5882 case WID_BEACON_INTERVAL:
5883 *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval;
5884 break;
5885
5886 case WID_DTIM_PERIOD:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005887 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005888 break;
5889
5890 case WID_SITE_SURVEY:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005891 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005892 break;
5893
5894 case WID_SITE_SURVEY_SCAN_TIME:
5895 *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time;
5896 break;
5897
5898 case WID_ACTIVE_SCAN_TIME:
5899 *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time;
5900 break;
5901
5902 case WID_PASSIVE_SCAN_TIME:
5903 *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time;
5904 break;
5905
5906 case WID_CURRENT_TX_RATE:
5907 *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate;
5908 break;
5909
5910 default:
5911 break;
5912 }
5913
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005914 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005915
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005916 return s32Error;
5917
5918}
5919
5920/*****************************************************************************/
5921/* Notification Functions */
5922/*****************************************************************************/
5923/**
5924 * @brief notifies host with join and leave requests
5925 * @details This function prepares an Information frame having the
5926 * information about a joining/leaving station.
5927 * @param[in,out] handle to the wifi driver,
5928 * @param[in] 6 byte Sta Adress
5929 * Join or leave flag:
5930 * Join = 1,
5931 * Leave =0
5932 * @return Error code indicating success/failure
5933 * @note
5934 * @author zsalah
5935 * @date 8 March 2012
5936 * @version 1.0
5937 */
5938void host_int_send_join_leave_info_to_host
Dean Lee72ed4dc2015-06-12 14:11:44 +09005939 (u16 assocId, u8 *stationAddr, bool joining)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005940{
5941}
5942/**
5943 * @brief notifies host with stations found in scan
5944 * @details sends the beacon/probe response from scan
5945 * @param[in,out] handle to the wifi driver,
5946 * @param[in] Sta Address,
5947 * Frame length,
5948 * Rssi of the Station found
5949 * @return Error code indicating success/failure
5950 * @note
5951 * @author zsalah
5952 * @date 8 March 2012
5953 * @version 1.0
5954 */
5955
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07005956static void GetPeriodicRSSI(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005957{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07005958 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02005959
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005960 if (pstrWFIDrv == NULL) {
5961 PRINT_ER("Driver handler is NULL\n");
5962 return;
5963 }
5964
5965 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
Leo Kime6e12662015-09-16 18:36:03 +09005966 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005967 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005968
5969 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09005970 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005971
Tony Choa9f812a2015-09-21 12:16:33 +09005972 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Cho143eb952015-09-21 12:16:32 +09005973 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005974
5975 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005976 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005977 if (s32Error) {
5978 PRINT_ER("Failed to send get host channel param's message queue ");
5979 return;
5980 }
5981 }
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005982 g_hPeriodicRSSI.data = (unsigned long)pstrWFIDrv;
5983 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005984}
5985
5986
5987void host_int_send_network_info_to_host
Chaehyun Limca356ad2015-06-11 14:35:57 +09005988 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005989{
5990}
5991/**
5992 * @brief host_int_init
5993 * @details host interface initialization function
5994 * @param[in,out] handle to the wifi driver,
5995 * @note
5996 * @author zsalah
5997 * @date 8 March 2012
5998 * @version 1.0
5999 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006000static u32 clients_count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006001
Johnny Kim218dc402015-08-13 13:41:19 +09006002s32 host_int_init(tstrWILC_WFIDrv **phWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006003{
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006004 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006005 tstrWILC_WFIDrv *pstrWFIDrv;
Johnny Kimd42ab082015-08-20 16:32:52 +09006006 int err;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006007
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006008 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
6009
Dean Lee72ed4dc2015-06-12 14:11:44 +09006010 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006011
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006012 sema_init(&hWaitResponse, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006013
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006014 /*Allocate host interface private structure*/
Chaehyun Lim27a82eb2015-09-22 18:34:55 +09006015 pstrWFIDrv = kzalloc(sizeof(tstrWILC_WFIDrv), GFP_KERNEL);
Chaehyun Lim16042962015-09-22 18:34:56 +09006016 if (!pstrWFIDrv) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006017 result = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006018 goto _fail_timer_2;
6019 }
Johnny Kim218dc402015-08-13 13:41:19 +09006020 *phWFIDrv = pstrWFIDrv;
Johnny Kimd42ab082015-08-20 16:32:52 +09006021 err = add_handler_in_list(pstrWFIDrv);
6022 if (err) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006023 result = -EFAULT;
Johnny Kimd42ab082015-08-20 16:32:52 +09006024 goto _fail_timer_2;
6025 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006026
Dean Lee72ed4dc2015-06-12 14:11:44 +09006027 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006028
Johnny Kim8a143302015-06-10 17:06:46 +09006029 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006030 if (clients_count == 0) {
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006031 sema_init(&hSemHostIFthrdEnd, 0);
6032 sema_init(&hSemDeinitDrvHandle, 0);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006033 sema_init(&hSemHostIntDeinit, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006034 }
6035
Chaehyun Limdddaba12015-09-22 18:35:01 +09006036 sema_init(&pstrWFIDrv->hSemTestKeyBlock, 0);
6037 sema_init(&pstrWFIDrv->hSemTestDisconnectBlock, 0);
6038 sema_init(&pstrWFIDrv->hSemGetRSSI, 0);
6039 sema_init(&pstrWFIDrv->hSemGetLINKSPEED, 0);
6040 sema_init(&pstrWFIDrv->hSemGetCHNL, 0);
6041 sema_init(&pstrWFIDrv->hSemInactiveTime, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006042
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006043 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
6044
6045 if (clients_count == 0) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006046 result = wilc_mq_create(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006047
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006048 if (result < 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006049 PRINT_ER("Failed to creat MQ\n");
6050 goto _fail_;
6051 }
Arnd Bergmann1999bd52015-05-29 22:52:14 +02006052 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
6053 if (IS_ERR(HostIFthreadHandler)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006054 PRINT_ER("Failed to creat Thread\n");
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006055 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006056 goto _fail_mq_;
6057 }
Greg Kroah-Hartman507d7fc2015-08-17 12:59:42 -07006058 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
6059 (unsigned long)pstrWFIDrv);
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07006060 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006061 }
6062
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006063 setup_timer(&pstrWFIDrv->hScanTimer, TimerCB_Scan, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006064
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006065 setup_timer(&pstrWFIDrv->hConnectTimer, TimerCB_Connect, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006066
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006067 /*Remain on channel timer*/
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006068 setup_timer(&pstrWFIDrv->hRemainOnChannel, ListenTimerCB, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006069
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006070 sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1);
Chaehyun Limdddaba12015-09-22 18:35:01 +09006071 down(&pstrWFIDrv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006072
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006073 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006074
6075 /*Initialize CFG WIDS Defualt Values*/
6076
6077 pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
6078 pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN;
6079 pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
6080 pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
6081 pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE;
6082
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006083 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
6084
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006085 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",
6086
6087 pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source,
6088 pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time,
6089 pstrWFIDrv->strCfgValues.curr_tx_rate);
6090
Chaehyun Limdddaba12015-09-22 18:35:01 +09006091 up(&pstrWFIDrv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006092
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006093 clients_count++; /* increase number of created entities */
6094
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006095 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006096
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006097_fail_timer_2:
Chaehyun Limdddaba12015-09-22 18:35:01 +09006098 up(&pstrWFIDrv->gtOsCfgValuesSem);
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006099 del_timer_sync(&pstrWFIDrv->hConnectTimer);
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006100 del_timer_sync(&pstrWFIDrv->hScanTimer);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02006101 kthread_stop(HostIFthreadHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006102_fail_mq_:
Chaehyun Lim1b128f62015-08-19 15:59:08 +09006103 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006104_fail_:
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006105 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006106}
6107/**
6108 * @brief host_int_deinit
6109 * @details host interface initialization function
6110 * @param[in,out] handle to the wifi driver,
6111 * @note
6112 * @author zsalah
6113 * @date 8 March 2012
6114 * @version 1.0
6115 */
6116
Johnny Kim218dc402015-08-13 13:41:19 +09006117s32 host_int_deinit(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006118{
Leo Kime6e12662015-09-16 18:36:03 +09006119 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006120 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006121 int ret;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006122
6123 /*obtain driver handle*/
6124 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006125
6126 if (pstrWFIDrv == NULL) {
6127 PRINT_ER("pstrWFIDrv = NULL\n");
6128 return 0;
6129 }
6130
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006131 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006132
6133 terminated_handle = pstrWFIDrv;
6134 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
6135
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006136 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
6137 /*to guarantee handling all messages befor proceeding*/
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006138 if (del_timer_sync(&pstrWFIDrv->hScanTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006139 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006140 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
6141 }
6142
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006143 if (del_timer_sync(&pstrWFIDrv->hConnectTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006144 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006145 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6146 }
6147
6148
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006149 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006150 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006151 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6152 }
6153
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006154 /*Destroy Remain-onchannel Timer*/
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006155 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006156
Johnny Kim218dc402015-08-13 13:41:19 +09006157 host_int_set_wfi_drv_handler(NULL);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006158 down(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006159
6160
6161 /*Calling the CFG80211 scan done function with the abort flag set to true*/
6162 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006163 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006164 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
6165
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006166 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006167 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006168
6169 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6170
Dean Lee72ed4dc2015-06-12 14:11:44 +09006171 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006172
Tony Cho143eb952015-09-21 12:16:32 +09006173 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006174
6175 if (clients_count == 1) {
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006176 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006177 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006178 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6179 }
Tony Choa9f812a2015-09-21 12:16:33 +09006180 msg.id = HOST_IF_MSG_EXIT;
Tony Cho143eb952015-09-21 12:16:32 +09006181 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006182
6183
Tony Cho143eb952015-09-21 12:16:32 +09006184 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kime6e12662015-09-16 18:36:03 +09006185 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006186 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006187
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006188 down(&hSemHostIFthrdEnd);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006189
Chaehyun Lim1b128f62015-08-19 15:59:08 +09006190 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006191 }
6192
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006193 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006194
6195 /*Setting the gloabl driver handler with NULL*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006196 /* gWFiDrvHandle = NULL; */
Johnny Kimd42ab082015-08-20 16:32:52 +09006197 ret = remove_handler_in_list(pstrWFIDrv);
6198 if (ret)
Leo Kime6e12662015-09-16 18:36:03 +09006199 s32Error = -ENOENT;
Johnny Kimd42ab082015-08-20 16:32:52 +09006200
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006201 if (pstrWFIDrv != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09006202 kfree(pstrWFIDrv);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006203 /* pstrWFIDrv=NULL; */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006204
6205 }
6206
6207 clients_count--; /* Decrease number of created entities */
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006208 terminated_handle = NULL;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006209 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006210 return s32Error;
6211}
6212
6213
6214/**
6215 * @brief NetworkInfoReceived
6216 * @details function to to be called when network info packet is received
6217 * @param[in] pu8Buffer the received packet
6218 * @param[in] u32Length length of the received packet
6219 * @return none
6220 * @note
6221 * @author
6222 * @date 1 Mar 2012
6223 * @version 1.0
6224 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006225void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006226{
Leo Kime6e12662015-09-16 18:36:03 +09006227 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006228 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006229 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006230 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006231
Johnny Kimd42ab082015-08-20 16:32:52 +09006232 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6233 pstrWFIDrv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006234
6235
6236
6237
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006238 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
Johnny Kim8a143302015-06-10 17:06:46 +09006239 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006240 return;
6241 }
6242
6243 /* prepare the Asynchronous Network Info message */
Tony Cho143eb952015-09-21 12:16:32 +09006244 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006245
Tony Choa9f812a2015-09-21 12:16:33 +09006246 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
Tony Cho143eb952015-09-21 12:16:32 +09006247 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006248
Tony Cho02d19462015-09-30 18:44:22 +09006249 msg.body.net_info.u32Length = u32Length;
6250 msg.body.net_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
6251 memcpy(msg.body.net_info.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006252 pu8Buffer, u32Length);
6253
6254 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006255 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006256 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006257 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006258}
6259
6260/**
6261 * @brief GnrlAsyncInfoReceived
6262 * @details function to be called when general Asynchronous info packet is received
6263 * @param[in] pu8Buffer the received packet
6264 * @param[in] u32Length length of the received packet
6265 * @return none
6266 * @note
6267 * @author
6268 * @date 15 Mar 2012
6269 * @version 1.0
6270 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006271void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006272{
Leo Kime6e12662015-09-16 18:36:03 +09006273 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006274 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006275 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006276 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006277
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006278 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006279
Johnny Kimd42ab082015-08-20 16:32:52 +09006280 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6281 pstrWFIDrv = get_handler_from_id(id);
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006282 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006283
6284
6285 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6286 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006287 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006288 return;
6289 }
6290
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006291 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006292 /* received mac status is not needed when there is no current Connect Request */
6293 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006294 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006295 return;
6296 }
6297
6298 /* prepare the General Asynchronous Info message */
Tony Cho143eb952015-09-21 12:16:32 +09006299 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006300
6301
Tony Choa9f812a2015-09-21 12:16:33 +09006302 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
Tony Cho143eb952015-09-21 12:16:32 +09006303 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006304
6305
Tony Cho66add622015-09-30 18:44:23 +09006306 msg.body.async_info.u32Length = u32Length;
6307 msg.body.async_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
6308 memcpy(msg.body.async_info.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006309 pu8Buffer, u32Length);
6310
6311 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006312 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006313 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006314 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006315
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006316 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006317}
6318
6319/**
6320 * @brief host_int_ScanCompleteReceived
6321 * @details Setting scan complete received notifcation in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006322 * @param[in] u8* pu8Buffer, u32 u32Length
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006323 * @return Error code.
6324 * @author
6325 * @date
6326 * @version 1.0
6327 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006328void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006329{
Leo Kime6e12662015-09-16 18:36:03 +09006330 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006331 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006332 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006333 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006334
Johnny Kimd42ab082015-08-20 16:32:52 +09006335 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6336 pstrWFIDrv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006337
6338
Johnny Kim8a143302015-06-10 17:06:46 +09006339 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006340
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006341 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006342 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006343
6344 /*if there is an ongoing scan request*/
6345 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6346 /* prepare theScan Done message */
Tony Cho143eb952015-09-21 12:16:32 +09006347 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006348
Tony Choa9f812a2015-09-21 12:16:33 +09006349 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
Tony Cho143eb952015-09-21 12:16:32 +09006350 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006351
6352
6353 /* will be deallocated by the receiving thread */
6354 /*no need to send message body*/
6355
Tony Cho410c2482015-09-21 12:16:35 +09006356 /*msg.body.strScanComplete.u32Length = u32Length;
6357 * msg.body.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
6358 * memcpy(msg.body.strScanComplete.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006359 * pu8Buffer, u32Length); */
6360
6361 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006362 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006363 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006364 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006365 }
6366
6367
6368 return;
6369
6370}
6371
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006372/**
6373 * @brief host_int_remain_on_channel
6374 * @details
6375 * @param[in] Handle to wifi driver
6376 * Duration to remain on channel
6377 * Channel to remain on
6378 * Pointer to fn to be called on receive frames in listen state
6379 * Pointer to remain-on-channel expired fn
6380 * Priv
6381 * @return Error code.
6382 * @author
6383 * @date
6384 * @version 1.0
6385 */
Johnny Kim218dc402015-08-13 13:41:19 +09006386s32 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 +09006387{
Leo Kime6e12662015-09-16 18:36:03 +09006388 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006389 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006390 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006391
Leo Kim24db7132015-09-16 18:36:01 +09006392 if (pstrWFIDrv == NULL) {
6393 PRINT_ER("driver is null\n");
6394 return -EFAULT;
6395 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006396
6397 /* prepare the remainonchan Message */
Tony Cho143eb952015-09-21 12:16:32 +09006398 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006399
6400 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006401 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
Tony Cho070d3652015-09-30 18:55:10 +09006402 msg.body.remain_on_ch.u16Channel = chan;
6403 msg.body.remain_on_ch.pRemainOnChanExpired = RemainOnChanExpired;
6404 msg.body.remain_on_ch.pRemainOnChanReady = RemainOnChanReady;
6405 msg.body.remain_on_ch.pVoid = pvUserArg;
6406 msg.body.remain_on_ch.u32duration = u32duration;
6407 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
Tony Cho143eb952015-09-21 12:16:32 +09006408 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006409
Tony Cho143eb952015-09-21 12:16:32 +09006410 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006411 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006412 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006413
6414 return s32Error;
6415}
6416
6417/**
6418 * @brief host_int_ListenStateExpired
6419 * @details
6420 * @param[in] Handle to wifi driver
6421 * Duration to remain on channel
6422 * Channel to remain on
6423 * Pointer to fn to be called on receive frames in listen state
6424 * Pointer to remain-on-channel expired fn
6425 * Priv
6426 * @return Error code.
6427 * @author
6428 * @date
6429 * @version 1.0
6430 */
Johnny Kim218dc402015-08-13 13:41:19 +09006431s32 host_int_ListenStateExpired(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006432{
Leo Kime6e12662015-09-16 18:36:03 +09006433 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006434 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006435 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006436
Leo Kim24db7132015-09-16 18:36:01 +09006437 if (pstrWFIDrv == NULL) {
6438 PRINT_ER("driver is null\n");
6439 return -EFAULT;
6440 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006441
6442 /*Stopping remain-on-channel timer*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07006443 del_timer(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006444
6445 /* prepare the timer fire Message */
Tony Cho143eb952015-09-21 12:16:32 +09006446 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09006447 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Cho143eb952015-09-21 12:16:32 +09006448 msg.drvHandler = hWFIDrv;
Tony Cho070d3652015-09-30 18:55:10 +09006449 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006450
Tony Cho143eb952015-09-21 12:16:32 +09006451 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006452 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006453 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006454
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006455 return s32Error;
6456}
6457
6458/**
6459 * @brief host_int_frame_register
6460 * @details
6461 * @param[in] Handle to wifi driver
6462 * @return Error code.
6463 * @author
6464 * @date
6465 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09006466s32 host_int_frame_register(tstrWILC_WFIDrv *hWFIDrv, u16 u16FrameType, bool bReg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006467{
Leo Kime6e12662015-09-16 18:36:03 +09006468 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006469 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006470 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006471
Leo Kim24db7132015-09-16 18:36:01 +09006472 if (pstrWFIDrv == NULL) {
6473 PRINT_ER("driver is null\n");
6474 return -EFAULT;
6475 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006476
Tony Cho143eb952015-09-21 12:16:32 +09006477 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006478
6479 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006480 msg.id = HOST_IF_MSG_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006481 switch (u16FrameType) {
6482 case ACTION:
6483 PRINT_D(HOSTINF_DBG, "ACTION\n");
Tony Cho410c2482015-09-21 12:16:35 +09006484 msg.body.strHostIfRegisterFrame.u8Regid = ACTION_FRM_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006485 break;
6486
6487 case PROBE_REQ:
6488 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
Tony Cho410c2482015-09-21 12:16:35 +09006489 msg.body.strHostIfRegisterFrame.u8Regid = PROBE_REQ_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006490 break;
6491
6492 default:
6493 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
6494 break;
6495 }
Tony Cho410c2482015-09-21 12:16:35 +09006496 msg.body.strHostIfRegisterFrame.u16FrameType = u16FrameType;
6497 msg.body.strHostIfRegisterFrame.bReg = bReg;
Tony Cho143eb952015-09-21 12:16:32 +09006498 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006499
Tony Cho143eb952015-09-21 12:16:32 +09006500 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006501 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006502 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006503
6504 return s32Error;
6505
6506
6507}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006508
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006509/**
6510 * @brief host_int_add_beacon
6511 * @details Setting add beacon params in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006512 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
6513 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
6514 * u32 u32TailLen, u8* pu8Tail
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006515 * @return Error code.
6516 * @author
6517 * @date
6518 * @version 1.0
6519 */
Johnny Kim218dc402015-08-13 13:41:19 +09006520s32 host_int_add_beacon(tstrWILC_WFIDrv *hWFIDrv, u32 u32Interval,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006521 u32 u32DTIMPeriod,
6522 u32 u32HeadLen, u8 *pu8Head,
6523 u32 u32TailLen, u8 *pu8Tail)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006524{
Leo Kime6e12662015-09-16 18:36:03 +09006525 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006526 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006527 struct host_if_msg msg;
Tony Choa98491e2015-09-30 18:44:31 +09006528 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006529
Leo Kim24db7132015-09-16 18:36:01 +09006530 if (pstrWFIDrv == NULL) {
6531 PRINT_ER("driver is null\n");
6532 return -EFAULT;
6533 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006534
Tony Cho143eb952015-09-21 12:16:32 +09006535 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006536
6537 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
6538
6539
6540 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006541 msg.id = HOST_IF_MSG_ADD_BEACON;
Tony Cho143eb952015-09-21 12:16:32 +09006542 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006543 pstrSetBeaconParam->u32Interval = u32Interval;
6544 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
6545 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
Glen Leef3052582015-09-10 12:03:04 +09006546 pstrSetBeaconParam->pu8Head = kmalloc(u32HeadLen, GFP_KERNEL);
Leo Kim24db7132015-09-16 18:36:01 +09006547 if (pstrSetBeaconParam->pu8Head == NULL) {
6548 s32Error = -ENOMEM;
6549 goto ERRORHANDLER;
6550 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006551 memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006552 pstrSetBeaconParam->u32TailLen = u32TailLen;
6553
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006554 if (u32TailLen > 0) {
Glen Leef3052582015-09-10 12:03:04 +09006555 pstrSetBeaconParam->pu8Tail = kmalloc(u32TailLen, GFP_KERNEL);
Leo Kim24db7132015-09-16 18:36:01 +09006556 if (pstrSetBeaconParam->pu8Tail == NULL) {
6557 s32Error = -ENOMEM;
6558 goto ERRORHANDLER;
6559 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006560 memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006561 } else {
6562 pstrSetBeaconParam->pu8Tail = NULL;
6563 }
6564
Tony Cho143eb952015-09-21 12:16:32 +09006565 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006566 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006567 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006568
Leo Kim24db7132015-09-16 18:36:01 +09006569ERRORHANDLER:
6570 if (s32Error) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006571 if (pstrSetBeaconParam->pu8Head != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006572 kfree(pstrSetBeaconParam->pu8Head);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006573
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006574 if (pstrSetBeaconParam->pu8Tail != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006575 kfree(pstrSetBeaconParam->pu8Tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006576 }
6577
6578 return s32Error;
6579
6580}
6581
6582
6583/**
6584 * @brief host_int_del_beacon
6585 * @details Setting add beacon params in message queue
6586 * @param[in] WILC_WFIDrvHandle hWFIDrv
6587 * @return Error code.
6588 * @author
6589 * @date
6590 * @version 1.0
6591 */
Johnny Kim218dc402015-08-13 13:41:19 +09006592s32 host_int_del_beacon(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006593{
Leo Kime6e12662015-09-16 18:36:03 +09006594 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006595 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006596 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006597
Leo Kim24db7132015-09-16 18:36:01 +09006598 if (pstrWFIDrv == NULL) {
6599 PRINT_ER("driver is null\n");
6600 return -EFAULT;
6601 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006602
6603 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006604 msg.id = HOST_IF_MSG_DEL_BEACON;
Tony Cho143eb952015-09-21 12:16:32 +09006605 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006606 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
6607
Tony Cho143eb952015-09-21 12:16:32 +09006608 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim7dc1d0c2015-09-16 18:36:00 +09006609 if (s32Error)
6610 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006611
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006612 return s32Error;
6613}
6614
6615
6616/**
6617 * @brief host_int_add_station
6618 * @details Setting add station params in message queue
Tony Cho6a89ba92015-09-21 12:16:46 +09006619 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006620 * @return Error code.
6621 * @author
6622 * @date
6623 * @version 1.0
6624 */
Tony Cho6a89ba92015-09-21 12:16:46 +09006625s32 host_int_add_station(tstrWILC_WFIDrv *hWFIDrv,
6626 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006627{
Leo Kime6e12662015-09-16 18:36:03 +09006628 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006629 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006630 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09006631 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006632
6633
Leo Kim24db7132015-09-16 18:36:01 +09006634 if (pstrWFIDrv == NULL) {
6635 PRINT_ER("driver is null\n");
6636 return -EFAULT;
6637 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006638
Tony Cho143eb952015-09-21 12:16:32 +09006639 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006640
6641 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
6642
6643
6644 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006645 msg.id = HOST_IF_MSG_ADD_STATION;
Tony Cho143eb952015-09-21 12:16:32 +09006646 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006647
Tony Cho6a89ba92015-09-21 12:16:46 +09006648 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006649 if (pstrAddStationMsg->u8NumRates > 0) {
Glen Leef3052582015-09-10 12:03:04 +09006650 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006651
Leo Kim7ae43362015-09-16 18:35:59 +09006652 if (!rates)
6653 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006654
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006655 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02006656 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006657 }
6658
6659
Tony Cho143eb952015-09-21 12:16:32 +09006660 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006661 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006662 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006663 return s32Error;
6664}
6665
6666/**
6667 * @brief host_int_del_station
6668 * @details Setting delete station params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006669 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006670 * @return Error code.
6671 * @author
6672 * @date
6673 * @version 1.0
6674 */
Johnny Kim218dc402015-08-13 13:41:19 +09006675s32 host_int_del_station(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8MacAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006676{
Leo Kime6e12662015-09-16 18:36:03 +09006677 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006678 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006679 struct host_if_msg msg;
Tony Cho889c25b2015-09-30 18:44:33 +09006680 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006681
Leo Kim24db7132015-09-16 18:36:01 +09006682 if (pstrWFIDrv == NULL) {
6683 PRINT_ER("driver is null\n");
6684 return -EFAULT;
6685 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006686
Tony Cho143eb952015-09-21 12:16:32 +09006687 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006688
6689 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
6690
6691
6692
6693 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006694 msg.id = HOST_IF_MSG_DEL_STATION;
Tony Cho143eb952015-09-21 12:16:32 +09006695 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006696
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006697 if (pu8MacAddr == NULL)
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006698 memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006699 else
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006700 memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006701
Tony Cho143eb952015-09-21 12:16:32 +09006702 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006703 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006704 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006705 return s32Error;
6706}
6707/**
6708 * @brief host_int_del_allstation
6709 * @details Setting del station params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006710 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006711 * @return Error code.
6712 * @author
6713 * @date
6714 * @version 1.0
6715 */
Johnny Kim218dc402015-08-13 13:41:19 +09006716s32 host_int_del_allstation(tstrWILC_WFIDrv *hWFIDrv, u8 pu8MacAddr[][ETH_ALEN])
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006717{
Leo Kime6e12662015-09-16 18:36:03 +09006718 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006719 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006720 struct host_if_msg msg;
Tony Chob4e644e2015-09-21 12:17:00 +09006721 struct del_all_sta *pstrDelAllStationMsg = &msg.body.strHostIFDelAllSta;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006722 u8 au8Zero_Buff[ETH_ALEN] = {0};
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006723 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006724 u8 u8AssocNumb = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006725
6726
Leo Kim24db7132015-09-16 18:36:01 +09006727 if (pstrWFIDrv == NULL) {
6728 PRINT_ER("driver is null\n");
6729 return -EFAULT;
6730 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006731
Tony Cho143eb952015-09-21 12:16:32 +09006732 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006733
6734 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
6735
6736 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006737 msg.id = HOST_IF_MSG_DEL_ALL_STA;
Tony Cho143eb952015-09-21 12:16:32 +09006738 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006739
6740 /* Handling situation of deauthenticing all associated stations*/
6741 for (i = 0; i < MAX_NUM_STA; i++) {
6742 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006743 memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006744 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],
6745 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
6746 u8AssocNumb++;
6747 }
6748 }
6749 if (!u8AssocNumb) {
6750 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
6751 return s32Error;
6752 }
6753
6754 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
Tony Cho143eb952015-09-21 12:16:32 +09006755 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006756
6757
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006758 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006759 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006760
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006761 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006762
6763 return s32Error;
6764
6765}
6766
6767/**
6768 * @brief host_int_edit_station
6769 * @details Setting edit station params in message queue
Tony Cho6a89ba92015-09-21 12:16:46 +09006770 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006771 * @return Error code.
6772 * @author
6773 * @date
6774 * @version 1.0
6775 */
Tony Cho6a89ba92015-09-21 12:16:46 +09006776s32 host_int_edit_station(tstrWILC_WFIDrv *hWFIDrv,
6777 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006778{
Leo Kime6e12662015-09-16 18:36:03 +09006779 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006780 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006781 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09006782 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006783
Leo Kim24db7132015-09-16 18:36:01 +09006784 if (pstrWFIDrv == NULL) {
6785 PRINT_ER("driver is null\n");
6786 return -EFAULT;
6787 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006788
6789 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
6790
Tony Cho143eb952015-09-21 12:16:32 +09006791 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006792
6793
6794 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006795 msg.id = HOST_IF_MSG_EDIT_STATION;
Tony Cho143eb952015-09-21 12:16:32 +09006796 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006797
Tony Cho6a89ba92015-09-21 12:16:46 +09006798 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006799 if (pstrAddStationMsg->u8NumRates > 0) {
Glen Leef3052582015-09-10 12:03:04 +09006800 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006801
Leo Kim7ae43362015-09-16 18:35:59 +09006802 if (!rates)
6803 return -ENOMEM;
6804
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006805 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02006806 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006807 }
6808
Tony Cho143eb952015-09-21 12:16:32 +09006809 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006810 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006811 PRINT_ER("wilc_mq_send fail\n");
6812
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006813 return s32Error;
6814}
Glen Lee108b3432015-09-16 18:53:20 +09006815
Johnny Kim218dc402015-08-13 13:41:19 +09006816s32 host_int_set_power_mgmt(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32Timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006817{
Leo Kime6e12662015-09-16 18:36:03 +09006818 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006819 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006820 struct host_if_msg msg;
Tony Cho49e1f812015-09-30 18:44:36 +09006821 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006822
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006823 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006824
Leo Kim24db7132015-09-16 18:36:01 +09006825 if (pstrWFIDrv == NULL) {
6826 PRINT_ER("driver is null\n");
6827 return -EFAULT;
6828 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006829
6830 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
6831
Tony Cho143eb952015-09-21 12:16:32 +09006832 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006833
6834
6835 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006836 msg.id = HOST_IF_MSG_POWER_MGMT;
Tony Cho143eb952015-09-21 12:16:32 +09006837 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006838
6839 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
6840 pstrPowerMgmtParam->u32Timeout = u32Timeout;
6841
6842
Tony Cho143eb952015-09-21 12:16:32 +09006843 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006844 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006845 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006846 return s32Error;
6847}
6848
Johnny Kim218dc402015-08-13 13:41:19 +09006849s32 host_int_setup_multicast_filter(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32count)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006850{
Leo Kime6e12662015-09-16 18:36:03 +09006851 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006852
6853 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006854 struct host_if_msg msg;
Tony Choa079cf4d2015-09-30 18:55:05 +09006855 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006856
6857
Leo Kim24db7132015-09-16 18:36:01 +09006858 if (pstrWFIDrv == NULL) {
6859 PRINT_ER("driver is null\n");
6860 return -EFAULT;
6861 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006862
6863 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
6864
Tony Cho143eb952015-09-21 12:16:32 +09006865 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006866
6867
6868 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006869 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
Tony Cho143eb952015-09-21 12:16:32 +09006870 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006871
6872 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
6873 pstrMulticastFilterParam->u32count = u32count;
6874
Tony Cho143eb952015-09-21 12:16:32 +09006875 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006876 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006877 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006878 return s32Error;
6879}
6880
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006881/**
6882 * @brief host_int_ParseJoinBssParam
6883 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
6884 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
6885 * @return
6886 * @author zsalah
6887 * @date
6888 * @version 1.0**/
6889static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
6890{
6891 tstrJoinBssParam *pNewJoinBssParam = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006892 u8 *pu8IEs;
Chaehyun Limd85f5322015-06-11 14:35:54 +09006893 u16 u16IEsLen;
6894 u16 index = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006895 u8 suppRatesNo = 0;
6896 u8 extSuppRatesNo;
Chaehyun Limd85f5322015-06-11 14:35:54 +09006897 u16 jumpOffset;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006898 u8 pcipherCount;
6899 u8 authCount;
6900 u8 pcipherTotalCount = 0;
6901 u8 authTotalCount = 0;
6902 u8 i, j;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006903
6904 pu8IEs = ptstrNetworkInfo->pu8IEs;
6905 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
6906
Glen Leef3052582015-09-10 12:03:04 +09006907 pNewJoinBssParam = kmalloc(sizeof(tstrJoinBssParam), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006908 if (pNewJoinBssParam != NULL) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006909 memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006910 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
6911 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
6912 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006913 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006914 /*for(i=0; i<6;i++)
6915 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006916 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006917 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006918 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
6919 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006920 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
6921 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
6922
6923 /* parse supported rates: */
6924 while (index < u16IEsLen) {
6925 /* supportedRates IE */
6926 if (pu8IEs[index] == SUPP_RATES_IE) {
6927 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
6928 suppRatesNo = pu8IEs[index + 1];
6929 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
6930 index += 2; /* skipping ID and length bytes; */
6931
6932 for (i = 0; i < suppRatesNo; i++) {
6933 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
6934 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
6935 }
6936 index += suppRatesNo;
6937 continue;
6938 }
6939 /* Ext SupportedRates IE */
6940 else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
6941 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
6942 /* checking if no of ext. supp and supp rates < max limit */
6943 extSuppRatesNo = pu8IEs[index + 1];
6944 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
6945 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
6946 else
6947 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
6948 index += 2;
6949 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
6950 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
6951 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
6952 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
6953 }
6954 index += extSuppRatesNo;
6955 continue;
6956 }
6957 /* HT Cap. IE */
6958 else if (pu8IEs[index] == HT_CAPABILITY_IE) {
6959 /* if IE found set the flag */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09006960 pNewJoinBssParam->ht_capable = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006961 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6962 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
6963 continue;
6964 } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
6965 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
6966 (pu8IEs[index + 4] == 0xF2) && /* OUI */
6967 (pu8IEs[index + 5] == 0x02) && /* OUI Type */
6968 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
6969 (pu8IEs[index + 7] == 0x01)) {
6970 /* Presence of WMM Info/Param element indicates WMM capability */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09006971 pNewJoinBssParam->wmm_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006972
6973 /* Check if Bit 7 is set indicating U-APSD capability */
Anish Bhattffda2032015-09-29 12:15:49 -07006974 if (pu8IEs[index + 8] & BIT(7))
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09006975 pNewJoinBssParam->uapsd_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006976 index += pu8IEs[index + 1] + 2;
6977 continue;
6978 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006979 else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
6980 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
6981 (pu8IEs[index + 4] == 0x9a) && /* OUI */
6982 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
Chaehyun Limd85f5322015-06-11 14:35:54 +09006983 u16 u16P2P_count;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006984
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006985 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
6986 pNewJoinBssParam->u8NoaEnbaled = 1;
6987 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
6988
6989 /* Check if Bit 7 is set indicating Opss capability */
Anish Bhattffda2032015-09-29 12:15:49 -07006990 if (pu8IEs[index + 10] & BIT(7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006991 pNewJoinBssParam->u8OppEnable = 1;
6992 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
6993 } else
6994 pNewJoinBssParam->u8OppEnable = 0;
6995 /* HOSTINF_DBG */
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006996 PRINT_D(GENERIC_DBG, "P2P Dump\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006997 for (i = 0; i < pu8IEs[index + 7]; i++)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006998 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006999
7000 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
7001 u16P2P_count = index + 12;
7002
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007003 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007004 u16P2P_count += 4;
7005
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007006 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007007 u16P2P_count += 4;
7008
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007009 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007010
7011 index += pu8IEs[index + 1] + 2;
7012 continue;
7013
7014 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007015 else if ((pu8IEs[index] == RSN_IE) ||
7016 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
7017 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
7018 (pu8IEs[index + 5] == 0x01))) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09007019 u16 rsnIndex = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007020 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
7021 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
7022 * {
7023 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
7024 * }*/
7025 if (pu8IEs[rsnIndex] == RSN_IE) {
7026 pNewJoinBssParam->mode_802_11i = 2;
7027 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
7028 } else { /* check if rsn was previously parsed */
7029 if (pNewJoinBssParam->mode_802_11i == 0)
7030 pNewJoinBssParam->mode_802_11i = 1;
7031 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
7032 rsnIndex += 4;
7033 }
7034 rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
7035 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
7036 rsnIndex++;
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007037 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007038 /* initialize policies with invalid values */
7039
7040 jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
7041
7042 /*parsing pairwise cipher*/
7043
7044 /* saving 3 pcipher max. */
7045 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7046 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7047
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007048 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007049 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
7050 /* each count corresponds to 4 bytes, only last byte is saved */
7051 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7052 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
7053 }
7054 pcipherTotalCount += pcipherCount;
7055 rsnIndex += jumpOffset;
7056
7057 jumpOffset = pu8IEs[rsnIndex] * 4;
7058
7059 /*parsing AKM suite (auth_policy)*/
7060 /* saving 3 auth policies max. */
7061 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7062 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7063
7064 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
7065 /* each count corresponds to 4 bytes, only last byte is saved */
7066 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7067 }
7068 authTotalCount += authCount;
7069 rsnIndex += jumpOffset;
7070 /*pasring rsn cap. only if rsn IE*/
7071 if (pu8IEs[index] == RSN_IE) {
7072 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
7073 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
7074 rsnIndex += 2;
7075 }
Abdul Hussainf717c0eb2015-06-16 09:49:49 +00007076 pNewJoinBssParam->rsn_found = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007077 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7078 continue;
7079 } else
7080 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7081
7082 }
7083
7084
7085 }
7086
7087 return (void *)pNewJoinBssParam;
7088
7089}
7090
7091void host_int_freeJoinParams(void *pJoinParams)
7092{
7093 if ((tstrJoinBssParam *)pJoinParams != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09007094 kfree((tstrJoinBssParam *)pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007095 else
7096 PRINT_ER("Unable to FREE null pointer\n");
7097}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007098
7099/**
7100 * @brief host_int_addBASession
7101 * @details Open a block Ack session with the given parameters
7102 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7103 * @return
7104 * @author anoureldin
7105 * @date
7106 * @version 1.0**/
7107
Johnny Kim2b05df52015-08-13 13:41:21 +09007108static int host_int_addBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID, short int BufferSize,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007109 short int SessionTimeout, void *drvHandler)
7110{
Leo Kime6e12662015-09-16 18:36:03 +09007111 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007112 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007113 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09007114 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007115
Leo Kim24db7132015-09-16 18:36:01 +09007116 if (pstrWFIDrv == NULL) {
7117 PRINT_ER("driver is null\n");
7118 return -EFAULT;
7119 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007120
Tony Cho143eb952015-09-21 12:16:32 +09007121 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007122
7123 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007124 msg.id = HOST_IF_MSG_ADD_BA_SESSION;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007125
7126 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7127 pBASessionInfo->u8Ted = TID;
7128 pBASessionInfo->u16BufferSize = BufferSize;
7129 pBASessionInfo->u16SessionTimeout = SessionTimeout;
Tony Cho143eb952015-09-21 12:16:32 +09007130 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007131
Tony Cho143eb952015-09-21 12:16:32 +09007132 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007133 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007134 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007135
7136 return s32Error;
7137}
7138
7139
Johnny Kim218dc402015-08-13 13:41:19 +09007140s32 host_int_delBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007141{
Leo Kime6e12662015-09-16 18:36:03 +09007142 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007143 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007144 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09007145 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007146
Leo Kim24db7132015-09-16 18:36:01 +09007147 if (pstrWFIDrv == NULL) {
7148 PRINT_ER("driver is null\n");
7149 return -EFAULT;
7150 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007151
Tony Cho143eb952015-09-21 12:16:32 +09007152 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007153
7154 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007155 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007156
7157 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7158 pBASessionInfo->u8Ted = TID;
Tony Cho143eb952015-09-21 12:16:32 +09007159 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007160
Tony Cho143eb952015-09-21 12:16:32 +09007161 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007162 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007163 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007164
Arnd Bergmann83383ea2015-06-01 21:06:43 +02007165 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007166
7167 return s32Error;
7168}
7169
Johnny Kim218dc402015-08-13 13:41:19 +09007170s32 host_int_del_All_Rx_BASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007171{
Leo Kime6e12662015-09-16 18:36:03 +09007172 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007173 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007174 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09007175 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007176
Leo Kim24db7132015-09-16 18:36:01 +09007177 if (pstrWFIDrv == NULL) {
7178 PRINT_ER("driver is null\n");
7179 return -EFAULT;
7180 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007181
Tony Cho143eb952015-09-21 12:16:32 +09007182 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007183
7184 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007185 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007186
7187 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7188 pBASessionInfo->u8Ted = TID;
Tony Cho143eb952015-09-21 12:16:32 +09007189 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007190
Tony Cho143eb952015-09-21 12:16:32 +09007191 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007192 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007193 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007194
Arnd Bergmann83383ea2015-06-01 21:06:43 +02007195 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007196
7197 return s32Error;
7198}
7199
7200/**
7201 * @brief host_int_setup_ipaddress
7202 * @details setup IP in firmware
7203 * @param[in] Handle to wifi driver
7204 * @return Error code.
7205 * @author Abdelrahman Sobhy
7206 * @date
7207 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09007208s32 host_int_setup_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007209{
Leo Kime6e12662015-09-16 18:36:03 +09007210 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007211 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007212 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007213
7214 /* TODO: Enable This feature on softap firmware */
7215 return 0;
7216
Leo Kim24db7132015-09-16 18:36:01 +09007217 if (pstrWFIDrv == NULL) {
7218 PRINT_ER("driver is null\n");
7219 return -EFAULT;
7220 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007221
Tony Cho143eb952015-09-21 12:16:32 +09007222 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007223
7224 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007225 msg.id = HOST_IF_MSG_SET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007226
Tony Chofb2d65e2015-09-30 18:44:39 +09007227 msg.body.ip_info.au8IPAddr = u16ipadd;
Tony Cho143eb952015-09-21 12:16:32 +09007228 msg.drvHandler = hWFIDrv;
Tony Chofb2d65e2015-09-30 18:44:39 +09007229 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007230
Tony Cho143eb952015-09-21 12:16:32 +09007231 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007232 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007233 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007234
7235 return s32Error;
7236
7237
7238}
7239
7240/**
7241 * @brief host_int_get_ipaddress
7242 * @details Get IP from firmware
7243 * @param[in] Handle to wifi driver
7244 * @return Error code.
7245 * @author Abdelrahman Sobhy
7246 * @date
7247 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09007248s32 host_int_get_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007249{
Leo Kime6e12662015-09-16 18:36:03 +09007250 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007251 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007252 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007253
Leo Kim24db7132015-09-16 18:36:01 +09007254 if (pstrWFIDrv == NULL) {
7255 PRINT_ER("driver is null\n");
7256 return -EFAULT;
7257 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007258
Tony Cho143eb952015-09-21 12:16:32 +09007259 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007260
7261 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007262 msg.id = HOST_IF_MSG_GET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007263
Tony Chofb2d65e2015-09-30 18:44:39 +09007264 msg.body.ip_info.au8IPAddr = u16ipadd;
Tony Cho143eb952015-09-21 12:16:32 +09007265 msg.drvHandler = hWFIDrv;
Tony Chofb2d65e2015-09-30 18:44:39 +09007266 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007267
Tony Cho143eb952015-09-21 12:16:32 +09007268 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007269 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007270 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007271
7272 return s32Error;
7273
7274
7275}