blob: c4c570ae4b968b047c6c87a8463c781d8f8806d5 [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"
Shraddha Barke281dd5a2015-10-05 17:00:33 +05309#include <linux/etherdevice.h>
Johnny Kimc5c77ba2015-05-11 14:30:56 +090010
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090011extern u8 connecting;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090012
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -070013extern struct timer_list hDuringIpTimer;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090014
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090015extern u8 g_wilc_initialized;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090016
17/* Message types of the Host IF Message Queue*/
Chaehyun Lim9eac3a12015-06-18 22:08:51 +090018#define HOST_IF_MSG_SCAN 0
19#define HOST_IF_MSG_CONNECT 1
20#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
21#define HOST_IF_MSG_KEY 3
22#define HOST_IF_MSG_RCVD_NTWRK_INFO 4
23#define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
24#define HOST_IF_MSG_CFG_PARAMS 6
25#define HOST_IF_MSG_SET_CHANNEL 7
26#define HOST_IF_MSG_DISCONNECT 8
27#define HOST_IF_MSG_GET_RSSI 9
28#define HOST_IF_MSG_GET_CHNL 10
29#define HOST_IF_MSG_ADD_BEACON 11
30#define HOST_IF_MSG_DEL_BEACON 12
31#define HOST_IF_MSG_ADD_STATION 13
32#define HOST_IF_MSG_DEL_STATION 14
33#define HOST_IF_MSG_EDIT_STATION 15
34#define HOST_IF_MSG_SCAN_TIMER_FIRED 16
35#define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
36#define HOST_IF_MSG_POWER_MGMT 18
37#define HOST_IF_MSG_GET_INACTIVETIME 19
38#define HOST_IF_MSG_REMAIN_ON_CHAN 20
39#define HOST_IF_MSG_REGISTER_FRAME 21
40#define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
41#define HOST_IF_MSG_GET_LINKSPEED 23
42#define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
43#define HOST_IF_MSG_SET_MAC_ADDRESS 25
44#define HOST_IF_MSG_GET_MAC_ADDRESS 26
45#define HOST_IF_MSG_SET_OPERATION_MODE 27
46#define HOST_IF_MSG_SET_IPADDRESS 28
47#define HOST_IF_MSG_GET_IPADDRESS 29
48#define HOST_IF_MSG_FLUSH_CONNECT 30
49#define HOST_IF_MSG_GET_STATISTICS 31
50#define HOST_IF_MSG_SET_MULTICAST_FILTER 32
51#define HOST_IF_MSG_ADD_BA_SESSION 33
52#define HOST_IF_MSG_DEL_BA_SESSION 34
53#define HOST_IF_MSG_Q_IDLE 35
54#define HOST_IF_MSG_DEL_ALL_STA 36
55#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
56#define HOST_IF_MSG_EXIT 100
Johnny Kimc5c77ba2015-05-11 14:30:56 +090057
Chaehyun Lime54d5b72015-06-18 22:08:50 +090058#define HOST_IF_SCAN_TIMEOUT 4000
59#define HOST_IF_CONNECT_TIMEOUT 9500
Johnny Kimc5c77ba2015-05-11 14:30:56 +090060
Chaehyun Lime54d5b72015-06-18 22:08:50 +090061#define BA_SESSION_DEFAULT_BUFFER_SIZE 16
62#define BA_SESSION_DEFAULT_TIMEOUT 1000
63#define BLOCK_ACK_REQ_SIZE 0x14
Johnny Kimc5c77ba2015-05-11 14:30:56 +090064
65/*!
Tony Cho361ff842015-09-21 12:16:41 +090066 * @struct cfg_param_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +090067 * @brief Structure to hold Host IF CFG Params Attributes
68 * @details
69 * @todo
70 * @sa
71 * @author Mai Daftedar
72 * @date 02 April 2012
73 * @version 1.0
74 */
Tony Cho361ff842015-09-21 12:16:41 +090075struct cfg_param_attr {
Tony Cho221371e2015-10-12 16:56:06 +090076 struct cfg_param_val cfg_attr_info;
Tony Cho361ff842015-09-21 12:16:41 +090077};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090078
79/*!
Leo Kim4372d3d2015-10-05 15:25:43 +090080 * @struct host_if_wpa_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +090081 * @brief Structure to hold Host IF Scan Attributes
82 * @details
83 * @todo
84 * @sa
85 * @author Mai Daftedar
86 * @date 25 March 2012
87 * @version 1.0
88 */
Leo Kim4372d3d2015-10-05 15:25:43 +090089struct host_if_wpa_attr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090090 u8 *pu8key;
91 const u8 *pu8macaddr;
92 u8 *pu8seq;
93 u8 u8seqlen;
94 u8 u8keyidx;
95 u8 u8Keylen;
96 u8 u8Ciphermode;
Leo Kim4372d3d2015-10-05 15:25:43 +090097};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090098
99
100/*!
Leo Kimc276c442015-10-05 15:25:42 +0900101 * @struct host_if_wep_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900102 * @brief Structure to hold Host IF Scan Attributes
103 * @details
104 * @todo
105 * @sa
106 * @author Mai Daftedar
107 * @date 25 March 2012
108 * @version 1.0
109 */
Leo Kimc276c442015-10-05 15:25:42 +0900110struct host_if_wep_attr {
Tony Choe5538d32015-10-12 16:56:11 +0900111 u8 *key;
Tony Chod520e352015-10-12 16:56:12 +0900112 u8 key_len;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900113 u8 u8Wepidx;
114 u8 u8mode;
Leo Kim841dfc42015-10-05 15:25:39 +0900115 enum AUTHTYPE tenuAuth_type;
Leo Kimc276c442015-10-05 15:25:42 +0900116};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900117
118/*!
Leo Kim40cc2c92015-10-05 15:25:41 +0900119 * @struct host_if_key_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900120 * @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 */
Leo Kim40cc2c92015-10-05 15:25:41 +0900128union host_if_key_attr {
Tony Cho2ed7a2f2015-10-12 16:56:08 +0900129 struct host_if_wep_attr wep;
Tony Choe3501a42015-10-12 16:56:09 +0900130 struct host_if_wpa_attr wpa;
Tony Cho610e3862015-10-12 16:56:10 +0900131 struct host_if_pmkid_attr pmkid;
Leo Kim40cc2c92015-10-05 15:25:41 +0900132};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900133
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 {
Leo Kimb9d96332015-10-05 15:25:40 +0900145 enum KEY_TYPE enuKeyType;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900146 u8 u8KeyAction;
Leo Kim40cc2c92015-10-05 15:25:41 +0900147 union host_if_key_attr 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;
Leo Kimba1d1a62015-10-05 15:25:36 +0900170 wilc_scan_result pfScanResult;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900171 void *pvUserArg;
Leo Kim607db442015-10-05 15:25:37 +0900172 struct hidden_network 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;
Leo Kimb6ab85f2015-10-05 15:25:38 +0900192 wilc_connect_result pfConnectResult;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900193 void *pvUserArg;
Leo Kim841dfc42015-10-05 15:25:39 +0900194 enum AUTHTYPE 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 Cho5c4008d2015-10-05 13:50:44 +0900388 struct reg_frame reg_frame;
Tony Choe60831e2015-10-05 13:50:45 +0900389 char *data;
Tony Chob0c1e802015-10-05 13:50:46 +0900390 struct del_all_sta del_all_sta_info;
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 */
Leo Kim2482a792015-10-12 16:55:36 +0900406 struct host_if_drv *drv;
Tony Cho3a8c41b2015-09-18 18:11:04 +0900407};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900408
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900409/*Struct containg joinParam of each AP*/
Leo Kime0a12212015-10-12 16:55:49 +0900410struct join_bss_param {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900411 BSSTYPE_T bss_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900412 u8 dtim_period;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900413 u16 beacon_period;
414 u16 cap_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900415 u8 au8bssid[6];
Dean Lee576917a2015-06-15 11:58:57 +0900416 char ssid[MAX_SSID_LEN];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900417 u8 ssidLen;
418 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
419 u8 ht_capable;
420 u8 wmm_cap;
421 u8 uapsd_cap;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900422 bool rsn_found;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900423 u8 rsn_grp_policy;
424 u8 mode_802_11i;
425 u8 rsn_pcip_policy[3];
426 u8 rsn_auth_policy[3];
427 u8 rsn_cap[2];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900428 u32 tsf;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900429 u8 u8NoaEnbaled;
430 u8 u8OppEnable;
431 u8 u8CtWindow;
432 u8 u8Count;
433 u8 u8Index;
434 u8 au8Duration[4];
435 u8 au8Interval[4];
436 u8 au8StartTime[4];
Leo Kime0a12212015-10-12 16:55:49 +0900437};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900438
Leo Kim7696edf2015-10-12 16:56:02 +0900439enum scan_conn_timer {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900440 SCAN_TIMER = 0,
441 CONNECT_TIMER = 1,
442 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
Leo Kim7696edf2015-10-12 16:56:02 +0900443};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900444
445/*****************************************************************************/
446/* */
447/* Global Variabls */
448/* */
449/*****************************************************************************/
Johnny Kimd42ab082015-08-20 16:32:52 +0900450/* Zero is not used, because a zero ID means termination */
Leo Kim441dc602015-10-12 16:55:35 +0900451static struct host_if_drv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
452struct host_if_drv *terminated_handle;
453struct host_if_drv *gWFiDrvHandle;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900454bool g_obtainingIP = false;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900455u8 P2P_LISTEN_STATE;
Arnd Bergmann1999bd52015-05-29 22:52:14 +0200456static struct task_struct *HostIFthreadHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900457static WILC_MsgQueueHandle gMsgQHostIF;
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200458static struct semaphore hSemHostIFthrdEnd;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900459
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200460struct semaphore hSemDeinitDrvHandle;
461static struct semaphore hWaitResponse;
462struct semaphore hSemHostIntDeinit;
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -0700463struct timer_list g_hPeriodicRSSI;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900464
465
466
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900467u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900468
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900469static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900470
Dean Lee72ed4dc2015-06-12 14:11:44 +0900471bool gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900472
Chaehyun Limca356ad2015-06-11 14:35:57 +0900473static s8 gs8Rssi;
474static s8 gs8lnkspd;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900475static u8 gu8Chnl;
476static u8 gs8SetIP[2][4];
477static u8 gs8GetIP[2][4];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900478static u32 gu32InactiveTime;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900479static u8 gu8DelBcn;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900480static u32 gu32WidConnRstHack;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900481
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900482u8 *gu8FlushedJoinReq;
483u8 *gu8FlushedInfoElemAsoc;
484u8 gu8Flushed11iMode;
485u8 gu8FlushedAuthType;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900486u32 gu32FlushedJoinReqSize;
487u32 gu32FlushedInfoElemAsocSize;
Leo Kim441dc602015-10-12 16:55:35 +0900488struct host_if_drv *gu8FlushedJoinReqDrvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900489#define REAL_JOIN_REQ 0
490#define FLUSHED_JOIN_REQ 1
491#define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
492
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900493static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900494
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900495extern void chip_sleep_manually(u32 u32SleepTime);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900496extern int linux_wlan_get_num_conn_ifcs(void);
497
Leo Kim441dc602015-10-12 16:55:35 +0900498static int add_handler_in_list(struct host_if_drv *handler)
Johnny Kimd42ab082015-08-20 16:32:52 +0900499{
500 int i;
501
502 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
503 if (!wfidrv_list[i]) {
504 wfidrv_list[i] = handler;
505 return 0;
506 }
507 }
508
509 return -ENOBUFS;
510}
511
Leo Kim441dc602015-10-12 16:55:35 +0900512static int remove_handler_in_list(struct host_if_drv *handler)
Johnny Kimd42ab082015-08-20 16:32:52 +0900513{
514 int i;
515
516 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
517 if (wfidrv_list[i] == handler) {
518 wfidrv_list[i] = NULL;
519 return 0;
520 }
521 }
522
523 return -EINVAL;
524}
525
Leo Kim441dc602015-10-12 16:55:35 +0900526static int get_id_from_handler(struct host_if_drv *handler)
Johnny Kimd42ab082015-08-20 16:32:52 +0900527{
528 int i;
529
530 if (!handler)
531 return 0;
532
533 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
534 if (wfidrv_list[i] == handler)
535 return i;
536 }
537
538 return 0;
539}
540
Leo Kim441dc602015-10-12 16:55:35 +0900541static struct host_if_drv *get_handler_from_id(int id)
Johnny Kimd42ab082015-08-20 16:32:52 +0900542{
Dan Carpenter6ae9ac02015-09-15 09:54:33 +0300543 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
Johnny Kimd42ab082015-08-20 16:32:52 +0900544 return NULL;
545 return wfidrv_list[id];
546}
547
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900548/**
549 * @brief Handle_SetChannel
550 * @details Sending config packet to firmware to set channel
Tony Cho94bdfe42015-09-30 18:44:27 +0900551 * @param[in] struct channel_attr *pstrHostIFSetChan
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900552 * @return Error code.
553 * @author
554 * @date
555 * @version 1.0
556 */
Tony Choa4ab1ad2015-10-12 16:56:05 +0900557static s32 Handle_SetChannel(struct host_if_drv *hif_drv,
Tony Cho94bdfe42015-09-30 18:44:27 +0900558 struct channel_attr *pstrHostIFSetChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900559{
560
Leo Kime6e12662015-09-16 18:36:03 +0900561 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900562 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900563
564 /*prepare configuration packet*/
Leo Kimdaaf16b2015-10-12 16:55:44 +0900565 strWID.id = (u16)WID_CURRENT_CHANNEL;
Leo Kim416d8322015-10-12 16:55:43 +0900566 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +0900567 strWID.val = (char *)&(pstrHostIFSetChan->u8SetChan);
Leo Kim2fd3e442015-10-12 16:55:45 +0900568 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900569
570 PRINT_D(HOSTINF_DBG, "Setting channel\n");
571 /*Sending Cfg*/
Tony Cho03362282015-10-12 16:55:39 +0900572 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +0900573 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900574 if (s32Error) {
575 PRINT_ER("Failed to set channel\n");
Leo Kim24db7132015-09-16 18:36:01 +0900576 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900577 }
578
579 return s32Error;
580}
581/**
582 * @brief Handle_SetWfiDrvHandler
583 * @details Sending config packet to firmware to set driver handler
Tony Cho127f9d92015-09-21 12:16:51 +0900584 * @param[in] void * drvHandler,
585 * struct drv_handler *pstrHostIfSetDrvHandler
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900586 * @return Error code.
587 * @author
588 * @date
589 * @version 1.0
590 */
Tony Choa4ab1ad2015-10-12 16:56:05 +0900591static s32 Handle_SetWfiDrvHandler(struct host_if_drv *hif_drv,
Tony Cho127f9d92015-09-21 12:16:51 +0900592 struct drv_handler *pstrHostIfSetDrvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900593{
594
Leo Kime6e12662015-09-16 18:36:03 +0900595 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900596 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900597
598 /*prepare configuration packet*/
Leo Kimdaaf16b2015-10-12 16:55:44 +0900599 strWID.id = (u16)WID_SET_DRV_HANDLER;
Leo Kim416d8322015-10-12 16:55:43 +0900600 strWID.type = WID_INT;
Leo Kim900bb4a2015-10-12 16:55:46 +0900601 strWID.val = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
Leo Kim2fd3e442015-10-12 16:55:45 +0900602 strWID.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900603
604 /*Sending Cfg*/
605
Tony Cho03362282015-10-12 16:55:39 +0900606 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900607 pstrHostIfSetDrvHandler->u32Address);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900608
Tony Choa4ab1ad2015-10-12 16:56:05 +0900609 if (!hif_drv)
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200610 up(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900611
612
613 if (s32Error) {
614 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900615 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900616 }
617
618 return s32Error;
619}
620
621/**
622 * @brief Handle_SetWfiAPDrvHandler
623 * @details Sending config packet to firmware to set driver handler
624 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
625 * @return Error code.
626 * @author
627 * @date
628 * @version 1.0
629 */
Tony Choa4ab1ad2015-10-12 16:56:05 +0900630static s32 Handle_SetOperationMode(struct host_if_drv *hif_drv,
Tony Cho801bee52015-09-21 12:16:53 +0900631 struct op_mode *pstrHostIfSetOperationMode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900632{
633
Leo Kime6e12662015-09-16 18:36:03 +0900634 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900635 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900636
637 /*prepare configuration packet*/
Leo Kimdaaf16b2015-10-12 16:55:44 +0900638 strWID.id = (u16)WID_SET_OPERATION_MODE;
Leo Kim416d8322015-10-12 16:55:43 +0900639 strWID.type = WID_INT;
Leo Kim900bb4a2015-10-12 16:55:46 +0900640 strWID.val = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
Leo Kim2fd3e442015-10-12 16:55:45 +0900641 strWID.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900642
Tony Cho03362282015-10-12 16:55:39 +0900643 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +0900644 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900645
646
Johnny Kimc590b9a2015-09-08 17:07:59 +0900647 if ((pstrHostIfSetOperationMode->u32Mode) == IDLE_MODE)
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200648 up(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900649
650
651 if (s32Error) {
652 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900653 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900654 }
655
656 return s32Error;
657}
658
659/**
660 * @brief host_int_set_IPAddress
661 * @details Setting IP address params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900662 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900663 * @return Error code.
664 * @author
665 * @date
666 * @version 1.0
667 */
Tony Choa4ab1ad2015-10-12 16:56:05 +0900668s32 Handle_set_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900669{
670
Leo Kime6e12662015-09-16 18:36:03 +0900671 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900672 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900673 char firmwareIPAddress[4] = {0};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900674
675 if (pu8IPAddr[0] < 192)
676 pu8IPAddr[0] = 0;
677
Luis de Bethencourtb3a02832015-06-26 17:40:25 +0200678 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900679
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900680 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900681
682 /*prepare configuration packet*/
Leo Kimdaaf16b2015-10-12 16:55:44 +0900683 strWID.id = (u16)WID_IP_ADDRESS;
Leo Kim416d8322015-10-12 16:55:43 +0900684 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +0900685 strWID.val = (u8 *)pu8IPAddr;
Leo Kim2fd3e442015-10-12 16:55:45 +0900686 strWID.size = IP_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900687
Tony Cho03362282015-10-12 16:55:39 +0900688 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +0900689 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900690
691
Tony Choa4ab1ad2015-10-12 16:56:05 +0900692 host_int_get_ipaddress(hif_drv, firmwareIPAddress, idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900693
694 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +0900695 PRINT_ER("Failed to set IP address\n");
696 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900697 }
698
Leo Kim24db7132015-09-16 18:36:01 +0900699 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900700
701 return s32Error;
702}
703
704
705/**
706 * @brief Handle_get_IPAddress
707 * @details Setting IP address params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900708 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900709 * @return Error code.
710 * @author
711 * @date
712 * @version 1.0
713 */
Tony Choa4ab1ad2015-10-12 16:56:05 +0900714s32 Handle_get_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900715{
716
Leo Kime6e12662015-09-16 18:36:03 +0900717 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900718 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900719
720 /*prepare configuration packet*/
Leo Kimdaaf16b2015-10-12 16:55:44 +0900721 strWID.id = (u16)WID_IP_ADDRESS;
Leo Kim416d8322015-10-12 16:55:43 +0900722 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +0900723 strWID.val = kmalloc(IP_ALEN, GFP_KERNEL);
Leo Kim2fd3e442015-10-12 16:55:45 +0900724 strWID.size = IP_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900725
Tony Cho03362282015-10-12 16:55:39 +0900726 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +0900727 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900728
Leo Kim900bb4a2015-10-12 16:55:46 +0900729 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900730
Leo Kim900bb4a2015-10-12 16:55:46 +0900731 memcpy(gs8GetIP[idx], strWID.val, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900732
733 /*get the value by searching the local copy*/
Leo Kim900bb4a2015-10-12 16:55:46 +0900734 kfree(strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900735
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900736 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
Tony Choa4ab1ad2015-10-12 16:56:05 +0900737 host_int_setup_ipaddress(hif_drv, gs8SetIP[idx], idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900738
Leo Kime6e12662015-09-16 18:36:03 +0900739 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900740 PRINT_ER("Failed to get IP address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900741 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900742 }
743
Leo Kim24db7132015-09-16 18:36:01 +0900744 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
745 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
746 PRINT_INFO(HOSTINF_DBG, "\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900747
748 return s32Error;
749}
750
751
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900752/**
753 * @brief Handle_SetMacAddress
754 * @details Setting mac address
755 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
756 * @return Error code.
757 * @author Amr Abdel-Moghny
758 * @date November 2013
759 * @version 7.0
760 */
Tony Choa4ab1ad2015-10-12 16:56:05 +0900761static s32 Handle_SetMacAddress(struct host_if_drv *hif_drv,
Tony Chob7611a82015-09-21 12:16:54 +0900762 struct set_mac_addr *pstrHostIfSetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900763{
764
Leo Kime6e12662015-09-16 18:36:03 +0900765 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900766 struct wid strWID;
Glen Leef3052582015-09-10 12:03:04 +0900767 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +0200768
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900769 if (mac_buf == NULL) {
770 PRINT_ER("No buffer to send mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +0900771 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900772 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900773 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900774
775 /*prepare configuration packet*/
Leo Kimdaaf16b2015-10-12 16:55:44 +0900776 strWID.id = (u16)WID_MAC_ADDR;
Leo Kim416d8322015-10-12 16:55:43 +0900777 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +0900778 strWID.val = mac_buf;
Leo Kim2fd3e442015-10-12 16:55:45 +0900779 strWID.size = ETH_ALEN;
Leo Kim900bb4a2015-10-12 16:55:46 +0900780 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900781 /*Sending Cfg*/
Tony Cho03362282015-10-12 16:55:39 +0900782 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +0900783 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900784 if (s32Error) {
785 PRINT_ER("Failed to set mac address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900786 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900787 }
788
Chaehyun Lim49188af2015-08-11 10:32:41 +0900789 kfree(mac_buf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900790 return s32Error;
791}
792
793
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900794/**
795 * @brief Handle_GetMacAddress
796 * @details Getting mac address
797 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
798 * @return Error code.
799 * @author Amr Abdel-Moghny
800 * @date JAN 2013
801 * @version 8.0
802 */
Tony Choa4ab1ad2015-10-12 16:56:05 +0900803static s32 Handle_GetMacAddress(struct host_if_drv *hif_drv,
Tony Chofcd27c52015-09-21 12:16:55 +0900804 struct get_mac_addr *pstrHostIfGetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900805{
806
Leo Kime6e12662015-09-16 18:36:03 +0900807 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900808 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900809
810 /*prepare configuration packet*/
Leo Kimdaaf16b2015-10-12 16:55:44 +0900811 strWID.id = (u16)WID_MAC_ADDR;
Leo Kim416d8322015-10-12 16:55:43 +0900812 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +0900813 strWID.val = pstrHostIfGetMacAddress->u8MacAddress;
Leo Kim2fd3e442015-10-12 16:55:45 +0900814 strWID.size = ETH_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900815
816 /*Sending Cfg*/
Tony Cho03362282015-10-12 16:55:39 +0900817 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +0900818 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900819 if (s32Error) {
820 PRINT_ER("Failed to get mac address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900821 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900822 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200823 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900824
825 return s32Error;
826}
827
828
829/**
830 * @brief Handle_CfgParam
831 * @details Sending config packet to firmware to set CFG params
Tony Cho361ff842015-09-21 12:16:41 +0900832 * @param[in] struct cfg_param_attr *strHostIFCfgParamAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900833 * @return Error code.
834 * @author
835 * @date
836 * @version 1.0
837 */
Tony Choa4ab1ad2015-10-12 16:56:05 +0900838static s32 Handle_CfgParam(struct host_if_drv *hif_drv,
Tony Cho361ff842015-09-21 12:16:41 +0900839 struct cfg_param_attr *strHostIFCfgParamAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900840{
Leo Kime6e12662015-09-16 18:36:03 +0900841 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900842 struct wid strWIDList[32];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900843 u8 u8WidCnt = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900844
Tony Choa4ab1ad2015-10-12 16:56:05 +0900845 down(&hif_drv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900846
847
848 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
849
Tony Cho87c05b22015-10-12 16:56:07 +0900850 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BSS_TYPE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900851 /*----------------------------------------------------------*/
852 /*Input Value: INFRASTRUCTURE = 1, */
853 /* INDEPENDENT= 2, */
854 /* ANY_BSS= 3 */
855 /*----------------------------------------------------------*/
856 /* validate input then copy>> need to check value 4 and 5 */
Tony Cho221371e2015-10-12 16:56:06 +0900857 if (strHostIFCfgParamAttr->cfg_attr_info.bss_type < 6) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900858 strWIDList[u8WidCnt].id = WID_BSS_TYPE;
Tony Cho221371e2015-10-12 16:56:06 +0900859 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.bss_type;
Leo Kim416d8322015-10-12 16:55:43 +0900860 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900861 strWIDList[u8WidCnt].size = sizeof(char);
Tony Cho221371e2015-10-12 16:56:06 +0900862 hif_drv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900863 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900864 PRINT_ER("check value 6 over\n");
865 s32Error = -EINVAL;
866 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900867 }
868 u8WidCnt++;
869 }
Tony Cho87c05b22015-10-12 16:56:07 +0900870 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTH_TYPE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900871 /*------------------------------------------------------*/
872 /*Input Values: OPEN_SYSTEM = 0, */
873 /* SHARED_KEY = 1, */
874 /* ANY = 2 */
875 /*------------------------------------------------------*/
876 /*validate Possible values*/
Tony Cho221371e2015-10-12 16:56:06 +0900877 if ((strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 1 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 2 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 5) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900878 strWIDList[u8WidCnt].id = WID_AUTH_TYPE;
Tony Cho221371e2015-10-12 16:56:06 +0900879 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_type;
Leo Kim416d8322015-10-12 16:55:43 +0900880 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900881 strWIDList[u8WidCnt].size = sizeof(char);
Tony Cho221371e2015-10-12 16:56:06 +0900882 hif_drv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900883 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900884 PRINT_ER("Impossible value \n");
885 s32Error = -EINVAL;
886 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900887 }
888 u8WidCnt++;
889 }
Tony Cho87c05b22015-10-12 16:56:07 +0900890 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTHEN_TIMEOUT) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900891 /* range is 1 to 65535. */
Tony Cho221371e2015-10-12 16:56:06 +0900892 if (strHostIFCfgParamAttr->cfg_attr_info.auth_timeout > 0 && strHostIFCfgParamAttr->cfg_attr_info.auth_timeout < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900893 strWIDList[u8WidCnt].id = WID_AUTH_TIMEOUT;
Tony Cho221371e2015-10-12 16:56:06 +0900894 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
Leo Kim416d8322015-10-12 16:55:43 +0900895 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900896 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +0900897 hif_drv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900898 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900899 PRINT_ER("Range(1 ~ 65535) over\n");
900 s32Error = -EINVAL;
901 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900902 }
903 u8WidCnt++;
904 }
Tony Cho87c05b22015-10-12 16:56:07 +0900905 if (strHostIFCfgParamAttr->cfg_attr_info.flag & POWER_MANAGEMENT) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900906 /*-----------------------------------------------------------*/
907 /*Input Values: NO_POWERSAVE = 0, */
908 /* MIN_FAST_PS = 1, */
909 /* MAX_FAST_PS = 2, */
910 /* MIN_PSPOLL_PS = 3, */
911 /* MAX_PSPOLL_PS = 4 */
912 /*----------------------------------------------------------*/
Tony Cho221371e2015-10-12 16:56:06 +0900913 if (strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode < 5) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900914 strWIDList[u8WidCnt].id = WID_POWER_MANAGEMENT;
Tony Cho221371e2015-10-12 16:56:06 +0900915 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
Leo Kim416d8322015-10-12 16:55:43 +0900916 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900917 strWIDList[u8WidCnt].size = sizeof(char);
Tony Cho221371e2015-10-12 16:56:06 +0900918 hif_drv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900919 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900920 PRINT_ER("Invalide power mode\n");
921 s32Error = -EINVAL;
922 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900923 }
924 u8WidCnt++;
925 }
Tony Cho87c05b22015-10-12 16:56:07 +0900926 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_SHORT) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900927 /* range from 1 to 256 */
Tony Cho221371e2015-10-12 16:56:06 +0900928 if ((strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit < 256)) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900929 strWIDList[u8WidCnt].id = WID_SHORT_RETRY_LIMIT;
Tony Cho221371e2015-10-12 16:56:06 +0900930 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
Leo Kim416d8322015-10-12 16:55:43 +0900931 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900932 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +0900933 hif_drv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900934 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900935 PRINT_ER("Range(1~256) over\n");
936 s32Error = -EINVAL;
937 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900938 }
939 u8WidCnt++;
940 }
Tony Cho87c05b22015-10-12 16:56:07 +0900941 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_LONG) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900942 /* range from 1 to 256 */
Tony Cho221371e2015-10-12 16:56:06 +0900943 if ((strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit < 256)) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900944 strWIDList[u8WidCnt].id = WID_LONG_RETRY_LIMIT;
Tony Cho221371e2015-10-12 16:56:06 +0900945 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900946
Leo Kim416d8322015-10-12 16:55:43 +0900947 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900948 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +0900949 hif_drv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900950 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900951 PRINT_ER("Range(1~256) over\n");
952 s32Error = -EINVAL;
953 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900954 }
955 u8WidCnt++;
956 }
Tony Cho87c05b22015-10-12 16:56:07 +0900957 if (strHostIFCfgParamAttr->cfg_attr_info.flag & FRAG_THRESHOLD) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900958
Tony Cho221371e2015-10-12 16:56:06 +0900959 if (strHostIFCfgParamAttr->cfg_attr_info.frag_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.frag_threshold < 7937) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900960 strWIDList[u8WidCnt].id = WID_FRAG_THRESHOLD;
Tony Cho221371e2015-10-12 16:56:06 +0900961 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
Leo Kim416d8322015-10-12 16:55:43 +0900962 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900963 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +0900964 hif_drv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900965 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900966 PRINT_ER("Threshold Range fail\n");
967 s32Error = -EINVAL;
968 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900969 }
970 u8WidCnt++;
971 }
Tony Cho87c05b22015-10-12 16:56:07 +0900972 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RTS_THRESHOLD) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900973 /* range 256 to 65535 */
Tony Cho221371e2015-10-12 16:56:06 +0900974 if (strHostIFCfgParamAttr->cfg_attr_info.rts_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.rts_threshold < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900975 strWIDList[u8WidCnt].id = WID_RTS_THRESHOLD;
Tony Cho221371e2015-10-12 16:56:06 +0900976 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
Leo Kim416d8322015-10-12 16:55:43 +0900977 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900978 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +0900979 hif_drv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900980 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900981 PRINT_ER("Threshold Range fail\n");
982 s32Error = -EINVAL;
983 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900984 }
985 u8WidCnt++;
986 }
Tony Cho87c05b22015-10-12 16:56:07 +0900987 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PREAMBLE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900988 /*-----------------------------------------------------*/
989 /*Input Values: Short= 0, */
990 /* Long= 1, */
991 /* Auto= 2 */
992 /*------------------------------------------------------*/
Tony Cho221371e2015-10-12 16:56:06 +0900993 if (strHostIFCfgParamAttr->cfg_attr_info.preamble_type < 3) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900994 strWIDList[u8WidCnt].id = WID_PREAMBLE;
Tony Cho221371e2015-10-12 16:56:06 +0900995 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
Leo Kim416d8322015-10-12 16:55:43 +0900996 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900997 strWIDList[u8WidCnt].size = sizeof(char);
Tony Cho221371e2015-10-12 16:56:06 +0900998 hif_drv->strCfgValues.preamble_type = strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900999 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001000 PRINT_ER("Preamle Range(0~2) over\n");
1001 s32Error = -EINVAL;
1002 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001003 }
1004 u8WidCnt++;
1005 }
Tony Cho87c05b22015-10-12 16:56:07 +09001006 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SHORT_SLOT_ALLOWED) {
Tony Cho221371e2015-10-12 16:56:06 +09001007 if (strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed < 2) {
Leo Kimdaaf16b2015-10-12 16:55:44 +09001008 strWIDList[u8WidCnt].id = WID_SHORT_SLOT_ALLOWED;
Tony Cho221371e2015-10-12 16:56:06 +09001009 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
Leo Kim416d8322015-10-12 16:55:43 +09001010 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001011 strWIDList[u8WidCnt].size = sizeof(char);
Tony Cho221371e2015-10-12 16:56:06 +09001012 hif_drv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001013 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001014 PRINT_ER("Short slot(2) over\n");
1015 s32Error = -EINVAL;
1016 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001017 }
1018 u8WidCnt++;
1019 }
Tony Cho87c05b22015-10-12 16:56:07 +09001020 if (strHostIFCfgParamAttr->cfg_attr_info.flag & TXOP_PROT_DISABLE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001021 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1022 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1023 /* this information is useful for external supplicant */
1024 /*Input Values: 1 for enable and 0 for disable. */
Tony Cho221371e2015-10-12 16:56:06 +09001025 if (strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled < 2) {
Leo Kimdaaf16b2015-10-12 16:55:44 +09001026 strWIDList[u8WidCnt].id = WID_11N_TXOP_PROT_DISABLE;
Tony Cho221371e2015-10-12 16:56:06 +09001027 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
Leo Kim416d8322015-10-12 16:55:43 +09001028 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001029 strWIDList[u8WidCnt].size = sizeof(char);
Tony Cho221371e2015-10-12 16:56:06 +09001030 hif_drv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001031 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001032 PRINT_ER("TXOP prot disable\n");
1033 s32Error = -EINVAL;
1034 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001035 }
1036 u8WidCnt++;
1037 }
Tony Cho87c05b22015-10-12 16:56:07 +09001038 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BEACON_INTERVAL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001039 /* range is 1 to 65535. */
Tony Cho221371e2015-10-12 16:56:06 +09001040 if (strHostIFCfgParamAttr->cfg_attr_info.beacon_interval > 0 && strHostIFCfgParamAttr->cfg_attr_info.beacon_interval < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +09001041 strWIDList[u8WidCnt].id = WID_BEACON_INTERVAL;
Tony Cho221371e2015-10-12 16:56:06 +09001042 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
Leo Kim416d8322015-10-12 16:55:43 +09001043 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001044 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +09001045 hif_drv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001046 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001047 PRINT_ER("Beacon interval(1~65535) fail\n");
1048 s32Error = -EINVAL;
1049 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001050 }
1051 u8WidCnt++;
1052 }
Tony Cho87c05b22015-10-12 16:56:07 +09001053 if (strHostIFCfgParamAttr->cfg_attr_info.flag & DTIM_PERIOD) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001054 /* range is 1 to 255. */
Tony Cho221371e2015-10-12 16:56:06 +09001055 if (strHostIFCfgParamAttr->cfg_attr_info.dtim_period > 0 && strHostIFCfgParamAttr->cfg_attr_info.dtim_period < 256) {
Leo Kimdaaf16b2015-10-12 16:55:44 +09001056 strWIDList[u8WidCnt].id = WID_DTIM_PERIOD;
Tony Cho221371e2015-10-12 16:56:06 +09001057 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
Leo Kim416d8322015-10-12 16:55:43 +09001058 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001059 strWIDList[u8WidCnt].size = sizeof(char);
Tony Cho221371e2015-10-12 16:56:06 +09001060 hif_drv->strCfgValues.dtim_period = strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001061 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001062 PRINT_ER("DTIM range(1~255) fail\n");
1063 s32Error = -EINVAL;
1064 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001065 }
1066 u8WidCnt++;
1067 }
Tony Cho87c05b22015-10-12 16:56:07 +09001068 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001069 /*----------------------------------------------------------------------*/
1070 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1071 /* SITE_SURVEY_ALL_CH = 1, */
1072 /* SITE_SURVEY_OFF = 2 */
1073 /*----------------------------------------------------------------------*/
Tony Cho221371e2015-10-12 16:56:06 +09001074 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled < 3) {
Leo Kimdaaf16b2015-10-12 16:55:44 +09001075 strWIDList[u8WidCnt].id = WID_SITE_SURVEY;
Tony Cho221371e2015-10-12 16:56:06 +09001076 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
Leo Kim416d8322015-10-12 16:55:43 +09001077 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001078 strWIDList[u8WidCnt].size = sizeof(char);
Tony Cho221371e2015-10-12 16:56:06 +09001079 hif_drv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001080 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001081 PRINT_ER("Site survey disable\n");
1082 s32Error = -EINVAL;
1083 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001084 }
1085 u8WidCnt++;
1086 }
Tony Cho87c05b22015-10-12 16:56:07 +09001087 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001088 /* range is 1 to 65535. */
Tony Cho221371e2015-10-12 16:56:06 +09001089 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +09001090 strWIDList[u8WidCnt].id = WID_SITE_SURVEY_SCAN_TIME;
Tony Cho221371e2015-10-12 16:56:06 +09001091 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
Leo Kim416d8322015-10-12 16:55:43 +09001092 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001093 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +09001094 hif_drv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001095 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001096 PRINT_ER("Site survey scan time(1~65535) over\n");
1097 s32Error = -EINVAL;
1098 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001099 }
1100 u8WidCnt++;
1101 }
Tony Cho87c05b22015-10-12 16:56:07 +09001102 if (strHostIFCfgParamAttr->cfg_attr_info.flag & ACTIVE_SCANTIME) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001103 /* range is 1 to 65535. */
Tony Cho221371e2015-10-12 16:56:06 +09001104 if (strHostIFCfgParamAttr->cfg_attr_info.active_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.active_scan_time < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +09001105 strWIDList[u8WidCnt].id = WID_ACTIVE_SCAN_TIME;
Tony Cho221371e2015-10-12 16:56:06 +09001106 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
Leo Kim416d8322015-10-12 16:55:43 +09001107 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001108 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +09001109 hif_drv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001110 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001111 PRINT_ER("Active scan time(1~65535) over\n");
1112 s32Error = -EINVAL;
1113 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001114 }
1115 u8WidCnt++;
1116 }
Tony Cho87c05b22015-10-12 16:56:07 +09001117 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PASSIVE_SCANTIME) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001118 /* range is 1 to 65535. */
Tony Cho221371e2015-10-12 16:56:06 +09001119 if (strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +09001120 strWIDList[u8WidCnt].id = WID_PASSIVE_SCAN_TIME;
Tony Cho221371e2015-10-12 16:56:06 +09001121 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
Leo Kim416d8322015-10-12 16:55:43 +09001122 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001123 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +09001124 hif_drv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001125 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001126 PRINT_ER("Passive scan time(1~65535) over\n");
1127 s32Error = -EINVAL;
1128 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001129 }
1130 u8WidCnt++;
1131 }
Tony Cho87c05b22015-10-12 16:56:07 +09001132 if (strHostIFCfgParamAttr->cfg_attr_info.flag & CURRENT_TX_RATE) {
Tony Cho221371e2015-10-12 16:56:06 +09001133 enum CURRENT_TXRATE curr_tx_rate = strHostIFCfgParamAttr->cfg_attr_info.curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001134 /*----------------------------------------------------------------------*/
1135 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1136 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1137 /*----------------------------------------------------------------------*/
1138 /* validate rate */
1139 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
1140 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
1141 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
1142 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
1143 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
1144 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
Leo Kimdaaf16b2015-10-12 16:55:44 +09001145 strWIDList[u8WidCnt].id = WID_CURRENT_TX_RATE;
Leo Kim900bb4a2015-10-12 16:55:46 +09001146 strWIDList[u8WidCnt].val = (s8 *)&curr_tx_rate;
Leo Kim416d8322015-10-12 16:55:43 +09001147 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001148 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001149 hif_drv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001150 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001151 PRINT_ER("out of TX rate\n");
1152 s32Error = -EINVAL;
1153 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001154 }
1155 u8WidCnt++;
1156 }
Tony Cho03362282015-10-12 16:55:39 +09001157 s32Error = send_config_pkt(SET_CFG, strWIDList, u8WidCnt,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001158 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001159
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001160 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001161 PRINT_ER("Error in setting CFG params\n");
1162
Leo Kim24db7132015-09-16 18:36:01 +09001163ERRORHANDLER:
Tony Choa4ab1ad2015-10-12 16:56:05 +09001164 up(&hif_drv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001165 return s32Error;
1166}
1167
1168
1169/**
1170 * @brief Handle_wait_msg_q_empty
1171 * @details this should be the last msg and then the msg Q becomes idle
1172 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1173 * @return Error code.
1174 * @author
1175 * @date
1176 * @version 1.0
1177 */
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001178static s32 Handle_wait_msg_q_empty(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001179{
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001180 g_wilc_initialized = 0;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02001181 up(&hWaitResponse);
Leo Kimb68d820b2015-10-12 16:55:37 +09001182 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001183}
1184
1185/**
1186 * @brief Handle_Scan
1187 * @details Sending config packet to firmware to set the scan params
Tony Choc476feb2015-09-21 12:16:36 +09001188 * @param[in] struct scan_attr *pstrHostIFscanAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001189 * @return Error code.
1190 * @author
1191 * @date
1192 * @version 1.0
1193 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09001194static s32 Handle_Scan(struct host_if_drv *hif_drv,
Tony Choc476feb2015-09-21 12:16:36 +09001195 struct scan_attr *pstrHostIFscanAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001196{
Leo Kime6e12662015-09-16 18:36:03 +09001197 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09001198 struct wid strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001199 u32 u32WidsCount = 0;
1200 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001201 u8 *pu8Buffer;
1202 u8 valuesize = 0;
1203 u8 *pu8HdnNtwrksWidVal = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001204
1205 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09001206 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", hif_drv->enuHostIFstate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001207
Tony Choa4ab1ad2015-10-12 16:56:05 +09001208 hif_drv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
1209 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001210
Tony Choa4ab1ad2015-10-12 16:56:05 +09001211 if ((hif_drv->enuHostIFstate >= HOST_IF_SCANNING) && (hif_drv->enuHostIFstate < HOST_IF_CONNECTED)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001212 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
Tony Choa4ab1ad2015-10-12 16:56:05 +09001213 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", hif_drv->enuHostIFstate);
Leo Kim24db7132015-09-16 18:36:01 +09001214 PRINT_ER("Already scan\n");
1215 s32Error = -EBUSY;
1216 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001217 }
1218
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001219 if (g_obtainingIP || connecting) {
1220 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +09001221 PRINT_ER("Don't do obss scan\n");
1222 s32Error = -EBUSY;
1223 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001224 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001225
1226 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1227
1228
Tony Choa4ab1ad2015-10-12 16:56:05 +09001229 hif_drv->strWILC_UsrScanReq.u32RcvdChCount = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001230
Leo Kimdaaf16b2015-10-12 16:55:44 +09001231 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
Leo Kim416d8322015-10-12 16:55:43 +09001232 strWIDList[u32WidsCount].type = WID_STR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001233
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001234 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001235 valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
Glen Leef3052582015-09-10 12:03:04 +09001236 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
Leo Kim900bb4a2015-10-12 16:55:46 +09001237 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
1238 if (strWIDList[u32WidsCount].val != NULL) {
1239 pu8Buffer = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001240
1241 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
1242
1243 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
1244
1245 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1246 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001247 memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001248 pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1249 }
1250
1251
1252
Leo Kim2fd3e442015-10-12 16:55:45 +09001253 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001254 u32WidsCount++;
1255 }
1256
1257 /*filling cfg param array*/
1258
1259 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1260 {
1261 /* IEs to be inserted in Probe Request */
Leo Kimdaaf16b2015-10-12 16:55:44 +09001262 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
Leo Kim416d8322015-10-12 16:55:43 +09001263 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kim900bb4a2015-10-12 16:55:46 +09001264 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->pu8IEs;
Leo Kim2fd3e442015-10-12 16:55:45 +09001265 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->IEsLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001266 u32WidsCount++;
1267 }
1268
1269 /*Scan Type*/
Leo Kimdaaf16b2015-10-12 16:55:44 +09001270 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001271 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001272 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim900bb4a2015-10-12 16:55:46 +09001273 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->u8ScanType));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001274 u32WidsCount++;
1275
1276 /*list of channels to be scanned*/
Leo Kimdaaf16b2015-10-12 16:55:44 +09001277 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
Leo Kim416d8322015-10-12 16:55:43 +09001278 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001279
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001280 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
1281 int i;
1282
1283 for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001284 if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001285 pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001286 }
1287 }
1288
Leo Kim900bb4a2015-10-12 16:55:46 +09001289 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->pu8ChnlFreqList;
Leo Kim2fd3e442015-10-12 16:55:45 +09001290 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->u8ChnlListLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001291 u32WidsCount++;
1292
1293 /*Scan Request*/
Leo Kimdaaf16b2015-10-12 16:55:44 +09001294 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
Leo Kim416d8322015-10-12 16:55:43 +09001295 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001296 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim900bb4a2015-10-12 16:55:46 +09001297 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001298 u32WidsCount++;
1299
1300 /*keep the state as is , no need to change it*/
1301 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1302
Tony Choa4ab1ad2015-10-12 16:56:05 +09001303 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001304 gbScanWhileConnected = true;
Tony Choa4ab1ad2015-10-12 16:56:05 +09001305 else if (hif_drv->enuHostIFstate == HOST_IF_IDLE)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001306 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001307
Tony Cho03362282015-10-12 16:55:39 +09001308 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001309 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001310
Leo Kim24db7132015-09-16 18:36:01 +09001311 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001312 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09001313 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001314 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001315
Leo Kim24db7132015-09-16 18:36:01 +09001316ERRORHANDLER:
1317 if (s32Error) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09001318 del_timer(&hif_drv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001319 /*if there is an ongoing scan request*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09001320 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001321 }
1322
1323 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1324 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001325 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001326 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1327 }
1328
1329 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1330 if (pstrHostIFscanAttr->pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001331 kfree(pstrHostIFscanAttr->pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001332 pstrHostIFscanAttr->pu8IEs = NULL;
1333 }
1334 if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001335 kfree(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001336 pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
1337 }
1338
1339 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1340 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001341 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001342 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1343 }
1344
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001345 if (pu8HdnNtwrksWidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001346 kfree(pu8HdnNtwrksWidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001347
1348 return s32Error;
1349}
1350
1351/**
1352 * @brief Handle_ScanDone
1353 * @details Call scan notification callback function
1354 * @param[in] NONE
1355 * @return Error code.
1356 * @author
1357 * @date
1358 * @version 1.0
1359 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09001360static s32 Handle_ScanDone(struct host_if_drv *hif_drv,
1361 enum scan_event enuEvent)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001362{
Leo Kime6e12662015-09-16 18:36:03 +09001363 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001364 u8 u8abort_running_scan;
Leo Kime9e0c262015-10-12 16:55:41 +09001365 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001366
1367
1368 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
1369
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001370 /*Ask FW to abort the running scan, if any*/
1371 if (enuEvent == SCAN_EVENT_ABORTED) {
1372 PRINT_D(GENERIC_DBG, "Abort running scan\n");
1373 u8abort_running_scan = 1;
Leo Kimdaaf16b2015-10-12 16:55:44 +09001374 strWID.id = (u16)WID_ABORT_RUNNING_SCAN;
Leo Kim416d8322015-10-12 16:55:43 +09001375 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09001376 strWID.val = (s8 *)&u8abort_running_scan;
Leo Kim2fd3e442015-10-12 16:55:45 +09001377 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001378
1379 /*Sending Cfg*/
Tony Cho03362282015-10-12 16:55:39 +09001380 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001381 get_id_from_handler(hif_drv));
Leo Kim24db7132015-09-16 18:36:01 +09001382 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001383 PRINT_ER("Failed to set abort running scan\n");
Leo Kim24db7132015-09-16 18:36:01 +09001384 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001385 }
1386 }
1387
Tony Choa4ab1ad2015-10-12 16:56:05 +09001388 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001389 PRINT_ER("Driver handler is NULL\n");
1390 return s32Error;
1391 }
1392
1393 /*if there is an ongoing scan request*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09001394 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
1395 hif_drv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
1396 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001397 /*delete current scan request*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09001398 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001399 }
1400
1401 return s32Error;
1402}
1403
1404/**
1405 * @brief Handle_Connect
1406 * @details Sending config packet to firmware to starting connection
Tony Cho120ae592015-09-21 12:16:37 +09001407 * @param[in] struct connect_attr *pstrHostIFconnectAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001408 * @return Error code.
1409 * @author
1410 * @date
1411 * @version 1.0
1412 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001413u8 u8ConnectedSSID[6] = {0};
Tony Choa4ab1ad2015-10-12 16:56:05 +09001414static s32 Handle_Connect(struct host_if_drv *hif_drv,
Tony Cho120ae592015-09-21 12:16:37 +09001415 struct connect_attr *pstrHostIFconnectAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001416{
Leo Kime6e12662015-09-16 18:36:03 +09001417 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09001418 struct wid strWIDList[8];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001419 u32 u32WidsCount = 0, dummyval = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001420 /* char passphrase[] = "12345678"; */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001421 u8 *pu8CurrByte = NULL;
Leo Kime0a12212015-10-12 16:55:49 +09001422 struct join_bss_param *ptstrJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001423
1424 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1425
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001426 /* if we try to connect to an already connected AP then discard the request */
1427
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001428 if (memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001429
Leo Kime6e12662015-09-16 18:36:03 +09001430 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001431 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1432 return s32Error;
1433 }
1434
1435 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1436
Leo Kime0a12212015-10-12 16:55:49 +09001437 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->pJoinParams;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001438 if (ptstrJoinBssParam == NULL) {
1439 PRINT_ER("Required BSSID not found\n");
Leo Kim24db7132015-09-16 18:36:01 +09001440 s32Error = -ENOENT;
1441 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001442 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001443
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001444 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09001445 hif_drv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
1446 memcpy(hif_drv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001447 }
1448
Tony Choa4ab1ad2015-10-12 16:56:05 +09001449 hif_drv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001450 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09001451 hif_drv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssidLen + 1, GFP_KERNEL);
1452 memcpy(hif_drv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001453 pstrHostIFconnectAttr->ssidLen);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001454 hif_drv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001455 }
1456
Tony Choa4ab1ad2015-10-12 16:56:05 +09001457 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001458 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09001459 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
1460 memcpy(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001461 pstrHostIFconnectAttr->IEsLen);
1462 }
1463
Tony Choa4ab1ad2015-10-12 16:56:05 +09001464 hif_drv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1465 hif_drv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1466 hif_drv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1467 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001468
Leo Kimdaaf16b2015-10-12 16:55:44 +09001469 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001470 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001471 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001472 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001473 u32WidsCount++;
1474
Leo Kimdaaf16b2015-10-12 16:55:44 +09001475 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001476 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001477 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001478 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001479 u32WidsCount++;
1480
Leo Kimdaaf16b2015-10-12 16:55:44 +09001481 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001482 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001483 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001484 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001485 u32WidsCount++;
1486
1487 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1488 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1489 {
1490 /* IEs to be inserted in Association Request */
Leo Kimdaaf16b2015-10-12 16:55:44 +09001491 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
Leo Kim416d8322015-10-12 16:55:43 +09001492 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Tony Choa4ab1ad2015-10-12 16:56:05 +09001493 strWIDList[u32WidsCount].val = hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs;
1494 strWIDList[u32WidsCount].size = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001495 u32WidsCount++;
1496
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001497 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001498
Tony Choa4ab1ad2015-10-12 16:56:05 +09001499 gu32FlushedInfoElemAsocSize = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001500 gu8FlushedInfoElemAsoc = kmalloc(gu32FlushedInfoElemAsocSize, GFP_KERNEL);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001501 memcpy(gu8FlushedInfoElemAsoc, hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001502 gu32FlushedInfoElemAsocSize);
1503 }
1504 }
Leo Kimdaaf16b2015-10-12 16:55:44 +09001505 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001506 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001507 strWIDList[u32WidsCount].size = sizeof(char);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001508 strWIDList[u32WidsCount].val = (s8 *)(&(hif_drv->strWILC_UsrConnReq.u8security));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001509 u32WidsCount++;
1510
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001511 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
Tony Choa4ab1ad2015-10-12 16:56:05 +09001512 gu8Flushed11iMode = hif_drv->strWILC_UsrConnReq.u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001513
Tony Choa4ab1ad2015-10-12 16:56:05 +09001514 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", hif_drv->strWILC_UsrConnReq.u8security);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001515
1516
Leo Kimdaaf16b2015-10-12 16:55:44 +09001517 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001518 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001519 strWIDList[u32WidsCount].size = sizeof(char);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001520 strWIDList[u32WidsCount].val = (s8 *)(&hif_drv->strWILC_UsrConnReq.tenuAuth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001521 u32WidsCount++;
1522
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001523 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
Tony Choa4ab1ad2015-10-12 16:56:05 +09001524 gu8FlushedAuthType = (u8)hif_drv->strWILC_UsrConnReq.tenuAuth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001525
Tony Choa4ab1ad2015-10-12 16:56:05 +09001526 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", hif_drv->strWILC_UsrConnReq.tenuAuth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001527 /*
Chaehyun Limd85f5322015-06-11 14:35:54 +09001528 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001529 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1530 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001531 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001532 * u32WidsCount++;
1533 */
1534
1535 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
Tony Choa4ab1ad2015-10-12 16:56:05 +09001536 hif_drv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001537
Leo Kimdaaf16b2015-10-12 16:55:44 +09001538 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
Leo Kim416d8322015-10-12 16:55:43 +09001539 strWIDList[u32WidsCount].type = WID_STR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001540
1541 /*Sending NoA attributes during connection*/
Leo Kim2fd3e442015-10-12 16:55:45 +09001542 strWIDList[u32WidsCount].size = 112; /* 79; */
Leo Kim900bb4a2015-10-12 16:55:46 +09001543 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001544
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001545 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Leo Kim2fd3e442015-10-12 16:55:45 +09001546 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].size;
Glen Leef3052582015-09-10 12:03:04 +09001547 gu8FlushedJoinReq = kmalloc(gu32FlushedJoinReqSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001548 }
Leo Kim900bb4a2015-10-12 16:55:46 +09001549 if (strWIDList[u32WidsCount].val == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09001550 s32Error = -EFAULT;
1551 goto ERRORHANDLER;
1552 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001553
Leo Kim900bb4a2015-10-12 16:55:46 +09001554 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001555
1556
1557 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001558 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001559 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1560 }
1561 pu8CurrByte += MAX_SSID_LEN;
1562
1563 /* BSS type*/
1564 *(pu8CurrByte++) = INFRASTRUCTURE;
1565 /* Channel*/
1566 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1567 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1568 } else {
1569 PRINT_ER("Channel out of range\n");
1570 *(pu8CurrByte++) = 0xFF;
1571 }
1572 /* Cap Info*/
1573 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1574 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1575 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1576
1577 /* sa*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001578 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001579 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001580 pu8CurrByte += 6;
1581
1582 /* bssid*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001583 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001584 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001585 pu8CurrByte += 6;
1586
1587 /* Beacon Period*/
1588 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1589 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1590 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1591 /* DTIM Period*/
1592 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1593 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1594 /* Supported rates*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001595 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001596 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1597
1598 /* wmm cap*/
1599 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1600 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1601 /* uapsd cap*/
1602 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1603
1604 /* ht cap*/
1605 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1606 /* copy this information to the user request */
Tony Choa4ab1ad2015-10-12 16:56:05 +09001607 hif_drv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001608
1609 /* rsn found*/
1610 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1611 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1612 /* rsn group policy*/
1613 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1614 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1615 /* mode_802_11i*/
1616 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1617 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1618 /* rsn pcip policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001619 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001620 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1621
1622 /* rsn auth policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001623 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001624 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1625
1626 /* rsn auth policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001627 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001628 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1629
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001630 *(pu8CurrByte++) = REAL_JOIN_REQ;
1631
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001632 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1633 if (ptstrJoinBssParam->u8NoaEnbaled) {
1634 PRINT_D(HOSTINF_DBG, "NOA present\n");
1635
1636 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1637 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1638 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1639 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1640
1641 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1642
1643 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1644
1645 if (ptstrJoinBssParam->u8OppEnable)
1646 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1647
1648 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1649
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001650 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001651
1652 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1653
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001654 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001655
1656 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1657
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001658 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001659
1660 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1661
1662 } else
1663 PRINT_D(HOSTINF_DBG, "NOA not present\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001664
1665 /* keep the buffer at the start of the allocated pointer to use it with the free*/
Leo Kim900bb4a2015-10-12 16:55:46 +09001666 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001667 u32WidsCount++;
1668
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001669 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1670 * firmware at chip reset when processing the WIDs of the Connect Request.
1671 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1672 /* ////////////////////// */
1673 gu32WidConnRstHack = 0;
1674 /* ////////////////////// */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001675
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001676 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001677 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001678 gu8FlushedJoinReqDrvHandler = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001679 }
1680
1681 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1682
1683 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001684 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001685
Alexander Kuleshov310a28f2015-09-04 00:48:14 +06001686 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->pu8bssid);
1687 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001688 }
1689
Tony Cho03362282015-10-12 16:55:39 +09001690 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001691 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001692 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09001693 PRINT_ER("failed to send config packet\n");
1694 s32Error = -EFAULT;
1695 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001696 } else {
1697 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09001698 hif_drv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001699 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001700
Leo Kim24db7132015-09-16 18:36:01 +09001701ERRORHANDLER:
1702 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001703 tstrConnectInfo strConnectInfo;
1704
Tony Choa4ab1ad2015-10-12 16:56:05 +09001705 del_timer(&hif_drv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001706
1707 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1708
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001709 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001710
1711 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001712 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001713 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001714
1715 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1716 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001717 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001718 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001719 pstrHostIFconnectAttr->pu8IEs,
1720 pstrHostIFconnectAttr->IEsLen);
1721 }
1722
1723 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1724 &strConnectInfo,
1725 MAC_DISCONNECTED,
1726 NULL,
1727 pstrHostIFconnectAttr->pvUserArg);
1728 /*Change state to idle*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09001729 hif_drv->enuHostIFstate = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001730 /* Deallocation */
1731 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001732 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001733 strConnectInfo.pu8ReqIEs = NULL;
1734 }
1735
1736 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001737 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001738 }
1739 }
1740
1741 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
1742 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
1743 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001744 kfree(pstrHostIFconnectAttr->pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001745 pstrHostIFconnectAttr->pu8bssid = NULL;
1746 }
1747
1748 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
1749 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001750 kfree(pstrHostIFconnectAttr->pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001751 pstrHostIFconnectAttr->pu8ssid = NULL;
1752 }
1753
1754 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
1755 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001756 kfree(pstrHostIFconnectAttr->pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001757 pstrHostIFconnectAttr->pu8IEs = NULL;
1758 }
1759
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001760 if (pu8CurrByte != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001761 kfree(pu8CurrByte);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001762 return s32Error;
1763}
1764
1765/**
1766 * @brief Handle_FlushConnect
1767 * @details Sending config packet to firmware to flush an old connection
1768 * after switching FW from station one to hybrid one
1769 * @param[in] void * drvHandler
1770 * @return Error code.
1771 * @author Amr Abdel-Moghny
1772 * @date 19 DEC 2013
1773 * @version 8.0
1774 */
1775
Tony Choa4ab1ad2015-10-12 16:56:05 +09001776static s32 Handle_FlushConnect(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001777{
Leo Kime6e12662015-09-16 18:36:03 +09001778 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09001779 struct wid strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001780 u32 u32WidsCount = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001781 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001782
1783
1784 /* IEs to be inserted in Association Request */
Leo Kimdaaf16b2015-10-12 16:55:44 +09001785 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
Leo Kim416d8322015-10-12 16:55:43 +09001786 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kim900bb4a2015-10-12 16:55:46 +09001787 strWIDList[u32WidsCount].val = gu8FlushedInfoElemAsoc;
Leo Kim2fd3e442015-10-12 16:55:45 +09001788 strWIDList[u32WidsCount].size = gu32FlushedInfoElemAsocSize;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001789 u32WidsCount++;
1790
Leo Kimdaaf16b2015-10-12 16:55:44 +09001791 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001792 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001793 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim900bb4a2015-10-12 16:55:46 +09001794 strWIDList[u32WidsCount].val = (s8 *)(&(gu8Flushed11iMode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001795 u32WidsCount++;
1796
1797
1798
Leo Kimdaaf16b2015-10-12 16:55:44 +09001799 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001800 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001801 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim900bb4a2015-10-12 16:55:46 +09001802 strWIDList[u32WidsCount].val = (s8 *)(&gu8FlushedAuthType);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001803 u32WidsCount++;
1804
Leo Kimdaaf16b2015-10-12 16:55:44 +09001805 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
Leo Kim416d8322015-10-12 16:55:43 +09001806 strWIDList[u32WidsCount].type = WID_STR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001807 strWIDList[u32WidsCount].size = gu32FlushedJoinReqSize;
Leo Kim900bb4a2015-10-12 16:55:46 +09001808 strWIDList[u32WidsCount].val = (s8 *)gu8FlushedJoinReq;
1809 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001810
1811 pu8CurrByte += FLUSHED_BYTE_POS;
1812 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1813
1814 u32WidsCount++;
1815
Tony Cho03362282015-10-12 16:55:39 +09001816 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001817 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001818 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09001819 PRINT_ER("failed to send config packet\n");
1820 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001821 }
1822
1823 return s32Error;
1824}
1825
1826/**
1827 * @brief Handle_ConnectTimeout
1828 * @details Call connect notification callback function indicating connection failure
1829 * @param[in] NONE
1830 * @return Error code.
1831 * @author
1832 * @date
1833 * @version 1.0
1834 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09001835static s32 Handle_ConnectTimeout(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001836{
Leo Kime6e12662015-09-16 18:36:03 +09001837 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001838 tstrConnectInfo strConnectInfo;
Leo Kime9e0c262015-10-12 16:55:41 +09001839 struct wid strWID;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001840 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001841
Tony Choa4ab1ad2015-10-12 16:56:05 +09001842 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001843 PRINT_ER("Driver handler is NULL\n");
1844 return s32Error;
1845 }
1846
Tony Choa4ab1ad2015-10-12 16:56:05 +09001847 hif_drv->enuHostIFstate = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001848
Dean Lee72ed4dc2015-06-12 14:11:44 +09001849 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001850
1851
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001852 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001853
1854
1855 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
1856 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
1857 * WID_DISCONNECT} */
Tony Choa4ab1ad2015-10-12 16:56:05 +09001858 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1859 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001860 memcpy(strConnectInfo.au8bssid,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001861 hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001862 }
1863
Tony Choa4ab1ad2015-10-12 16:56:05 +09001864 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1865 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1866 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001867 memcpy(strConnectInfo.pu8ReqIEs,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001868 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1869 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001870 }
1871
Tony Choa4ab1ad2015-10-12 16:56:05 +09001872 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001873 &strConnectInfo,
1874 MAC_DISCONNECTED,
1875 NULL,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001876 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001877
1878 /* Deallocation of strConnectInfo.pu8ReqIEs */
1879 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001880 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001881 strConnectInfo.pu8ReqIEs = NULL;
1882 }
1883 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001884 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001885 }
1886
1887 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
1888 * WID_DISCONNECT} */
Leo Kimdaaf16b2015-10-12 16:55:44 +09001889 strWID.id = (u16)WID_DISCONNECT;
Leo Kim416d8322015-10-12 16:55:43 +09001890 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09001891 strWID.val = (s8 *)&u16DummyReasonCode;
Leo Kim2fd3e442015-10-12 16:55:45 +09001892 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001893
1894 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1895
Tony Cho03362282015-10-12 16:55:39 +09001896 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001897 get_id_from_handler(hif_drv));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001898 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001899 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001900
1901 /* Deallocation of the Saved Connect Request in the global Handle */
Tony Choa4ab1ad2015-10-12 16:56:05 +09001902 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1903 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1904 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1905 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1906 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001907
Shraddha Barke281dd5a2015-10-05 17:00:33 +05301908 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001909 /*Freeing flushed join request params on connect timeout*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09001910 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001911 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001912 gu8FlushedJoinReq = NULL;
1913 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09001914 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001915 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001916 gu8FlushedInfoElemAsoc = NULL;
1917 }
1918
1919 return s32Error;
1920}
1921
1922/**
1923 * @brief Handle_RcvdNtwrkInfo
1924 * @details Handling received network information
Tony Cho3bbd59f2015-09-21 12:16:38 +09001925 * @param[in] struct rcvd_net_info *pstrRcvdNetworkInfo
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001926 * @return Error code.
1927 * @author
1928 * @date
1929 * @version 1.0
1930 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09001931static s32 Handle_RcvdNtwrkInfo(struct host_if_drv *hif_drv,
Tony Cho3bbd59f2015-09-21 12:16:38 +09001932 struct rcvd_net_info *pstrRcvdNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001933{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001934 u32 i;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001935 bool bNewNtwrkFound;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001936
1937
1938
Leo Kime6e12662015-09-16 18:36:03 +09001939 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001940 tstrNetworkInfo *pstrNetworkInfo = NULL;
1941 void *pJoinParams = NULL;
1942
Dean Lee72ed4dc2015-06-12 14:11:44 +09001943 bNewNtwrkFound = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001944 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1945
1946 /*if there is a an ongoing scan request*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09001947 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001948 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
Chaehyun Lima1f7f642015-09-22 22:47:44 +09001949 parse_network_info(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001950 if ((pstrNetworkInfo == NULL)
Tony Choa4ab1ad2015-10-12 16:56:05 +09001951 || (hif_drv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
Leo Kim24db7132015-09-16 18:36:01 +09001952 PRINT_ER("driver is null\n");
1953 s32Error = -EINVAL;
1954 goto done;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001955 }
1956
1957 /* check whether this network is discovered before */
Tony Choa4ab1ad2015-10-12 16:56:05 +09001958 for (i = 0; i < hif_drv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001959
Tony Choa4ab1ad2015-10-12 16:56:05 +09001960 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001961 (pstrNetworkInfo->au8bssid != NULL)) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09001962 if (memcmp(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001963 pstrNetworkInfo->au8bssid, 6) == 0) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09001964 if (pstrNetworkInfo->s8rssi <= hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001965 /*we have already found this network with better rssi, so keep the old cached one and don't
1966 * send anything to the upper layer */
1967 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
1968 goto done;
1969 } else {
1970 /* here the same already found network is found again but with a better rssi, so just update
1971 * the rssi for this cached network and send this updated network to the upper layer but
1972 * don't add a new record for it */
Tony Choa4ab1ad2015-10-12 16:56:05 +09001973 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001974 bNewNtwrkFound = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001975 break;
1976 }
1977 }
1978 }
1979 }
1980
Dean Lee72ed4dc2015-06-12 14:11:44 +09001981 if (bNewNtwrkFound == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001982 /* here it is confirmed that it is a new discovered network,
1983 * so add its record then call the User CallBack function */
1984
1985 PRINT_D(HOSTINF_DBG, "New network found\n");
1986
Tony Choa4ab1ad2015-10-12 16:56:05 +09001987 if (hif_drv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
1988 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001989
Tony Choa4ab1ad2015-10-12 16:56:05 +09001990 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001991 && (pstrNetworkInfo->au8bssid != NULL)) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09001992 memcpy(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001993 pstrNetworkInfo->au8bssid, 6);
1994
Tony Choa4ab1ad2015-10-12 16:56:05 +09001995 hif_drv->strWILC_UsrScanReq.u32RcvdChCount++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001996
Dean Lee72ed4dc2015-06-12 14:11:44 +09001997 pstrNetworkInfo->bNewNetwork = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001998 /* add new BSS to JoinBssTable */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001999 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002000
Tony Choa4ab1ad2015-10-12 16:56:05 +09002001 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2002 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002003 pJoinParams);
2004
2005
2006 }
2007 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002008 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002009 }
2010 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002011 pstrNetworkInfo->bNewNetwork = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002012 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
Tony Choa4ab1ad2015-10-12 16:56:05 +09002013 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2014 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002015 }
2016 }
2017
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002018done:
2019 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2020 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002021 kfree(pstrRcvdNetworkInfo->pu8Buffer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002022 pstrRcvdNetworkInfo->pu8Buffer = NULL;
2023 }
2024
2025 /*free structure allocated*/
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002026 if (pstrNetworkInfo != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002027 DeallocateNetworkInfo(pstrNetworkInfo);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002028 pstrNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002029 }
2030
2031 return s32Error;
2032}
2033
2034/**
2035 * @brief Handle_RcvdGnrlAsyncInfo
2036 * @details Handling received asynchrous general network information
Tony Chof23a9ea2015-09-21 12:16:39 +09002037 * @param[in] struct rcvd_async_info *pstrRcvdGnrlAsyncInfo
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002038 * @return Error code.
2039 * @author
2040 * @date
2041 * @version 1.0
2042 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09002043static s32 Handle_RcvdGnrlAsyncInfo(struct host_if_drv *hif_drv,
Tony Chof23a9ea2015-09-21 12:16:39 +09002044 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002045{
2046 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2047 /* which carries only 1 WID which have WID ID = WID_STATUS */
Leo Kime6e12662015-09-16 18:36:03 +09002048 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002049 u8 u8MsgType = 0;
2050 u8 u8MsgID = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002051 u16 u16MsgLen = 0;
2052 u16 u16WidID = (u16)WID_NIL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002053 u8 u8WidLen = 0;
2054 u8 u8MacStatus;
2055 u8 u8MacStatusReasonCode;
2056 u8 u8MacStatusAdditionalInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002057 tstrConnectInfo strConnectInfo;
2058 tstrDisconnectNotifInfo strDisconnectNotifInfo;
Leo Kime6e12662015-09-16 18:36:03 +09002059 s32 s32Err = 0;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002060
Tony Choa4ab1ad2015-10-12 16:56:05 +09002061 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002062 PRINT_ER("Driver handler is NULL\n");
Leo Kim234837d2015-09-22 14:34:43 +09002063 return -ENODEV;
2064 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09002065 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", hif_drv->enuHostIFstate,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002066 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
2067
Tony Choa4ab1ad2015-10-12 16:56:05 +09002068 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
2069 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) ||
2070 hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002071 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
Tony Choa4ab1ad2015-10-12 16:56:05 +09002072 (hif_drv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
Leo Kim24db7132015-09-16 18:36:01 +09002073 PRINT_ER("driver is null\n");
2074 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002075 }
2076
2077 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
2078
2079 /* Check whether the received message type is 'I' */
2080 if ('I' != u8MsgType) {
2081 PRINT_ER("Received Message format incorrect.\n");
Leo Kim24db7132015-09-16 18:36:01 +09002082 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002083 }
2084
2085 /* Extract message ID */
2086 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
2087
2088 /* Extract message Length */
2089 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
2090
2091 /* Extract WID ID [expected to be = WID_STATUS] */
2092 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
2093
2094 /* Extract WID Length [expected to be = 1] */
2095 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
2096
2097 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2098 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
2099 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
2100 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
2101 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
Tony Choa4ab1ad2015-10-12 16:56:05 +09002102 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002103 /* 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 +09002104 u32 u32RcvdAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002105 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
2106
2107 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2108
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002109 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002110
2111 if (u8MacStatus == MAC_CONNECTED) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002112 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002113
Tony Choa4ab1ad2015-10-12 16:56:05 +09002114 host_int_get_assoc_res_info(hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002115 gapu8RcvdAssocResp,
2116 MAX_ASSOC_RESP_FRAME_SIZE,
2117 &u32RcvdAssocRespInfoLen);
2118
2119 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
2120
2121 if (u32RcvdAssocRespInfoLen != 0) {
2122
2123 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
2124 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
2125 &pstrConnectRespInfo);
2126 if (s32Err) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002127 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002128 } else {
2129 /* use the necessary parsed Info from the Received Association Response */
2130 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
2131
2132 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
2133 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
2134 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
2135 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
2136
2137
Glen Leef3052582015-09-10 12:03:04 +09002138 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002139 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002140 pstrConnectRespInfo->u16RespIEsLen);
2141 }
2142 }
2143
2144 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2145 if (pstrConnectRespInfo != NULL) {
2146 DeallocateAssocRespInfo(pstrConnectRespInfo);
2147 pstrConnectRespInfo = NULL;
2148 }
2149 }
2150 }
2151 }
2152
2153 /* The station has just received mac status and it also received assoc. response which
2154 * it was waiting for.
2155 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2156 if ((u8MacStatus == MAC_CONNECTED) &&
2157 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002158 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
Shraddha Barke281dd5a2015-10-05 17:00:33 +05302159 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002160
2161 } else if (u8MacStatus == MAC_DISCONNECTED) {
2162 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
Shraddha Barke281dd5a2015-10-05 17:00:33 +05302163 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002164 }
2165
2166 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2167 /* through a structure of type tstrConnectRespInfo */
Tony Choa4ab1ad2015-10-12 16:56:05 +09002168 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002169 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09002170 memcpy(strConnectInfo.au8bssid, hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002171
2172 if ((u8MacStatus == MAC_CONNECTED) &&
2173 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09002174 memcpy(hif_drv->au8AssociatedBSSID,
2175 hif_drv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002176 }
2177 }
2178
2179
Tony Choa4ab1ad2015-10-12 16:56:05 +09002180 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2181 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
2182 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002183 memcpy(strConnectInfo.pu8ReqIEs,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002184 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
2185 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002186 }
2187
2188
Tony Choa4ab1ad2015-10-12 16:56:05 +09002189 del_timer(&hif_drv->hConnectTimer);
2190 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002191 &strConnectInfo,
2192 u8MacStatus,
2193 NULL,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002194 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002195
2196
2197 /* if received mac status is MAC_CONNECTED and
2198 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2199 * else change state to IDLE */
2200 if ((u8MacStatus == MAC_CONNECTED) &&
2201 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09002202 host_int_set_power_mgmt(hif_drv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002203
2204 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09002205 hif_drv->enuHostIFstate = HOST_IF_CONNECTED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002206
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002207 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +09002208 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002209 mod_timer(&hDuringIpTimer,
2210 jiffies + msecs_to_jiffies(10000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002211
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002212 /* open a BA session if possible */
2213 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002214 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2215 } else {
2216 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
Tony Choa4ab1ad2015-10-12 16:56:05 +09002217 hif_drv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002218 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002219 }
2220
2221 /* Deallocation */
2222 if (strConnectInfo.pu8RespIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002223 kfree(strConnectInfo.pu8RespIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002224 strConnectInfo.pu8RespIEs = NULL;
2225 }
2226
2227 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002228 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002229 strConnectInfo.pu8ReqIEs = NULL;
2230 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09002231 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
2232 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
2233 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
2234 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2235 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002236 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
Tony Choa4ab1ad2015-10-12 16:56:05 +09002237 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002238 /* Disassociation or Deauthentication frame has been received */
2239 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
2240
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002241 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002242
Tony Choa4ab1ad2015-10-12 16:56:05 +09002243 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002244 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09002245 del_timer(&hif_drv->hScanTimer);
2246 Handle_ScanDone((void *)hif_drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002247 }
2248
2249 strDisconnectNotifInfo.u16reason = 0;
2250 strDisconnectNotifInfo.ie = NULL;
2251 strDisconnectNotifInfo.ie_len = 0;
2252
Tony Choa4ab1ad2015-10-12 16:56:05 +09002253 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002254 g_obtainingIP = false;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002255 host_int_set_power_mgmt(hif_drv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002256
Tony Choa4ab1ad2015-10-12 16:56:05 +09002257 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002258 NULL,
2259 0,
2260 &strDisconnectNotifInfo,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002261 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002262
2263 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002264 PRINT_ER("Connect result callback function is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002265 }
2266
Tony Choa4ab1ad2015-10-12 16:56:05 +09002267 eth_zero_addr(hif_drv->au8AssociatedBSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002268
2269
2270 /* Deallocation */
2271
2272 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2273 * should be deallocated here */
2274 /*
2275 * if(strDisconnectNotifInfo.ie != NULL)
2276 * {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002277 * kfree(strDisconnectNotifInfo.ie);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002278 * strDisconnectNotifInfo.ie = NULL;
2279 * }
2280 */
2281
Tony Choa4ab1ad2015-10-12 16:56:05 +09002282 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
2283 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
2284 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
2285 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2286 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002287
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002288 /*Freeing flushed join request params on receiving*/
2289 /*MAC_DISCONNECTED while connected*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09002290 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002291 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002292 gu8FlushedJoinReq = NULL;
2293 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09002294 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002295 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002296 gu8FlushedInfoElemAsoc = NULL;
2297 }
2298
Tony Choa4ab1ad2015-10-12 16:56:05 +09002299 hif_drv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002300 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002301
2302 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
Tony Choa4ab1ad2015-10-12 16:56:05 +09002303 (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002304 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002305 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002306 /*Abort the running scan*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09002307 del_timer(&hif_drv->hScanTimer);
2308 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult)
2309 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002310
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002311 }
2312
2313 }
2314
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002315 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2316 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002317 kfree(pstrRcvdGnrlAsyncInfo->pu8Buffer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002318 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
2319 }
2320
2321 return s32Error;
2322}
2323
2324/**
2325 * @brief Handle_Key
2326 * @details Sending config packet to firmware to set key
Tony Choc98387a2015-09-21 12:16:40 +09002327 * @param[in] struct key_attr *pstrHostIFkeyAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002328 * @return Error code.
2329 * @author
2330 * @date
2331 * @version 1.0
2332 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09002333static int Handle_Key(struct host_if_drv *hif_drv,
Tony Choc98387a2015-09-21 12:16:40 +09002334 struct key_attr *pstrHostIFkeyAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002335{
Leo Kime6e12662015-09-16 18:36:03 +09002336 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09002337 struct wid strWID;
2338 struct wid strWIDList[5];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002339 u8 i;
2340 u8 *pu8keybuf;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002341 s8 s8idxarray[1];
2342 s8 ret = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002343
2344 switch (pstrHostIFkeyAttr->enuKeyType) {
2345
2346
2347 case WEP:
2348
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002349 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2350
2351 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Tony Cho2ed7a2f2015-10-12 16:56:08 +09002352 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.u8Wepidx));
Leo Kimdaaf16b2015-10-12 16:55:44 +09002353 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09002354 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002355 strWIDList[0].size = sizeof(char);
Tony Cho2ed7a2f2015-10-12 16:56:08 +09002356 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.u8mode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002357
Leo Kimdaaf16b2015-10-12 16:55:44 +09002358 strWIDList[1].id = WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09002359 strWIDList[1].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002360 strWIDList[1].size = sizeof(char);
Tony Cho2ed7a2f2015-10-12 16:56:08 +09002361 strWIDList[1].val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.tenuAuth_type));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002362
Leo Kimdaaf16b2015-10-12 16:55:44 +09002363 strWIDList[2].id = (u16)WID_KEY_ID;
Leo Kim416d8322015-10-12 16:55:43 +09002364 strWIDList[2].type = WID_CHAR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002365
Tony Cho2ed7a2f2015-10-12 16:56:08 +09002366 strWIDList[2].val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.u8Wepidx));
Leo Kim2fd3e442015-10-12 16:55:45 +09002367 strWIDList[2].size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002368
2369
Tony Chod520e352015-10-12 16:56:12 +09002370 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002371
2372
2373 if (pu8keybuf == NULL) {
2374 PRINT_ER("No buffer to send Key\n");
2375 return -1;
2376 }
2377
Tony Choe5538d32015-10-12 16:56:11 +09002378 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.key,
Tony Chod520e352015-10-12 16:56:12 +09002379 pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002380
2381
Tony Choe5538d32015-10-12 16:56:11 +09002382 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002383
Leo Kimdaaf16b2015-10-12 16:55:44 +09002384 strWIDList[3].id = (u16)WID_WEP_KEY_VALUE;
Leo Kim416d8322015-10-12 16:55:43 +09002385 strWIDList[3].type = WID_STR;
Tony Chod520e352015-10-12 16:56:12 +09002386 strWIDList[3].size = pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.key_len;
Leo Kim900bb4a2015-10-12 16:55:46 +09002387 strWIDList[3].val = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002388
2389
Tony Cho03362282015-10-12 16:55:39 +09002390 s32Error = send_config_pkt(SET_CFG, strWIDList, 4,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002391 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002392 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002393
2394
2395 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002396
2397 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2398 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Tony Chod520e352015-10-12 16:56:12 +09002399 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.key_len + 2, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002400 if (pu8keybuf == NULL) {
2401 PRINT_ER("No buffer to send Key\n");
2402 return -1;
2403 }
Tony Cho2ed7a2f2015-10-12 16:56:08 +09002404 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.u8Wepidx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002405
Tony Chod520e352015-10-12 16:56:12 +09002406 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.key_len, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002407
Tony Choe5538d32015-10-12 16:56:11 +09002408 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.key,
Tony Chod520e352015-10-12 16:56:12 +09002409 pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002410
Tony Choe5538d32015-10-12 16:56:11 +09002411 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002412
Leo Kimdaaf16b2015-10-12 16:55:44 +09002413 strWID.id = (u16)WID_ADD_WEP_KEY;
Leo Kim416d8322015-10-12 16:55:43 +09002414 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002415 strWID.val = (s8 *)pu8keybuf;
Tony Chod520e352015-10-12 16:56:12 +09002416 strWID.size = pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.key_len + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002417
Tony Cho03362282015-10-12 16:55:39 +09002418 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002419 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002420 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002421 } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) {
2422
2423 PRINT_D(HOSTINF_DBG, "Removing key\n");
Leo Kimdaaf16b2015-10-12 16:55:44 +09002424 strWID.id = (u16)WID_REMOVE_WEP_KEY;
Leo Kim416d8322015-10-12 16:55:43 +09002425 strWID.type = WID_STR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002426
Tony Cho2ed7a2f2015-10-12 16:56:08 +09002427 s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.u8Wepidx;
Leo Kim900bb4a2015-10-12 16:55:46 +09002428 strWID.val = s8idxarray;
Leo Kim2fd3e442015-10-12 16:55:45 +09002429 strWID.size = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002430
Tony Cho03362282015-10-12 16:55:39 +09002431 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002432 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002433 } else {
Leo Kimdaaf16b2015-10-12 16:55:44 +09002434 strWID.id = (u16)WID_KEY_ID;
Leo Kim416d8322015-10-12 16:55:43 +09002435 strWID.type = WID_CHAR;
Tony Cho2ed7a2f2015-10-12 16:56:08 +09002436 strWID.val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.u8Wepidx));
Leo Kim2fd3e442015-10-12 16:55:45 +09002437 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002438
2439 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
2440
Tony Cho03362282015-10-12 16:55:39 +09002441 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002442 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002443 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09002444 up(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002445 break;
2446
2447 case WPARxGtk:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002448 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
Glen Leef3052582015-09-10 12:03:04 +09002449 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002450 if (pu8keybuf == NULL) {
2451 PRINT_ER("No buffer to send RxGTK Key\n");
2452 ret = -1;
2453 goto _WPARxGtk_end_case_;
2454 }
2455
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002456 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002457
2458
2459 /*|----------------------------------------------------------------------------|
2460 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2461 * |------------|---------|-------|------------|---------------|----------------|
2462 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2463
2464
2465
Tony Choe3501a42015-10-12 16:56:09 +09002466 if (pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.pu8seq != NULL)
2467 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002468
2469
Tony Choe3501a42015-10-12 16:56:09 +09002470 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002471
Tony Choe3501a42015-10-12 16:56:09 +09002472 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002473
Tony Choe3501a42015-10-12 16:56:09 +09002474 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.pu8key,
2475 pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.u8Keylen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002476 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
Leo Kimdaaf16b2015-10-12 16:55:44 +09002477 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09002478 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002479 strWIDList[0].size = sizeof(char);
Tony Choe3501a42015-10-12 16:56:09 +09002480 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.u8Ciphermode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002481
Leo Kimdaaf16b2015-10-12 16:55:44 +09002482 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
Leo Kim416d8322015-10-12 16:55:43 +09002483 strWIDList[1].type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002484 strWIDList[1].val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09002485 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002486
Tony Cho03362282015-10-12 16:55:39 +09002487 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002488 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002489
Chaehyun Lim49188af2015-08-11 10:32:41 +09002490 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002491
2492 /* ////////////////////////// */
Tony Choa4ab1ad2015-10-12 16:56:05 +09002493 up(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002494 /* ///////////////////////// */
2495 }
2496
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002497 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2498 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
2499
Glen Leef3052582015-09-10 12:03:04 +09002500 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002501 if (pu8keybuf == NULL) {
2502 PRINT_ER("No buffer to send RxGTK Key\n");
2503 ret = -1;
2504 goto _WPARxGtk_end_case_;
2505 }
2506
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002507 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002508
2509
2510 /*|----------------------------------------------------------------------------|
2511 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2512 * |------------|---------|-------|------------|---------------|----------------|
2513 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2514
Tony Choa4ab1ad2015-10-12 16:56:05 +09002515 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
2516 memcpy(pu8keybuf, hif_drv->au8AssociatedBSSID, ETH_ALEN);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302517 else
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002518 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002519
Tony Choe3501a42015-10-12 16:56:09 +09002520 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002521
Tony Choe3501a42015-10-12 16:56:09 +09002522 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002523
Tony Choe3501a42015-10-12 16:56:09 +09002524 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.u8Keylen, 1);
2525 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.pu8key,
2526 pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.u8Keylen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002527
Leo Kimdaaf16b2015-10-12 16:55:44 +09002528 strWID.id = (u16)WID_ADD_RX_GTK;
Leo Kim416d8322015-10-12 16:55:43 +09002529 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002530 strWID.val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09002531 strWID.size = RX_MIC_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002532
Tony Cho03362282015-10-12 16:55:39 +09002533 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002534 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002535
Chaehyun Lim49188af2015-08-11 10:32:41 +09002536 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002537
2538 /* ////////////////////////// */
Tony Choa4ab1ad2015-10-12 16:56:05 +09002539 up(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002540 /* ///////////////////////// */
2541 }
2542_WPARxGtk_end_case_:
Tony Choe3501a42015-10-12 16:56:09 +09002543 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.pu8key);
2544 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.pu8seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002545 if (ret == -1)
2546 return ret;
2547
2548 break;
2549
2550 case WPAPtk:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002551 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2552
2553
Glen Leef3052582015-09-10 12:03:04 +09002554 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002555
2556
2557
2558 if (pu8keybuf == NULL) {
2559 PRINT_ER("No buffer to send PTK Key\n");
2560 ret = -1;
2561 goto _WPAPtk_end_case_;
2562
2563 }
2564
2565 /*|-----------------------------------------------------------------------------|
2566 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2567 * |----------------|------------ |--------------|----------------|---------------|
2568 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2569 |-----------------------------------------------------------------------------|*/
2570
Tony Choe3501a42015-10-12 16:56:09 +09002571 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002572
Tony Choe3501a42015-10-12 16:56:09 +09002573 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.u8keyidx, 1);
2574 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002575 /*16 byte TK*/
Tony Choe3501a42015-10-12 16:56:09 +09002576 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.pu8key,
2577 pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.u8Keylen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002578
2579
Leo Kimdaaf16b2015-10-12 16:55:44 +09002580 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09002581 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002582 strWIDList[0].size = sizeof(char);
Tony Choe3501a42015-10-12 16:56:09 +09002583 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.u8Ciphermode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002584
Leo Kimdaaf16b2015-10-12 16:55:44 +09002585 strWIDList[1].id = (u16)WID_ADD_PTK;
Leo Kim416d8322015-10-12 16:55:43 +09002586 strWIDList[1].type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002587 strWIDList[1].val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09002588 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002589
Tony Cho03362282015-10-12 16:55:39 +09002590 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002591 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002592 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002593
2594 /* ////////////////////////// */
Tony Choa4ab1ad2015-10-12 16:56:05 +09002595 up(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002596 /* ///////////////////////// */
2597 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002598 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2599
2600
Glen Leef3052582015-09-10 12:03:04 +09002601 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002602
2603
2604
2605 if (pu8keybuf == NULL) {
2606 PRINT_ER("No buffer to send PTK Key\n");
2607 ret = -1;
2608 goto _WPAPtk_end_case_;
2609
2610 }
2611
2612 /*|-----------------------------------------------------------------------------|
2613 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
2614 * |----------------|------------|--------------|----------------|---------------|
2615 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
2616 |-----------------------------------------------------------------------------|*/
2617
Tony Choe3501a42015-10-12 16:56:09 +09002618 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002619
Tony Choe3501a42015-10-12 16:56:09 +09002620 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002621 /*16 byte TK*/
Tony Choe3501a42015-10-12 16:56:09 +09002622 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.pu8key,
2623 pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.u8Keylen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002624
2625
Leo Kimdaaf16b2015-10-12 16:55:44 +09002626 strWID.id = (u16)WID_ADD_PTK;
Leo Kim416d8322015-10-12 16:55:43 +09002627 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002628 strWID.val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09002629 strWID.size = PTK_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002630
Tony Cho03362282015-10-12 16:55:39 +09002631 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002632 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002633 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002634
2635 /* ////////////////////////// */
Tony Choa4ab1ad2015-10-12 16:56:05 +09002636 up(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002637 /* ///////////////////////// */
2638 }
2639
2640_WPAPtk_end_case_:
Tony Choe3501a42015-10-12 16:56:09 +09002641 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.wpa.pu8key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002642 if (ret == -1)
2643 return ret;
2644
2645 break;
2646
2647
2648 case PMKSA:
2649
2650 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
2651
Tony Cho610e3862015-10-12 16:56:10 +09002652 pu8keybuf = kmalloc((pstrHostIFkeyAttr->uniHostIFkeyAttr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002653 if (pu8keybuf == NULL) {
2654 PRINT_ER("No buffer to send PMKSA Key\n");
2655 return -1;
2656 }
2657
Tony Cho610e3862015-10-12 16:56:10 +09002658 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.pmkid.numpmkid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002659
Tony Cho610e3862015-10-12 16:56:10 +09002660 for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.pmkid.numpmkid; i++) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002661
Tony Cho610e3862015-10-12 16:56:10 +09002662 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
2663 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002664 }
2665
Leo Kimdaaf16b2015-10-12 16:55:44 +09002666 strWID.id = (u16)WID_PMKID_INFO;
Leo Kim416d8322015-10-12 16:55:43 +09002667 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002668 strWID.val = (s8 *)pu8keybuf;
Tony Cho610e3862015-10-12 16:56:10 +09002669 strWID.size = (pstrHostIFkeyAttr->uniHostIFkeyAttr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002670
Tony Cho03362282015-10-12 16:55:39 +09002671 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002672 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002673
Chaehyun Lim49188af2015-08-11 10:32:41 +09002674 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002675 break;
2676 }
2677
2678 if (s32Error)
2679 PRINT_ER("Failed to send key config packet\n");
2680
2681
2682 return s32Error;
2683}
2684
2685
2686/**
2687 * @brief Handle_Disconnect
2688 * @details Sending config packet to firmware to disconnect
2689 * @param[in] NONE
2690 * @return NONE
2691 * @author
2692 * @date
2693 * @version 1.0
2694 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09002695static void Handle_Disconnect(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002696{
Leo Kime9e0c262015-10-12 16:55:41 +09002697 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002698
Leo Kime6e12662015-09-16 18:36:03 +09002699 s32 s32Error = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002700 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002701
Leo Kimdaaf16b2015-10-12 16:55:44 +09002702 strWID.id = (u16)WID_DISCONNECT;
Leo Kim416d8322015-10-12 16:55:43 +09002703 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002704 strWID.val = (s8 *)&u16DummyReasonCode;
Leo Kim2fd3e442015-10-12 16:55:45 +09002705 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002706
2707
2708
2709 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2710
Dean Lee72ed4dc2015-06-12 14:11:44 +09002711 g_obtainingIP = false;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002712 host_int_set_power_mgmt(hif_drv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002713
Shraddha Barke281dd5a2015-10-05 17:00:33 +05302714 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002715
Tony Cho03362282015-10-12 16:55:39 +09002716 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002717 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002718
2719 if (s32Error) {
2720 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002721 } else {
2722 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2723
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002724 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002725
2726 strDisconnectNotifInfo.u16reason = 0;
2727 strDisconnectNotifInfo.ie = NULL;
2728 strDisconnectNotifInfo.ie_len = 0;
2729
Tony Choa4ab1ad2015-10-12 16:56:05 +09002730 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
2731 del_timer(&hif_drv->hScanTimer);
2732 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
2733 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002734
Tony Choa4ab1ad2015-10-12 16:56:05 +09002735 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002736 }
2737
Tony Choa4ab1ad2015-10-12 16:56:05 +09002738 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002739
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002740 /*Stop connect timer, if connection in progress*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09002741 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002742 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09002743 del_timer(&hif_drv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002744 }
2745
Tony Choa4ab1ad2015-10-12 16:56:05 +09002746 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
2747 0, &strDisconnectNotifInfo, hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002748 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002749 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002750 }
2751
Dean Lee72ed4dc2015-06-12 14:11:44 +09002752 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002753
Tony Choa4ab1ad2015-10-12 16:56:05 +09002754 hif_drv->enuHostIFstate = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002755
Tony Choa4ab1ad2015-10-12 16:56:05 +09002756 eth_zero_addr(hif_drv->au8AssociatedBSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002757
2758
2759 /* Deallocation */
Tony Choa4ab1ad2015-10-12 16:56:05 +09002760 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
2761 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
2762 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
2763 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2764 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002765
Tony Choa4ab1ad2015-10-12 16:56:05 +09002766 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002767 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002768 gu8FlushedJoinReq = NULL;
2769 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09002770 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002771 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002772 gu8FlushedInfoElemAsoc = NULL;
2773 }
2774
2775 }
2776
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002777 /* ////////////////////////// */
Tony Choa4ab1ad2015-10-12 16:56:05 +09002778 up(&hif_drv->hSemTestDisconnectBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002779 /* ///////////////////////// */
2780
2781}
2782
2783
Tony Choa4ab1ad2015-10-12 16:56:05 +09002784void resolve_disconnect_aberration(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002785{
Tony Choa4ab1ad2015-10-12 16:56:05 +09002786 if (!hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002787 return;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002788 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (hif_drv->enuHostIFstate == HOST_IF_CONNECTING)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002789 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09002790 host_int_disconnect(hif_drv, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002791 }
2792}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002793
2794/**
2795 * @brief Handle_GetChnl
2796 * @details Sending config packet to get channel
2797 * @param[in] NONE
2798 * @return NONE
2799 *
2800 * @author
2801 * @date
2802 * @version 1.0
2803 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09002804static s32 Handle_GetChnl(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002805{
2806
Leo Kime6e12662015-09-16 18:36:03 +09002807 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09002808 struct wid strWID;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002809
Leo Kimdaaf16b2015-10-12 16:55:44 +09002810 strWID.id = (u16)WID_CURRENT_CHANNEL;
Leo Kim416d8322015-10-12 16:55:43 +09002811 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002812 strWID.val = (s8 *)&gu8Chnl;
Leo Kim2fd3e442015-10-12 16:55:45 +09002813 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002814
2815 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2816
Tony Cho03362282015-10-12 16:55:39 +09002817 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002818 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002819 /*get the value by searching the local copy*/
2820 if (s32Error) {
2821 PRINT_ER("Failed to get channel number\n");
Leo Kim24db7132015-09-16 18:36:01 +09002822 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002823 }
2824
Tony Choa4ab1ad2015-10-12 16:56:05 +09002825 up(&hif_drv->hSemGetCHNL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002826
2827 return s32Error;
2828
2829
2830
2831}
2832
2833
2834/**
2835 * @brief Handle_GetRssi
2836 * @details Sending config packet to get RSSI
2837 * @param[in] NONE
2838 * @return NONE
2839 * @author
2840 * @date
2841 * @version 1.0
2842 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09002843static void Handle_GetRssi(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002844{
Leo Kime6e12662015-09-16 18:36:03 +09002845 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09002846 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002847
Leo Kimdaaf16b2015-10-12 16:55:44 +09002848 strWID.id = (u16)WID_RSSI;
Leo Kim416d8322015-10-12 16:55:43 +09002849 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002850 strWID.val = &gs8Rssi;
Leo Kim2fd3e442015-10-12 16:55:45 +09002851 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002852
2853 /*Sending Cfg*/
2854 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2855
Tony Cho03362282015-10-12 16:55:39 +09002856 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002857 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002858 if (s32Error) {
2859 PRINT_ER("Failed to get RSSI value\n");
Leo Kim24db7132015-09-16 18:36:01 +09002860 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002861 }
2862
Tony Choa4ab1ad2015-10-12 16:56:05 +09002863 up(&hif_drv->hSemGetRSSI);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002864
2865
2866}
2867
2868
Tony Choa4ab1ad2015-10-12 16:56:05 +09002869static void Handle_GetLinkspeed(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002870{
Leo Kime6e12662015-09-16 18:36:03 +09002871 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09002872 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002873
2874 gs8lnkspd = 0;
2875
Leo Kimdaaf16b2015-10-12 16:55:44 +09002876 strWID.id = (u16)WID_LINKSPEED;
Leo Kim416d8322015-10-12 16:55:43 +09002877 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002878 strWID.val = &gs8lnkspd;
Leo Kim2fd3e442015-10-12 16:55:45 +09002879 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002880 /*Sending Cfg*/
2881 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2882
Tony Cho03362282015-10-12 16:55:39 +09002883 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002884 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002885 if (s32Error) {
2886 PRINT_ER("Failed to get LINKSPEED value\n");
Leo Kim24db7132015-09-16 18:36:01 +09002887 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002888 }
2889
Tony Choa4ab1ad2015-10-12 16:56:05 +09002890 up(&(hif_drv->hSemGetLINKSPEED));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002891
2892
2893}
2894
Tony Choa4ab1ad2015-10-12 16:56:05 +09002895s32 Handle_GetStatistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002896{
Leo Kime9e0c262015-10-12 16:55:41 +09002897 struct wid strWIDList[5];
Chaehyun Limfbc2fe12015-09-15 14:06:16 +09002898 u32 u32WidsCount = 0, s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002899
Leo Kimdaaf16b2015-10-12 16:55:44 +09002900 strWIDList[u32WidsCount].id = WID_LINKSPEED;
Leo Kim416d8322015-10-12 16:55:43 +09002901 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002902 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim900bb4a2015-10-12 16:55:46 +09002903 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u8LinkSpeed));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002904 u32WidsCount++;
2905
Leo Kimdaaf16b2015-10-12 16:55:44 +09002906 strWIDList[u32WidsCount].id = WID_RSSI;
Leo Kim416d8322015-10-12 16:55:43 +09002907 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002908 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim900bb4a2015-10-12 16:55:46 +09002909 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->s8RSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002910 u32WidsCount++;
2911
Leo Kimdaaf16b2015-10-12 16:55:44 +09002912 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002913 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002914 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09002915 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002916 u32WidsCount++;
2917
Leo Kimdaaf16b2015-10-12 16:55:44 +09002918 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002919 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002920 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09002921 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32RxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002922 u32WidsCount++;
2923
Leo Kimdaaf16b2015-10-12 16:55:44 +09002924 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002925 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002926 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09002927 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxFailureCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002928 u32WidsCount++;
2929
Tony Cho03362282015-10-12 16:55:39 +09002930 s32Error = send_config_pkt(GET_CFG, strWIDList, u32WidsCount,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002931 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002932
Leo Kim24db7132015-09-16 18:36:01 +09002933 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002934 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09002935
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002936 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002937 return 0;
2938
2939}
2940
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002941/**
2942 * @brief Handle_Get_InActiveTime
2943 * @details Sending config packet to set mac adddress for station and
2944 * get inactive time
2945 * @param[in] NONE
2946 * @return NONE
2947 *
2948 * @author
2949 * @date
2950 * @version 1.0
2951 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09002952static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,
Tony Cho3d1eac02015-09-21 12:16:49 +09002953 struct sta_inactive_t *strHostIfStaInactiveT)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002954{
2955
Leo Kime6e12662015-09-16 18:36:03 +09002956 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002957 u8 *stamac;
Leo Kime9e0c262015-10-12 16:55:41 +09002958 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002959
Leo Kimdaaf16b2015-10-12 16:55:44 +09002960 strWID.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
Leo Kim416d8322015-10-12 16:55:43 +09002961 strWID.type = WID_STR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002962 strWID.size = ETH_ALEN;
Leo Kim900bb4a2015-10-12 16:55:46 +09002963 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002964
2965
Leo Kim900bb4a2015-10-12 16:55:46 +09002966 stamac = strWID.val;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002967 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002968
2969
2970 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2971
2972
Tony Cho03362282015-10-12 16:55:39 +09002973 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002974 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002975 /*get the value by searching the local copy*/
2976 if (s32Error) {
2977 PRINT_ER("Failed to SET incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09002978 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002979 }
2980
2981
Leo Kimdaaf16b2015-10-12 16:55:44 +09002982 strWID.id = (u16)WID_GET_INACTIVE_TIME;
Leo Kim416d8322015-10-12 16:55:43 +09002983 strWID.type = WID_INT;
Leo Kim900bb4a2015-10-12 16:55:46 +09002984 strWID.val = (s8 *)&gu32InactiveTime;
Leo Kim2fd3e442015-10-12 16:55:45 +09002985 strWID.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002986
2987
Tony Cho03362282015-10-12 16:55:39 +09002988 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002989 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002990 /*get the value by searching the local copy*/
2991 if (s32Error) {
2992 PRINT_ER("Failed to get incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09002993 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002994 }
2995
2996
2997 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
2998
Tony Choa4ab1ad2015-10-12 16:56:05 +09002999 up(&hif_drv->hSemInactiveTime);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003000
3001 return s32Error;
3002
3003
3004
3005}
3006
3007
3008/**
3009 * @brief Handle_AddBeacon
3010 * @details Sending config packet to add beacon
Tony Cho7f33fec2015-09-30 18:44:30 +09003011 * @param[in] struct beacon_attr *pstrSetBeaconParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003012 * @return NONE
3013 * @author
3014 * @date
3015 * @version 1.0
3016 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09003017static void Handle_AddBeacon(struct host_if_drv *hif_drv,
Tony Cho7f33fec2015-09-30 18:44:30 +09003018 struct beacon_attr *pstrSetBeaconParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003019{
Leo Kime6e12662015-09-16 18:36:03 +09003020 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09003021 struct wid strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003022 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003023
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003024 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
3025
Leo Kimdaaf16b2015-10-12 16:55:44 +09003026 strWID.id = (u16)WID_ADD_BEACON;
Leo Kim416d8322015-10-12 16:55:43 +09003027 strWID.type = WID_BIN;
Leo Kim2fd3e442015-10-12 16:55:45 +09003028 strWID.size = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
Leo Kim900bb4a2015-10-12 16:55:46 +09003029 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
3030 if (strWID.val == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003031 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003032
Leo Kim900bb4a2015-10-12 16:55:46 +09003033 pu8CurrByte = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003034 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
3035 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
3036 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
3037 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
3038
3039 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
3040 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
3041 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
3042 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
3043
3044 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
3045 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
3046 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
3047 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
3048
3049 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
3050 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
3051
3052 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
3053 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
3054 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
3055 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
3056
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003057 if (pstrSetBeaconParam->pu8Tail > 0)
3058 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
3059 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
3060
3061
3062
3063 /*Sending Cfg*/
Tony Cho03362282015-10-12 16:55:39 +09003064 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09003065 get_id_from_handler(hif_drv));
Leo Kim24db7132015-09-16 18:36:01 +09003066 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003067 PRINT_ER("Failed to send add beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003068
Leo Kim24db7132015-09-16 18:36:01 +09003069ERRORHANDLER:
Leo Kim900bb4a2015-10-12 16:55:46 +09003070 kfree(strWID.val);
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003071 kfree(pstrSetBeaconParam->pu8Head);
3072 kfree(pstrSetBeaconParam->pu8Tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003073}
3074
3075
3076/**
3077 * @brief Handle_AddBeacon
3078 * @details Sending config packet to delete beacon
Leo Kim441dc602015-10-12 16:55:35 +09003079 * @param[in] struct host_if_drv *drvHandler
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003080 * @return NONE
3081 * @author
3082 * @date
3083 * @version 1.0
3084 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09003085static void Handle_DelBeacon(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003086{
Leo Kime6e12662015-09-16 18:36:03 +09003087 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09003088 struct wid strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003089 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003090
Leo Kimdaaf16b2015-10-12 16:55:44 +09003091 strWID.id = (u16)WID_DEL_BEACON;
Leo Kim416d8322015-10-12 16:55:43 +09003092 strWID.type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09003093 strWID.size = sizeof(char);
Leo Kim900bb4a2015-10-12 16:55:46 +09003094 strWID.val = &gu8DelBcn;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003095
Leo Kim900bb4a2015-10-12 16:55:46 +09003096 if (strWID.val == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003097 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003098
Leo Kim900bb4a2015-10-12 16:55:46 +09003099 pu8CurrByte = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003100
3101 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
3102 /* TODO: build del beacon message*/
3103
3104 /*Sending Cfg*/
Tony Cho03362282015-10-12 16:55:39 +09003105 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09003106 get_id_from_handler(hif_drv));
Leo Kim24db7132015-09-16 18:36:01 +09003107 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003108 PRINT_ER("Failed to send delete beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003109}
3110
3111
3112/**
3113 * @brief WILC_HostIf_PackStaParam
3114 * @details Handling packing of the station params in a buffer
Tony Cho6a89ba92015-09-21 12:16:46 +09003115 * @param[in] u8* pu8Buffer, struct add_sta_param *pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003116 * @return NONE
3117 * @author
3118 * @date
3119 * @version 1.0
3120 */
Tony Cho6a89ba92015-09-21 12:16:46 +09003121static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
3122 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003123{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003124 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003125
3126 pu8CurrByte = pu8Buffer;
3127
3128 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003129 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003130 pu8CurrByte += ETH_ALEN;
3131
3132 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
3133 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
3134
3135 *pu8CurrByte++ = pstrStationParam->u8NumRates;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003136 if (pstrStationParam->u8NumRates > 0)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003137 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003138 pu8CurrByte += pstrStationParam->u8NumRates;
3139
3140 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
3141 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
3142 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
3143
3144 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003145 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003146 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
3147
3148 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
3149 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
3150
3151 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
3152 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
3153 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
3154 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
3155
3156 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
3157
3158 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
3159 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
3160
3161 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
3162 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
3163
3164 return pu8CurrByte - pu8Buffer;
3165}
3166
3167/**
3168 * @brief Handle_AddStation
3169 * @details Sending config packet to add station
Tony Cho6a89ba92015-09-21 12:16:46 +09003170 * @param[in] struct add_sta_param *pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003171 * @return NONE
3172 * @author
3173 * @date
3174 * @version 1.0
3175 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09003176static void Handle_AddStation(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09003177 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003178{
Leo Kime6e12662015-09-16 18:36:03 +09003179 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09003180 struct wid strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003181 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003182
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003183 PRINT_D(HOSTINF_DBG, "Handling add station\n");
Leo Kimdaaf16b2015-10-12 16:55:44 +09003184 strWID.id = (u16)WID_ADD_STA;
Leo Kim416d8322015-10-12 16:55:43 +09003185 strWID.type = WID_BIN;
Leo Kim2fd3e442015-10-12 16:55:45 +09003186 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003187
Leo Kim900bb4a2015-10-12 16:55:46 +09003188 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
3189 if (strWID.val == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003190 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003191
Leo Kim900bb4a2015-10-12 16:55:46 +09003192 pu8CurrByte = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003193 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3194
3195 /*Sending Cfg*/
Tony Cho03362282015-10-12 16:55:39 +09003196 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09003197 get_id_from_handler(hif_drv));
Leo Kime6e12662015-09-16 18:36:03 +09003198 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003199 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003200
Leo Kim24db7132015-09-16 18:36:01 +09003201ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003202 kfree(pstrStationParam->pu8Rates);
Leo Kim900bb4a2015-10-12 16:55:46 +09003203 kfree(strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003204}
3205
3206/**
3207 * @brief Handle_DelAllSta
3208 * @details Sending config packet to delete station
3209 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3210 * @return NONE
3211 * @author
3212 * @date
3213 * @version 1.0
3214 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09003215static void Handle_DelAllSta(struct host_if_drv *hif_drv,
Tony Chob4e644e2015-09-21 12:17:00 +09003216 struct del_all_sta *pstrDelAllStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003217{
Leo Kime6e12662015-09-16 18:36:03 +09003218 s32 s32Error = 0;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003219
Leo Kime9e0c262015-10-12 16:55:41 +09003220 struct wid strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003221 u8 *pu8CurrByte;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003222 u8 i;
Chaehyun Lim37034802015-06-11 14:34:32 +09003223 u8 au8Zero_Buff[6] = {0};
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003224
Leo Kimdaaf16b2015-10-12 16:55:44 +09003225 strWID.id = (u16)WID_DEL_ALL_STA;
Leo Kim416d8322015-10-12 16:55:43 +09003226 strWID.type = WID_STR;
Leo Kim2fd3e442015-10-12 16:55:45 +09003227 strWID.size = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003228
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003229 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003230
Leo Kim900bb4a2015-10-12 16:55:46 +09003231 strWID.val = kmalloc((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1, GFP_KERNEL);
3232 if (strWID.val == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003233 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003234
Leo Kim900bb4a2015-10-12 16:55:46 +09003235 pu8CurrByte = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003236
3237 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
3238
3239 for (i = 0; i < MAX_NUM_STA; i++) {
3240 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003241 memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003242 else
3243 continue;
3244
3245 pu8CurrByte += ETH_ALEN;
3246 }
3247
3248 /*Sending Cfg*/
Tony Cho03362282015-10-12 16:55:39 +09003249 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09003250 get_id_from_handler(hif_drv));
Leo Kim24db7132015-09-16 18:36:01 +09003251 if (s32Error)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02003252 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003253
Leo Kim24db7132015-09-16 18:36:01 +09003254ERRORHANDLER:
Leo Kim900bb4a2015-10-12 16:55:46 +09003255 kfree(strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003256
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003257 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003258}
3259
3260
3261/**
3262 * @brief Handle_DelStation
3263 * @details Sending config packet to delete station
Tony Chofb93a1e2015-09-21 12:16:57 +09003264 * @param[in] struct del_sta *pstrDelStaParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003265 * @return NONE
3266 * @author
3267 * @date
3268 * @version 1.0
3269 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09003270static void Handle_DelStation(struct host_if_drv *hif_drv,
Tony Chofb93a1e2015-09-21 12:16:57 +09003271 struct del_sta *pstrDelStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003272{
Leo Kime6e12662015-09-16 18:36:03 +09003273 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09003274 struct wid strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003275 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003276
Leo Kimdaaf16b2015-10-12 16:55:44 +09003277 strWID.id = (u16)WID_REMOVE_STA;
Leo Kim416d8322015-10-12 16:55:43 +09003278 strWID.type = WID_BIN;
Leo Kim2fd3e442015-10-12 16:55:45 +09003279 strWID.size = ETH_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003280
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003281 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003282
Leo Kim900bb4a2015-10-12 16:55:46 +09003283 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
3284 if (strWID.val == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003285 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003286
Leo Kim900bb4a2015-10-12 16:55:46 +09003287 pu8CurrByte = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003288
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003289 memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003290
3291 /*Sending Cfg*/
Tony Cho03362282015-10-12 16:55:39 +09003292 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09003293 get_id_from_handler(hif_drv));
Leo Kim24db7132015-09-16 18:36:01 +09003294 if (s32Error)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02003295 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003296
Leo Kim24db7132015-09-16 18:36:01 +09003297ERRORHANDLER:
Leo Kim900bb4a2015-10-12 16:55:46 +09003298 kfree(strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003299}
3300
3301
3302/**
3303 * @brief Handle_EditStation
3304 * @details Sending config packet to edit station
Tony Cho6a89ba92015-09-21 12:16:46 +09003305 * @param[in] struct add_sta_param *pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003306 * @return NONE
3307 * @author
3308 * @date
3309 * @version 1.0
3310 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09003311static void Handle_EditStation(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09003312 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003313{
Leo Kime6e12662015-09-16 18:36:03 +09003314 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09003315 struct wid strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003316 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003317
Leo Kimdaaf16b2015-10-12 16:55:44 +09003318 strWID.id = (u16)WID_EDIT_STA;
Leo Kim416d8322015-10-12 16:55:43 +09003319 strWID.type = WID_BIN;
Leo Kim2fd3e442015-10-12 16:55:45 +09003320 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003321
3322 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
Leo Kim900bb4a2015-10-12 16:55:46 +09003323 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
3324 if (strWID.val == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003325 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003326
Leo Kim900bb4a2015-10-12 16:55:46 +09003327 pu8CurrByte = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003328 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3329
3330 /*Sending Cfg*/
Tony Cho03362282015-10-12 16:55:39 +09003331 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09003332 get_id_from_handler(hif_drv));
Leo Kim24db7132015-09-16 18:36:01 +09003333 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003334 PRINT_ER("Failed to send edit station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003335
Leo Kim24db7132015-09-16 18:36:01 +09003336ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003337 kfree(pstrStationParam->pu8Rates);
Leo Kim900bb4a2015-10-12 16:55:46 +09003338 kfree(strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003339}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003340
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003341/**
3342 * @brief Handle_RemainOnChan
3343 * @details Sending config packet to edit station
3344 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3345 * @return NONE
3346 * @author
3347 * @date
3348 * @version 1.0
3349 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09003350static int Handle_RemainOnChan(struct host_if_drv *hif_drv,
Tony Cho2f9c03f2015-09-21 12:16:58 +09003351 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003352{
Leo Kime6e12662015-09-16 18:36:03 +09003353 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003354 u8 u8remain_on_chan_flag;
Leo Kime9e0c262015-10-12 16:55:41 +09003355 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003356
3357 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09003358 if (!hif_drv->u8RemainOnChan_pendingreq) {
3359 hif_drv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
3360 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
3361 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
3362 hif_drv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
3363 hif_drv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003364 } else {
3365 /*Set the channel to use it as a wid val*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09003366 pstrHostIfRemainOnChan->u16Channel = hif_drv->strHostIfRemainOnChan.u16Channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003367 }
3368
Tony Choa4ab1ad2015-10-12 16:56:05 +09003369 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003370 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09003371 hif_drv->u8RemainOnChan_pendingreq = 1;
Leo Kim24db7132015-09-16 18:36:01 +09003372 s32Error = -EBUSY;
3373 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003374 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09003375 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003376 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
Leo Kim24db7132015-09-16 18:36:01 +09003377 s32Error = -EBUSY;
3378 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003379 }
3380
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003381 if (g_obtainingIP || connecting) {
3382 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +09003383 s32Error = -EBUSY;
3384 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003385 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003386
3387 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
3388
Dean Lee72ed4dc2015-06-12 14:11:44 +09003389 u8remain_on_chan_flag = true;
Leo Kimdaaf16b2015-10-12 16:55:44 +09003390 strWID.id = (u16)WID_REMAIN_ON_CHAN;
Leo Kim416d8322015-10-12 16:55:43 +09003391 strWID.type = WID_STR;
Leo Kim2fd3e442015-10-12 16:55:45 +09003392 strWID.size = 2;
Leo Kim900bb4a2015-10-12 16:55:46 +09003393 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003394
Leo Kim900bb4a2015-10-12 16:55:46 +09003395 if (strWID.val == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09003396 s32Error = -ENOMEM;
3397 goto ERRORHANDLER;
3398 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003399
Leo Kim900bb4a2015-10-12 16:55:46 +09003400 strWID.val[0] = u8remain_on_chan_flag;
3401 strWID.val[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003402
3403 /*Sending Cfg*/
Tony Cho03362282015-10-12 16:55:39 +09003404 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09003405 get_id_from_handler(hif_drv));
Leo Kime6e12662015-09-16 18:36:03 +09003406 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003407 PRINT_ER("Failed to set remain on channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003408
Leo Kim24db7132015-09-16 18:36:01 +09003409ERRORHANDLER:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003410 {
3411 P2P_LISTEN_STATE = 1;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003412 hif_drv->hRemainOnChannel.data = (unsigned long)hif_drv;
3413 mod_timer(&hif_drv->hRemainOnChannel,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003414 jiffies +
3415 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003416
3417 /*Calling CFG ready_on_channel*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09003418 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanReady)
3419 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady(hif_drv->strHostIfRemainOnChan.pVoid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003420
Tony Choa4ab1ad2015-10-12 16:56:05 +09003421 if (hif_drv->u8RemainOnChan_pendingreq)
3422 hif_drv->u8RemainOnChan_pendingreq = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003423 }
3424 return s32Error;
3425}
3426
3427/**
3428 * @brief Handle_RegisterFrame
3429 * @details
3430 * @param[in]
3431 * @return NONE
3432 * @author
3433 * @date
3434 * @version 1.0
3435 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09003436static int Handle_RegisterFrame(struct host_if_drv *hif_drv,
Tony Chobc37c5d2015-09-21 12:16:59 +09003437 struct reg_frame *pstrHostIfRegisterFrame)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003438{
Leo Kime6e12662015-09-16 18:36:03 +09003439 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09003440 struct wid strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003441 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003442
3443 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
3444
3445 /*prepare configuration packet*/
Leo Kimdaaf16b2015-10-12 16:55:44 +09003446 strWID.id = (u16)WID_REGISTER_FRAME;
Leo Kim416d8322015-10-12 16:55:43 +09003447 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09003448 strWID.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
3449 if (strWID.val == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003450 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003451
Leo Kim900bb4a2015-10-12 16:55:46 +09003452 pu8CurrByte = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003453
3454 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
3455 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003456 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003457
3458
Leo Kim2fd3e442015-10-12 16:55:45 +09003459 strWID.size = sizeof(u16) + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003460
3461
3462 /*Sending Cfg*/
Tony Cho03362282015-10-12 16:55:39 +09003463 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09003464 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003465 if (s32Error) {
3466 PRINT_ER("Failed to frame register config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09003467 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003468 }
3469
3470 return s32Error;
3471
3472}
3473
3474/**
3475 * @brief Handle_ListenStateExpired
3476 * @details Handle of listen state expiration
3477 * @param[in] NONE
3478 * @return Error code.
3479 * @author
3480 * @date
3481 * @version 1.0
3482 */
3483#define FALSE_FRMWR_CHANNEL 100
Tony Choa4ab1ad2015-10-12 16:56:05 +09003484static u32 Handle_ListenStateExpired(struct host_if_drv *hif_drv,
Tony Cho2f9c03f2015-09-21 12:16:58 +09003485 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003486{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003487 u8 u8remain_on_chan_flag;
Leo Kime9e0c262015-10-12 16:55:41 +09003488 struct wid strWID;
Leo Kime6e12662015-09-16 18:36:03 +09003489 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003490
3491 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
3492
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003493 /*Make sure we are already in listen state*/
3494 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
3495 if (P2P_LISTEN_STATE) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003496 u8remain_on_chan_flag = false;
Leo Kimdaaf16b2015-10-12 16:55:44 +09003497 strWID.id = (u16)WID_REMAIN_ON_CHAN;
Leo Kim416d8322015-10-12 16:55:43 +09003498 strWID.type = WID_STR;
Leo Kim2fd3e442015-10-12 16:55:45 +09003499 strWID.size = 2;
Leo Kim900bb4a2015-10-12 16:55:46 +09003500 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003501
Leo Kim900bb4a2015-10-12 16:55:46 +09003502 if (strWID.val == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003503 PRINT_ER("Failed to allocate memory\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003504
Leo Kim900bb4a2015-10-12 16:55:46 +09003505 strWID.val[0] = u8remain_on_chan_flag;
3506 strWID.val[1] = FALSE_FRMWR_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003507
3508 /*Sending Cfg*/
Tony Cho03362282015-10-12 16:55:39 +09003509 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09003510 get_id_from_handler(hif_drv));
Leo Kime6e12662015-09-16 18:36:03 +09003511 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003512 PRINT_ER("Failed to set remain on channel\n");
3513 goto _done_;
3514 }
3515
Tony Choa4ab1ad2015-10-12 16:56:05 +09003516 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired) {
3517 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired(hif_drv->strHostIfRemainOnChan.pVoid
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003518 , pstrHostIfRemainOnChan->u32ListenSessionID);
3519 }
3520 P2P_LISTEN_STATE = 0;
3521 } else {
3522 PRINT_D(GENERIC_DBG, "Not in listen state\n");
Leo Kime6e12662015-09-16 18:36:03 +09003523 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003524 }
3525
3526_done_:
3527 return s32Error;
3528}
3529
3530
3531/**
3532 * @brief ListenTimerCB
3533 * @details Callback function of remain-on-channel timer
3534 * @param[in] NONE
3535 * @return Error code.
3536 * @author
3537 * @date
3538 * @version 1.0
3539 */
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003540static void ListenTimerCB(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003541{
Leo Kime6e12662015-09-16 18:36:03 +09003542 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003543 struct host_if_msg msg;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003544 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003545 /*Stopping remain-on-channel timer*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09003546 del_timer(&hif_drv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003547
3548 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09003549 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003550 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003551 msg.drv = hif_drv;
3552 msg.body.remain_on_ch.u32ListenSessionID = hif_drv->strHostIfRemainOnChan.u32ListenSessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003553
3554 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09003555 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003556 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09003557 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003558}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003559
3560/**
3561 * @brief Handle_EditStation
3562 * @details Sending config packet to edit station
3563 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3564 * @return NONE
3565 * @author
3566 * @date
3567 * @version 1.0
3568 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09003569static void Handle_PowerManagement(struct host_if_drv *hif_drv,
Tony Cho5a008f12015-09-21 12:16:48 +09003570 struct power_mgmt_param *strPowerMgmtParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003571{
Leo Kime6e12662015-09-16 18:36:03 +09003572 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09003573 struct wid strWID;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003574 s8 s8PowerMode;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003575
Leo Kimdaaf16b2015-10-12 16:55:44 +09003576 strWID.id = (u16)WID_POWER_MANAGEMENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003577
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05303578 if (strPowerMgmtParam->bIsEnabled == true)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003579 s8PowerMode = MIN_FAST_PS;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05303580 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003581 s8PowerMode = NO_POWERSAVE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003582 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
Leo Kim900bb4a2015-10-12 16:55:46 +09003583 strWID.val = &s8PowerMode;
Leo Kim2fd3e442015-10-12 16:55:45 +09003584 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003585
3586 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
3587
3588 /*Sending Cfg*/
Tony Cho03362282015-10-12 16:55:39 +09003589 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09003590 get_id_from_handler(hif_drv));
Leo Kim24db7132015-09-16 18:36:01 +09003591 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003592 PRINT_ER("Failed to send power management config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003593}
3594
3595/**
3596 * @brief Handle_SetMulticastFilter
3597 * @details Set Multicast filter in firmware
Tony Cho641210a2015-09-21 12:16:52 +09003598 * @param[in] struct set_multicast *strHostIfSetMulti
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003599 * @return NONE
3600 * @author asobhy
3601 * @date
3602 * @version 1.0
3603 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09003604static void Handle_SetMulticastFilter(struct host_if_drv *hif_drv,
Tony Cho641210a2015-09-21 12:16:52 +09003605 struct set_multicast *strHostIfSetMulti)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003606{
Leo Kime6e12662015-09-16 18:36:03 +09003607 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09003608 struct wid strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003609 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003610
3611 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
3612
Leo Kimdaaf16b2015-10-12 16:55:44 +09003613 strWID.id = (u16)WID_SETUP_MULTICAST_FILTER;
Leo Kim416d8322015-10-12 16:55:43 +09003614 strWID.type = WID_BIN;
Leo Kim2fd3e442015-10-12 16:55:45 +09003615 strWID.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
Leo Kim900bb4a2015-10-12 16:55:46 +09003616 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
3617 if (strWID.val == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003618 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003619
Leo Kim900bb4a2015-10-12 16:55:46 +09003620 pu8CurrByte = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003621 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
3622 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
3623 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
3624 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
3625
3626 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
3627 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
3628 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
3629 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
3630
3631 if ((strHostIfSetMulti->u32count) > 0)
3632 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
3633
3634 /*Sending Cfg*/
Tony Cho03362282015-10-12 16:55:39 +09003635 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09003636 get_id_from_handler(hif_drv));
Leo Kim24db7132015-09-16 18:36:01 +09003637 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003638 PRINT_ER("Failed to send setup multicast config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003639
Leo Kim24db7132015-09-16 18:36:01 +09003640ERRORHANDLER:
Leo Kim900bb4a2015-10-12 16:55:46 +09003641 kfree(strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003642
3643}
3644
3645
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003646/**
3647 * @brief Handle_AddBASession
3648 * @details Add block ack session
3649 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
3650 * @return NONE
3651 * @author Amr Abdel-Moghny
3652 * @date Feb. 2014
3653 * @version 9.0
3654 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09003655static s32 Handle_AddBASession(struct host_if_drv *hif_drv,
Tony Cho54265472015-09-21 12:16:56 +09003656 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003657{
Leo Kime6e12662015-09-16 18:36:03 +09003658 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09003659 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003660 int AddbaTimeout = 100;
3661 char *ptr = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003662
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003663 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 +09003664 strHostIfBASessionInfo->au8Bssid[0],
3665 strHostIfBASessionInfo->au8Bssid[1],
3666 strHostIfBASessionInfo->au8Bssid[2],
3667 strHostIfBASessionInfo->u16BufferSize,
3668 strHostIfBASessionInfo->u16SessionTimeout,
3669 strHostIfBASessionInfo->u8Ted);
3670
Leo Kimdaaf16b2015-10-12 16:55:44 +09003671 strWID.id = (u16)WID_11E_P_ACTION_REQ;
Leo Kim416d8322015-10-12 16:55:43 +09003672 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09003673 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Leo Kim2fd3e442015-10-12 16:55:45 +09003674 strWID.size = BLOCK_ACK_REQ_SIZE;
Leo Kim900bb4a2015-10-12 16:55:46 +09003675 ptr = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003676 /* *ptr++ = 0x14; */
3677 *ptr++ = 0x14;
3678 *ptr++ = 0x3;
3679 *ptr++ = 0x0;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003680 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003681 ptr += ETH_ALEN;
3682 *ptr++ = strHostIfBASessionInfo->u8Ted;
3683 /* BA Policy*/
3684 *ptr++ = 1;
3685 /* Buffer size*/
3686 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
3687 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
3688 /* BA timeout*/
3689 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
3690 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
3691 /* ADDBA timeout*/
3692 *ptr++ = (AddbaTimeout & 0xFF);
3693 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
3694 /* Group Buffer Max Frames*/
3695 *ptr++ = 8;
3696 /* Group Buffer Timeout */
3697 *ptr++ = 0;
3698
Tony Cho03362282015-10-12 16:55:39 +09003699 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09003700 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003701 if (s32Error)
3702 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
3703
3704
Leo Kimdaaf16b2015-10-12 16:55:44 +09003705 strWID.id = (u16)WID_11E_P_ACTION_REQ;
Leo Kim416d8322015-10-12 16:55:43 +09003706 strWID.type = WID_STR;
Leo Kim2fd3e442015-10-12 16:55:45 +09003707 strWID.size = 15;
Leo Kim900bb4a2015-10-12 16:55:46 +09003708 ptr = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003709 /* *ptr++ = 0x14; */
3710 *ptr++ = 15;
3711 *ptr++ = 7;
3712 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003713 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003714 ptr += ETH_ALEN;
3715 /* TID*/
3716 *ptr++ = strHostIfBASessionInfo->u8Ted;
3717 /* Max Num MSDU */
3718 *ptr++ = 8;
3719 /* BA timeout*/
3720 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
3721 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
3722 /*Ack-Policy */
3723 *ptr++ = 3;
Tony Cho03362282015-10-12 16:55:39 +09003724 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09003725 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003726
Leo Kim900bb4a2015-10-12 16:55:46 +09003727 if (strWID.val != NULL)
3728 kfree(strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003729
3730 return s32Error;
3731
3732}
3733
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003734/**
3735 * @brief Handle_DelAllRxBASessions
3736 * @details Delete all Rx BA sessions
3737 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
3738 * @return NONE
3739 * @author Abdelrahman Sobhy
3740 * @date Feb. 2013
3741 * @version 9.0
3742 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09003743static s32 Handle_DelAllRxBASessions(struct host_if_drv *hif_drv,
Tony Cho54265472015-09-21 12:16:56 +09003744 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003745{
Leo Kime6e12662015-09-16 18:36:03 +09003746 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09003747 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003748 char *ptr = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003749
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003750 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003751 strHostIfBASessionInfo->au8Bssid[0],
3752 strHostIfBASessionInfo->au8Bssid[1],
3753 strHostIfBASessionInfo->au8Bssid[2],
3754 strHostIfBASessionInfo->u8Ted);
3755
Leo Kimdaaf16b2015-10-12 16:55:44 +09003756 strWID.id = (u16)WID_DEL_ALL_RX_BA;
Leo Kim416d8322015-10-12 16:55:43 +09003757 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09003758 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Leo Kim2fd3e442015-10-12 16:55:45 +09003759 strWID.size = BLOCK_ACK_REQ_SIZE;
Leo Kim900bb4a2015-10-12 16:55:46 +09003760 ptr = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003761 *ptr++ = 0x14;
3762 *ptr++ = 0x3;
3763 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003764 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003765 ptr += ETH_ALEN;
3766 *ptr++ = strHostIfBASessionInfo->u8Ted;
3767 /* BA direction = recipent*/
3768 *ptr++ = 0;
3769 /* Delba Reason */
3770 *ptr++ = 32; /* Unspecific QOS reason */
3771
Tony Cho03362282015-10-12 16:55:39 +09003772 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09003773 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003774 if (s32Error)
3775 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
3776
3777
Leo Kim900bb4a2015-10-12 16:55:46 +09003778 if (strWID.val != NULL)
3779 kfree(strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003780
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003781 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003782
3783 return s32Error;
3784
3785}
3786
3787/**
3788 * @brief hostIFthread
3789 * @details Main thread to handle message queue requests
3790 * @param[in] void* pvArg
3791 * @return NONE
3792 * @author
3793 * @date
3794 * @version 1.0
3795 */
Arnd Bergmann1999bd52015-05-29 22:52:14 +02003796static int hostIFthread(void *pvArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003797{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003798 u32 u32Ret;
Tony Cho143eb952015-09-21 12:16:32 +09003799 struct host_if_msg msg;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003800 struct host_if_drv *hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003801
Tony Cho143eb952015-09-21 12:16:32 +09003802 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003803
3804 while (1) {
Tony Cho143eb952015-09-21 12:16:32 +09003805 wilc_mq_recv(&gMsgQHostIF, &msg, sizeof(struct host_if_msg), &u32Ret);
Tony Choa4ab1ad2015-10-12 16:56:05 +09003806 hif_drv = (struct host_if_drv *)msg.drv;
Tony Choa9f812a2015-09-21 12:16:33 +09003807 if (msg.id == HOST_IF_MSG_EXIT) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003808 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
3809 break;
3810 }
3811
3812
3813 /*Re-Queue HIF message*/
3814 if ((!g_wilc_initialized)) {
3815 PRINT_D(GENERIC_DBG, "--WAIT--");
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07003816 usleep_range(200 * 1000, 200 * 1000);
Tony Cho143eb952015-09-21 12:16:32 +09003817 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003818 continue;
3819 }
3820
Tony Choa4ab1ad2015-10-12 16:56:05 +09003821 if (msg.id == HOST_IF_MSG_CONNECT && hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003822 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
Tony Cho143eb952015-09-21 12:16:32 +09003823 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07003824 usleep_range(2 * 1000, 2 * 1000);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003825 continue;
3826 }
3827
Tony Choa9f812a2015-09-21 12:16:33 +09003828 switch (msg.id) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003829 case HOST_IF_MSG_Q_IDLE:
3830 Handle_wait_msg_q_empty();
3831 break;
3832
3833 case HOST_IF_MSG_SCAN:
Leo Kim2482a792015-10-12 16:55:36 +09003834 Handle_Scan(msg.drv, &msg.body.scan_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003835 break;
3836
3837 case HOST_IF_MSG_CONNECT:
Leo Kim2482a792015-10-12 16:55:36 +09003838 Handle_Connect(msg.drv, &msg.body.con_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003839 break;
3840
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003841 case HOST_IF_MSG_FLUSH_CONNECT:
Leo Kim2482a792015-10-12 16:55:36 +09003842 Handle_FlushConnect(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003843 break;
3844
3845 case HOST_IF_MSG_RCVD_NTWRK_INFO:
Leo Kim2482a792015-10-12 16:55:36 +09003846 Handle_RcvdNtwrkInfo(msg.drv, &msg.body.net_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003847 break;
3848
3849 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
Leo Kim2482a792015-10-12 16:55:36 +09003850 Handle_RcvdGnrlAsyncInfo(msg.drv, &msg.body.async_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003851 break;
3852
3853 case HOST_IF_MSG_KEY:
Leo Kim2482a792015-10-12 16:55:36 +09003854 Handle_Key(msg.drv, &msg.body.key_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003855 break;
3856
3857 case HOST_IF_MSG_CFG_PARAMS:
3858
Leo Kim2482a792015-10-12 16:55:36 +09003859 Handle_CfgParam(msg.drv, &msg.body.cfg_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003860 break;
3861
3862 case HOST_IF_MSG_SET_CHANNEL:
Leo Kim2482a792015-10-12 16:55:36 +09003863 Handle_SetChannel(msg.drv, &msg.body.channel_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003864 break;
3865
3866 case HOST_IF_MSG_DISCONNECT:
Leo Kim2482a792015-10-12 16:55:36 +09003867 Handle_Disconnect(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003868 break;
3869
3870 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
Tony Choa4ab1ad2015-10-12 16:56:05 +09003871 del_timer(&hif_drv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003872 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
3873
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003874 /*Allow chip sleep, only if both interfaces are not connected*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003875 if (!linux_wlan_get_num_conn_ifcs())
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003876 chip_sleep_manually(INFINITE_SLEEP_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003877
Leo Kim2482a792015-10-12 16:55:36 +09003878 Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003879
Tony Choa4ab1ad2015-10-12 16:56:05 +09003880 if (hif_drv->u8RemainOnChan_pendingreq)
Leo Kim2482a792015-10-12 16:55:36 +09003881 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003882
3883 break;
3884
3885 case HOST_IF_MSG_GET_RSSI:
Leo Kim2482a792015-10-12 16:55:36 +09003886 Handle_GetRssi(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003887 break;
3888
3889 case HOST_IF_MSG_GET_LINKSPEED:
Leo Kim2482a792015-10-12 16:55:36 +09003890 Handle_GetLinkspeed(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003891 break;
3892
3893 case HOST_IF_MSG_GET_STATISTICS:
Leo Kim03e7b9c2015-10-12 16:55:58 +09003894 Handle_GetStatistics(msg.drv, (struct rf_info *)msg.body.data);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003895 break;
3896
3897 case HOST_IF_MSG_GET_CHNL:
Leo Kim2482a792015-10-12 16:55:36 +09003898 Handle_GetChnl(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003899 break;
3900
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003901 case HOST_IF_MSG_ADD_BEACON:
Leo Kim2482a792015-10-12 16:55:36 +09003902 Handle_AddBeacon(msg.drv, &msg.body.beacon_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003903 break;
3904
3905 case HOST_IF_MSG_DEL_BEACON:
Leo Kim2482a792015-10-12 16:55:36 +09003906 Handle_DelBeacon(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003907 break;
3908
3909 case HOST_IF_MSG_ADD_STATION:
Leo Kim2482a792015-10-12 16:55:36 +09003910 Handle_AddStation(msg.drv, &msg.body.add_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003911 break;
3912
3913 case HOST_IF_MSG_DEL_STATION:
Leo Kim2482a792015-10-12 16:55:36 +09003914 Handle_DelStation(msg.drv, &msg.body.del_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003915 break;
3916
3917 case HOST_IF_MSG_EDIT_STATION:
Leo Kim2482a792015-10-12 16:55:36 +09003918 Handle_EditStation(msg.drv, &msg.body.edit_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003919 break;
3920
3921 case HOST_IF_MSG_GET_INACTIVETIME:
Leo Kim2482a792015-10-12 16:55:36 +09003922 Handle_Get_InActiveTime(msg.drv, &msg.body.mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003923 break;
3924
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003925 case HOST_IF_MSG_SCAN_TIMER_FIRED:
3926 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
3927
Leo Kim2482a792015-10-12 16:55:36 +09003928 Handle_ScanDone(msg.drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003929 break;
3930
3931 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003932 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
Leo Kim2482a792015-10-12 16:55:36 +09003933 Handle_ConnectTimeout(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003934 break;
3935
3936 case HOST_IF_MSG_POWER_MGMT:
Leo Kim2482a792015-10-12 16:55:36 +09003937 Handle_PowerManagement(msg.drv, &msg.body.pwr_mgmt_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003938 break;
3939
3940 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
Leo Kim2482a792015-10-12 16:55:36 +09003941 Handle_SetWfiDrvHandler(msg.drv,
Tony Cho5e4377e2015-09-30 18:44:38 +09003942 &msg.body.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003943 break;
3944
3945 case HOST_IF_MSG_SET_OPERATION_MODE:
Leo Kim2482a792015-10-12 16:55:36 +09003946 Handle_SetOperationMode(msg.drv, &msg.body.mode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003947 break;
3948
3949 case HOST_IF_MSG_SET_IPADDRESS:
3950 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Leo Kim2482a792015-10-12 16:55:36 +09003951 Handle_set_IPAddress(msg.drv, msg.body.ip_info.au8IPAddr, msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003952 break;
3953
3954 case HOST_IF_MSG_GET_IPADDRESS:
3955 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Leo Kim2482a792015-10-12 16:55:36 +09003956 Handle_get_IPAddress(msg.drv, msg.body.ip_info.au8IPAddr, msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003957 break;
3958
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003959 case HOST_IF_MSG_SET_MAC_ADDRESS:
Leo Kim2482a792015-10-12 16:55:36 +09003960 Handle_SetMacAddress(msg.drv, &msg.body.set_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003961 break;
3962
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003963 case HOST_IF_MSG_GET_MAC_ADDRESS:
Leo Kim2482a792015-10-12 16:55:36 +09003964 Handle_GetMacAddress(msg.drv, &msg.body.get_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003965 break;
3966
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003967 case HOST_IF_MSG_REMAIN_ON_CHAN:
3968 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
Leo Kim2482a792015-10-12 16:55:36 +09003969 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003970 break;
3971
3972 case HOST_IF_MSG_REGISTER_FRAME:
3973 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
Leo Kim2482a792015-10-12 16:55:36 +09003974 Handle_RegisterFrame(msg.drv, &msg.body.reg_frame);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003975 break;
3976
3977 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
Leo Kim2482a792015-10-12 16:55:36 +09003978 Handle_ListenStateExpired(msg.drv, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003979 break;
3980
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003981 case HOST_IF_MSG_SET_MULTICAST_FILTER:
3982 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
Leo Kim2482a792015-10-12 16:55:36 +09003983 Handle_SetMulticastFilter(msg.drv, &msg.body.multicast_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003984 break;
3985
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003986 case HOST_IF_MSG_ADD_BA_SESSION:
Leo Kim2482a792015-10-12 16:55:36 +09003987 Handle_AddBASession(msg.drv, &msg.body.session_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003988 break;
3989
3990 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
Leo Kim2482a792015-10-12 16:55:36 +09003991 Handle_DelAllRxBASessions(msg.drv, &msg.body.session_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003992 break;
3993
3994 case HOST_IF_MSG_DEL_ALL_STA:
Leo Kim2482a792015-10-12 16:55:36 +09003995 Handle_DelAllSta(msg.drv, &msg.body.del_all_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003996 break;
3997
3998 default:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003999 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004000 break;
4001 }
4002 }
4003
4004 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004005 up(&hSemHostIFthrdEnd);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02004006 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004007}
4008
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004009static void TimerCB_Scan(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004010{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004011 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09004012 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004013
4014 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09004015 memset(&msg, 0, sizeof(struct host_if_msg));
Leo Kim2482a792015-10-12 16:55:36 +09004016 msg.drv = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09004017 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004018
4019 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004020 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004021}
4022
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004023static void TimerCB_Connect(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004024{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004025 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09004026 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004027
4028 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09004029 memset(&msg, 0, sizeof(struct host_if_msg));
Leo Kim2482a792015-10-12 16:55:36 +09004030 msg.drv = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09004031 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004032
4033 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004034 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004035}
4036
4037
4038/**
4039 * @brief removes wpa/wpa2 keys
4040 * @details only in BSS STA mode if External Supplicant support is enabled.
4041 * removes all WPA/WPA2 station key entries from MAC hardware.
4042 * @param[in,out] handle to the wifi driver
4043 * @param[in] 6 bytes of Station Adress in the station entry table
4044 * @return Error code indicating success/failure
4045 * @note
4046 * @author zsalah
4047 * @date 8 March 2012
4048 * @version 1.0
4049 */
4050/* Check implementation in core adding 9 bytes to the input! */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004051s32 host_int_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004052{
Leo Kime9e0c262015-10-12 16:55:41 +09004053 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004054
Leo Kimdaaf16b2015-10-12 16:55:44 +09004055 strWID.id = (u16)WID_REMOVE_KEY;
Leo Kim416d8322015-10-12 16:55:43 +09004056 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09004057 strWID.val = (s8 *)pu8StaAddress;
Leo Kim2fd3e442015-10-12 16:55:45 +09004058 strWID.size = 6;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004059
Leo Kimb68d820b2015-10-12 16:55:37 +09004060 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004061}
4062
4063/**
4064 * @brief removes WEP key
4065 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4066 * remove a WEP key entry from MAC HW.
4067 * The BSS Station automatically finds the index of the entry using its
4068 * BSS ID and removes that entry from the MAC hardware.
4069 * @param[in,out] handle to the wifi driver
4070 * @param[in] 6 bytes of Station Adress in the station entry table
4071 * @return Error code indicating success/failure
4072 * @note NO need for the STA add since it is not used for processing
4073 * @author zsalah
4074 * @date 8 March 2012
4075 * @version 1.0
4076 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004077int host_int_remove_wep_key(struct host_if_drv *hif_drv, u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004078{
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09004079 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004080 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004081
Tony Choa4ab1ad2015-10-12 16:56:05 +09004082 if (!hif_drv) {
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09004083 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09004084 PRINT_ER("Failed to send setup multicast config packet\n");
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09004085 return result;
Leo Kim24db7132015-09-16 18:36:01 +09004086 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004087
4088 /* prepare the Remove Wep Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004089 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004090
Tony Choa9f812a2015-09-21 12:16:33 +09004091 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004092 msg.body.key_info.enuKeyType = WEP;
4093 msg.body.key_info.u8KeyAction = REMOVEKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004094 msg.drv = hif_drv;
Tony Cho2ed7a2f2015-10-12 16:56:08 +09004095 msg.body.key_info.uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004096
4097 /* send the message */
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09004098 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4099 if (result)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004100 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09004101 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004102
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09004103 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004104}
4105
4106/**
4107 * @brief sets WEP default key
4108 * @details Sets the index of the WEP encryption key in use,
4109 * in the key table
4110 * @param[in,out] handle to the wifi driver
4111 * @param[in] key index ( 0, 1, 2, 3)
4112 * @return Error code indicating success/failure
4113 * @note
4114 * @author zsalah
4115 * @date 8 March 2012
4116 * @version 1.0
4117 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004118s32 host_int_set_WEPDefaultKeyID(struct host_if_drv *hif_drv, u8 u8Index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004119{
Leo Kime6e12662015-09-16 18:36:03 +09004120 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004121 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004122
4123
Tony Choa4ab1ad2015-10-12 16:56:05 +09004124 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004125 s32Error = -EFAULT;
4126 PRINT_ER("driver is null\n");
4127 return s32Error;
4128 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004129
4130 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004131 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004132
4133
Tony Choa9f812a2015-09-21 12:16:33 +09004134 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004135 msg.body.key_info.enuKeyType = WEP;
4136 msg.body.key_info.u8KeyAction = DEFAULTKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004137 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004138
4139
Tony Cho2ed7a2f2015-10-12 16:56:08 +09004140 msg.body.key_info.uniHostIFkeyAttr.wep.u8Wepidx = u8Index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004141
4142 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004143 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004144 if (s32Error)
4145 PRINT_ER("Error in sending message queue : Default key index\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09004146 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004147
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004148 return s32Error;
4149}
4150
4151/**
4152 * @brief sets WEP deafault key
4153 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4154 * sets WEP key entry into MAC hardware when it receives the
4155 * corresponding request from NDIS.
4156 * @param[in,out] handle to the wifi driver
4157 * @param[in] message containing WEP Key in the following format
4158 *|---------------------------------------|
4159 *|Key ID Value | Key Length | Key |
4160 *|-------------|------------|------------|
4161 | 1byte | 1byte | Key Length |
4162 ||---------------------------------------|
4163 |
4164 * @return Error code indicating success/failure
4165 * @note
4166 * @author zsalah
4167 * @date 8 March 2012
4168 * @version 1.0
4169 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004170s32 host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
4171 const u8 *pu8WepKey,
4172 u8 u8WepKeylen,
4173 u8 u8Keyidx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004174{
4175
Leo Kime6e12662015-09-16 18:36:03 +09004176 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004177 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004178
Tony Choa4ab1ad2015-10-12 16:56:05 +09004179 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004180 s32Error = -EFAULT;
4181 PRINT_ER("driver is null\n");
4182 return s32Error;
4183 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004184
4185 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004186 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004187
4188
Tony Choa9f812a2015-09-21 12:16:33 +09004189 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004190 msg.body.key_info.enuKeyType = WEP;
4191 msg.body.key_info.u8KeyAction = ADDKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004192 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004193
4194
Tony Cho18990bf2015-09-30 18:44:24 +09004195 msg.body.key_info.
Tony Choe5538d32015-10-12 16:56:11 +09004196 uniHostIFkeyAttr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004197
Tony Choe5538d32015-10-12 16:56:11 +09004198 memcpy(msg.body.key_info.uniHostIFkeyAttr.wep.key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004199 pu8WepKey, u8WepKeylen);
4200
4201
Tony Chod520e352015-10-12 16:56:12 +09004202 msg.body.key_info.uniHostIFkeyAttr.wep.key_len = (u8WepKeylen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004203
Tony Cho2ed7a2f2015-10-12 16:56:08 +09004204 msg.body.key_info.uniHostIFkeyAttr.wep.u8Wepidx = u8Keyidx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004205
4206 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004207 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004208 if (s32Error)
4209 PRINT_ER("Error in sending message queue :WEP Key\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09004210 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004211
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004212 return s32Error;
4213
4214}
4215
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004216/**
4217 *
4218 * @brief host_int_add_wep_key_bss_ap
4219 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4220 * sets WEP key entry into MAC hardware when it receives the
4221 *
4222 * corresponding request from NDIS.
4223 * @param[in,out] handle to the wifi driver
4224 *
4225 *
4226 * @return Error code indicating success/failure
4227 * @note
4228 * @author mdaftedar
4229 * @date 28 FEB 2013
4230 * @version 1.0
4231 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004232s32 host_int_add_wep_key_bss_ap(struct host_if_drv *hif_drv,
4233 const u8 *pu8WepKey,
4234 u8 u8WepKeylen,
4235 u8 u8Keyidx,
4236 u8 u8mode,
4237 enum AUTHTYPE tenuAuth_type)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004238{
4239
Leo Kime6e12662015-09-16 18:36:03 +09004240 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004241 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004242 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004243
Tony Choa4ab1ad2015-10-12 16:56:05 +09004244 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004245 s32Error = -EFAULT;
4246 PRINT_ER("driver is null\n");
4247 return s32Error;
4248 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004249
4250 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004251 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004252
4253 if (INFO) {
4254 for (i = 0; i < u8WepKeylen; i++)
4255 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4256 }
Tony Choa9f812a2015-09-21 12:16:33 +09004257 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004258 msg.body.key_info.enuKeyType = WEP;
4259 msg.body.key_info.u8KeyAction = ADDKEY_AP;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004260 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004261
4262
Tony Cho18990bf2015-09-30 18:44:24 +09004263 msg.body.key_info.
Tony Choe5538d32015-10-12 16:56:11 +09004264 uniHostIFkeyAttr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004265
4266
Tony Choe5538d32015-10-12 16:56:11 +09004267 memcpy(msg.body.key_info.uniHostIFkeyAttr.wep.key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004268 pu8WepKey, (u8WepKeylen));
4269
4270
Tony Chod520e352015-10-12 16:56:12 +09004271 msg.body.key_info.uniHostIFkeyAttr.wep.key_len = (u8WepKeylen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004272
Tony Cho2ed7a2f2015-10-12 16:56:08 +09004273 msg.body.key_info.uniHostIFkeyAttr.wep.u8Wepidx = u8Keyidx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004274
Tony Cho2ed7a2f2015-10-12 16:56:08 +09004275 msg.body.key_info.uniHostIFkeyAttr.wep.u8mode = u8mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004276
Tony Cho2ed7a2f2015-10-12 16:56:08 +09004277 msg.body.key_info.uniHostIFkeyAttr.wep.tenuAuth_type = tenuAuth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004278 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004279 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004280
4281 if (s32Error)
4282 PRINT_ER("Error in sending message queue :WEP Key\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09004283 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004284
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004285 return s32Error;
4286
4287}
Glen Lee108b3432015-09-16 18:53:20 +09004288
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004289/**
4290 * @brief adds ptk Key
4291 * @details
4292 * @param[in,out] handle to the wifi driver
4293 * @param[in] message containing PTK Key in the following format
4294 *|-----------------------------------------------------------------------------|
4295 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4296 *|----------------|------------|--------------|----------------|---------------|
4297 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4298 ||-----------------------------------------------------------------------------|
4299 * @return Error code indicating success/failure
4300 * @note
4301 * @author zsalah
4302 * @date 8 March 2012
4303 * @version 1.0
4304 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004305s32 host_int_add_ptk(struct host_if_drv *hif_drv, const u8 *pu8Ptk,
4306 u8 u8PtkKeylen, const u8 *mac_addr,
4307 const u8 *pu8RxMic, const u8 *pu8TxMic,
4308 u8 mode, u8 u8Ciphermode, u8 u8Idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004309{
Leo Kime6e12662015-09-16 18:36:03 +09004310 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004311 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004312 u8 u8KeyLen = u8PtkKeylen;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004313 u32 i;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004314
Tony Choa4ab1ad2015-10-12 16:56:05 +09004315 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004316 s32Error = -EFAULT;
4317 PRINT_ER("driver is null\n");
4318 return s32Error;
4319 }
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004320 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004321 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004322 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004323 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004324
4325 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004326 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004327
4328
Tony Choa9f812a2015-09-21 12:16:33 +09004329 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004330 msg.body.key_info.enuKeyType = WPAPtk;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004331 if (mode == AP_MODE) {
Tony Cho18990bf2015-09-30 18:44:24 +09004332 msg.body.key_info.u8KeyAction = ADDKEY_AP;
Tony Choe3501a42015-10-12 16:56:09 +09004333 msg.body.key_info.uniHostIFkeyAttr.wpa.u8keyidx = u8Idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004334 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004335 if (mode == STATION_MODE)
Tony Cho18990bf2015-09-30 18:44:24 +09004336 msg.body.key_info.u8KeyAction = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004337
4338
Tony Cho18990bf2015-09-30 18:44:24 +09004339 msg.body.key_info.
Tony Choe3501a42015-10-12 16:56:09 +09004340 uniHostIFkeyAttr.wpa.pu8key = kmalloc(u8PtkKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004341
4342
Tony Choe3501a42015-10-12 16:56:09 +09004343 memcpy(msg.body.key_info.uniHostIFkeyAttr.wpa.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004344 pu8Ptk, u8PtkKeylen);
4345
4346 if (pu8RxMic != NULL) {
4347
Tony Choe3501a42015-10-12 16:56:09 +09004348 memcpy(msg.body.key_info.uniHostIFkeyAttr.wpa.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004349 pu8RxMic, RX_MIC_KEY_LEN);
4350 if (INFO) {
4351 for (i = 0; i < RX_MIC_KEY_LEN; i++)
4352 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
4353 }
4354 }
4355 if (pu8TxMic != NULL) {
4356
Tony Choe3501a42015-10-12 16:56:09 +09004357 memcpy(msg.body.key_info.uniHostIFkeyAttr.wpa.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004358 pu8TxMic, TX_MIC_KEY_LEN);
4359 if (INFO) {
4360 for (i = 0; i < TX_MIC_KEY_LEN; i++)
4361 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
4362 }
4363 }
4364
Tony Choe3501a42015-10-12 16:56:09 +09004365 msg.body.key_info.uniHostIFkeyAttr.wpa.u8Keylen = u8KeyLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004366
Tony Choe3501a42015-10-12 16:56:09 +09004367 msg.body.key_info.uniHostIFkeyAttr.wpa.u8Ciphermode = u8Ciphermode;
4368 msg.body.key_info.uniHostIFkeyAttr.wpa.pu8macaddr = mac_addr;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004369 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004370
4371 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004372 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004373
4374 if (s32Error)
4375 PRINT_ER("Error in sending message queue: PTK Key\n");
4376
4377 /* ////////////// */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004378 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004379 /* /////// */
4380
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004381 return s32Error;
4382}
4383
4384/**
4385 * @brief adds Rx GTk Key
4386 * @details
4387 * @param[in,out] handle to the wifi driver
4388 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
4389 * u8GtkKeylen :The total key length
4390 *
4391 * @return Error code indicating success/failure
4392 * @note
4393 * @author zsalah
4394 * @date 8 March 2012
4395 * @version 1.0
4396 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004397s32 host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *pu8RxGtk,
4398 u8 u8GtkKeylen, u8 u8KeyIdx,
4399 u32 u32KeyRSClen, const u8 *KeyRSC,
4400 const u8 *pu8RxMic, const u8 *pu8TxMic,
4401 u8 mode, u8 u8Ciphermode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004402{
Leo Kime6e12662015-09-16 18:36:03 +09004403 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004404 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004405 u8 u8KeyLen = u8GtkKeylen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004406
Tony Choa4ab1ad2015-10-12 16:56:05 +09004407 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004408 s32Error = -EFAULT;
4409 PRINT_ER("driver is null\n");
4410 return s32Error;
4411 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004412 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004413 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004414
4415
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004416 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004417 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004418 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004419 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004420 if (KeyRSC != NULL) {
Tony Cho18990bf2015-09-30 18:44:24 +09004421 msg.body.key_info.
Tony Choe3501a42015-10-12 16:56:09 +09004422 uniHostIFkeyAttr.wpa.pu8seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004423
Tony Choe3501a42015-10-12 16:56:09 +09004424 memcpy(msg.body.key_info.uniHostIFkeyAttr.wpa.pu8seq,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004425 KeyRSC, u32KeyRSClen);
4426 }
4427
4428
Tony Choa9f812a2015-09-21 12:16:33 +09004429 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004430 msg.body.key_info.enuKeyType = WPARxGtk;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004431 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004432
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004433 if (mode == AP_MODE) {
Tony Cho18990bf2015-09-30 18:44:24 +09004434 msg.body.key_info.u8KeyAction = ADDKEY_AP;
Tony Choe3501a42015-10-12 16:56:09 +09004435 msg.body.key_info.uniHostIFkeyAttr.wpa.u8Ciphermode = u8Ciphermode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004436 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004437 if (mode == STATION_MODE)
Tony Cho18990bf2015-09-30 18:44:24 +09004438 msg.body.key_info.u8KeyAction = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004439
4440
Tony Cho18990bf2015-09-30 18:44:24 +09004441 msg.body.key_info.
Tony Choe3501a42015-10-12 16:56:09 +09004442 uniHostIFkeyAttr.wpa.pu8key = kmalloc(u8KeyLen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004443
Tony Choe3501a42015-10-12 16:56:09 +09004444 memcpy(msg.body.key_info.uniHostIFkeyAttr.wpa.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004445 pu8RxGtk, u8GtkKeylen);
4446
4447 if (pu8RxMic != NULL) {
4448
Tony Choe3501a42015-10-12 16:56:09 +09004449 memcpy(msg.body.key_info.uniHostIFkeyAttr.wpa.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004450 pu8RxMic, RX_MIC_KEY_LEN);
4451
4452 }
4453 if (pu8TxMic != NULL) {
4454
Tony Choe3501a42015-10-12 16:56:09 +09004455 memcpy(msg.body.key_info.uniHostIFkeyAttr.wpa.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004456 pu8TxMic, TX_MIC_KEY_LEN);
4457
4458 }
4459
Tony Choe3501a42015-10-12 16:56:09 +09004460 msg.body.key_info.uniHostIFkeyAttr.wpa.u8keyidx = u8KeyIdx;
4461 msg.body.key_info.uniHostIFkeyAttr.wpa.u8Keylen = u8KeyLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004462
Tony Choe3501a42015-10-12 16:56:09 +09004463 msg.body.key_info.uniHostIFkeyAttr.wpa.u8seqlen = u32KeyRSClen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004464
4465
4466
4467 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004468 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004469 if (s32Error)
4470 PRINT_ER("Error in sending message queue: RX GTK\n");
4471 /* ////////////// */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004472 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004473 /* /////// */
4474
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004475 return s32Error;
4476}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004477
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004478/**
4479 * @brief host_int_set_pmkid_info
4480 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
4481 * support is enabled. This Function sets the PMKID in firmware
4482 * when host drivr receives the corresponding request from NDIS.
4483 * The firmware then includes theset PMKID in the appropriate
4484 * management frames
4485 * @param[in,out] handle to the wifi driver
4486 * @param[in] message containing PMKID Info in the following format
4487 *|-----------------------------------------------------------------|
4488 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
4489 *|-----------|------------|----------|-------|----------|----------|
4490 | 1 | 6 | 16 | ... | 6 | 16 |
4491 ||-----------------------------------------------------------------|
4492 * @return Error code indicating success/failure
4493 * @note
4494 * @author zsalah
4495 * @date 8 March 2012
4496 * @version 1.0
4497 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004498s32 host_int_set_pmkid_info(struct host_if_drv *hif_drv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004499{
Leo Kime6e12662015-09-16 18:36:03 +09004500 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004501 struct host_if_msg msg;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004502 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004503
4504
Tony Choa4ab1ad2015-10-12 16:56:05 +09004505 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004506 s32Error = -EFAULT;
4507 PRINT_ER("driver is null\n");
4508 return s32Error;
4509 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004510
4511 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004512 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004513
Tony Choa9f812a2015-09-21 12:16:33 +09004514 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004515 msg.body.key_info.enuKeyType = PMKSA;
4516 msg.body.key_info.u8KeyAction = ADDKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004517 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004518
4519 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
4520
Tony Cho610e3862015-10-12 16:56:10 +09004521 memcpy(msg.body.key_info.uniHostIFkeyAttr.pmkid.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004522 ETH_ALEN);
4523
Tony Cho610e3862015-10-12 16:56:10 +09004524 memcpy(msg.body.key_info.uniHostIFkeyAttr.pmkid.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004525 PMKID_LEN);
4526 }
4527
4528 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004529 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004530 if (s32Error)
4531 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
4532
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004533 return s32Error;
4534}
4535
4536/**
4537 * @brief gets the cached the pmkid info
4538 * @details valid only in BSS STA mode if External Supplicant
4539 * support is enabled. This Function sets the PMKID in firmware
4540 * when host drivr receives the corresponding request from NDIS.
4541 * The firmware then includes theset PMKID in the appropriate
4542 * management frames
4543 * @param[in,out] handle to the wifi driver,
4544 * message containing PMKID Info in the following format
4545 *|-----------------------------------------------------------------|
4546 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
4547 *|-----------|------------|----------|-------|----------|----------|
4548 | 1 | 6 | 16 | ... | 6 | 16 |
4549 ||-----------------------------------------------------------------|
4550 * @param[in]
4551 * @return Error code indicating success/failure
4552 * @note
4553 * @author zsalah
4554 * @date 8 March 2012
4555 * @version 1.0
4556 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004557s32 host_int_get_pmkid_info(struct host_if_drv *hif_drv,
4558 u8 *pu8PmkidInfoArray,
4559 u32 u32PmkidInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004560{
Leo Kime9e0c262015-10-12 16:55:41 +09004561 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004562
Leo Kimdaaf16b2015-10-12 16:55:44 +09004563 strWID.id = (u16)WID_PMKID_INFO;
Leo Kim416d8322015-10-12 16:55:43 +09004564 strWID.type = WID_STR;
Leo Kim2fd3e442015-10-12 16:55:45 +09004565 strWID.size = u32PmkidInfoLen;
Leo Kim900bb4a2015-10-12 16:55:46 +09004566 strWID.val = pu8PmkidInfoArray;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004567
Leo Kimb68d820b2015-10-12 16:55:37 +09004568 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004569}
4570
4571/**
4572 * @brief sets the pass phrase
4573 * @details AP/STA mode. This function gives the pass phrase used to
4574 * generate the Pre-Shared Key when WPA/WPA2 is enabled
4575 * The length of the field can vary from 8 to 64 bytes,
4576 * the lower layer should get the
4577 * @param[in,out] handle to the wifi driver,
4578 * @param[in] String containing PSK
4579 * @return Error code indicating success/failure
4580 * @note
4581 * @author zsalah
4582 * @date 8 March 2012
4583 * @version 1.0
4584 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004585s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
4586 u8 *pu8PassPhrase,
4587 u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004588{
Leo Kime9e0c262015-10-12 16:55:41 +09004589 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004590
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004591 /*validating psk length*/
4592 if ((u8Psklength > 7) && (u8Psklength < 65)) {
Leo Kimdaaf16b2015-10-12 16:55:44 +09004593 strWID.id = (u16)WID_11I_PSK;
Leo Kim416d8322015-10-12 16:55:43 +09004594 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09004595 strWID.val = pu8PassPhrase;
Leo Kim2fd3e442015-10-12 16:55:45 +09004596 strWID.size = u8Psklength;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004597 }
4598
Leo Kimb68d820b2015-10-12 16:55:37 +09004599 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004600}
4601/**
4602 * @brief host_int_get_MacAddress
4603 * @details gets mac address
4604 * @param[in,out] handle to the wifi driver,
4605 *
4606 * @return Error code indicating success/failure
4607 * @note
4608 * @author mdaftedar
4609 * @date 19 April 2012
4610 * @version 1.0
4611 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004612s32 host_int_get_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004613{
Leo Kime6e12662015-09-16 18:36:03 +09004614 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004615 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004616
4617
4618 /* prepare the Message */
Tony Cho143eb952015-09-21 12:16:32 +09004619 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004620
Tony Choa9f812a2015-09-21 12:16:33 +09004621 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
Tony Choa5848692015-09-30 18:55:08 +09004622 msg.body.get_mac_info.u8MacAddress = pu8MacAddress;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004623 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004624 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004625 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004626 if (s32Error) {
4627 PRINT_ER("Failed to send get mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +09004628 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004629 }
4630
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004631 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004632 return s32Error;
4633}
4634
4635/**
4636 * @brief host_int_set_MacAddress
4637 * @details sets mac address
4638 * @param[in,out] handle to the wifi driver,
4639 *
4640 * @return Error code indicating success/failure
4641 * @note
4642 * @author mabubakr
4643 * @date 16 July 2012
4644 * @version 1.0
4645 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004646s32 host_int_set_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004647{
Leo Kime6e12662015-09-16 18:36:03 +09004648 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004649 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004650
4651 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
4652
4653 /* prepare setting mac address message */
Tony Cho143eb952015-09-21 12:16:32 +09004654 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09004655 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
Tony Cho15326e22015-09-30 18:55:07 +09004656 memcpy(msg.body.set_mac_info.u8MacAddress, pu8MacAddress, ETH_ALEN);
Tony Choa4ab1ad2015-10-12 16:56:05 +09004657 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004658
Tony Cho143eb952015-09-21 12:16:32 +09004659 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09004660 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004661 PRINT_ER("Failed to send message queue: Set mac address\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004662
4663 return s32Error;
4664
4665}
4666
4667/**
4668 * @brief host_int_get_RSNAConfigPSKPassPhrase
4669 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
4670 * generate the Pre-Shared Key when WPA/WPA2 is enabled
4671 * The length of the field can vary from 8 to 64 bytes,
4672 * the lower layer should get the
4673 * @param[in,out] handle to the wifi driver,
4674 * String containing PSK
4675 * @return Error code indicating success/failure
4676 * @note
4677 * @author zsalah
4678 * @date 8 March 2012
4679 * @version 1.0
4680 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004681s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
4682 u8 *pu8PassPhrase, u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004683{
Leo Kime9e0c262015-10-12 16:55:41 +09004684 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004685
Leo Kimdaaf16b2015-10-12 16:55:44 +09004686 strWID.id = (u16)WID_11I_PSK;
Leo Kim416d8322015-10-12 16:55:43 +09004687 strWID.type = WID_STR;
Leo Kim2fd3e442015-10-12 16:55:45 +09004688 strWID.size = u8Psklength;
Leo Kim900bb4a2015-10-12 16:55:46 +09004689 strWID.val = pu8PassPhrase;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004690
Leo Kimb68d820b2015-10-12 16:55:37 +09004691 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004692}
4693
4694/**
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004695 * @brief sets a start scan request
4696 * @details
4697 * @param[in,out] handle to the wifi driver,
4698 * @param[in] Scan Source one of the following values
4699 * DEFAULT_SCAN 0
4700 * USER_SCAN BIT0
4701 * OBSS_PERIODIC_SCAN BIT1
4702 * OBSS_ONETIME_SCAN BIT2
4703 * @return Error code indicating success/failure
4704 * @note
4705 * @author zsalah
4706 * @date 8 March 2012
4707 * @version 1.0
4708 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004709s32 host_int_set_start_scan_req(struct host_if_drv *hif_drv, u8 scanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004710{
Leo Kime9e0c262015-10-12 16:55:41 +09004711 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004712
Leo Kimdaaf16b2015-10-12 16:55:44 +09004713 strWID.id = (u16)WID_START_SCAN_REQ;
Leo Kim416d8322015-10-12 16:55:43 +09004714 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09004715 strWID.val = (s8 *)&scanSource;
Leo Kim2fd3e442015-10-12 16:55:45 +09004716 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004717
Leo Kimb68d820b2015-10-12 16:55:37 +09004718 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004719}
4720
4721/**
4722 * @brief host_int_get_start_scan_req
4723 * @details gets a start scan request
4724 * @param[in,out] handle to the wifi driver,
4725 * @param[in] Scan Source one of the following values
4726 * DEFAULT_SCAN 0
4727 * USER_SCAN BIT0
4728 * OBSS_PERIODIC_SCAN BIT1
4729 * OBSS_ONETIME_SCAN BIT2
4730 * @return Error code indicating success/failure
4731 * @note
4732 * @author zsalah
4733 * @date 8 March 2012
4734 * @version 1.0
4735 */
4736
Tony Choa4ab1ad2015-10-12 16:56:05 +09004737s32 host_int_get_start_scan_req(struct host_if_drv *hif_drv, u8 *pu8ScanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004738{
Leo Kime9e0c262015-10-12 16:55:41 +09004739 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004740
Leo Kimdaaf16b2015-10-12 16:55:44 +09004741 strWID.id = (u16)WID_START_SCAN_REQ;
Leo Kim416d8322015-10-12 16:55:43 +09004742 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09004743 strWID.val = (s8 *)pu8ScanSource;
Leo Kim2fd3e442015-10-12 16:55:45 +09004744 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004745
Leo Kimb68d820b2015-10-12 16:55:37 +09004746 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004747}
4748
4749/**
4750 * @brief host_int_set_join_req
4751 * @details sets a join request
4752 * @param[in,out] handle to the wifi driver,
4753 * @param[in] Index of the bss descriptor
4754 * @return Error code indicating success/failure
4755 * @note
4756 * @author zsalah
4757 * @date 8 March 2012
4758 * @version 1.0
4759 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004760s32 host_int_set_join_req(struct host_if_drv *hif_drv, u8 *pu8bssid,
4761 const u8 *pu8ssid, size_t ssidLen,
4762 const u8 *pu8IEs, size_t IEsLen,
4763 wilc_connect_result pfConnectResult, void *pvUserArg,
4764 u8 u8security, enum AUTHTYPE tenuAuth_type,
4765 u8 u8channel, void *pJoinParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004766{
Leo Kime6e12662015-09-16 18:36:03 +09004767 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004768 struct host_if_msg msg;
Leo Kim7696edf2015-10-12 16:56:02 +09004769 enum scan_conn_timer enuScanConnTimer;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004770
Tony Choa4ab1ad2015-10-12 16:56:05 +09004771 if (!hif_drv || pfConnectResult == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09004772 s32Error = -EFAULT;
4773 PRINT_ER("Driver is null\n");
4774 return s32Error;
4775 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004776
Tony Choa4ab1ad2015-10-12 16:56:05 +09004777 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004778 PRINT_ER("Driver is null\n");
4779 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004780 }
4781
4782 if (pJoinParams == NULL) {
4783 PRINT_ER("Unable to Join - JoinParams is NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09004784 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004785 }
Leo Kim24db7132015-09-16 18:36:01 +09004786
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004787 /* prepare the Connect Message */
Tony Cho143eb952015-09-21 12:16:32 +09004788 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004789
Tony Choa9f812a2015-09-21 12:16:33 +09004790 msg.id = HOST_IF_MSG_CONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004791
Tony Cho3f501972015-09-30 18:44:21 +09004792 msg.body.con_info.u8security = u8security;
4793 msg.body.con_info.tenuAuth_type = tenuAuth_type;
4794 msg.body.con_info.u8channel = u8channel;
4795 msg.body.con_info.pfConnectResult = pfConnectResult;
4796 msg.body.con_info.pvUserArg = pvUserArg;
4797 msg.body.con_info.pJoinParams = pJoinParams;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004798 msg.drv = hif_drv ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004799
4800 if (pu8bssid != NULL) {
Tony Cho3f501972015-09-30 18:44:21 +09004801 msg.body.con_info.pu8bssid = kmalloc(6, GFP_KERNEL); /* will be deallocated by the receiving thread */
4802 memcpy(msg.body.con_info.pu8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004803 pu8bssid, 6);
4804 }
4805
4806 if (pu8ssid != NULL) {
Tony Cho3f501972015-09-30 18:44:21 +09004807 msg.body.con_info.ssidLen = ssidLen;
4808 msg.body.con_info.pu8ssid = kmalloc(ssidLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
4809 memcpy(msg.body.con_info.pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004810
4811 pu8ssid, ssidLen);
4812 }
4813
4814 if (pu8IEs != NULL) {
Tony Cho3f501972015-09-30 18:44:21 +09004815 msg.body.con_info.IEsLen = IEsLen;
4816 msg.body.con_info.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
4817 memcpy(msg.body.con_info.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004818 pu8IEs, IEsLen);
4819 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09004820 if (hif_drv->enuHostIFstate < HOST_IF_CONNECTING)
4821 hif_drv->enuHostIFstate = HOST_IF_CONNECTING;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05304822 else
Tony Choa4ab1ad2015-10-12 16:56:05 +09004823 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", hif_drv->enuHostIFstate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004824
4825 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004826 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004827 if (s32Error) {
4828 PRINT_ER("Failed to send message queue: Set join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09004829 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004830 }
4831
4832 enuScanConnTimer = CONNECT_TIMER;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004833 hif_drv->hConnectTimer.data = (unsigned long)hif_drv;
4834 mod_timer(&hif_drv->hConnectTimer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07004835 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004836
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004837 return s32Error;
4838}
4839
4840/**
4841 * @brief Flush a join request parameters to FW, but actual connection
4842 * @details The function is called in situation where WILC is connected to AP and
4843 * required to switch to hybrid FW for P2P connection
4844 * @param[in] handle to the wifi driver,
4845 * @return Error code indicating success/failure
4846 * @note
4847 * @author Amr Abdel-Moghny
4848 * @date 19 DEC 2013
4849 * @version 8.0
4850 */
4851
Tony Choa4ab1ad2015-10-12 16:56:05 +09004852s32 host_int_flush_join_req(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004853{
Leo Kime6e12662015-09-16 18:36:03 +09004854 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004855 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004856
4857 if (!gu8FlushedJoinReq) {
Leo Kime6e12662015-09-16 18:36:03 +09004858 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004859 return s32Error;
4860 }
4861
4862
Tony Choa4ab1ad2015-10-12 16:56:05 +09004863 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004864 s32Error = -EFAULT;
4865 PRINT_ER("Driver is null\n");
4866 return s32Error;
4867 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004868
Tony Choa9f812a2015-09-21 12:16:33 +09004869 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004870 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004871
4872 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004873 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004874 if (s32Error) {
4875 PRINT_ER("Failed to send message queue: Flush join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09004876 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004877 }
4878
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004879 return s32Error;
4880}
4881
4882/**
4883 * @brief host_int_disconnect
4884 * @details disconnects from the currently associated network
4885 * @param[in,out] handle to the wifi driver,
4886 * @param[in] Reason Code of the Disconnection
4887 * @return Error code indicating success/failure
4888 * @note
4889 * @author zsalah
4890 * @date 8 March 2012
4891 * @version 1.0
4892 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004893s32 host_int_disconnect(struct host_if_drv *hif_drv, u16 u16ReasonCode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004894{
Leo Kime6e12662015-09-16 18:36:03 +09004895 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004896 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004897
Tony Choa4ab1ad2015-10-12 16:56:05 +09004898 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004899 PRINT_ER("Driver is null\n");
4900 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004901 }
4902
4903 /* prepare the Disconnect Message */
Tony Cho143eb952015-09-21 12:16:32 +09004904 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004905
Tony Choa9f812a2015-09-21 12:16:33 +09004906 msg.id = HOST_IF_MSG_DISCONNECT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004907 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004908
4909 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004910 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004911 if (s32Error)
4912 PRINT_ER("Failed to send message queue: disconnect\n");
4913 /* ////////////// */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004914 down(&hif_drv->hSemTestDisconnectBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004915 /* /////// */
4916
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004917 return s32Error;
4918}
4919
4920/**
4921 * @brief host_int_disconnect_station
4922 * @details disconnects a sta
4923 * @param[in,out] handle to the wifi driver,
4924 * @param[in] Association Id of the station to be disconnected
4925 * @return Error code indicating success/failure
4926 * @note
4927 * @author zsalah
4928 * @date 8 March 2012
4929 * @version 1.0
4930 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004931s32 host_int_disconnect_station(struct host_if_drv *hif_drv, u8 assoc_id)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004932{
Leo Kime9e0c262015-10-12 16:55:41 +09004933 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004934
Leo Kimdaaf16b2015-10-12 16:55:44 +09004935 strWID.id = (u16)WID_DISCONNECT;
Leo Kim416d8322015-10-12 16:55:43 +09004936 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09004937 strWID.val = (s8 *)&assoc_id;
Leo Kim2fd3e442015-10-12 16:55:45 +09004938 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004939
Leo Kimb68d820b2015-10-12 16:55:37 +09004940 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004941}
4942
4943/**
4944 * @brief host_int_get_assoc_req_info
4945 * @details gets a Association request info
4946 * @param[in,out] handle to the wifi driver,
4947 * Message containg assoc. req info in the following format
4948 * ------------------------------------------------------------------------
4949 | Management Frame Format |
4950 ||-------------------------------------------------------------------|
4951 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
4952 ||-------------|--------|--|--|-----|----------------|----------|----|
4953 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
4954 ||-------------------------------------------------------------------|
4955 | |
4956 | Association Request Frame - Frame Body |
4957 ||-------------------------------------------------------------------|
4958 | Capability Information | Listen Interval | SSID | Supported Rates |
4959 ||------------------------|-----------------|------|-----------------|
4960 | 2 | 2 | 2-34 | 3-10 |
4961 | ---------------------------------------------------------------------
4962 * @return Error code indicating success/failure
4963 * @note
4964 * @author zsalah
4965 * @date 8 March 2012
4966 * @version 1.0
4967 */
4968
Tony Choa4ab1ad2015-10-12 16:56:05 +09004969s32 host_int_get_assoc_req_info(struct host_if_drv *hif_drv, u8 *pu8AssocReqInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004970 u32 u32AssocReqInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004971{
Leo Kime9e0c262015-10-12 16:55:41 +09004972 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004973
Leo Kimdaaf16b2015-10-12 16:55:44 +09004974 strWID.id = (u16)WID_ASSOC_REQ_INFO;
Leo Kim416d8322015-10-12 16:55:43 +09004975 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09004976 strWID.val = pu8AssocReqInfo;
Leo Kim2fd3e442015-10-12 16:55:45 +09004977 strWID.size = u32AssocReqInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004978
Leo Kimb68d820b2015-10-12 16:55:37 +09004979 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004980}
4981
4982/**
4983 * @brief gets a Association Response info
4984 * @details
4985 * @param[in,out] handle to the wifi driver,
4986 * Message containg assoc. resp info
4987 * @return Error code indicating success/failure
4988 * @note
4989 * @author zsalah
4990 * @date 8 March 2012
4991 * @version 1.0
4992 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004993s32 host_int_get_assoc_res_info(struct host_if_drv *hif_drv, u8 *pu8AssocRespInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004994 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004995{
Leo Kime6e12662015-09-16 18:36:03 +09004996 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09004997 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004998
Tony Choa4ab1ad2015-10-12 16:56:05 +09004999 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005000 PRINT_ER("Driver is null\n");
5001 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005002 }
5003
Leo Kimdaaf16b2015-10-12 16:55:44 +09005004 strWID.id = (u16)WID_ASSOC_RES_INFO;
Leo Kim416d8322015-10-12 16:55:43 +09005005 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09005006 strWID.val = pu8AssocRespInfo;
Leo Kim2fd3e442015-10-12 16:55:45 +09005007 strWID.size = u32MaxAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005008
5009
5010 /* Sending Configuration packet */
Tony Cho03362282015-10-12 16:55:39 +09005011 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09005012 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005013 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005014 *pu32RcvdAssocRespInfoLen = 0;
Leo Kim24db7132015-09-16 18:36:01 +09005015 PRINT_ER("Failed to send association response config packet\n");
5016 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005017 } else {
Leo Kim2fd3e442015-10-12 16:55:45 +09005018 *pu32RcvdAssocRespInfoLen = strWID.size;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005019 }
5020
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005021 return s32Error;
5022}
5023
5024/**
5025 * @brief gets a Association Response info
5026 * @details Valid only in STA mode. This function gives the RSSI
5027 * values observed in all the channels at the time of scanning.
5028 * The length of the field is 1 greater that the total number of
5029 * channels supported. Byte 0 contains the number of channels while
5030 * each of Byte N contains the observed RSSI value for the channel index N.
5031 * @param[in,out] handle to the wifi driver,
5032 * array of scanned channels' RSSI
5033 * @return Error code indicating success/failure
5034 * @note
5035 * @author zsalah
5036 * @date 8 March 2012
5037 * @version 1.0
5038 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005039s32 host_int_get_rx_power_level(struct host_if_drv *hif_drv, u8 *pu8RxPowerLevel,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005040 u32 u32RxPowerLevelLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005041{
Leo Kime9e0c262015-10-12 16:55:41 +09005042 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005043
Leo Kimdaaf16b2015-10-12 16:55:44 +09005044 strWID.id = (u16)WID_RX_POWER_LEVEL;
Leo Kim416d8322015-10-12 16:55:43 +09005045 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09005046 strWID.val = pu8RxPowerLevel;
Leo Kim2fd3e442015-10-12 16:55:45 +09005047 strWID.size = u32RxPowerLevelLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005048
Leo Kimb68d820b2015-10-12 16:55:37 +09005049 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005050}
5051
5052/**
5053 * @brief sets a channel
5054 * @details
5055 * @param[in,out] handle to the wifi driver,
5056 * @param[in] Index of the channel to be set
5057 *|-------------------------------------------------------------------|
5058 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5059 | Input: 1 2 14 |
5060 ||-------------------------------------------------------------------|
5061 * @return Error code indicating success/failure
5062 * @note
5063 * @author zsalah
5064 * @date 8 March 2012
5065 * @version 1.0
5066 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005067int host_int_set_mac_chnl_num(struct host_if_drv *hif_drv, u8 channel)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005068{
Chaehyun Lim792fb252015-10-05 11:07:22 +09005069 int result;
Tony Cho143eb952015-09-21 12:16:32 +09005070 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005071
Tony Choa4ab1ad2015-10-12 16:56:05 +09005072 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005073 PRINT_ER("driver is null\n");
5074 return -EFAULT;
5075 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005076
5077 /* prepare the set channel message */
Tony Cho143eb952015-09-21 12:16:32 +09005078 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005079 msg.id = HOST_IF_MSG_SET_CHANNEL;
Chaehyun Lim1c5833c2015-10-02 21:44:51 +09005080 msg.body.channel_info.u8SetChan = channel;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005081 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005082
Chaehyun Lim1ef58e42015-10-02 21:44:49 +09005083 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5084 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09005085 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim792fb252015-10-05 11:07:22 +09005086 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005087 }
5088
Chaehyun Lim792fb252015-10-05 11:07:22 +09005089 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005090}
5091
Chaehyun Lim244efb12015-10-02 21:44:53 +09005092int host_int_wait_msg_queue_idle(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005093{
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09005094 int result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005095
Tony Cho143eb952015-09-21 12:16:32 +09005096 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005097
5098 /* prepare the set driver handler message */
5099
Tony Cho143eb952015-09-21 12:16:32 +09005100 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005101 msg.id = HOST_IF_MSG_Q_IDLE;
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09005102 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5103 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09005104 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09005105 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005106 }
5107
5108 /* wait untill MSG Q is empty */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005109 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005110
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09005111 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005112}
5113
Tony Choa4ab1ad2015-10-12 16:56:05 +09005114int host_int_set_wfi_drv_handler(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005115{
Chaehyun Lima0941012015-10-05 19:34:47 +09005116 int result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005117
Tony Cho143eb952015-09-21 12:16:32 +09005118 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005119
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005120 /* prepare the set driver handler message */
5121
Tony Cho143eb952015-09-21 12:16:32 +09005122 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005123 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005124 msg.body.drv.u32Address = get_id_from_handler(hif_drv);
5125 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005126
Chaehyun Lima0941012015-10-05 19:34:47 +09005127 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5128 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09005129 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0941012015-10-05 19:34:47 +09005130 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005131 }
5132
Chaehyun Lima0941012015-10-05 19:34:47 +09005133 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005134}
5135
Tony Choa4ab1ad2015-10-12 16:56:05 +09005136int host_int_set_operation_mode(struct host_if_drv *hif_drv, u32 mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005137{
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09005138 int result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005139
Tony Cho143eb952015-09-21 12:16:32 +09005140 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005141
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005142 /* prepare the set driver handler message */
5143
Tony Cho143eb952015-09-21 12:16:32 +09005144 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005145 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
Chaehyun Lim49fb6f72015-10-05 19:34:52 +09005146 msg.body.mode.u32Mode = mode;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005147 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005148
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09005149 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5150 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09005151 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09005152 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005153 }
5154
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09005155 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005156}
5157
5158/**
5159 * @brief gets the current channel index
5160 * @details
5161 * @param[in,out] handle to the wifi driver,
5162 * current channel index
5163 *|-----------------------------------------------------------------------|
5164 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5165 | Input: 1 2 14 |
5166 ||-----------------------------------------------------------------------|
5167 * @return Error code indicating success/failure
5168 * @note
5169 * @author zsalah
5170 * @date 8 March 2012
5171 * @version 1.0
5172 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005173s32 host_int_get_host_chnl_num(struct host_if_drv *hif_drv, u8 *pu8ChNo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005174{
Leo Kime6e12662015-09-16 18:36:03 +09005175 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005176 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005177
Tony Choa4ab1ad2015-10-12 16:56:05 +09005178 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005179 PRINT_ER("driver is null\n");
5180 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005181 }
5182
5183 /* prepare the Get Channel Message */
Tony Cho143eb952015-09-21 12:16:32 +09005184 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005185
Tony Choa9f812a2015-09-21 12:16:33 +09005186 msg.id = HOST_IF_MSG_GET_CHNL;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005187 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005188
5189 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005190 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005191 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09005192 PRINT_ER("wilc mq send fail\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09005193 down(&hif_drv->hSemGetCHNL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005194 /* gu8Chnl = 11; */
5195
5196 *pu8ChNo = gu8Chnl;
5197
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005198 return s32Error;
5199
5200
5201}
5202
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005203/**
5204 * @brief host_int_get_inactive_time
5205 * @details
5206 * @param[in,out] handle to the wifi driver,
5207 * current sta macaddress, inactive_time
5208 * @return
5209 * @note
5210 * @author
5211 * @date
5212 * @version 1.0
5213 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005214s32 host_int_get_inactive_time(struct host_if_drv *hif_drv,
5215 const u8 *mac, u32 *pu32InactiveTime)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005216{
Leo Kime6e12662015-09-16 18:36:03 +09005217 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005218 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005219
Tony Choa4ab1ad2015-10-12 16:56:05 +09005220 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005221 PRINT_ER("driver is null\n");
5222 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005223 }
5224
Tony Cho143eb952015-09-21 12:16:32 +09005225 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005226
5227
Tony Cho66bac7f2015-09-30 18:44:37 +09005228 memcpy(msg.body.mac_info.mac,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005229 mac, ETH_ALEN);
5230
Tony Choa9f812a2015-09-21 12:16:33 +09005231 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005232 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005233
5234 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005235 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005236 if (s32Error)
5237 PRINT_ER("Failed to send get host channel param's message queue ");
5238
Tony Choa4ab1ad2015-10-12 16:56:05 +09005239 down(&hif_drv->hSemInactiveTime);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005240
5241 *pu32InactiveTime = gu32InactiveTime;
5242
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005243 return s32Error;
5244}
Glen Lee108b3432015-09-16 18:53:20 +09005245
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005246/**
5247 * @brief host_int_test_get_int_wid
5248 * @details Test function for getting wids
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005249 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005250 * @return Error code indicating success/failure
5251 * @note
5252 * @author zsalah
5253 * @date 8 March 2012
5254 * @version 1.0
5255 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005256s32 host_int_test_get_int_wid(struct host_if_drv *hif_drv, u32 *pu32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005257{
5258
Leo Kime6e12662015-09-16 18:36:03 +09005259 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09005260 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005261
Tony Choa4ab1ad2015-10-12 16:56:05 +09005262 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005263 PRINT_ER("driver is null\n");
5264 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005265 }
5266
Leo Kimdaaf16b2015-10-12 16:55:44 +09005267 strWID.id = (u16)WID_MEMORY_ADDRESS;
Leo Kim416d8322015-10-12 16:55:43 +09005268 strWID.type = WID_INT;
Leo Kim900bb4a2015-10-12 16:55:46 +09005269 strWID.val = (s8 *)pu32TestMemAddr;
Leo Kim2fd3e442015-10-12 16:55:45 +09005270 strWID.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005271
Tony Cho03362282015-10-12 16:55:39 +09005272 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09005273 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005274 /*get the value by searching the local copy*/
5275 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09005276 PRINT_ER("Failed to get wid value\n");
5277 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005278 } else {
5279 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
5280
5281 }
5282
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005283 return s32Error;
5284}
5285
5286
5287/**
5288 * @brief host_int_get_rssi
5289 * @details gets the currently maintained RSSI value for the station.
5290 * The received signal strength value in dB.
5291 * The range of valid values is -128 to 0.
5292 * @param[in,out] handle to the wifi driver,
5293 * rssi value in dB
5294 * @return Error code indicating success/failure
5295 * @note
5296 * @author zsalah
5297 * @date 8 March 2012
5298 * @version 1.0
5299 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005300s32 host_int_get_rssi(struct host_if_drv *hif_drv, s8 *ps8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005301{
Leo Kime6e12662015-09-16 18:36:03 +09005302 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005303 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005304
5305 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09005306 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005307
Tony Choa9f812a2015-09-21 12:16:33 +09005308 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005309 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005310
5311 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005312 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005313 if (s32Error) {
5314 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005315 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005316 }
5317
Tony Choa4ab1ad2015-10-12 16:56:05 +09005318 down(&hif_drv->hSemGetRSSI);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005319
5320
5321 if (ps8Rssi == NULL) {
5322 PRINT_ER("RSS pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09005323 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005324 }
5325
5326
5327 *ps8Rssi = gs8Rssi;
5328
5329
5330 return s32Error;
5331}
5332
Tony Choa4ab1ad2015-10-12 16:56:05 +09005333s32 host_int_get_link_speed(struct host_if_drv *hif_drv, s8 *ps8lnkspd)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005334{
Tony Cho143eb952015-09-21 12:16:32 +09005335 struct host_if_msg msg;
Leo Kime6e12662015-09-16 18:36:03 +09005336 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005337
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005338 /* prepare the Get LINKSPEED Message */
Tony Cho143eb952015-09-21 12:16:32 +09005339 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005340
Tony Choa9f812a2015-09-21 12:16:33 +09005341 msg.id = HOST_IF_MSG_GET_LINKSPEED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005342 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005343
5344 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005345 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005346 if (s32Error) {
5347 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005348 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005349 }
5350
Tony Choa4ab1ad2015-10-12 16:56:05 +09005351 down(&hif_drv->hSemGetLINKSPEED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005352
5353
5354 if (ps8lnkspd == NULL) {
5355 PRINT_ER("LINKSPEED pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09005356 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005357 }
5358
5359
5360 *ps8lnkspd = gs8lnkspd;
5361
5362
5363 return s32Error;
5364}
5365
Tony Choa4ab1ad2015-10-12 16:56:05 +09005366s32 host_int_get_statistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005367{
Leo Kime6e12662015-09-16 18:36:03 +09005368 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005369 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005370
5371
5372 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09005373 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005374
Tony Choa9f812a2015-09-21 12:16:33 +09005375 msg.id = HOST_IF_MSG_GET_STATISTICS;
Tony Choe60831e2015-10-05 13:50:45 +09005376 msg.body.data = (char *)pstrStatistics;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005377 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005378 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005379 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005380 if (s32Error) {
5381 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005382 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005383 }
5384
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005385 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005386 return s32Error;
5387}
5388
5389
5390/**
5391 * @brief host_int_scan
5392 * @details scans a set of channels
5393 * @param[in,out] handle to the wifi driver,
5394 * @param[in] Scan source
5395 * Scan Type PASSIVE_SCAN = 0,
5396 * ACTIVE_SCAN = 1
5397 * Channels Array
5398 * Channels Array length
5399 * Scan Callback function
5400 * @return Error code indicating success/failure
5401 * @note
5402 * @author zsalah
5403 * @date 8 March 2012
5404 * @version 1.0
5405 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005406s32 host_int_scan(struct host_if_drv *hif_drv, u8 u8ScanSource,
5407 u8 u8ScanType, u8 *pu8ChnlFreqList,
5408 u8 u8ChnlListLen, const u8 *pu8IEs,
5409 size_t IEsLen, wilc_scan_result ScanResult,
5410 void *pvUserArg, struct hidden_network *pstrHiddenNetwork)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005411{
Leo Kime6e12662015-09-16 18:36:03 +09005412 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005413 struct host_if_msg msg;
Leo Kim7696edf2015-10-12 16:56:02 +09005414 enum scan_conn_timer enuScanConnTimer;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005415
Tony Choa4ab1ad2015-10-12 16:56:05 +09005416 if (!hif_drv || ScanResult == NULL) {
5417 PRINT_ER("hif_drv or ScanResult = NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09005418 return -EFAULT;
5419 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005420
5421 /* prepare the Scan Message */
Tony Cho143eb952015-09-21 12:16:32 +09005422 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005423
Tony Choa9f812a2015-09-21 12:16:33 +09005424 msg.id = HOST_IF_MSG_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005425
5426 if (pstrHiddenNetwork != NULL) {
Tony Cho4528bdb2015-09-30 18:44:20 +09005427 msg.body.scan_info.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
5428 msg.body.scan_info.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005429
5430 } else
5431 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
5432
Tony Choa4ab1ad2015-10-12 16:56:05 +09005433 msg.drv = hif_drv;
Tony Cho4528bdb2015-09-30 18:44:20 +09005434 msg.body.scan_info.u8ScanSource = u8ScanSource;
5435 msg.body.scan_info.u8ScanType = u8ScanType;
5436 msg.body.scan_info.pfScanResult = ScanResult;
5437 msg.body.scan_info.pvUserArg = pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005438
Tony Cho4528bdb2015-09-30 18:44:20 +09005439 msg.body.scan_info.u8ChnlListLen = u8ChnlListLen;
5440 msg.body.scan_info.pu8ChnlFreqList = kmalloc(u8ChnlListLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5441 memcpy(msg.body.scan_info.pu8ChnlFreqList,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005442 pu8ChnlFreqList, u8ChnlListLen);
5443
Tony Cho4528bdb2015-09-30 18:44:20 +09005444 msg.body.scan_info.IEsLen = IEsLen;
5445 msg.body.scan_info.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5446 memcpy(msg.body.scan_info.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005447 pu8IEs, IEsLen);
5448
5449 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005450 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005451 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09005452 PRINT_ER("Error in sending message queue\n");
5453 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005454 }
5455
5456 enuScanConnTimer = SCAN_TIMER;
5457 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09005458 hif_drv->hScanTimer.data = (unsigned long)hif_drv;
5459 mod_timer(&hif_drv->hScanTimer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005460 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005461
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005462 return s32Error;
5463
5464}
5465/**
5466 * @brief hif_set_cfg
5467 * @details sets configuration wids values
5468 * @param[in,out] handle to the wifi driver,
5469 * @param[in] WID, WID value
5470 * @return Error code indicating success/failure
5471 * @note
5472 * @author zsalah
5473 * @date 8 March 2012
5474 * @version 1.0
5475 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005476s32 hif_set_cfg(struct host_if_drv *hif_drv,
5477 struct cfg_param_val *pstrCfgParamVal)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005478{
5479
Leo Kime6e12662015-09-16 18:36:03 +09005480 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005481 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005482
5483
Tony Choa4ab1ad2015-10-12 16:56:05 +09005484 if (!hif_drv) {
5485 PRINT_ER("hif_drv NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09005486 return -EFAULT;
5487 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005488 /* prepare the WiphyParams Message */
Tony Cho143eb952015-09-21 12:16:32 +09005489 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005490 msg.id = HOST_IF_MSG_CFG_PARAMS;
Tony Cho221371e2015-10-12 16:56:06 +09005491 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005492 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005493
Tony Cho143eb952015-09-21 12:16:32 +09005494 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005495
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005496 return s32Error;
5497
5498}
5499
5500
5501/**
5502 * @brief hif_get_cfg
5503 * @details gets configuration wids values
5504 * @param[in,out] handle to the wifi driver,
5505 * WID value
5506 * @param[in] WID,
5507 * @return Error code indicating success/failure
5508 * @note
5509 * @author zsalah
5510 *
5511 * @date 8 March 2012
5512 * @version 1.0
5513 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005514s32 hif_get_cfg(struct host_if_drv *hif_drv, u16 u16WID, u16 *pu16WID_Value)
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
Tony Choa4ab1ad2015-10-12 16:56:05 +09005518 down(&hif_drv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005519
Tony Choa4ab1ad2015-10-12 16:56:05 +09005520 if (!hif_drv) {
5521 PRINT_ER("hif_drv NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09005522 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005523 }
5524 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
5525 switch (u16WID) {
5526
5527 case WID_BSS_TYPE:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005528 *pu16WID_Value = (u16)hif_drv->strCfgValues.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005529 break;
5530
5531 case WID_AUTH_TYPE:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005532 *pu16WID_Value = (u16)hif_drv->strCfgValues.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005533 break;
5534
5535 case WID_AUTH_TIMEOUT:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005536 *pu16WID_Value = hif_drv->strCfgValues.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005537 break;
5538
5539 case WID_POWER_MANAGEMENT:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005540 *pu16WID_Value = (u16)hif_drv->strCfgValues.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005541 break;
5542
5543 case WID_SHORT_RETRY_LIMIT:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005544 *pu16WID_Value = hif_drv->strCfgValues.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005545 break;
5546
5547 case WID_LONG_RETRY_LIMIT:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005548 *pu16WID_Value = hif_drv->strCfgValues.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005549 break;
5550
5551 case WID_FRAG_THRESHOLD:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005552 *pu16WID_Value = hif_drv->strCfgValues.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005553 break;
5554
5555 case WID_RTS_THRESHOLD:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005556 *pu16WID_Value = hif_drv->strCfgValues.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005557 break;
5558
5559 case WID_PREAMBLE:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005560 *pu16WID_Value = (u16)hif_drv->strCfgValues.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005561 break;
5562
5563 case WID_SHORT_SLOT_ALLOWED:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005564 *pu16WID_Value = (u16) hif_drv->strCfgValues.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005565 break;
5566
5567 case WID_11N_TXOP_PROT_DISABLE:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005568 *pu16WID_Value = (u16)hif_drv->strCfgValues.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005569 break;
5570
5571 case WID_BEACON_INTERVAL:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005572 *pu16WID_Value = hif_drv->strCfgValues.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005573 break;
5574
5575 case WID_DTIM_PERIOD:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005576 *pu16WID_Value = (u16)hif_drv->strCfgValues.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005577 break;
5578
5579 case WID_SITE_SURVEY:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005580 *pu16WID_Value = (u16)hif_drv->strCfgValues.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005581 break;
5582
5583 case WID_SITE_SURVEY_SCAN_TIME:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005584 *pu16WID_Value = hif_drv->strCfgValues.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005585 break;
5586
5587 case WID_ACTIVE_SCAN_TIME:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005588 *pu16WID_Value = hif_drv->strCfgValues.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005589 break;
5590
5591 case WID_PASSIVE_SCAN_TIME:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005592 *pu16WID_Value = hif_drv->strCfgValues.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005593 break;
5594
5595 case WID_CURRENT_TX_RATE:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005596 *pu16WID_Value = hif_drv->strCfgValues.curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005597 break;
5598
5599 default:
5600 break;
5601 }
5602
Tony Choa4ab1ad2015-10-12 16:56:05 +09005603 up(&hif_drv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005604
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005605 return s32Error;
5606
5607}
5608
5609/*****************************************************************************/
5610/* Notification Functions */
5611/*****************************************************************************/
5612/**
5613 * @brief notifies host with join and leave requests
5614 * @details This function prepares an Information frame having the
5615 * information about a joining/leaving station.
5616 * @param[in,out] handle to the wifi driver,
5617 * @param[in] 6 byte Sta Adress
5618 * Join or leave flag:
5619 * Join = 1,
5620 * Leave =0
5621 * @return Error code indicating success/failure
5622 * @note
5623 * @author zsalah
5624 * @date 8 March 2012
5625 * @version 1.0
5626 */
5627void host_int_send_join_leave_info_to_host
Dean Lee72ed4dc2015-06-12 14:11:44 +09005628 (u16 assocId, u8 *stationAddr, bool joining)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005629{
5630}
5631/**
5632 * @brief notifies host with stations found in scan
5633 * @details sends the beacon/probe response from scan
5634 * @param[in,out] handle to the wifi driver,
5635 * @param[in] Sta Address,
5636 * Frame length,
5637 * Rssi of the Station found
5638 * @return Error code indicating success/failure
5639 * @note
5640 * @author zsalah
5641 * @date 8 March 2012
5642 * @version 1.0
5643 */
5644
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07005645static void GetPeriodicRSSI(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005646{
Tony Choa4ab1ad2015-10-12 16:56:05 +09005647 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02005648
Tony Choa4ab1ad2015-10-12 16:56:05 +09005649 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005650 PRINT_ER("Driver handler is NULL\n");
5651 return;
5652 }
5653
Tony Choa4ab1ad2015-10-12 16:56:05 +09005654 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) {
Leo Kime6e12662015-09-16 18:36:03 +09005655 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005656 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005657
5658 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09005659 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005660
Tony Choa9f812a2015-09-21 12:16:33 +09005661 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005662 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005663
5664 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005665 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005666 if (s32Error) {
5667 PRINT_ER("Failed to send get host channel param's message queue ");
5668 return;
5669 }
5670 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09005671 g_hPeriodicRSSI.data = (unsigned long)hif_drv;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005672 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005673}
5674
5675
5676void host_int_send_network_info_to_host
Chaehyun Limca356ad2015-06-11 14:35:57 +09005677 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005678{
5679}
5680/**
5681 * @brief host_int_init
5682 * @details host interface initialization function
5683 * @param[in,out] handle to the wifi driver,
5684 * @note
5685 * @author zsalah
5686 * @date 8 March 2012
5687 * @version 1.0
5688 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005689static u32 clients_count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005690
Tony Choa4ab1ad2015-10-12 16:56:05 +09005691s32 host_int_init(struct host_if_drv **hif_drv_handler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005692{
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09005693 s32 result = 0;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005694 struct host_if_drv *hif_drv;
Johnny Kimd42ab082015-08-20 16:32:52 +09005695 int err;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005696
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005697 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
5698
Dean Lee72ed4dc2015-06-12 14:11:44 +09005699 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005700
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005701 sema_init(&hWaitResponse, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005702
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005703 /*Allocate host interface private structure*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09005704 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
5705 if (!hif_drv) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09005706 result = -ENOMEM;
Vincent Stehlé17db84e2015-10-07 07:08:25 +02005707 goto _fail_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005708 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09005709 *hif_drv_handler = hif_drv;
5710 err = add_handler_in_list(hif_drv);
Johnny Kimd42ab082015-08-20 16:32:52 +09005711 if (err) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09005712 result = -EFAULT;
Johnny Kimd42ab082015-08-20 16:32:52 +09005713 goto _fail_timer_2;
5714 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005715
Dean Lee72ed4dc2015-06-12 14:11:44 +09005716 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005717
Tony Choa4ab1ad2015-10-12 16:56:05 +09005718 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005719 if (clients_count == 0) {
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005720 sema_init(&hSemHostIFthrdEnd, 0);
5721 sema_init(&hSemDeinitDrvHandle, 0);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005722 sema_init(&hSemHostIntDeinit, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005723 }
5724
Tony Choa4ab1ad2015-10-12 16:56:05 +09005725 sema_init(&hif_drv->hSemTestKeyBlock, 0);
5726 sema_init(&hif_drv->hSemTestDisconnectBlock, 0);
5727 sema_init(&hif_drv->hSemGetRSSI, 0);
5728 sema_init(&hif_drv->hSemGetLINKSPEED, 0);
5729 sema_init(&hif_drv->hSemGetCHNL, 0);
5730 sema_init(&hif_drv->hSemInactiveTime, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005731
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005732 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
5733
5734 if (clients_count == 0) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09005735 result = wilc_mq_create(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005736
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09005737 if (result < 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005738 PRINT_ER("Failed to creat MQ\n");
5739 goto _fail_;
5740 }
Arnd Bergmann1999bd52015-05-29 22:52:14 +02005741 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
5742 if (IS_ERR(HostIFthreadHandler)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005743 PRINT_ER("Failed to creat Thread\n");
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09005744 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005745 goto _fail_mq_;
5746 }
Greg Kroah-Hartman507d7fc2015-08-17 12:59:42 -07005747 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
Tony Choa4ab1ad2015-10-12 16:56:05 +09005748 (unsigned long)hif_drv);
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005749 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005750 }
5751
Tony Choa4ab1ad2015-10-12 16:56:05 +09005752 setup_timer(&hif_drv->hScanTimer, TimerCB_Scan, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005753
Tony Choa4ab1ad2015-10-12 16:56:05 +09005754 setup_timer(&hif_drv->hConnectTimer, TimerCB_Connect, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005755
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005756 /*Remain on channel timer*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09005757 setup_timer(&hif_drv->hRemainOnChannel, ListenTimerCB, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005758
Tony Choa4ab1ad2015-10-12 16:56:05 +09005759 sema_init(&(hif_drv->gtOsCfgValuesSem), 1);
5760 down(&hif_drv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005761
Tony Choa4ab1ad2015-10-12 16:56:05 +09005762 hif_drv->enuHostIFstate = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005763
5764 /*Initialize CFG WIDS Defualt Values*/
5765
Tony Choa4ab1ad2015-10-12 16:56:05 +09005766 hif_drv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
5767 hif_drv->strCfgValues.scan_source = DEFAULT_SCAN;
5768 hif_drv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
5769 hif_drv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
5770 hif_drv->strCfgValues.curr_tx_rate = AUTORATE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005771
Tony Choa4ab1ad2015-10-12 16:56:05 +09005772 hif_drv->u64P2p_MgmtTimeout = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005773
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005774 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",
5775
Tony Choa4ab1ad2015-10-12 16:56:05 +09005776 hif_drv->strCfgValues.site_survey_enabled, hif_drv->strCfgValues.scan_source,
5777 hif_drv->strCfgValues.active_scan_time, hif_drv->strCfgValues.passive_scan_time,
5778 hif_drv->strCfgValues.curr_tx_rate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005779
Tony Choa4ab1ad2015-10-12 16:56:05 +09005780 up(&hif_drv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005781
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005782 clients_count++; /* increase number of created entities */
5783
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09005784 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005785
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005786_fail_timer_2:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005787 up(&hif_drv->gtOsCfgValuesSem);
5788 del_timer_sync(&hif_drv->hConnectTimer);
5789 del_timer_sync(&hif_drv->hScanTimer);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02005790 kthread_stop(HostIFthreadHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005791_fail_mq_:
Chaehyun Lim1b128f62015-08-19 15:59:08 +09005792 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005793_fail_:
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09005794 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005795}
5796/**
5797 * @brief host_int_deinit
5798 * @details host interface initialization function
5799 * @param[in,out] handle to the wifi driver,
5800 * @note
5801 * @author zsalah
5802 * @date 8 March 2012
5803 * @version 1.0
5804 */
5805
Tony Choa4ab1ad2015-10-12 16:56:05 +09005806s32 host_int_deinit(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005807{
Leo Kime6e12662015-09-16 18:36:03 +09005808 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005809 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09005810 int ret;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005811
5812 /*obtain driver handle*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005813
Tony Choa4ab1ad2015-10-12 16:56:05 +09005814 if (!hif_drv) {
5815 PRINT_ER("hif_drv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005816 return 0;
5817 }
5818
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005819 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005820
Tony Choa4ab1ad2015-10-12 16:56:05 +09005821 terminated_handle = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005822 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
5823
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005824 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
5825 /*to guarantee handling all messages befor proceeding*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09005826 if (del_timer_sync(&hif_drv->hScanTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005827 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005828 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
5829 }
5830
Tony Choa4ab1ad2015-10-12 16:56:05 +09005831 if (del_timer_sync(&hif_drv->hConnectTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005832 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005833 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
5834 }
5835
5836
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07005837 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005838 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005839 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
5840 }
5841
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005842 /*Destroy Remain-onchannel Timer*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09005843 del_timer_sync(&hif_drv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005844
Johnny Kim218dc402015-08-13 13:41:19 +09005845 host_int_set_wfi_drv_handler(NULL);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005846 down(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005847
5848
5849 /*Calling the CFG80211 scan done function with the abort flag set to true*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09005850 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
5851 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
5852 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005853
Tony Choa4ab1ad2015-10-12 16:56:05 +09005854 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005855 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005856
Tony Choa4ab1ad2015-10-12 16:56:05 +09005857 hif_drv->enuHostIFstate = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005858
Dean Lee72ed4dc2015-06-12 14:11:44 +09005859 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005860
Tony Cho143eb952015-09-21 12:16:32 +09005861 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005862
5863 if (clients_count == 1) {
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07005864 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005865 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005866 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
5867 }
Tony Choa9f812a2015-09-21 12:16:33 +09005868 msg.id = HOST_IF_MSG_EXIT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005869 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005870
5871
Tony Cho143eb952015-09-21 12:16:32 +09005872 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kime6e12662015-09-16 18:36:03 +09005873 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005874 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005875
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005876 down(&hSemHostIFthrdEnd);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005877
Chaehyun Lim1b128f62015-08-19 15:59:08 +09005878 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005879 }
5880
Tony Choa4ab1ad2015-10-12 16:56:05 +09005881 down(&(hif_drv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005882
5883 /*Setting the gloabl driver handler with NULL*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005884 /* gWFiDrvHandle = NULL; */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005885 ret = remove_handler_in_list(hif_drv);
Johnny Kimd42ab082015-08-20 16:32:52 +09005886 if (ret)
Leo Kime6e12662015-09-16 18:36:03 +09005887 s32Error = -ENOENT;
Johnny Kimd42ab082015-08-20 16:32:52 +09005888
Tony Choa4ab1ad2015-10-12 16:56:05 +09005889 kfree(hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005890
5891 clients_count--; /* Decrease number of created entities */
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005892 terminated_handle = NULL;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005893 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005894 return s32Error;
5895}
5896
5897
5898/**
5899 * @brief NetworkInfoReceived
5900 * @details function to to be called when network info packet is received
5901 * @param[in] pu8Buffer the received packet
5902 * @param[in] u32Length length of the received packet
5903 * @return none
5904 * @note
5905 * @author
5906 * @date 1 Mar 2012
5907 * @version 1.0
5908 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005909void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005910{
Leo Kime6e12662015-09-16 18:36:03 +09005911 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005912 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09005913 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005914 struct host_if_drv *hif_drv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005915
Johnny Kimd42ab082015-08-20 16:32:52 +09005916 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09005917 hif_drv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005918
5919
5920
5921
Tony Choa4ab1ad2015-10-12 16:56:05 +09005922 if (!hif_drv || hif_drv == terminated_handle) {
5923 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005924 return;
5925 }
5926
5927 /* prepare the Asynchronous Network Info message */
Tony Cho143eb952015-09-21 12:16:32 +09005928 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005929
Tony Choa9f812a2015-09-21 12:16:33 +09005930 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005931 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005932
Tony Cho02d19462015-09-30 18:44:22 +09005933 msg.body.net_info.u32Length = u32Length;
5934 msg.body.net_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
5935 memcpy(msg.body.net_info.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005936 pu8Buffer, u32Length);
5937
5938 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005939 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005940 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005941 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005942}
5943
5944/**
5945 * @brief GnrlAsyncInfoReceived
5946 * @details function to be called when general Asynchronous info packet is received
5947 * @param[in] pu8Buffer the received packet
5948 * @param[in] u32Length length of the received packet
5949 * @return none
5950 * @note
5951 * @author
5952 * @date 15 Mar 2012
5953 * @version 1.0
5954 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005955void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005956{
Leo Kime6e12662015-09-16 18:36:03 +09005957 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005958 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09005959 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005960 struct host_if_drv *hif_drv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005961
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005962 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005963
Johnny Kimd42ab082015-08-20 16:32:52 +09005964 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09005965 hif_drv = get_handler_from_id(id);
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005966 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005967
5968
Tony Choa4ab1ad2015-10-12 16:56:05 +09005969 if (!hif_drv || hif_drv == terminated_handle) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005970 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005971 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005972 return;
5973 }
5974
Tony Choa4ab1ad2015-10-12 16:56:05 +09005975 if (!hif_drv->strWILC_UsrConnReq.pfUserConnectResult) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005976 /* received mac status is not needed when there is no current Connect Request */
5977 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005978 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005979 return;
5980 }
5981
5982 /* prepare the General Asynchronous Info message */
Tony Cho143eb952015-09-21 12:16:32 +09005983 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005984
5985
Tony Choa9f812a2015-09-21 12:16:33 +09005986 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005987 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005988
5989
Tony Cho66add622015-09-30 18:44:23 +09005990 msg.body.async_info.u32Length = u32Length;
5991 msg.body.async_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
5992 memcpy(msg.body.async_info.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005993 pu8Buffer, u32Length);
5994
5995 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005996 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005997 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005998 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005999
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006000 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006001}
6002
6003/**
6004 * @brief host_int_ScanCompleteReceived
6005 * @details Setting scan complete received notifcation in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006006 * @param[in] u8* pu8Buffer, u32 u32Length
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006007 * @return Error code.
6008 * @author
6009 * @date
6010 * @version 1.0
6011 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006012void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006013{
Leo Kime6e12662015-09-16 18:36:03 +09006014 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006015 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006016 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006017 struct host_if_drv *hif_drv = NULL;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006018
Johnny Kimd42ab082015-08-20 16:32:52 +09006019 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09006020 hif_drv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006021
6022
Tony Choa4ab1ad2015-10-12 16:56:05 +09006023 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006024
Tony Choa4ab1ad2015-10-12 16:56:05 +09006025 if (!hif_drv || hif_drv == terminated_handle)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006026 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006027
6028 /*if there is an ongoing scan request*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09006029 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006030 /* prepare theScan Done message */
Tony Cho143eb952015-09-21 12:16:32 +09006031 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006032
Tony Choa9f812a2015-09-21 12:16:33 +09006033 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006034 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006035
6036
6037 /* will be deallocated by the receiving thread */
6038 /*no need to send message body*/
6039
Tony Cho410c2482015-09-21 12:16:35 +09006040 /*msg.body.strScanComplete.u32Length = u32Length;
6041 * msg.body.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
6042 * memcpy(msg.body.strScanComplete.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006043 * pu8Buffer, u32Length); */
6044
6045 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006046 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006047 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006048 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006049 }
6050
6051
6052 return;
6053
6054}
6055
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006056/**
6057 * @brief host_int_remain_on_channel
6058 * @details
6059 * @param[in] Handle to wifi driver
6060 * Duration to remain on channel
6061 * Channel to remain on
6062 * Pointer to fn to be called on receive frames in listen state
6063 * Pointer to remain-on-channel expired fn
6064 * Priv
6065 * @return Error code.
6066 * @author
6067 * @date
6068 * @version 1.0
6069 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09006070s32 host_int_remain_on_channel(struct host_if_drv *hif_drv, u32 u32SessionID,
6071 u32 u32duration, u16 chan,
6072 wilc_remain_on_chan_expired RemainOnChanExpired,
6073 wilc_remain_on_chan_ready RemainOnChanReady,
6074 void *pvUserArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006075{
Leo Kime6e12662015-09-16 18:36:03 +09006076 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006077 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006078
Tony Choa4ab1ad2015-10-12 16:56:05 +09006079 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006080 PRINT_ER("driver is null\n");
6081 return -EFAULT;
6082 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006083
6084 /* prepare the remainonchan Message */
Tony Cho143eb952015-09-21 12:16:32 +09006085 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006086
6087 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006088 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
Tony Cho070d3652015-09-30 18:55:10 +09006089 msg.body.remain_on_ch.u16Channel = chan;
6090 msg.body.remain_on_ch.pRemainOnChanExpired = RemainOnChanExpired;
6091 msg.body.remain_on_ch.pRemainOnChanReady = RemainOnChanReady;
6092 msg.body.remain_on_ch.pVoid = pvUserArg;
6093 msg.body.remain_on_ch.u32duration = u32duration;
6094 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006095 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006096
Tony Cho143eb952015-09-21 12:16:32 +09006097 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006098 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006099 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006100
6101 return s32Error;
6102}
6103
6104/**
6105 * @brief host_int_ListenStateExpired
6106 * @details
6107 * @param[in] Handle to wifi driver
6108 * Duration to remain on channel
6109 * Channel to remain on
6110 * Pointer to fn to be called on receive frames in listen state
6111 * Pointer to remain-on-channel expired fn
6112 * Priv
6113 * @return Error code.
6114 * @author
6115 * @date
6116 * @version 1.0
6117 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09006118s32 host_int_ListenStateExpired(struct host_if_drv *hif_drv, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006119{
Leo Kime6e12662015-09-16 18:36:03 +09006120 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006121 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006122
Tony Choa4ab1ad2015-10-12 16:56:05 +09006123 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006124 PRINT_ER("driver is null\n");
6125 return -EFAULT;
6126 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006127
6128 /*Stopping remain-on-channel timer*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09006129 del_timer(&hif_drv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006130
6131 /* prepare the timer fire Message */
Tony Cho143eb952015-09-21 12:16:32 +09006132 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09006133 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006134 msg.drv = hif_drv;
Tony Cho070d3652015-09-30 18:55:10 +09006135 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006136
Tony Cho143eb952015-09-21 12:16:32 +09006137 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006138 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006139 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006140
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006141 return s32Error;
6142}
6143
6144/**
6145 * @brief host_int_frame_register
6146 * @details
6147 * @param[in] Handle to wifi driver
6148 * @return Error code.
6149 * @author
6150 * @date
6151 * @version 1.0*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09006152s32 host_int_frame_register(struct host_if_drv *hif_drv, u16 u16FrameType, bool bReg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006153{
Leo Kime6e12662015-09-16 18:36:03 +09006154 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006155 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006156
Tony Choa4ab1ad2015-10-12 16:56:05 +09006157 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006158 PRINT_ER("driver is null\n");
6159 return -EFAULT;
6160 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006161
Tony Cho143eb952015-09-21 12:16:32 +09006162 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006163
6164 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006165 msg.id = HOST_IF_MSG_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006166 switch (u16FrameType) {
6167 case ACTION:
6168 PRINT_D(HOSTINF_DBG, "ACTION\n");
Tony Cho5c4008d2015-10-05 13:50:44 +09006169 msg.body.reg_frame.u8Regid = ACTION_FRM_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006170 break;
6171
6172 case PROBE_REQ:
6173 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
Tony Cho5c4008d2015-10-05 13:50:44 +09006174 msg.body.reg_frame.u8Regid = PROBE_REQ_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006175 break;
6176
6177 default:
6178 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
6179 break;
6180 }
Tony Cho5c4008d2015-10-05 13:50:44 +09006181 msg.body.reg_frame.u16FrameType = u16FrameType;
6182 msg.body.reg_frame.bReg = bReg;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006183 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006184
Tony Cho143eb952015-09-21 12:16:32 +09006185 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006186 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006187 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006188
6189 return s32Error;
6190
6191
6192}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006193
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006194/**
6195 * @brief host_int_add_beacon
6196 * @details Setting add beacon params in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006197 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
6198 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
6199 * u32 u32TailLen, u8* pu8Tail
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006200 * @return Error code.
6201 * @author
6202 * @date
6203 * @version 1.0
6204 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09006205s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
6206 u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head,
6207 u32 u32TailLen, u8 *pu8Tail)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006208{
Leo Kime6e12662015-09-16 18:36:03 +09006209 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006210 struct host_if_msg msg;
Tony Choa98491e2015-09-30 18:44:31 +09006211 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006212
Tony Choa4ab1ad2015-10-12 16:56:05 +09006213 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006214 PRINT_ER("driver is null\n");
6215 return -EFAULT;
6216 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006217
Tony Cho143eb952015-09-21 12:16:32 +09006218 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006219
6220 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
6221
6222
6223 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006224 msg.id = HOST_IF_MSG_ADD_BEACON;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006225 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006226 pstrSetBeaconParam->u32Interval = u32Interval;
6227 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
6228 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
Glen Leef3052582015-09-10 12:03:04 +09006229 pstrSetBeaconParam->pu8Head = kmalloc(u32HeadLen, GFP_KERNEL);
Leo Kim24db7132015-09-16 18:36:01 +09006230 if (pstrSetBeaconParam->pu8Head == NULL) {
6231 s32Error = -ENOMEM;
6232 goto ERRORHANDLER;
6233 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006234 memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006235 pstrSetBeaconParam->u32TailLen = u32TailLen;
6236
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006237 if (u32TailLen > 0) {
Glen Leef3052582015-09-10 12:03:04 +09006238 pstrSetBeaconParam->pu8Tail = kmalloc(u32TailLen, GFP_KERNEL);
Leo Kim24db7132015-09-16 18:36:01 +09006239 if (pstrSetBeaconParam->pu8Tail == NULL) {
6240 s32Error = -ENOMEM;
6241 goto ERRORHANDLER;
6242 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006243 memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006244 } else {
6245 pstrSetBeaconParam->pu8Tail = NULL;
6246 }
6247
Tony Cho143eb952015-09-21 12:16:32 +09006248 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006249 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006250 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006251
Leo Kim24db7132015-09-16 18:36:01 +09006252ERRORHANDLER:
6253 if (s32Error) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006254 if (pstrSetBeaconParam->pu8Head != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006255 kfree(pstrSetBeaconParam->pu8Head);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006256
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006257 if (pstrSetBeaconParam->pu8Tail != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006258 kfree(pstrSetBeaconParam->pu8Tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006259 }
6260
6261 return s32Error;
6262
6263}
6264
6265
6266/**
6267 * @brief host_int_del_beacon
6268 * @details Setting add beacon params in message queue
6269 * @param[in] WILC_WFIDrvHandle hWFIDrv
6270 * @return Error code.
6271 * @author
6272 * @date
6273 * @version 1.0
6274 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09006275s32 host_int_del_beacon(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006276{
Leo Kime6e12662015-09-16 18:36:03 +09006277 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006278 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006279
Tony Choa4ab1ad2015-10-12 16:56:05 +09006280 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006281 PRINT_ER("driver is null\n");
6282 return -EFAULT;
6283 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006284
6285 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006286 msg.id = HOST_IF_MSG_DEL_BEACON;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006287 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006288 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
6289
Tony Cho143eb952015-09-21 12:16:32 +09006290 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim7dc1d0c2015-09-16 18:36:00 +09006291 if (s32Error)
6292 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006293
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006294 return s32Error;
6295}
6296
6297
6298/**
6299 * @brief host_int_add_station
6300 * @details Setting add station params in message queue
Tony Cho6a89ba92015-09-21 12:16:46 +09006301 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006302 * @return Error code.
6303 * @author
6304 * @date
6305 * @version 1.0
6306 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09006307s32 host_int_add_station(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09006308 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006309{
Leo Kime6e12662015-09-16 18:36:03 +09006310 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006311 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09006312 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006313
6314
Tony Choa4ab1ad2015-10-12 16:56:05 +09006315 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006316 PRINT_ER("driver is null\n");
6317 return -EFAULT;
6318 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006319
Tony Cho143eb952015-09-21 12:16:32 +09006320 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006321
6322 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
6323
6324
6325 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006326 msg.id = HOST_IF_MSG_ADD_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006327 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006328
Tony Cho6a89ba92015-09-21 12:16:46 +09006329 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006330 if (pstrAddStationMsg->u8NumRates > 0) {
Glen Leef3052582015-09-10 12:03:04 +09006331 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006332
Leo Kim7ae43362015-09-16 18:35:59 +09006333 if (!rates)
6334 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006335
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006336 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02006337 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006338 }
6339
6340
Tony Cho143eb952015-09-21 12:16:32 +09006341 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006342 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006343 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006344 return s32Error;
6345}
6346
6347/**
6348 * @brief host_int_del_station
6349 * @details Setting delete station params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006350 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006351 * @return Error code.
6352 * @author
6353 * @date
6354 * @version 1.0
6355 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09006356s32 host_int_del_station(struct host_if_drv *hif_drv, const u8 *pu8MacAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006357{
Leo Kime6e12662015-09-16 18:36:03 +09006358 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006359 struct host_if_msg msg;
Tony Cho889c25b2015-09-30 18:44:33 +09006360 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006361
Tony Choa4ab1ad2015-10-12 16:56:05 +09006362 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006363 PRINT_ER("driver is null\n");
6364 return -EFAULT;
6365 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006366
Tony Cho143eb952015-09-21 12:16:32 +09006367 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006368
6369 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
6370
6371
6372
6373 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006374 msg.id = HOST_IF_MSG_DEL_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006375 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006376
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006377 if (pu8MacAddr == NULL)
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006378 memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006379 else
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006380 memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006381
Tony Cho143eb952015-09-21 12:16:32 +09006382 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006383 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006384 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006385 return s32Error;
6386}
6387/**
6388 * @brief host_int_del_allstation
6389 * @details Setting del station params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006390 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006391 * @return Error code.
6392 * @author
6393 * @date
6394 * @version 1.0
6395 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09006396s32 host_int_del_allstation(struct host_if_drv *hif_drv,
Leo Kim441dc602015-10-12 16:55:35 +09006397 u8 pu8MacAddr[][ETH_ALEN])
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006398{
Leo Kime6e12662015-09-16 18:36:03 +09006399 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006400 struct host_if_msg msg;
Tony Chob0c1e802015-10-05 13:50:46 +09006401 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006402 u8 au8Zero_Buff[ETH_ALEN] = {0};
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006403 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006404 u8 u8AssocNumb = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006405
6406
Tony Choa4ab1ad2015-10-12 16:56:05 +09006407 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006408 PRINT_ER("driver is null\n");
6409 return -EFAULT;
6410 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006411
Tony Cho143eb952015-09-21 12:16:32 +09006412 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006413
6414 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
6415
6416 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006417 msg.id = HOST_IF_MSG_DEL_ALL_STA;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006418 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006419
6420 /* Handling situation of deauthenticing all associated stations*/
6421 for (i = 0; i < MAX_NUM_STA; i++) {
6422 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006423 memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006424 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],
6425 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
6426 u8AssocNumb++;
6427 }
6428 }
6429 if (!u8AssocNumb) {
6430 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
6431 return s32Error;
6432 }
6433
6434 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
Tony Cho143eb952015-09-21 12:16:32 +09006435 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006436
6437
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006438 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006439 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006440
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006441 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006442
6443 return s32Error;
6444
6445}
6446
6447/**
6448 * @brief host_int_edit_station
6449 * @details Setting edit station params in message queue
Tony Cho6a89ba92015-09-21 12:16:46 +09006450 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006451 * @return Error code.
6452 * @author
6453 * @date
6454 * @version 1.0
6455 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09006456s32 host_int_edit_station(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09006457 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006458{
Leo Kime6e12662015-09-16 18:36:03 +09006459 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006460 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09006461 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006462
Tony Choa4ab1ad2015-10-12 16:56:05 +09006463 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006464 PRINT_ER("driver is null\n");
6465 return -EFAULT;
6466 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006467
6468 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
6469
Tony Cho143eb952015-09-21 12:16:32 +09006470 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006471
6472
6473 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006474 msg.id = HOST_IF_MSG_EDIT_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006475 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006476
Tony Cho6a89ba92015-09-21 12:16:46 +09006477 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006478 if (pstrAddStationMsg->u8NumRates > 0) {
Glen Leef3052582015-09-10 12:03:04 +09006479 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006480
Leo Kim7ae43362015-09-16 18:35:59 +09006481 if (!rates)
6482 return -ENOMEM;
6483
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006484 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02006485 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006486 }
6487
Tony Cho143eb952015-09-21 12:16:32 +09006488 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006489 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006490 PRINT_ER("wilc_mq_send fail\n");
6491
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006492 return s32Error;
6493}
Glen Lee108b3432015-09-16 18:53:20 +09006494
Tony Choa4ab1ad2015-10-12 16:56:05 +09006495s32 host_int_set_power_mgmt(struct host_if_drv *hif_drv,
6496 bool bIsEnabled,
6497 u32 u32Timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006498{
Leo Kime6e12662015-09-16 18:36:03 +09006499 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006500 struct host_if_msg msg;
Tony Cho49e1f812015-09-30 18:44:36 +09006501 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006502
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006503 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006504
Tony Choa4ab1ad2015-10-12 16:56:05 +09006505 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006506 PRINT_ER("driver is null\n");
6507 return -EFAULT;
6508 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006509
6510 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
6511
Tony Cho143eb952015-09-21 12:16:32 +09006512 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006513
6514
6515 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006516 msg.id = HOST_IF_MSG_POWER_MGMT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006517 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006518
6519 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
6520 pstrPowerMgmtParam->u32Timeout = u32Timeout;
6521
6522
Tony Cho143eb952015-09-21 12:16:32 +09006523 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006524 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006525 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006526 return s32Error;
6527}
6528
Tony Choa4ab1ad2015-10-12 16:56:05 +09006529s32 host_int_setup_multicast_filter(struct host_if_drv *hif_drv,
6530 bool bIsEnabled,
6531 u32 u32count)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006532{
Leo Kime6e12662015-09-16 18:36:03 +09006533 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006534 struct host_if_msg msg;
Tony Choa079cf4d2015-09-30 18:55:05 +09006535 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006536
6537
Tony Choa4ab1ad2015-10-12 16:56:05 +09006538 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006539 PRINT_ER("driver is null\n");
6540 return -EFAULT;
6541 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006542
6543 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
6544
Tony Cho143eb952015-09-21 12:16:32 +09006545 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006546
6547
6548 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006549 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006550 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006551
6552 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
6553 pstrMulticastFilterParam->u32count = u32count;
6554
Tony Cho143eb952015-09-21 12:16:32 +09006555 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006556 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006557 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006558 return s32Error;
6559}
6560
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006561/**
6562 * @brief host_int_ParseJoinBssParam
6563 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
6564 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
6565 * @return
6566 * @author zsalah
6567 * @date
6568 * @version 1.0**/
6569static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
6570{
Leo Kime0a12212015-10-12 16:55:49 +09006571 struct join_bss_param *pNewJoinBssParam = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006572 u8 *pu8IEs;
Chaehyun Limd85f5322015-06-11 14:35:54 +09006573 u16 u16IEsLen;
6574 u16 index = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006575 u8 suppRatesNo = 0;
6576 u8 extSuppRatesNo;
Chaehyun Limd85f5322015-06-11 14:35:54 +09006577 u16 jumpOffset;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006578 u8 pcipherCount;
6579 u8 authCount;
6580 u8 pcipherTotalCount = 0;
6581 u8 authTotalCount = 0;
6582 u8 i, j;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006583
6584 pu8IEs = ptstrNetworkInfo->pu8IEs;
6585 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
6586
Leo Kime0a12212015-10-12 16:55:49 +09006587 pNewJoinBssParam = kmalloc(sizeof(struct join_bss_param), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006588 if (pNewJoinBssParam != NULL) {
Leo Kime0a12212015-10-12 16:55:49 +09006589 memset(pNewJoinBssParam, 0, sizeof(struct join_bss_param));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006590 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
6591 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
6592 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006593 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006594 /*for(i=0; i<6;i++)
6595 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006596 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006597 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006598 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
6599 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006600 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
6601 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
6602
6603 /* parse supported rates: */
6604 while (index < u16IEsLen) {
6605 /* supportedRates IE */
6606 if (pu8IEs[index] == SUPP_RATES_IE) {
6607 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
6608 suppRatesNo = pu8IEs[index + 1];
6609 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
6610 index += 2; /* skipping ID and length bytes; */
6611
6612 for (i = 0; i < suppRatesNo; i++) {
6613 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
6614 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
6615 }
6616 index += suppRatesNo;
6617 continue;
6618 }
6619 /* Ext SupportedRates IE */
6620 else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
6621 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
6622 /* checking if no of ext. supp and supp rates < max limit */
6623 extSuppRatesNo = pu8IEs[index + 1];
6624 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
6625 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
6626 else
6627 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
6628 index += 2;
6629 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
6630 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
6631 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
6632 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
6633 }
6634 index += extSuppRatesNo;
6635 continue;
6636 }
6637 /* HT Cap. IE */
6638 else if (pu8IEs[index] == HT_CAPABILITY_IE) {
6639 /* if IE found set the flag */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09006640 pNewJoinBssParam->ht_capable = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006641 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6642 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
6643 continue;
6644 } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
6645 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
6646 (pu8IEs[index + 4] == 0xF2) && /* OUI */
6647 (pu8IEs[index + 5] == 0x02) && /* OUI Type */
6648 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
6649 (pu8IEs[index + 7] == 0x01)) {
6650 /* Presence of WMM Info/Param element indicates WMM capability */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09006651 pNewJoinBssParam->wmm_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006652
6653 /* Check if Bit 7 is set indicating U-APSD capability */
Anish Bhattffda2032015-09-29 12:15:49 -07006654 if (pu8IEs[index + 8] & BIT(7))
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09006655 pNewJoinBssParam->uapsd_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006656 index += pu8IEs[index + 1] + 2;
6657 continue;
6658 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006659 else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
6660 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
6661 (pu8IEs[index + 4] == 0x9a) && /* OUI */
6662 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
Chaehyun Limd85f5322015-06-11 14:35:54 +09006663 u16 u16P2P_count;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006664
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006665 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
6666 pNewJoinBssParam->u8NoaEnbaled = 1;
6667 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
6668
6669 /* Check if Bit 7 is set indicating Opss capability */
Anish Bhattffda2032015-09-29 12:15:49 -07006670 if (pu8IEs[index + 10] & BIT(7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006671 pNewJoinBssParam->u8OppEnable = 1;
6672 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
6673 } else
6674 pNewJoinBssParam->u8OppEnable = 0;
6675 /* HOSTINF_DBG */
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006676 PRINT_D(GENERIC_DBG, "P2P Dump\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006677 for (i = 0; i < pu8IEs[index + 7]; i++)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006678 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006679
6680 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
6681 u16P2P_count = index + 12;
6682
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006683 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006684 u16P2P_count += 4;
6685
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006686 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006687 u16P2P_count += 4;
6688
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006689 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006690
6691 index += pu8IEs[index + 1] + 2;
6692 continue;
6693
6694 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006695 else if ((pu8IEs[index] == RSN_IE) ||
6696 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
6697 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
6698 (pu8IEs[index + 5] == 0x01))) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09006699 u16 rsnIndex = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006700 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
6701 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
6702 * {
6703 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
6704 * }*/
6705 if (pu8IEs[rsnIndex] == RSN_IE) {
6706 pNewJoinBssParam->mode_802_11i = 2;
6707 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
6708 } else { /* check if rsn was previously parsed */
6709 if (pNewJoinBssParam->mode_802_11i == 0)
6710 pNewJoinBssParam->mode_802_11i = 1;
6711 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
6712 rsnIndex += 4;
6713 }
6714 rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
6715 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
6716 rsnIndex++;
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006717 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006718 /* initialize policies with invalid values */
6719
6720 jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
6721
6722 /*parsing pairwise cipher*/
6723
6724 /* saving 3 pcipher max. */
6725 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
6726 rsnIndex += 2; /* jump 2 bytes of pcipher count */
6727
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006728 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006729 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
6730 /* each count corresponds to 4 bytes, only last byte is saved */
6731 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
6732 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
6733 }
6734 pcipherTotalCount += pcipherCount;
6735 rsnIndex += jumpOffset;
6736
6737 jumpOffset = pu8IEs[rsnIndex] * 4;
6738
6739 /*parsing AKM suite (auth_policy)*/
6740 /* saving 3 auth policies max. */
6741 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
6742 rsnIndex += 2; /* jump 2 bytes of pcipher count */
6743
6744 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
6745 /* each count corresponds to 4 bytes, only last byte is saved */
6746 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
6747 }
6748 authTotalCount += authCount;
6749 rsnIndex += jumpOffset;
6750 /*pasring rsn cap. only if rsn IE*/
6751 if (pu8IEs[index] == RSN_IE) {
6752 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
6753 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
6754 rsnIndex += 2;
6755 }
Abdul Hussainf717c0eb2015-06-16 09:49:49 +00006756 pNewJoinBssParam->rsn_found = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006757 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6758 continue;
6759 } else
6760 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6761
6762 }
6763
6764
6765 }
6766
6767 return (void *)pNewJoinBssParam;
6768
6769}
6770
6771void host_int_freeJoinParams(void *pJoinParams)
6772{
Leo Kime0a12212015-10-12 16:55:49 +09006773 if ((struct bss_param *)pJoinParams != NULL)
6774 kfree((struct bss_param *)pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006775 else
6776 PRINT_ER("Unable to FREE null pointer\n");
6777}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006778
Tony Choa4ab1ad2015-10-12 16:56:05 +09006779s32 host_int_delBASession(struct host_if_drv *hif_drv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006780{
Leo Kime6e12662015-09-16 18:36:03 +09006781 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006782 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09006783 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006784
Tony Choa4ab1ad2015-10-12 16:56:05 +09006785 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006786 PRINT_ER("driver is null\n");
6787 return -EFAULT;
6788 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006789
Tony Cho143eb952015-09-21 12:16:32 +09006790 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006791
6792 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006793 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006794
6795 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
6796 pBASessionInfo->u8Ted = TID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006797 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006798
Tony Cho143eb952015-09-21 12:16:32 +09006799 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006800 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006801 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006802
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006803 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006804
6805 return s32Error;
6806}
6807
Tony Choa4ab1ad2015-10-12 16:56:05 +09006808s32 host_int_del_All_Rx_BASession(struct host_if_drv *hif_drv,
6809 char *pBSSID,
6810 char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006811{
Leo Kime6e12662015-09-16 18:36:03 +09006812 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006813 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09006814 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006815
Tony Choa4ab1ad2015-10-12 16:56:05 +09006816 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006817 PRINT_ER("driver is null\n");
6818 return -EFAULT;
6819 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006820
Tony Cho143eb952015-09-21 12:16:32 +09006821 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006822
6823 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006824 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006825
6826 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
6827 pBASessionInfo->u8Ted = TID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006828 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006829
Tony Cho143eb952015-09-21 12:16:32 +09006830 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006831 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006832 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006833
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006834 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006835
6836 return s32Error;
6837}
6838
6839/**
6840 * @brief host_int_setup_ipaddress
6841 * @details setup IP in firmware
6842 * @param[in] Handle to wifi driver
6843 * @return Error code.
6844 * @author Abdelrahman Sobhy
6845 * @date
6846 * @version 1.0*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09006847s32 host_int_setup_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006848{
Leo Kime6e12662015-09-16 18:36:03 +09006849 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006850 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006851
6852 /* TODO: Enable This feature on softap firmware */
6853 return 0;
6854
Tony Choa4ab1ad2015-10-12 16:56:05 +09006855 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006856 PRINT_ER("driver is null\n");
6857 return -EFAULT;
6858 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006859
Tony Cho143eb952015-09-21 12:16:32 +09006860 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006861
6862 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006863 msg.id = HOST_IF_MSG_SET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006864
Tony Chofb2d65e2015-09-30 18:44:39 +09006865 msg.body.ip_info.au8IPAddr = u16ipadd;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006866 msg.drv = hif_drv;
Tony Chofb2d65e2015-09-30 18:44:39 +09006867 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006868
Tony Cho143eb952015-09-21 12:16:32 +09006869 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006870 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006871 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006872
6873 return s32Error;
6874
6875
6876}
6877
6878/**
6879 * @brief host_int_get_ipaddress
6880 * @details Get IP from firmware
6881 * @param[in] Handle to wifi driver
6882 * @return Error code.
6883 * @author Abdelrahman Sobhy
6884 * @date
6885 * @version 1.0*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09006886s32 host_int_get_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006887{
Leo Kime6e12662015-09-16 18:36:03 +09006888 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006889 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006890
Tony Choa4ab1ad2015-10-12 16:56:05 +09006891 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006892 PRINT_ER("driver is null\n");
6893 return -EFAULT;
6894 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006895
Tony Cho143eb952015-09-21 12:16:32 +09006896 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006897
6898 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006899 msg.id = HOST_IF_MSG_GET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006900
Tony Chofb2d65e2015-09-30 18:44:39 +09006901 msg.body.ip_info.au8IPAddr = u16ipadd;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006902 msg.drv = hif_drv;
Tony Chofb2d65e2015-09-30 18:44:39 +09006903 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006904
Tony Cho143eb952015-09-21 12:16:32 +09006905 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006906 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006907 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006908
6909 return s32Error;
6910
6911
6912}