blob: d905e17e7fb222218492a47cea588518bbccc2bc [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 {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900111 u8 *pu8WepKey;
112 u8 u8WepKeylen;
113 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 {
Leo Kimc276c442015-10-05 15:25:42 +0900129 struct host_if_wep_attr strHostIFwepAttr;
Leo Kim4372d3d2015-10-05 15:25:43 +0900130 struct host_if_wpa_attr strHostIFwpaAttr;
Leo Kima949f902015-10-05 15:25:44 +0900131 struct host_if_pmkid_attr strHostIFpmkidAttr;
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");
2352 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.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);
Leo Kim900bb4a2015-10-12 16:55:46 +09002356 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.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);
Leo Kim900bb4a2015-10-12 16:55:46 +09002361 strWIDList[1].val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.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
Leo Kim900bb4a2015-10-12 16:55:46 +09002366 strWIDList[2].val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Leo Kim2fd3e442015-10-12 16:55:45 +09002367 strWIDList[2].size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002368
2369
Glen Leef3052582015-09-10 12:03:04 +09002370 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 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
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002378 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002379 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2380
2381
Chaehyun Lim49188af2015-08-11 10:32:41 +09002382 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
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;
Leo Kim2fd3e442015-10-12 16:55:45 +09002386 strWIDList[3].size = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
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");
Glen Leef3052582015-09-10 12:03:04 +09002399 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 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 }
2404 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2405
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002406 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002407
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002408 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002409 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2410
Chaehyun Lim49188af2015-08-11 10:32:41 +09002411 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
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;
Leo Kim2fd3e442015-10-12 16:55:45 +09002416 strWID.size = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 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
Chaehyun Limca356ad2015-06-11 14:35:57 +09002427 s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.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;
Leo Kim900bb4a2015-10-12 16:55:46 +09002436 strWID.val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.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
2466 if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002467 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002468
2469
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002470 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002471
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002472 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002473
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002474 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002475 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2476 /* 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);
Leo Kim900bb4a2015-10-12 16:55:46 +09002480 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.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
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002520 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002521
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002522 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002523
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002524 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2525 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002526 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2527
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_:
Chaehyun Lim49188af2015-08-11 10:32:41 +09002543 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2544 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.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
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002571 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002572
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002573 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2574 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002575 /*16 byte TK*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002576 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002577 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2578
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);
Leo Kim900bb4a2015-10-12 16:55:46 +09002583 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.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
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002618 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002619
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002620 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002621 /*16 byte TK*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002622 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002623 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2624
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_:
Chaehyun Lim49188af2015-08-11 10:32:41 +09002641 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.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
Glen Leef3052582015-09-10 12:03:04 +09002652 pu8keybuf = kmalloc((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.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
2658 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
2659
2660 for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
2661
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002662 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
2663 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.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;
Leo Kim2fd3e442015-10-12 16:55:45 +09002669 strWID.size = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.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;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004095
Tony Cho18990bf2015-09-30 18:44:24 +09004096 msg.body.key_info.
Chaehyun Lim517af2f2015-10-05 19:34:59 +09004097 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004098
4099 /* send the message */
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09004100 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
4101 if (result)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004102 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09004103 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004104
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09004105 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004106}
4107
4108/**
4109 * @brief sets WEP default key
4110 * @details Sets the index of the WEP encryption key in use,
4111 * in the key table
4112 * @param[in,out] handle to the wifi driver
4113 * @param[in] key index ( 0, 1, 2, 3)
4114 * @return Error code indicating success/failure
4115 * @note
4116 * @author zsalah
4117 * @date 8 March 2012
4118 * @version 1.0
4119 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004120s32 host_int_set_WEPDefaultKeyID(struct host_if_drv *hif_drv, u8 u8Index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004121{
Leo Kime6e12662015-09-16 18:36:03 +09004122 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004123 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004124
4125
Tony Choa4ab1ad2015-10-12 16:56:05 +09004126 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004127 s32Error = -EFAULT;
4128 PRINT_ER("driver is null\n");
4129 return s32Error;
4130 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004131
4132 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004133 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004134
4135
Tony Choa9f812a2015-09-21 12:16:33 +09004136 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004137 msg.body.key_info.enuKeyType = WEP;
4138 msg.body.key_info.u8KeyAction = DEFAULTKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004139 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004140
4141
Tony Cho18990bf2015-09-30 18:44:24 +09004142 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004143 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
4144
4145 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004146 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004147 if (s32Error)
4148 PRINT_ER("Error in sending message queue : Default key index\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09004149 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004150
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004151 return s32Error;
4152}
4153
4154/**
4155 * @brief sets WEP deafault key
4156 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4157 * sets WEP key entry into MAC hardware when it receives the
4158 * corresponding request from NDIS.
4159 * @param[in,out] handle to the wifi driver
4160 * @param[in] message containing WEP Key in the following format
4161 *|---------------------------------------|
4162 *|Key ID Value | Key Length | Key |
4163 *|-------------|------------|------------|
4164 | 1byte | 1byte | Key Length |
4165 ||---------------------------------------|
4166 |
4167 * @return Error code indicating success/failure
4168 * @note
4169 * @author zsalah
4170 * @date 8 March 2012
4171 * @version 1.0
4172 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004173s32 host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
4174 const u8 *pu8WepKey,
4175 u8 u8WepKeylen,
4176 u8 u8Keyidx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004177{
4178
Leo Kime6e12662015-09-16 18:36:03 +09004179 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004180 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004181
Tony Choa4ab1ad2015-10-12 16:56:05 +09004182 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004183 s32Error = -EFAULT;
4184 PRINT_ER("driver is null\n");
4185 return s32Error;
4186 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004187
4188 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004189 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004190
4191
Tony Choa9f812a2015-09-21 12:16:33 +09004192 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004193 msg.body.key_info.enuKeyType = WEP;
4194 msg.body.key_info.u8KeyAction = ADDKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004195 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004196
4197
Tony Cho18990bf2015-09-30 18:44:24 +09004198 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004199 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004200
Tony Cho18990bf2015-09-30 18:44:24 +09004201 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004202 pu8WepKey, u8WepKeylen);
4203
4204
Tony Cho18990bf2015-09-30 18:44:24 +09004205 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004206 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4207
Tony Cho18990bf2015-09-30 18:44:24 +09004208 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004209 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4210
4211 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004212 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004213 if (s32Error)
4214 PRINT_ER("Error in sending message queue :WEP Key\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09004215 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004216
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004217 return s32Error;
4218
4219}
4220
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004221/**
4222 *
4223 * @brief host_int_add_wep_key_bss_ap
4224 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4225 * sets WEP key entry into MAC hardware when it receives the
4226 *
4227 * corresponding request from NDIS.
4228 * @param[in,out] handle to the wifi driver
4229 *
4230 *
4231 * @return Error code indicating success/failure
4232 * @note
4233 * @author mdaftedar
4234 * @date 28 FEB 2013
4235 * @version 1.0
4236 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004237s32 host_int_add_wep_key_bss_ap(struct host_if_drv *hif_drv,
4238 const u8 *pu8WepKey,
4239 u8 u8WepKeylen,
4240 u8 u8Keyidx,
4241 u8 u8mode,
4242 enum AUTHTYPE tenuAuth_type)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004243{
4244
Leo Kime6e12662015-09-16 18:36:03 +09004245 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004246 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004247 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004248
Tony Choa4ab1ad2015-10-12 16:56:05 +09004249 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004250 s32Error = -EFAULT;
4251 PRINT_ER("driver is null\n");
4252 return s32Error;
4253 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004254
4255 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004256 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004257
4258 if (INFO) {
4259 for (i = 0; i < u8WepKeylen; i++)
4260 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4261 }
Tony Choa9f812a2015-09-21 12:16:33 +09004262 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004263 msg.body.key_info.enuKeyType = WEP;
4264 msg.body.key_info.u8KeyAction = ADDKEY_AP;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004265 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004266
4267
Tony Cho18990bf2015-09-30 18:44:24 +09004268 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004269 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004270
4271
Tony Cho18990bf2015-09-30 18:44:24 +09004272 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004273 pu8WepKey, (u8WepKeylen));
4274
4275
Tony Cho18990bf2015-09-30 18:44:24 +09004276 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004277 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4278
Tony Cho18990bf2015-09-30 18:44:24 +09004279 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004280 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4281
Tony Cho18990bf2015-09-30 18:44:24 +09004282 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004283 uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
4284
Tony Cho18990bf2015-09-30 18:44:24 +09004285 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004286 uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
4287 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004288 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004289
4290 if (s32Error)
4291 PRINT_ER("Error in sending message queue :WEP Key\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09004292 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004293
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004294 return s32Error;
4295
4296}
Glen Lee108b3432015-09-16 18:53:20 +09004297
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004298/**
4299 * @brief adds ptk Key
4300 * @details
4301 * @param[in,out] handle to the wifi driver
4302 * @param[in] message containing PTK Key in the following format
4303 *|-----------------------------------------------------------------------------|
4304 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4305 *|----------------|------------|--------------|----------------|---------------|
4306 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4307 ||-----------------------------------------------------------------------------|
4308 * @return Error code indicating success/failure
4309 * @note
4310 * @author zsalah
4311 * @date 8 March 2012
4312 * @version 1.0
4313 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004314s32 host_int_add_ptk(struct host_if_drv *hif_drv, const u8 *pu8Ptk,
4315 u8 u8PtkKeylen, const u8 *mac_addr,
4316 const u8 *pu8RxMic, const u8 *pu8TxMic,
4317 u8 mode, u8 u8Ciphermode, u8 u8Idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004318{
Leo Kime6e12662015-09-16 18:36:03 +09004319 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004320 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004321 u8 u8KeyLen = u8PtkKeylen;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004322 u32 i;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004323
Tony Choa4ab1ad2015-10-12 16:56:05 +09004324 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004325 s32Error = -EFAULT;
4326 PRINT_ER("driver is null\n");
4327 return s32Error;
4328 }
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004329 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004330 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004331 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004332 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004333
4334 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004335 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004336
4337
Tony Choa9f812a2015-09-21 12:16:33 +09004338 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004339 msg.body.key_info.enuKeyType = WPAPtk;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004340 if (mode == AP_MODE) {
Tony Cho18990bf2015-09-30 18:44:24 +09004341 msg.body.key_info.u8KeyAction = ADDKEY_AP;
4342 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004343 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
4344 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004345 if (mode == STATION_MODE)
Tony Cho18990bf2015-09-30 18:44:24 +09004346 msg.body.key_info.u8KeyAction = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004347
4348
Tony Cho18990bf2015-09-30 18:44:24 +09004349 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004350 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8PtkKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004351
4352
Tony Cho18990bf2015-09-30 18:44:24 +09004353 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004354 pu8Ptk, u8PtkKeylen);
4355
4356 if (pu8RxMic != NULL) {
4357
Tony Cho18990bf2015-09-30 18:44:24 +09004358 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004359 pu8RxMic, RX_MIC_KEY_LEN);
4360 if (INFO) {
4361 for (i = 0; i < RX_MIC_KEY_LEN; i++)
4362 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
4363 }
4364 }
4365 if (pu8TxMic != NULL) {
4366
Tony Cho18990bf2015-09-30 18:44:24 +09004367 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004368 pu8TxMic, TX_MIC_KEY_LEN);
4369 if (INFO) {
4370 for (i = 0; i < TX_MIC_KEY_LEN; i++)
4371 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
4372 }
4373 }
4374
Tony Cho18990bf2015-09-30 18:44:24 +09004375 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004376 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4377
Tony Cho18990bf2015-09-30 18:44:24 +09004378 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004379 uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
Tony Cho18990bf2015-09-30 18:44:24 +09004380 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004381 uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004382 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004383
4384 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004385 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004386
4387 if (s32Error)
4388 PRINT_ER("Error in sending message queue: PTK Key\n");
4389
4390 /* ////////////// */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004391 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004392 /* /////// */
4393
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004394 return s32Error;
4395}
4396
4397/**
4398 * @brief adds Rx GTk Key
4399 * @details
4400 * @param[in,out] handle to the wifi driver
4401 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
4402 * u8GtkKeylen :The total key length
4403 *
4404 * @return Error code indicating success/failure
4405 * @note
4406 * @author zsalah
4407 * @date 8 March 2012
4408 * @version 1.0
4409 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004410s32 host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *pu8RxGtk,
4411 u8 u8GtkKeylen, u8 u8KeyIdx,
4412 u32 u32KeyRSClen, const u8 *KeyRSC,
4413 const u8 *pu8RxMic, const u8 *pu8TxMic,
4414 u8 mode, u8 u8Ciphermode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004415{
Leo Kime6e12662015-09-16 18:36:03 +09004416 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004417 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004418 u8 u8KeyLen = u8GtkKeylen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004419
Tony Choa4ab1ad2015-10-12 16:56:05 +09004420 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004421 s32Error = -EFAULT;
4422 PRINT_ER("driver is null\n");
4423 return s32Error;
4424 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004425 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004426 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004427
4428
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004429 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004430 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004431 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004432 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004433 if (KeyRSC != NULL) {
Tony Cho18990bf2015-09-30 18:44:24 +09004434 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004435 uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004436
Tony Cho18990bf2015-09-30 18:44:24 +09004437 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004438 KeyRSC, u32KeyRSClen);
4439 }
4440
4441
Tony Choa9f812a2015-09-21 12:16:33 +09004442 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004443 msg.body.key_info.enuKeyType = WPARxGtk;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004444 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004445
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004446 if (mode == AP_MODE) {
Tony Cho18990bf2015-09-30 18:44:24 +09004447 msg.body.key_info.u8KeyAction = ADDKEY_AP;
4448 msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004449 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004450 if (mode == STATION_MODE)
Tony Cho18990bf2015-09-30 18:44:24 +09004451 msg.body.key_info.u8KeyAction = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004452
4453
Tony Cho18990bf2015-09-30 18:44:24 +09004454 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004455 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8KeyLen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004456
Tony Cho18990bf2015-09-30 18:44:24 +09004457 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004458 pu8RxGtk, u8GtkKeylen);
4459
4460 if (pu8RxMic != NULL) {
4461
Tony Cho18990bf2015-09-30 18:44:24 +09004462 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004463 pu8RxMic, RX_MIC_KEY_LEN);
4464
4465 }
4466 if (pu8TxMic != NULL) {
4467
Tony Cho18990bf2015-09-30 18:44:24 +09004468 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004469 pu8TxMic, TX_MIC_KEY_LEN);
4470
4471 }
4472
Tony Cho18990bf2015-09-30 18:44:24 +09004473 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004474 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
Tony Cho18990bf2015-09-30 18:44:24 +09004475 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004476 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4477
Tony Cho18990bf2015-09-30 18:44:24 +09004478 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004479 uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
4480
4481
4482
4483 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004484 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004485 if (s32Error)
4486 PRINT_ER("Error in sending message queue: RX GTK\n");
4487 /* ////////////// */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004488 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004489 /* /////// */
4490
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004491 return s32Error;
4492}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004493
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004494/**
4495 * @brief host_int_set_pmkid_info
4496 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
4497 * support is enabled. This Function sets the PMKID in firmware
4498 * when host drivr receives the corresponding request from NDIS.
4499 * The firmware then includes theset PMKID in the appropriate
4500 * management frames
4501 * @param[in,out] handle to the wifi driver
4502 * @param[in] message containing PMKID Info in the following format
4503 *|-----------------------------------------------------------------|
4504 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
4505 *|-----------|------------|----------|-------|----------|----------|
4506 | 1 | 6 | 16 | ... | 6 | 16 |
4507 ||-----------------------------------------------------------------|
4508 * @return Error code indicating success/failure
4509 * @note
4510 * @author zsalah
4511 * @date 8 March 2012
4512 * @version 1.0
4513 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004514s32 host_int_set_pmkid_info(struct host_if_drv *hif_drv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004515{
Leo Kime6e12662015-09-16 18:36:03 +09004516 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004517 struct host_if_msg msg;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004518 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004519
4520
Tony Choa4ab1ad2015-10-12 16:56:05 +09004521 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004522 s32Error = -EFAULT;
4523 PRINT_ER("driver is null\n");
4524 return s32Error;
4525 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004526
4527 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004528 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004529
Tony Choa9f812a2015-09-21 12:16:33 +09004530 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004531 msg.body.key_info.enuKeyType = PMKSA;
4532 msg.body.key_info.u8KeyAction = ADDKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004533 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004534
4535 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
4536
Tony Cho18990bf2015-09-30 18:44:24 +09004537 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004538 ETH_ALEN);
4539
Tony Cho18990bf2015-09-30 18:44:24 +09004540 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004541 PMKID_LEN);
4542 }
4543
4544 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004545 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004546 if (s32Error)
4547 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
4548
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004549 return s32Error;
4550}
4551
4552/**
4553 * @brief gets the cached the pmkid info
4554 * @details valid only in BSS STA mode if External Supplicant
4555 * support is enabled. This Function sets the PMKID in firmware
4556 * when host drivr receives the corresponding request from NDIS.
4557 * The firmware then includes theset PMKID in the appropriate
4558 * management frames
4559 * @param[in,out] handle to the wifi driver,
4560 * message containing PMKID Info in the following format
4561 *|-----------------------------------------------------------------|
4562 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
4563 *|-----------|------------|----------|-------|----------|----------|
4564 | 1 | 6 | 16 | ... | 6 | 16 |
4565 ||-----------------------------------------------------------------|
4566 * @param[in]
4567 * @return Error code indicating success/failure
4568 * @note
4569 * @author zsalah
4570 * @date 8 March 2012
4571 * @version 1.0
4572 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004573s32 host_int_get_pmkid_info(struct host_if_drv *hif_drv,
4574 u8 *pu8PmkidInfoArray,
4575 u32 u32PmkidInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004576{
Leo Kime9e0c262015-10-12 16:55:41 +09004577 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004578
Leo Kimdaaf16b2015-10-12 16:55:44 +09004579 strWID.id = (u16)WID_PMKID_INFO;
Leo Kim416d8322015-10-12 16:55:43 +09004580 strWID.type = WID_STR;
Leo Kim2fd3e442015-10-12 16:55:45 +09004581 strWID.size = u32PmkidInfoLen;
Leo Kim900bb4a2015-10-12 16:55:46 +09004582 strWID.val = pu8PmkidInfoArray;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004583
Leo Kimb68d820b2015-10-12 16:55:37 +09004584 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004585}
4586
4587/**
4588 * @brief sets the pass phrase
4589 * @details AP/STA mode. This function gives the pass phrase used to
4590 * generate the Pre-Shared Key when WPA/WPA2 is enabled
4591 * The length of the field can vary from 8 to 64 bytes,
4592 * the lower layer should get the
4593 * @param[in,out] handle to the wifi driver,
4594 * @param[in] String containing PSK
4595 * @return Error code indicating success/failure
4596 * @note
4597 * @author zsalah
4598 * @date 8 March 2012
4599 * @version 1.0
4600 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004601s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
4602 u8 *pu8PassPhrase,
4603 u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004604{
Leo Kime9e0c262015-10-12 16:55:41 +09004605 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004606
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004607 /*validating psk length*/
4608 if ((u8Psklength > 7) && (u8Psklength < 65)) {
Leo Kimdaaf16b2015-10-12 16:55:44 +09004609 strWID.id = (u16)WID_11I_PSK;
Leo Kim416d8322015-10-12 16:55:43 +09004610 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09004611 strWID.val = pu8PassPhrase;
Leo Kim2fd3e442015-10-12 16:55:45 +09004612 strWID.size = u8Psklength;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004613 }
4614
Leo Kimb68d820b2015-10-12 16:55:37 +09004615 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004616}
4617/**
4618 * @brief host_int_get_MacAddress
4619 * @details gets mac address
4620 * @param[in,out] handle to the wifi driver,
4621 *
4622 * @return Error code indicating success/failure
4623 * @note
4624 * @author mdaftedar
4625 * @date 19 April 2012
4626 * @version 1.0
4627 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004628s32 host_int_get_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004629{
Leo Kime6e12662015-09-16 18:36:03 +09004630 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004631 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004632
4633
4634 /* prepare the Message */
Tony Cho143eb952015-09-21 12:16:32 +09004635 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004636
Tony Choa9f812a2015-09-21 12:16:33 +09004637 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
Tony Choa5848692015-09-30 18:55:08 +09004638 msg.body.get_mac_info.u8MacAddress = pu8MacAddress;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004639 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004640 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004641 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004642 if (s32Error) {
4643 PRINT_ER("Failed to send get mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +09004644 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004645 }
4646
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004647 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004648 return s32Error;
4649}
4650
4651/**
4652 * @brief host_int_set_MacAddress
4653 * @details sets mac address
4654 * @param[in,out] handle to the wifi driver,
4655 *
4656 * @return Error code indicating success/failure
4657 * @note
4658 * @author mabubakr
4659 * @date 16 July 2012
4660 * @version 1.0
4661 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004662s32 host_int_set_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004663{
Leo Kime6e12662015-09-16 18:36:03 +09004664 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004665 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004666
4667 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
4668
4669 /* prepare setting mac address message */
Tony Cho143eb952015-09-21 12:16:32 +09004670 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09004671 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
Tony Cho15326e22015-09-30 18:55:07 +09004672 memcpy(msg.body.set_mac_info.u8MacAddress, pu8MacAddress, ETH_ALEN);
Tony Choa4ab1ad2015-10-12 16:56:05 +09004673 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004674
Tony Cho143eb952015-09-21 12:16:32 +09004675 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09004676 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004677 PRINT_ER("Failed to send message queue: Set mac address\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004678
4679 return s32Error;
4680
4681}
4682
4683/**
4684 * @brief host_int_get_RSNAConfigPSKPassPhrase
4685 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
4686 * generate the Pre-Shared Key when WPA/WPA2 is enabled
4687 * The length of the field can vary from 8 to 64 bytes,
4688 * the lower layer should get the
4689 * @param[in,out] handle to the wifi driver,
4690 * String containing PSK
4691 * @return Error code indicating success/failure
4692 * @note
4693 * @author zsalah
4694 * @date 8 March 2012
4695 * @version 1.0
4696 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004697s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
4698 u8 *pu8PassPhrase, u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004699{
Leo Kime9e0c262015-10-12 16:55:41 +09004700 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004701
Leo Kimdaaf16b2015-10-12 16:55:44 +09004702 strWID.id = (u16)WID_11I_PSK;
Leo Kim416d8322015-10-12 16:55:43 +09004703 strWID.type = WID_STR;
Leo Kim2fd3e442015-10-12 16:55:45 +09004704 strWID.size = u8Psklength;
Leo Kim900bb4a2015-10-12 16:55:46 +09004705 strWID.val = pu8PassPhrase;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004706
Leo Kimb68d820b2015-10-12 16:55:37 +09004707 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004708}
4709
4710/**
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004711 * @brief sets a start scan request
4712 * @details
4713 * @param[in,out] handle to the wifi driver,
4714 * @param[in] Scan Source one of the following values
4715 * DEFAULT_SCAN 0
4716 * USER_SCAN BIT0
4717 * OBSS_PERIODIC_SCAN BIT1
4718 * OBSS_ONETIME_SCAN BIT2
4719 * @return Error code indicating success/failure
4720 * @note
4721 * @author zsalah
4722 * @date 8 March 2012
4723 * @version 1.0
4724 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004725s32 host_int_set_start_scan_req(struct host_if_drv *hif_drv, u8 scanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004726{
Leo Kime9e0c262015-10-12 16:55:41 +09004727 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004728
Leo Kimdaaf16b2015-10-12 16:55:44 +09004729 strWID.id = (u16)WID_START_SCAN_REQ;
Leo Kim416d8322015-10-12 16:55:43 +09004730 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09004731 strWID.val = (s8 *)&scanSource;
Leo Kim2fd3e442015-10-12 16:55:45 +09004732 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004733
Leo Kimb68d820b2015-10-12 16:55:37 +09004734 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004735}
4736
4737/**
4738 * @brief host_int_get_start_scan_req
4739 * @details gets a start scan request
4740 * @param[in,out] handle to the wifi driver,
4741 * @param[in] Scan Source one of the following values
4742 * DEFAULT_SCAN 0
4743 * USER_SCAN BIT0
4744 * OBSS_PERIODIC_SCAN BIT1
4745 * OBSS_ONETIME_SCAN BIT2
4746 * @return Error code indicating success/failure
4747 * @note
4748 * @author zsalah
4749 * @date 8 March 2012
4750 * @version 1.0
4751 */
4752
Tony Choa4ab1ad2015-10-12 16:56:05 +09004753s32 host_int_get_start_scan_req(struct host_if_drv *hif_drv, u8 *pu8ScanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004754{
Leo Kime9e0c262015-10-12 16:55:41 +09004755 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004756
Leo Kimdaaf16b2015-10-12 16:55:44 +09004757 strWID.id = (u16)WID_START_SCAN_REQ;
Leo Kim416d8322015-10-12 16:55:43 +09004758 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09004759 strWID.val = (s8 *)pu8ScanSource;
Leo Kim2fd3e442015-10-12 16:55:45 +09004760 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004761
Leo Kimb68d820b2015-10-12 16:55:37 +09004762 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004763}
4764
4765/**
4766 * @brief host_int_set_join_req
4767 * @details sets a join request
4768 * @param[in,out] handle to the wifi driver,
4769 * @param[in] Index of the bss descriptor
4770 * @return Error code indicating success/failure
4771 * @note
4772 * @author zsalah
4773 * @date 8 March 2012
4774 * @version 1.0
4775 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004776s32 host_int_set_join_req(struct host_if_drv *hif_drv, u8 *pu8bssid,
4777 const u8 *pu8ssid, size_t ssidLen,
4778 const u8 *pu8IEs, size_t IEsLen,
4779 wilc_connect_result pfConnectResult, void *pvUserArg,
4780 u8 u8security, enum AUTHTYPE tenuAuth_type,
4781 u8 u8channel, void *pJoinParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004782{
Leo Kime6e12662015-09-16 18:36:03 +09004783 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004784 struct host_if_msg msg;
Leo Kim7696edf2015-10-12 16:56:02 +09004785 enum scan_conn_timer enuScanConnTimer;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004786
Tony Choa4ab1ad2015-10-12 16:56:05 +09004787 if (!hif_drv || pfConnectResult == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09004788 s32Error = -EFAULT;
4789 PRINT_ER("Driver is null\n");
4790 return s32Error;
4791 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004792
Tony Choa4ab1ad2015-10-12 16:56:05 +09004793 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004794 PRINT_ER("Driver is null\n");
4795 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004796 }
4797
4798 if (pJoinParams == NULL) {
4799 PRINT_ER("Unable to Join - JoinParams is NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09004800 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004801 }
Leo Kim24db7132015-09-16 18:36:01 +09004802
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004803 /* prepare the Connect Message */
Tony Cho143eb952015-09-21 12:16:32 +09004804 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004805
Tony Choa9f812a2015-09-21 12:16:33 +09004806 msg.id = HOST_IF_MSG_CONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004807
Tony Cho3f501972015-09-30 18:44:21 +09004808 msg.body.con_info.u8security = u8security;
4809 msg.body.con_info.tenuAuth_type = tenuAuth_type;
4810 msg.body.con_info.u8channel = u8channel;
4811 msg.body.con_info.pfConnectResult = pfConnectResult;
4812 msg.body.con_info.pvUserArg = pvUserArg;
4813 msg.body.con_info.pJoinParams = pJoinParams;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004814 msg.drv = hif_drv ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004815
4816 if (pu8bssid != NULL) {
Tony Cho3f501972015-09-30 18:44:21 +09004817 msg.body.con_info.pu8bssid = kmalloc(6, GFP_KERNEL); /* will be deallocated by the receiving thread */
4818 memcpy(msg.body.con_info.pu8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004819 pu8bssid, 6);
4820 }
4821
4822 if (pu8ssid != NULL) {
Tony Cho3f501972015-09-30 18:44:21 +09004823 msg.body.con_info.ssidLen = ssidLen;
4824 msg.body.con_info.pu8ssid = kmalloc(ssidLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
4825 memcpy(msg.body.con_info.pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004826
4827 pu8ssid, ssidLen);
4828 }
4829
4830 if (pu8IEs != NULL) {
Tony Cho3f501972015-09-30 18:44:21 +09004831 msg.body.con_info.IEsLen = IEsLen;
4832 msg.body.con_info.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
4833 memcpy(msg.body.con_info.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004834 pu8IEs, IEsLen);
4835 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09004836 if (hif_drv->enuHostIFstate < HOST_IF_CONNECTING)
4837 hif_drv->enuHostIFstate = HOST_IF_CONNECTING;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05304838 else
Tony Choa4ab1ad2015-10-12 16:56:05 +09004839 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 +09004840
4841 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004842 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004843 if (s32Error) {
4844 PRINT_ER("Failed to send message queue: Set join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09004845 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004846 }
4847
4848 enuScanConnTimer = CONNECT_TIMER;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004849 hif_drv->hConnectTimer.data = (unsigned long)hif_drv;
4850 mod_timer(&hif_drv->hConnectTimer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07004851 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004852
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004853 return s32Error;
4854}
4855
4856/**
4857 * @brief Flush a join request parameters to FW, but actual connection
4858 * @details The function is called in situation where WILC is connected to AP and
4859 * required to switch to hybrid FW for P2P connection
4860 * @param[in] handle to the wifi driver,
4861 * @return Error code indicating success/failure
4862 * @note
4863 * @author Amr Abdel-Moghny
4864 * @date 19 DEC 2013
4865 * @version 8.0
4866 */
4867
Tony Choa4ab1ad2015-10-12 16:56:05 +09004868s32 host_int_flush_join_req(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004869{
Leo Kime6e12662015-09-16 18:36:03 +09004870 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004871 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004872
4873 if (!gu8FlushedJoinReq) {
Leo Kime6e12662015-09-16 18:36:03 +09004874 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004875 return s32Error;
4876 }
4877
4878
Tony Choa4ab1ad2015-10-12 16:56:05 +09004879 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004880 s32Error = -EFAULT;
4881 PRINT_ER("Driver is null\n");
4882 return s32Error;
4883 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004884
Tony Choa9f812a2015-09-21 12:16:33 +09004885 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004886 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004887
4888 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004889 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004890 if (s32Error) {
4891 PRINT_ER("Failed to send message queue: Flush join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09004892 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004893 }
4894
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004895 return s32Error;
4896}
4897
4898/**
4899 * @brief host_int_disconnect
4900 * @details disconnects from the currently associated network
4901 * @param[in,out] handle to the wifi driver,
4902 * @param[in] Reason Code of the Disconnection
4903 * @return Error code indicating success/failure
4904 * @note
4905 * @author zsalah
4906 * @date 8 March 2012
4907 * @version 1.0
4908 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004909s32 host_int_disconnect(struct host_if_drv *hif_drv, u16 u16ReasonCode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004910{
Leo Kime6e12662015-09-16 18:36:03 +09004911 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004912 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004913
Tony Choa4ab1ad2015-10-12 16:56:05 +09004914 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004915 PRINT_ER("Driver is null\n");
4916 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004917 }
4918
4919 /* prepare the Disconnect Message */
Tony Cho143eb952015-09-21 12:16:32 +09004920 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004921
Tony Choa9f812a2015-09-21 12:16:33 +09004922 msg.id = HOST_IF_MSG_DISCONNECT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004923 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004924
4925 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004926 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004927 if (s32Error)
4928 PRINT_ER("Failed to send message queue: disconnect\n");
4929 /* ////////////// */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004930 down(&hif_drv->hSemTestDisconnectBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004931 /* /////// */
4932
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004933 return s32Error;
4934}
4935
4936/**
4937 * @brief host_int_disconnect_station
4938 * @details disconnects a sta
4939 * @param[in,out] handle to the wifi driver,
4940 * @param[in] Association Id of the station to be disconnected
4941 * @return Error code indicating success/failure
4942 * @note
4943 * @author zsalah
4944 * @date 8 March 2012
4945 * @version 1.0
4946 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09004947s32 host_int_disconnect_station(struct host_if_drv *hif_drv, u8 assoc_id)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004948{
Leo Kime9e0c262015-10-12 16:55:41 +09004949 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004950
Leo Kimdaaf16b2015-10-12 16:55:44 +09004951 strWID.id = (u16)WID_DISCONNECT;
Leo Kim416d8322015-10-12 16:55:43 +09004952 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09004953 strWID.val = (s8 *)&assoc_id;
Leo Kim2fd3e442015-10-12 16:55:45 +09004954 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004955
Leo Kimb68d820b2015-10-12 16:55:37 +09004956 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004957}
4958
4959/**
4960 * @brief host_int_get_assoc_req_info
4961 * @details gets a Association request info
4962 * @param[in,out] handle to the wifi driver,
4963 * Message containg assoc. req info in the following format
4964 * ------------------------------------------------------------------------
4965 | Management Frame Format |
4966 ||-------------------------------------------------------------------|
4967 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
4968 ||-------------|--------|--|--|-----|----------------|----------|----|
4969 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
4970 ||-------------------------------------------------------------------|
4971 | |
4972 | Association Request Frame - Frame Body |
4973 ||-------------------------------------------------------------------|
4974 | Capability Information | Listen Interval | SSID | Supported Rates |
4975 ||------------------------|-----------------|------|-----------------|
4976 | 2 | 2 | 2-34 | 3-10 |
4977 | ---------------------------------------------------------------------
4978 * @return Error code indicating success/failure
4979 * @note
4980 * @author zsalah
4981 * @date 8 March 2012
4982 * @version 1.0
4983 */
4984
Tony Choa4ab1ad2015-10-12 16:56:05 +09004985s32 host_int_get_assoc_req_info(struct host_if_drv *hif_drv, u8 *pu8AssocReqInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004986 u32 u32AssocReqInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004987{
Leo Kime9e0c262015-10-12 16:55:41 +09004988 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004989
Leo Kimdaaf16b2015-10-12 16:55:44 +09004990 strWID.id = (u16)WID_ASSOC_REQ_INFO;
Leo Kim416d8322015-10-12 16:55:43 +09004991 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09004992 strWID.val = pu8AssocReqInfo;
Leo Kim2fd3e442015-10-12 16:55:45 +09004993 strWID.size = u32AssocReqInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004994
Leo Kimb68d820b2015-10-12 16:55:37 +09004995 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004996}
4997
4998/**
4999 * @brief gets a Association Response info
5000 * @details
5001 * @param[in,out] handle to the wifi driver,
5002 * Message containg assoc. resp info
5003 * @return Error code indicating success/failure
5004 * @note
5005 * @author zsalah
5006 * @date 8 March 2012
5007 * @version 1.0
5008 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005009s32 host_int_get_assoc_res_info(struct host_if_drv *hif_drv, u8 *pu8AssocRespInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005010 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005011{
Leo Kime6e12662015-09-16 18:36:03 +09005012 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09005013 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005014
Tony Choa4ab1ad2015-10-12 16:56:05 +09005015 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005016 PRINT_ER("Driver is null\n");
5017 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005018 }
5019
Leo Kimdaaf16b2015-10-12 16:55:44 +09005020 strWID.id = (u16)WID_ASSOC_RES_INFO;
Leo Kim416d8322015-10-12 16:55:43 +09005021 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09005022 strWID.val = pu8AssocRespInfo;
Leo Kim2fd3e442015-10-12 16:55:45 +09005023 strWID.size = u32MaxAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005024
5025
5026 /* Sending Configuration packet */
Tony Cho03362282015-10-12 16:55:39 +09005027 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09005028 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005029 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005030 *pu32RcvdAssocRespInfoLen = 0;
Leo Kim24db7132015-09-16 18:36:01 +09005031 PRINT_ER("Failed to send association response config packet\n");
5032 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005033 } else {
Leo Kim2fd3e442015-10-12 16:55:45 +09005034 *pu32RcvdAssocRespInfoLen = strWID.size;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005035 }
5036
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005037 return s32Error;
5038}
5039
5040/**
5041 * @brief gets a Association Response info
5042 * @details Valid only in STA mode. This function gives the RSSI
5043 * values observed in all the channels at the time of scanning.
5044 * The length of the field is 1 greater that the total number of
5045 * channels supported. Byte 0 contains the number of channels while
5046 * each of Byte N contains the observed RSSI value for the channel index N.
5047 * @param[in,out] handle to the wifi driver,
5048 * array of scanned channels' RSSI
5049 * @return Error code indicating success/failure
5050 * @note
5051 * @author zsalah
5052 * @date 8 March 2012
5053 * @version 1.0
5054 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005055s32 host_int_get_rx_power_level(struct host_if_drv *hif_drv, u8 *pu8RxPowerLevel,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005056 u32 u32RxPowerLevelLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005057{
Leo Kime9e0c262015-10-12 16:55:41 +09005058 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005059
Leo Kimdaaf16b2015-10-12 16:55:44 +09005060 strWID.id = (u16)WID_RX_POWER_LEVEL;
Leo Kim416d8322015-10-12 16:55:43 +09005061 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09005062 strWID.val = pu8RxPowerLevel;
Leo Kim2fd3e442015-10-12 16:55:45 +09005063 strWID.size = u32RxPowerLevelLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005064
Leo Kimb68d820b2015-10-12 16:55:37 +09005065 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005066}
5067
5068/**
5069 * @brief sets a channel
5070 * @details
5071 * @param[in,out] handle to the wifi driver,
5072 * @param[in] Index of the channel to be set
5073 *|-------------------------------------------------------------------|
5074 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5075 | Input: 1 2 14 |
5076 ||-------------------------------------------------------------------|
5077 * @return Error code indicating success/failure
5078 * @note
5079 * @author zsalah
5080 * @date 8 March 2012
5081 * @version 1.0
5082 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005083int host_int_set_mac_chnl_num(struct host_if_drv *hif_drv, u8 channel)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005084{
Chaehyun Lim792fb252015-10-05 11:07:22 +09005085 int result;
Tony Cho143eb952015-09-21 12:16:32 +09005086 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005087
Tony Choa4ab1ad2015-10-12 16:56:05 +09005088 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005089 PRINT_ER("driver is null\n");
5090 return -EFAULT;
5091 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005092
5093 /* prepare the set channel message */
Tony Cho143eb952015-09-21 12:16:32 +09005094 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005095 msg.id = HOST_IF_MSG_SET_CHANNEL;
Chaehyun Lim1c5833c2015-10-02 21:44:51 +09005096 msg.body.channel_info.u8SetChan = channel;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005097 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005098
Chaehyun Lim1ef58e42015-10-02 21:44:49 +09005099 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5100 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09005101 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim792fb252015-10-05 11:07:22 +09005102 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005103 }
5104
Chaehyun Lim792fb252015-10-05 11:07:22 +09005105 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005106}
5107
Chaehyun Lim244efb12015-10-02 21:44:53 +09005108int host_int_wait_msg_queue_idle(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005109{
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09005110 int result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005111
Tony Cho143eb952015-09-21 12:16:32 +09005112 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005113
5114 /* prepare the set driver handler message */
5115
Tony Cho143eb952015-09-21 12:16:32 +09005116 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005117 msg.id = HOST_IF_MSG_Q_IDLE;
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09005118 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5119 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09005120 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09005121 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005122 }
5123
5124 /* wait untill MSG Q is empty */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005125 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005126
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09005127 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005128}
5129
Tony Choa4ab1ad2015-10-12 16:56:05 +09005130int host_int_set_wfi_drv_handler(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005131{
Chaehyun Lima0941012015-10-05 19:34:47 +09005132 int result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005133
Tony Cho143eb952015-09-21 12:16:32 +09005134 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005135
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005136 /* prepare the set driver handler message */
5137
Tony Cho143eb952015-09-21 12:16:32 +09005138 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005139 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005140 msg.body.drv.u32Address = get_id_from_handler(hif_drv);
5141 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005142
Chaehyun Lima0941012015-10-05 19:34:47 +09005143 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5144 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09005145 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0941012015-10-05 19:34:47 +09005146 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005147 }
5148
Chaehyun Lima0941012015-10-05 19:34:47 +09005149 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005150}
5151
Tony Choa4ab1ad2015-10-12 16:56:05 +09005152int host_int_set_operation_mode(struct host_if_drv *hif_drv, u32 mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005153{
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09005154 int result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005155
Tony Cho143eb952015-09-21 12:16:32 +09005156 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005157
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005158 /* prepare the set driver handler message */
5159
Tony Cho143eb952015-09-21 12:16:32 +09005160 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005161 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
Chaehyun Lim49fb6f72015-10-05 19:34:52 +09005162 msg.body.mode.u32Mode = mode;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005163 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005164
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09005165 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
5166 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09005167 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09005168 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005169 }
5170
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09005171 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005172}
5173
5174/**
5175 * @brief gets the current channel index
5176 * @details
5177 * @param[in,out] handle to the wifi driver,
5178 * current channel index
5179 *|-----------------------------------------------------------------------|
5180 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5181 | Input: 1 2 14 |
5182 ||-----------------------------------------------------------------------|
5183 * @return Error code indicating success/failure
5184 * @note
5185 * @author zsalah
5186 * @date 8 March 2012
5187 * @version 1.0
5188 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005189s32 host_int_get_host_chnl_num(struct host_if_drv *hif_drv, u8 *pu8ChNo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005190{
Leo Kime6e12662015-09-16 18:36:03 +09005191 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005192 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005193
Tony Choa4ab1ad2015-10-12 16:56:05 +09005194 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005195 PRINT_ER("driver is null\n");
5196 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005197 }
5198
5199 /* prepare the Get Channel Message */
Tony Cho143eb952015-09-21 12:16:32 +09005200 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005201
Tony Choa9f812a2015-09-21 12:16:33 +09005202 msg.id = HOST_IF_MSG_GET_CHNL;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005203 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005204
5205 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005206 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005207 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09005208 PRINT_ER("wilc mq send fail\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09005209 down(&hif_drv->hSemGetCHNL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005210 /* gu8Chnl = 11; */
5211
5212 *pu8ChNo = gu8Chnl;
5213
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005214 return s32Error;
5215
5216
5217}
5218
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005219/**
5220 * @brief host_int_get_inactive_time
5221 * @details
5222 * @param[in,out] handle to the wifi driver,
5223 * current sta macaddress, inactive_time
5224 * @return
5225 * @note
5226 * @author
5227 * @date
5228 * @version 1.0
5229 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005230s32 host_int_get_inactive_time(struct host_if_drv *hif_drv,
5231 const u8 *mac, u32 *pu32InactiveTime)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005232{
Leo Kime6e12662015-09-16 18:36:03 +09005233 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005234 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005235
Tony Choa4ab1ad2015-10-12 16:56:05 +09005236 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005237 PRINT_ER("driver is null\n");
5238 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005239 }
5240
Tony Cho143eb952015-09-21 12:16:32 +09005241 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005242
5243
Tony Cho66bac7f2015-09-30 18:44:37 +09005244 memcpy(msg.body.mac_info.mac,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005245 mac, ETH_ALEN);
5246
Tony Choa9f812a2015-09-21 12:16:33 +09005247 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005248 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005249
5250 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005251 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005252 if (s32Error)
5253 PRINT_ER("Failed to send get host channel param's message queue ");
5254
Tony Choa4ab1ad2015-10-12 16:56:05 +09005255 down(&hif_drv->hSemInactiveTime);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005256
5257 *pu32InactiveTime = gu32InactiveTime;
5258
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005259 return s32Error;
5260}
Glen Lee108b3432015-09-16 18:53:20 +09005261
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005262/**
5263 * @brief host_int_test_get_int_wid
5264 * @details Test function for getting wids
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005265 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005266 * @return Error code indicating success/failure
5267 * @note
5268 * @author zsalah
5269 * @date 8 March 2012
5270 * @version 1.0
5271 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005272s32 host_int_test_get_int_wid(struct host_if_drv *hif_drv, u32 *pu32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005273{
5274
Leo Kime6e12662015-09-16 18:36:03 +09005275 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09005276 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005277
Tony Choa4ab1ad2015-10-12 16:56:05 +09005278 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005279 PRINT_ER("driver is null\n");
5280 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005281 }
5282
Leo Kimdaaf16b2015-10-12 16:55:44 +09005283 strWID.id = (u16)WID_MEMORY_ADDRESS;
Leo Kim416d8322015-10-12 16:55:43 +09005284 strWID.type = WID_INT;
Leo Kim900bb4a2015-10-12 16:55:46 +09005285 strWID.val = (s8 *)pu32TestMemAddr;
Leo Kim2fd3e442015-10-12 16:55:45 +09005286 strWID.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005287
Tony Cho03362282015-10-12 16:55:39 +09005288 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09005289 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005290 /*get the value by searching the local copy*/
5291 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09005292 PRINT_ER("Failed to get wid value\n");
5293 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005294 } else {
5295 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
5296
5297 }
5298
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005299 return s32Error;
5300}
5301
5302
5303/**
5304 * @brief host_int_get_rssi
5305 * @details gets the currently maintained RSSI value for the station.
5306 * The received signal strength value in dB.
5307 * The range of valid values is -128 to 0.
5308 * @param[in,out] handle to the wifi driver,
5309 * rssi value in dB
5310 * @return Error code indicating success/failure
5311 * @note
5312 * @author zsalah
5313 * @date 8 March 2012
5314 * @version 1.0
5315 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005316s32 host_int_get_rssi(struct host_if_drv *hif_drv, s8 *ps8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005317{
Leo Kime6e12662015-09-16 18:36:03 +09005318 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005319 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005320
5321 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09005322 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005323
Tony Choa9f812a2015-09-21 12:16:33 +09005324 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005325 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005326
5327 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005328 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005329 if (s32Error) {
5330 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005331 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005332 }
5333
Tony Choa4ab1ad2015-10-12 16:56:05 +09005334 down(&hif_drv->hSemGetRSSI);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005335
5336
5337 if (ps8Rssi == NULL) {
5338 PRINT_ER("RSS pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09005339 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005340 }
5341
5342
5343 *ps8Rssi = gs8Rssi;
5344
5345
5346 return s32Error;
5347}
5348
Tony Choa4ab1ad2015-10-12 16:56:05 +09005349s32 host_int_get_link_speed(struct host_if_drv *hif_drv, s8 *ps8lnkspd)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005350{
Tony Cho143eb952015-09-21 12:16:32 +09005351 struct host_if_msg msg;
Leo Kime6e12662015-09-16 18:36:03 +09005352 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005353
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005354 /* prepare the Get LINKSPEED Message */
Tony Cho143eb952015-09-21 12:16:32 +09005355 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005356
Tony Choa9f812a2015-09-21 12:16:33 +09005357 msg.id = HOST_IF_MSG_GET_LINKSPEED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005358 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005359
5360 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005361 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005362 if (s32Error) {
5363 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005364 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005365 }
5366
Tony Choa4ab1ad2015-10-12 16:56:05 +09005367 down(&hif_drv->hSemGetLINKSPEED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005368
5369
5370 if (ps8lnkspd == NULL) {
5371 PRINT_ER("LINKSPEED pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09005372 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005373 }
5374
5375
5376 *ps8lnkspd = gs8lnkspd;
5377
5378
5379 return s32Error;
5380}
5381
Tony Choa4ab1ad2015-10-12 16:56:05 +09005382s32 host_int_get_statistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005383{
Leo Kime6e12662015-09-16 18:36:03 +09005384 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005385 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005386
5387
5388 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09005389 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005390
Tony Choa9f812a2015-09-21 12:16:33 +09005391 msg.id = HOST_IF_MSG_GET_STATISTICS;
Tony Choe60831e2015-10-05 13:50:45 +09005392 msg.body.data = (char *)pstrStatistics;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005393 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005394 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005395 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005396 if (s32Error) {
5397 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005398 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005399 }
5400
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005401 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005402 return s32Error;
5403}
5404
5405
5406/**
5407 * @brief host_int_scan
5408 * @details scans a set of channels
5409 * @param[in,out] handle to the wifi driver,
5410 * @param[in] Scan source
5411 * Scan Type PASSIVE_SCAN = 0,
5412 * ACTIVE_SCAN = 1
5413 * Channels Array
5414 * Channels Array length
5415 * Scan Callback function
5416 * @return Error code indicating success/failure
5417 * @note
5418 * @author zsalah
5419 * @date 8 March 2012
5420 * @version 1.0
5421 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005422s32 host_int_scan(struct host_if_drv *hif_drv, u8 u8ScanSource,
5423 u8 u8ScanType, u8 *pu8ChnlFreqList,
5424 u8 u8ChnlListLen, const u8 *pu8IEs,
5425 size_t IEsLen, wilc_scan_result ScanResult,
5426 void *pvUserArg, struct hidden_network *pstrHiddenNetwork)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005427{
Leo Kime6e12662015-09-16 18:36:03 +09005428 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005429 struct host_if_msg msg;
Leo Kim7696edf2015-10-12 16:56:02 +09005430 enum scan_conn_timer enuScanConnTimer;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005431
Tony Choa4ab1ad2015-10-12 16:56:05 +09005432 if (!hif_drv || ScanResult == NULL) {
5433 PRINT_ER("hif_drv or ScanResult = NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09005434 return -EFAULT;
5435 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005436
5437 /* prepare the Scan Message */
Tony Cho143eb952015-09-21 12:16:32 +09005438 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005439
Tony Choa9f812a2015-09-21 12:16:33 +09005440 msg.id = HOST_IF_MSG_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005441
5442 if (pstrHiddenNetwork != NULL) {
Tony Cho4528bdb2015-09-30 18:44:20 +09005443 msg.body.scan_info.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
5444 msg.body.scan_info.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005445
5446 } else
5447 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
5448
Tony Choa4ab1ad2015-10-12 16:56:05 +09005449 msg.drv = hif_drv;
Tony Cho4528bdb2015-09-30 18:44:20 +09005450 msg.body.scan_info.u8ScanSource = u8ScanSource;
5451 msg.body.scan_info.u8ScanType = u8ScanType;
5452 msg.body.scan_info.pfScanResult = ScanResult;
5453 msg.body.scan_info.pvUserArg = pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005454
Tony Cho4528bdb2015-09-30 18:44:20 +09005455 msg.body.scan_info.u8ChnlListLen = u8ChnlListLen;
5456 msg.body.scan_info.pu8ChnlFreqList = kmalloc(u8ChnlListLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5457 memcpy(msg.body.scan_info.pu8ChnlFreqList,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005458 pu8ChnlFreqList, u8ChnlListLen);
5459
Tony Cho4528bdb2015-09-30 18:44:20 +09005460 msg.body.scan_info.IEsLen = IEsLen;
5461 msg.body.scan_info.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5462 memcpy(msg.body.scan_info.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005463 pu8IEs, IEsLen);
5464
5465 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005466 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005467 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09005468 PRINT_ER("Error in sending message queue\n");
5469 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005470 }
5471
5472 enuScanConnTimer = SCAN_TIMER;
5473 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09005474 hif_drv->hScanTimer.data = (unsigned long)hif_drv;
5475 mod_timer(&hif_drv->hScanTimer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005476 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005477
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005478 return s32Error;
5479
5480}
5481/**
5482 * @brief hif_set_cfg
5483 * @details sets configuration wids values
5484 * @param[in,out] handle to the wifi driver,
5485 * @param[in] WID, WID value
5486 * @return Error code indicating success/failure
5487 * @note
5488 * @author zsalah
5489 * @date 8 March 2012
5490 * @version 1.0
5491 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005492s32 hif_set_cfg(struct host_if_drv *hif_drv,
5493 struct cfg_param_val *pstrCfgParamVal)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005494{
5495
Leo Kime6e12662015-09-16 18:36:03 +09005496 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005497 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005498
5499
Tony Choa4ab1ad2015-10-12 16:56:05 +09005500 if (!hif_drv) {
5501 PRINT_ER("hif_drv NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09005502 return -EFAULT;
5503 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005504 /* prepare the WiphyParams Message */
Tony Cho143eb952015-09-21 12:16:32 +09005505 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005506 msg.id = HOST_IF_MSG_CFG_PARAMS;
Tony Cho221371e2015-10-12 16:56:06 +09005507 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005508 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005509
Tony Cho143eb952015-09-21 12:16:32 +09005510 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005511
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005512 return s32Error;
5513
5514}
5515
5516
5517/**
5518 * @brief hif_get_cfg
5519 * @details gets configuration wids values
5520 * @param[in,out] handle to the wifi driver,
5521 * WID value
5522 * @param[in] WID,
5523 * @return Error code indicating success/failure
5524 * @note
5525 * @author zsalah
5526 *
5527 * @date 8 March 2012
5528 * @version 1.0
5529 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005530s32 hif_get_cfg(struct host_if_drv *hif_drv, u16 u16WID, u16 *pu16WID_Value)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005531{
Leo Kime6e12662015-09-16 18:36:03 +09005532 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005533
Tony Choa4ab1ad2015-10-12 16:56:05 +09005534 down(&hif_drv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005535
Tony Choa4ab1ad2015-10-12 16:56:05 +09005536 if (!hif_drv) {
5537 PRINT_ER("hif_drv NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09005538 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005539 }
5540 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
5541 switch (u16WID) {
5542
5543 case WID_BSS_TYPE:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005544 *pu16WID_Value = (u16)hif_drv->strCfgValues.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005545 break;
5546
5547 case WID_AUTH_TYPE:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005548 *pu16WID_Value = (u16)hif_drv->strCfgValues.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005549 break;
5550
5551 case WID_AUTH_TIMEOUT:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005552 *pu16WID_Value = hif_drv->strCfgValues.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005553 break;
5554
5555 case WID_POWER_MANAGEMENT:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005556 *pu16WID_Value = (u16)hif_drv->strCfgValues.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005557 break;
5558
5559 case WID_SHORT_RETRY_LIMIT:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005560 *pu16WID_Value = hif_drv->strCfgValues.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005561 break;
5562
5563 case WID_LONG_RETRY_LIMIT:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005564 *pu16WID_Value = hif_drv->strCfgValues.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005565 break;
5566
5567 case WID_FRAG_THRESHOLD:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005568 *pu16WID_Value = hif_drv->strCfgValues.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005569 break;
5570
5571 case WID_RTS_THRESHOLD:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005572 *pu16WID_Value = hif_drv->strCfgValues.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005573 break;
5574
5575 case WID_PREAMBLE:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005576 *pu16WID_Value = (u16)hif_drv->strCfgValues.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005577 break;
5578
5579 case WID_SHORT_SLOT_ALLOWED:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005580 *pu16WID_Value = (u16) hif_drv->strCfgValues.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005581 break;
5582
5583 case WID_11N_TXOP_PROT_DISABLE:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005584 *pu16WID_Value = (u16)hif_drv->strCfgValues.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005585 break;
5586
5587 case WID_BEACON_INTERVAL:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005588 *pu16WID_Value = hif_drv->strCfgValues.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005589 break;
5590
5591 case WID_DTIM_PERIOD:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005592 *pu16WID_Value = (u16)hif_drv->strCfgValues.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005593 break;
5594
5595 case WID_SITE_SURVEY:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005596 *pu16WID_Value = (u16)hif_drv->strCfgValues.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005597 break;
5598
5599 case WID_SITE_SURVEY_SCAN_TIME:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005600 *pu16WID_Value = hif_drv->strCfgValues.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005601 break;
5602
5603 case WID_ACTIVE_SCAN_TIME:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005604 *pu16WID_Value = hif_drv->strCfgValues.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005605 break;
5606
5607 case WID_PASSIVE_SCAN_TIME:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005608 *pu16WID_Value = hif_drv->strCfgValues.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005609 break;
5610
5611 case WID_CURRENT_TX_RATE:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005612 *pu16WID_Value = hif_drv->strCfgValues.curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005613 break;
5614
5615 default:
5616 break;
5617 }
5618
Tony Choa4ab1ad2015-10-12 16:56:05 +09005619 up(&hif_drv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005620
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005621 return s32Error;
5622
5623}
5624
5625/*****************************************************************************/
5626/* Notification Functions */
5627/*****************************************************************************/
5628/**
5629 * @brief notifies host with join and leave requests
5630 * @details This function prepares an Information frame having the
5631 * information about a joining/leaving station.
5632 * @param[in,out] handle to the wifi driver,
5633 * @param[in] 6 byte Sta Adress
5634 * Join or leave flag:
5635 * Join = 1,
5636 * Leave =0
5637 * @return Error code indicating success/failure
5638 * @note
5639 * @author zsalah
5640 * @date 8 March 2012
5641 * @version 1.0
5642 */
5643void host_int_send_join_leave_info_to_host
Dean Lee72ed4dc2015-06-12 14:11:44 +09005644 (u16 assocId, u8 *stationAddr, bool joining)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005645{
5646}
5647/**
5648 * @brief notifies host with stations found in scan
5649 * @details sends the beacon/probe response from scan
5650 * @param[in,out] handle to the wifi driver,
5651 * @param[in] Sta Address,
5652 * Frame length,
5653 * Rssi of the Station found
5654 * @return Error code indicating success/failure
5655 * @note
5656 * @author zsalah
5657 * @date 8 March 2012
5658 * @version 1.0
5659 */
5660
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07005661static void GetPeriodicRSSI(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005662{
Tony Choa4ab1ad2015-10-12 16:56:05 +09005663 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02005664
Tony Choa4ab1ad2015-10-12 16:56:05 +09005665 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005666 PRINT_ER("Driver handler is NULL\n");
5667 return;
5668 }
5669
Tony Choa4ab1ad2015-10-12 16:56:05 +09005670 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) {
Leo Kime6e12662015-09-16 18:36:03 +09005671 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005672 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005673
5674 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09005675 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005676
Tony Choa9f812a2015-09-21 12:16:33 +09005677 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005678 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005679
5680 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005681 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005682 if (s32Error) {
5683 PRINT_ER("Failed to send get host channel param's message queue ");
5684 return;
5685 }
5686 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09005687 g_hPeriodicRSSI.data = (unsigned long)hif_drv;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005688 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005689}
5690
5691
5692void host_int_send_network_info_to_host
Chaehyun Limca356ad2015-06-11 14:35:57 +09005693 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005694{
5695}
5696/**
5697 * @brief host_int_init
5698 * @details host interface initialization function
5699 * @param[in,out] handle to the wifi driver,
5700 * @note
5701 * @author zsalah
5702 * @date 8 March 2012
5703 * @version 1.0
5704 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005705static u32 clients_count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005706
Tony Choa4ab1ad2015-10-12 16:56:05 +09005707s32 host_int_init(struct host_if_drv **hif_drv_handler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005708{
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09005709 s32 result = 0;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005710 struct host_if_drv *hif_drv;
Johnny Kimd42ab082015-08-20 16:32:52 +09005711 int err;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005712
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005713 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
5714
Dean Lee72ed4dc2015-06-12 14:11:44 +09005715 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005716
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005717 sema_init(&hWaitResponse, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005718
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005719 /*Allocate host interface private structure*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09005720 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
5721 if (!hif_drv) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09005722 result = -ENOMEM;
Vincent Stehlé17db84e2015-10-07 07:08:25 +02005723 goto _fail_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005724 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09005725 *hif_drv_handler = hif_drv;
5726 err = add_handler_in_list(hif_drv);
Johnny Kimd42ab082015-08-20 16:32:52 +09005727 if (err) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09005728 result = -EFAULT;
Johnny Kimd42ab082015-08-20 16:32:52 +09005729 goto _fail_timer_2;
5730 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005731
Dean Lee72ed4dc2015-06-12 14:11:44 +09005732 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005733
Tony Choa4ab1ad2015-10-12 16:56:05 +09005734 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005735 if (clients_count == 0) {
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005736 sema_init(&hSemHostIFthrdEnd, 0);
5737 sema_init(&hSemDeinitDrvHandle, 0);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005738 sema_init(&hSemHostIntDeinit, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005739 }
5740
Tony Choa4ab1ad2015-10-12 16:56:05 +09005741 sema_init(&hif_drv->hSemTestKeyBlock, 0);
5742 sema_init(&hif_drv->hSemTestDisconnectBlock, 0);
5743 sema_init(&hif_drv->hSemGetRSSI, 0);
5744 sema_init(&hif_drv->hSemGetLINKSPEED, 0);
5745 sema_init(&hif_drv->hSemGetCHNL, 0);
5746 sema_init(&hif_drv->hSemInactiveTime, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005747
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005748 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
5749
5750 if (clients_count == 0) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09005751 result = wilc_mq_create(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005752
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09005753 if (result < 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005754 PRINT_ER("Failed to creat MQ\n");
5755 goto _fail_;
5756 }
Arnd Bergmann1999bd52015-05-29 22:52:14 +02005757 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
5758 if (IS_ERR(HostIFthreadHandler)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005759 PRINT_ER("Failed to creat Thread\n");
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09005760 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005761 goto _fail_mq_;
5762 }
Greg Kroah-Hartman507d7fc2015-08-17 12:59:42 -07005763 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
Tony Choa4ab1ad2015-10-12 16:56:05 +09005764 (unsigned long)hif_drv);
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005765 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005766 }
5767
Tony Choa4ab1ad2015-10-12 16:56:05 +09005768 setup_timer(&hif_drv->hScanTimer, TimerCB_Scan, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005769
Tony Choa4ab1ad2015-10-12 16:56:05 +09005770 setup_timer(&hif_drv->hConnectTimer, TimerCB_Connect, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005771
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005772 /*Remain on channel timer*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09005773 setup_timer(&hif_drv->hRemainOnChannel, ListenTimerCB, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005774
Tony Choa4ab1ad2015-10-12 16:56:05 +09005775 sema_init(&(hif_drv->gtOsCfgValuesSem), 1);
5776 down(&hif_drv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005777
Tony Choa4ab1ad2015-10-12 16:56:05 +09005778 hif_drv->enuHostIFstate = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005779
5780 /*Initialize CFG WIDS Defualt Values*/
5781
Tony Choa4ab1ad2015-10-12 16:56:05 +09005782 hif_drv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
5783 hif_drv->strCfgValues.scan_source = DEFAULT_SCAN;
5784 hif_drv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
5785 hif_drv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
5786 hif_drv->strCfgValues.curr_tx_rate = AUTORATE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005787
Tony Choa4ab1ad2015-10-12 16:56:05 +09005788 hif_drv->u64P2p_MgmtTimeout = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005789
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005790 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",
5791
Tony Choa4ab1ad2015-10-12 16:56:05 +09005792 hif_drv->strCfgValues.site_survey_enabled, hif_drv->strCfgValues.scan_source,
5793 hif_drv->strCfgValues.active_scan_time, hif_drv->strCfgValues.passive_scan_time,
5794 hif_drv->strCfgValues.curr_tx_rate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005795
Tony Choa4ab1ad2015-10-12 16:56:05 +09005796 up(&hif_drv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005797
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005798 clients_count++; /* increase number of created entities */
5799
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09005800 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005801
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005802_fail_timer_2:
Tony Choa4ab1ad2015-10-12 16:56:05 +09005803 up(&hif_drv->gtOsCfgValuesSem);
5804 del_timer_sync(&hif_drv->hConnectTimer);
5805 del_timer_sync(&hif_drv->hScanTimer);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02005806 kthread_stop(HostIFthreadHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005807_fail_mq_:
Chaehyun Lim1b128f62015-08-19 15:59:08 +09005808 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005809_fail_:
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09005810 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005811}
5812/**
5813 * @brief host_int_deinit
5814 * @details host interface initialization function
5815 * @param[in,out] handle to the wifi driver,
5816 * @note
5817 * @author zsalah
5818 * @date 8 March 2012
5819 * @version 1.0
5820 */
5821
Tony Choa4ab1ad2015-10-12 16:56:05 +09005822s32 host_int_deinit(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005823{
Leo Kime6e12662015-09-16 18:36:03 +09005824 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005825 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09005826 int ret;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005827
5828 /*obtain driver handle*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005829
Tony Choa4ab1ad2015-10-12 16:56:05 +09005830 if (!hif_drv) {
5831 PRINT_ER("hif_drv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005832 return 0;
5833 }
5834
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005835 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005836
Tony Choa4ab1ad2015-10-12 16:56:05 +09005837 terminated_handle = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005838 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
5839
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005840 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
5841 /*to guarantee handling all messages befor proceeding*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09005842 if (del_timer_sync(&hif_drv->hScanTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005843 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005844 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
5845 }
5846
Tony Choa4ab1ad2015-10-12 16:56:05 +09005847 if (del_timer_sync(&hif_drv->hConnectTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005848 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005849 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
5850 }
5851
5852
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07005853 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005854 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005855 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
5856 }
5857
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005858 /*Destroy Remain-onchannel Timer*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09005859 del_timer_sync(&hif_drv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005860
Johnny Kim218dc402015-08-13 13:41:19 +09005861 host_int_set_wfi_drv_handler(NULL);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005862 down(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005863
5864
5865 /*Calling the CFG80211 scan done function with the abort flag set to true*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09005866 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
5867 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
5868 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005869
Tony Choa4ab1ad2015-10-12 16:56:05 +09005870 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005871 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005872
Tony Choa4ab1ad2015-10-12 16:56:05 +09005873 hif_drv->enuHostIFstate = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005874
Dean Lee72ed4dc2015-06-12 14:11:44 +09005875 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005876
Tony Cho143eb952015-09-21 12:16:32 +09005877 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005878
5879 if (clients_count == 1) {
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07005880 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005881 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005882 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
5883 }
Tony Choa9f812a2015-09-21 12:16:33 +09005884 msg.id = HOST_IF_MSG_EXIT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005885 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005886
5887
Tony Cho143eb952015-09-21 12:16:32 +09005888 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kime6e12662015-09-16 18:36:03 +09005889 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005890 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005891
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005892 down(&hSemHostIFthrdEnd);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005893
Chaehyun Lim1b128f62015-08-19 15:59:08 +09005894 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005895 }
5896
Tony Choa4ab1ad2015-10-12 16:56:05 +09005897 down(&(hif_drv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005898
5899 /*Setting the gloabl driver handler with NULL*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005900 /* gWFiDrvHandle = NULL; */
Tony Choa4ab1ad2015-10-12 16:56:05 +09005901 ret = remove_handler_in_list(hif_drv);
Johnny Kimd42ab082015-08-20 16:32:52 +09005902 if (ret)
Leo Kime6e12662015-09-16 18:36:03 +09005903 s32Error = -ENOENT;
Johnny Kimd42ab082015-08-20 16:32:52 +09005904
Tony Choa4ab1ad2015-10-12 16:56:05 +09005905 kfree(hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005906
5907 clients_count--; /* Decrease number of created entities */
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005908 terminated_handle = NULL;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005909 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005910 return s32Error;
5911}
5912
5913
5914/**
5915 * @brief NetworkInfoReceived
5916 * @details function to to be called when network info packet is received
5917 * @param[in] pu8Buffer the received packet
5918 * @param[in] u32Length length of the received packet
5919 * @return none
5920 * @note
5921 * @author
5922 * @date 1 Mar 2012
5923 * @version 1.0
5924 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005925void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005926{
Leo Kime6e12662015-09-16 18:36:03 +09005927 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005928 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09005929 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005930 struct host_if_drv *hif_drv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005931
Johnny Kimd42ab082015-08-20 16:32:52 +09005932 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09005933 hif_drv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005934
5935
5936
5937
Tony Choa4ab1ad2015-10-12 16:56:05 +09005938 if (!hif_drv || hif_drv == terminated_handle) {
5939 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005940 return;
5941 }
5942
5943 /* prepare the Asynchronous Network Info message */
Tony Cho143eb952015-09-21 12:16:32 +09005944 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005945
Tony Choa9f812a2015-09-21 12:16:33 +09005946 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005947 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005948
Tony Cho02d19462015-09-30 18:44:22 +09005949 msg.body.net_info.u32Length = u32Length;
5950 msg.body.net_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
5951 memcpy(msg.body.net_info.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005952 pu8Buffer, u32Length);
5953
5954 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005955 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005956 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005957 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005958}
5959
5960/**
5961 * @brief GnrlAsyncInfoReceived
5962 * @details function to be called when general Asynchronous info packet is received
5963 * @param[in] pu8Buffer the received packet
5964 * @param[in] u32Length length of the received packet
5965 * @return none
5966 * @note
5967 * @author
5968 * @date 15 Mar 2012
5969 * @version 1.0
5970 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005971void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005972{
Leo Kime6e12662015-09-16 18:36:03 +09005973 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005974 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09005975 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005976 struct host_if_drv *hif_drv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005977
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005978 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005979
Johnny Kimd42ab082015-08-20 16:32:52 +09005980 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09005981 hif_drv = get_handler_from_id(id);
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005982 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005983
5984
Tony Choa4ab1ad2015-10-12 16:56:05 +09005985 if (!hif_drv || hif_drv == terminated_handle) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005986 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005987 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005988 return;
5989 }
5990
Tony Choa4ab1ad2015-10-12 16:56:05 +09005991 if (!hif_drv->strWILC_UsrConnReq.pfUserConnectResult) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005992 /* received mac status is not needed when there is no current Connect Request */
5993 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005994 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005995 return;
5996 }
5997
5998 /* prepare the General Asynchronous Info message */
Tony Cho143eb952015-09-21 12:16:32 +09005999 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006000
6001
Tony Choa9f812a2015-09-21 12:16:33 +09006002 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006003 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006004
6005
Tony Cho66add622015-09-30 18:44:23 +09006006 msg.body.async_info.u32Length = u32Length;
6007 msg.body.async_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
6008 memcpy(msg.body.async_info.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006009 pu8Buffer, u32Length);
6010
6011 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006012 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006013 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006014 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006015
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006016 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006017}
6018
6019/**
6020 * @brief host_int_ScanCompleteReceived
6021 * @details Setting scan complete received notifcation in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006022 * @param[in] u8* pu8Buffer, u32 u32Length
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006023 * @return Error code.
6024 * @author
6025 * @date
6026 * @version 1.0
6027 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006028void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006029{
Leo Kime6e12662015-09-16 18:36:03 +09006030 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006031 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006032 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006033 struct host_if_drv *hif_drv = NULL;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006034
Johnny Kimd42ab082015-08-20 16:32:52 +09006035 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09006036 hif_drv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006037
6038
Tony Choa4ab1ad2015-10-12 16:56:05 +09006039 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006040
Tony Choa4ab1ad2015-10-12 16:56:05 +09006041 if (!hif_drv || hif_drv == terminated_handle)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006042 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006043
6044 /*if there is an ongoing scan request*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09006045 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006046 /* prepare theScan Done message */
Tony Cho143eb952015-09-21 12:16:32 +09006047 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006048
Tony Choa9f812a2015-09-21 12:16:33 +09006049 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006050 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006051
6052
6053 /* will be deallocated by the receiving thread */
6054 /*no need to send message body*/
6055
Tony Cho410c2482015-09-21 12:16:35 +09006056 /*msg.body.strScanComplete.u32Length = u32Length;
6057 * msg.body.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
6058 * memcpy(msg.body.strScanComplete.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006059 * pu8Buffer, u32Length); */
6060
6061 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006062 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006063 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006064 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006065 }
6066
6067
6068 return;
6069
6070}
6071
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006072/**
6073 * @brief host_int_remain_on_channel
6074 * @details
6075 * @param[in] Handle to wifi driver
6076 * Duration to remain on channel
6077 * Channel to remain on
6078 * Pointer to fn to be called on receive frames in listen state
6079 * Pointer to remain-on-channel expired fn
6080 * Priv
6081 * @return Error code.
6082 * @author
6083 * @date
6084 * @version 1.0
6085 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09006086s32 host_int_remain_on_channel(struct host_if_drv *hif_drv, u32 u32SessionID,
6087 u32 u32duration, u16 chan,
6088 wilc_remain_on_chan_expired RemainOnChanExpired,
6089 wilc_remain_on_chan_ready RemainOnChanReady,
6090 void *pvUserArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006091{
Leo Kime6e12662015-09-16 18:36:03 +09006092 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006093 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006094
Tony Choa4ab1ad2015-10-12 16:56:05 +09006095 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006096 PRINT_ER("driver is null\n");
6097 return -EFAULT;
6098 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006099
6100 /* prepare the remainonchan Message */
Tony Cho143eb952015-09-21 12:16:32 +09006101 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006102
6103 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006104 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
Tony Cho070d3652015-09-30 18:55:10 +09006105 msg.body.remain_on_ch.u16Channel = chan;
6106 msg.body.remain_on_ch.pRemainOnChanExpired = RemainOnChanExpired;
6107 msg.body.remain_on_ch.pRemainOnChanReady = RemainOnChanReady;
6108 msg.body.remain_on_ch.pVoid = pvUserArg;
6109 msg.body.remain_on_ch.u32duration = u32duration;
6110 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006111 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006112
Tony Cho143eb952015-09-21 12:16:32 +09006113 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006114 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006115 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006116
6117 return s32Error;
6118}
6119
6120/**
6121 * @brief host_int_ListenStateExpired
6122 * @details
6123 * @param[in] Handle to wifi driver
6124 * Duration to remain on channel
6125 * Channel to remain on
6126 * Pointer to fn to be called on receive frames in listen state
6127 * Pointer to remain-on-channel expired fn
6128 * Priv
6129 * @return Error code.
6130 * @author
6131 * @date
6132 * @version 1.0
6133 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09006134s32 host_int_ListenStateExpired(struct host_if_drv *hif_drv, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006135{
Leo Kime6e12662015-09-16 18:36:03 +09006136 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006137 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006138
Tony Choa4ab1ad2015-10-12 16:56:05 +09006139 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006140 PRINT_ER("driver is null\n");
6141 return -EFAULT;
6142 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006143
6144 /*Stopping remain-on-channel timer*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09006145 del_timer(&hif_drv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006146
6147 /* prepare the timer fire Message */
Tony Cho143eb952015-09-21 12:16:32 +09006148 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09006149 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006150 msg.drv = hif_drv;
Tony Cho070d3652015-09-30 18:55:10 +09006151 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006152
Tony Cho143eb952015-09-21 12:16:32 +09006153 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006154 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006155 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006156
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006157 return s32Error;
6158}
6159
6160/**
6161 * @brief host_int_frame_register
6162 * @details
6163 * @param[in] Handle to wifi driver
6164 * @return Error code.
6165 * @author
6166 * @date
6167 * @version 1.0*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09006168s32 host_int_frame_register(struct host_if_drv *hif_drv, u16 u16FrameType, bool bReg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006169{
Leo Kime6e12662015-09-16 18:36:03 +09006170 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006171 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006172
Tony Choa4ab1ad2015-10-12 16:56:05 +09006173 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006174 PRINT_ER("driver is null\n");
6175 return -EFAULT;
6176 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006177
Tony Cho143eb952015-09-21 12:16:32 +09006178 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006179
6180 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006181 msg.id = HOST_IF_MSG_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006182 switch (u16FrameType) {
6183 case ACTION:
6184 PRINT_D(HOSTINF_DBG, "ACTION\n");
Tony Cho5c4008d2015-10-05 13:50:44 +09006185 msg.body.reg_frame.u8Regid = ACTION_FRM_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006186 break;
6187
6188 case PROBE_REQ:
6189 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
Tony Cho5c4008d2015-10-05 13:50:44 +09006190 msg.body.reg_frame.u8Regid = PROBE_REQ_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006191 break;
6192
6193 default:
6194 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
6195 break;
6196 }
Tony Cho5c4008d2015-10-05 13:50:44 +09006197 msg.body.reg_frame.u16FrameType = u16FrameType;
6198 msg.body.reg_frame.bReg = bReg;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006199 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006200
Tony Cho143eb952015-09-21 12:16:32 +09006201 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006202 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006203 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006204
6205 return s32Error;
6206
6207
6208}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006209
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006210/**
6211 * @brief host_int_add_beacon
6212 * @details Setting add beacon params in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006213 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
6214 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
6215 * u32 u32TailLen, u8* pu8Tail
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006216 * @return Error code.
6217 * @author
6218 * @date
6219 * @version 1.0
6220 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09006221s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
6222 u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head,
6223 u32 u32TailLen, u8 *pu8Tail)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006224{
Leo Kime6e12662015-09-16 18:36:03 +09006225 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006226 struct host_if_msg msg;
Tony Choa98491e2015-09-30 18:44:31 +09006227 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006228
Tony Choa4ab1ad2015-10-12 16:56:05 +09006229 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006230 PRINT_ER("driver is null\n");
6231 return -EFAULT;
6232 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006233
Tony Cho143eb952015-09-21 12:16:32 +09006234 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006235
6236 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
6237
6238
6239 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006240 msg.id = HOST_IF_MSG_ADD_BEACON;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006241 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006242 pstrSetBeaconParam->u32Interval = u32Interval;
6243 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
6244 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
Glen Leef3052582015-09-10 12:03:04 +09006245 pstrSetBeaconParam->pu8Head = kmalloc(u32HeadLen, GFP_KERNEL);
Leo Kim24db7132015-09-16 18:36:01 +09006246 if (pstrSetBeaconParam->pu8Head == NULL) {
6247 s32Error = -ENOMEM;
6248 goto ERRORHANDLER;
6249 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006250 memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006251 pstrSetBeaconParam->u32TailLen = u32TailLen;
6252
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006253 if (u32TailLen > 0) {
Glen Leef3052582015-09-10 12:03:04 +09006254 pstrSetBeaconParam->pu8Tail = kmalloc(u32TailLen, GFP_KERNEL);
Leo Kim24db7132015-09-16 18:36:01 +09006255 if (pstrSetBeaconParam->pu8Tail == NULL) {
6256 s32Error = -ENOMEM;
6257 goto ERRORHANDLER;
6258 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006259 memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006260 } else {
6261 pstrSetBeaconParam->pu8Tail = NULL;
6262 }
6263
Tony Cho143eb952015-09-21 12:16:32 +09006264 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006265 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006266 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006267
Leo Kim24db7132015-09-16 18:36:01 +09006268ERRORHANDLER:
6269 if (s32Error) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006270 if (pstrSetBeaconParam->pu8Head != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006271 kfree(pstrSetBeaconParam->pu8Head);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006272
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006273 if (pstrSetBeaconParam->pu8Tail != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006274 kfree(pstrSetBeaconParam->pu8Tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006275 }
6276
6277 return s32Error;
6278
6279}
6280
6281
6282/**
6283 * @brief host_int_del_beacon
6284 * @details Setting add beacon params in message queue
6285 * @param[in] WILC_WFIDrvHandle hWFIDrv
6286 * @return Error code.
6287 * @author
6288 * @date
6289 * @version 1.0
6290 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09006291s32 host_int_del_beacon(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006292{
Leo Kime6e12662015-09-16 18:36:03 +09006293 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006294 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006295
Tony Choa4ab1ad2015-10-12 16:56:05 +09006296 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006297 PRINT_ER("driver is null\n");
6298 return -EFAULT;
6299 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006300
6301 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006302 msg.id = HOST_IF_MSG_DEL_BEACON;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006303 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006304 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
6305
Tony Cho143eb952015-09-21 12:16:32 +09006306 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim7dc1d0c2015-09-16 18:36:00 +09006307 if (s32Error)
6308 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006309
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006310 return s32Error;
6311}
6312
6313
6314/**
6315 * @brief host_int_add_station
6316 * @details Setting add station params in message queue
Tony Cho6a89ba92015-09-21 12:16:46 +09006317 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006318 * @return Error code.
6319 * @author
6320 * @date
6321 * @version 1.0
6322 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09006323s32 host_int_add_station(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09006324 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006325{
Leo Kime6e12662015-09-16 18:36:03 +09006326 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006327 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09006328 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006329
6330
Tony Choa4ab1ad2015-10-12 16:56:05 +09006331 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006332 PRINT_ER("driver is null\n");
6333 return -EFAULT;
6334 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006335
Tony Cho143eb952015-09-21 12:16:32 +09006336 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006337
6338 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
6339
6340
6341 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006342 msg.id = HOST_IF_MSG_ADD_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006343 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006344
Tony Cho6a89ba92015-09-21 12:16:46 +09006345 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006346 if (pstrAddStationMsg->u8NumRates > 0) {
Glen Leef3052582015-09-10 12:03:04 +09006347 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006348
Leo Kim7ae43362015-09-16 18:35:59 +09006349 if (!rates)
6350 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006351
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006352 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02006353 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006354 }
6355
6356
Tony Cho143eb952015-09-21 12:16:32 +09006357 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006358 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006359 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006360 return s32Error;
6361}
6362
6363/**
6364 * @brief host_int_del_station
6365 * @details Setting delete station params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006366 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006367 * @return Error code.
6368 * @author
6369 * @date
6370 * @version 1.0
6371 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09006372s32 host_int_del_station(struct host_if_drv *hif_drv, const u8 *pu8MacAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006373{
Leo Kime6e12662015-09-16 18:36:03 +09006374 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006375 struct host_if_msg msg;
Tony Cho889c25b2015-09-30 18:44:33 +09006376 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006377
Tony Choa4ab1ad2015-10-12 16:56:05 +09006378 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006379 PRINT_ER("driver is null\n");
6380 return -EFAULT;
6381 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006382
Tony Cho143eb952015-09-21 12:16:32 +09006383 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006384
6385 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
6386
6387
6388
6389 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006390 msg.id = HOST_IF_MSG_DEL_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006391 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006392
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006393 if (pu8MacAddr == NULL)
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006394 memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006395 else
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006396 memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006397
Tony Cho143eb952015-09-21 12:16:32 +09006398 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006399 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006400 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006401 return s32Error;
6402}
6403/**
6404 * @brief host_int_del_allstation
6405 * @details Setting del station params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006406 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006407 * @return Error code.
6408 * @author
6409 * @date
6410 * @version 1.0
6411 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09006412s32 host_int_del_allstation(struct host_if_drv *hif_drv,
Leo Kim441dc602015-10-12 16:55:35 +09006413 u8 pu8MacAddr[][ETH_ALEN])
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006414{
Leo Kime6e12662015-09-16 18:36:03 +09006415 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006416 struct host_if_msg msg;
Tony Chob0c1e802015-10-05 13:50:46 +09006417 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006418 u8 au8Zero_Buff[ETH_ALEN] = {0};
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006419 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006420 u8 u8AssocNumb = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006421
6422
Tony Choa4ab1ad2015-10-12 16:56:05 +09006423 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006424 PRINT_ER("driver is null\n");
6425 return -EFAULT;
6426 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006427
Tony Cho143eb952015-09-21 12:16:32 +09006428 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006429
6430 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
6431
6432 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006433 msg.id = HOST_IF_MSG_DEL_ALL_STA;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006434 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006435
6436 /* Handling situation of deauthenticing all associated stations*/
6437 for (i = 0; i < MAX_NUM_STA; i++) {
6438 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006439 memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006440 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],
6441 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
6442 u8AssocNumb++;
6443 }
6444 }
6445 if (!u8AssocNumb) {
6446 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
6447 return s32Error;
6448 }
6449
6450 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
Tony Cho143eb952015-09-21 12:16:32 +09006451 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006452
6453
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006454 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006455 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006456
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006457 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006458
6459 return s32Error;
6460
6461}
6462
6463/**
6464 * @brief host_int_edit_station
6465 * @details Setting edit station params in message queue
Tony Cho6a89ba92015-09-21 12:16:46 +09006466 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006467 * @return Error code.
6468 * @author
6469 * @date
6470 * @version 1.0
6471 */
Tony Choa4ab1ad2015-10-12 16:56:05 +09006472s32 host_int_edit_station(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09006473 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006474{
Leo Kime6e12662015-09-16 18:36:03 +09006475 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006476 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09006477 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006478
Tony Choa4ab1ad2015-10-12 16:56:05 +09006479 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006480 PRINT_ER("driver is null\n");
6481 return -EFAULT;
6482 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006483
6484 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
6485
Tony Cho143eb952015-09-21 12:16:32 +09006486 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006487
6488
6489 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006490 msg.id = HOST_IF_MSG_EDIT_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006491 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006492
Tony Cho6a89ba92015-09-21 12:16:46 +09006493 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006494 if (pstrAddStationMsg->u8NumRates > 0) {
Glen Leef3052582015-09-10 12:03:04 +09006495 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006496
Leo Kim7ae43362015-09-16 18:35:59 +09006497 if (!rates)
6498 return -ENOMEM;
6499
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006500 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02006501 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006502 }
6503
Tony Cho143eb952015-09-21 12:16:32 +09006504 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006505 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006506 PRINT_ER("wilc_mq_send fail\n");
6507
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006508 return s32Error;
6509}
Glen Lee108b3432015-09-16 18:53:20 +09006510
Tony Choa4ab1ad2015-10-12 16:56:05 +09006511s32 host_int_set_power_mgmt(struct host_if_drv *hif_drv,
6512 bool bIsEnabled,
6513 u32 u32Timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006514{
Leo Kime6e12662015-09-16 18:36:03 +09006515 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006516 struct host_if_msg msg;
Tony Cho49e1f812015-09-30 18:44:36 +09006517 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006518
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006519 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006520
Tony Choa4ab1ad2015-10-12 16:56:05 +09006521 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006522 PRINT_ER("driver is null\n");
6523 return -EFAULT;
6524 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006525
6526 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
6527
Tony Cho143eb952015-09-21 12:16:32 +09006528 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006529
6530
6531 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006532 msg.id = HOST_IF_MSG_POWER_MGMT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006533 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006534
6535 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
6536 pstrPowerMgmtParam->u32Timeout = u32Timeout;
6537
6538
Tony Cho143eb952015-09-21 12:16:32 +09006539 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006540 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006541 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006542 return s32Error;
6543}
6544
Tony Choa4ab1ad2015-10-12 16:56:05 +09006545s32 host_int_setup_multicast_filter(struct host_if_drv *hif_drv,
6546 bool bIsEnabled,
6547 u32 u32count)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006548{
Leo Kime6e12662015-09-16 18:36:03 +09006549 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006550 struct host_if_msg msg;
Tony Choa079cf4d2015-09-30 18:55:05 +09006551 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006552
6553
Tony Choa4ab1ad2015-10-12 16:56:05 +09006554 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006555 PRINT_ER("driver is null\n");
6556 return -EFAULT;
6557 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006558
6559 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
6560
Tony Cho143eb952015-09-21 12:16:32 +09006561 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006562
6563
6564 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006565 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006566 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006567
6568 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
6569 pstrMulticastFilterParam->u32count = u32count;
6570
Tony Cho143eb952015-09-21 12:16:32 +09006571 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006572 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006573 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006574 return s32Error;
6575}
6576
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006577/**
6578 * @brief host_int_ParseJoinBssParam
6579 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
6580 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
6581 * @return
6582 * @author zsalah
6583 * @date
6584 * @version 1.0**/
6585static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
6586{
Leo Kime0a12212015-10-12 16:55:49 +09006587 struct join_bss_param *pNewJoinBssParam = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006588 u8 *pu8IEs;
Chaehyun Limd85f5322015-06-11 14:35:54 +09006589 u16 u16IEsLen;
6590 u16 index = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006591 u8 suppRatesNo = 0;
6592 u8 extSuppRatesNo;
Chaehyun Limd85f5322015-06-11 14:35:54 +09006593 u16 jumpOffset;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006594 u8 pcipherCount;
6595 u8 authCount;
6596 u8 pcipherTotalCount = 0;
6597 u8 authTotalCount = 0;
6598 u8 i, j;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006599
6600 pu8IEs = ptstrNetworkInfo->pu8IEs;
6601 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
6602
Leo Kime0a12212015-10-12 16:55:49 +09006603 pNewJoinBssParam = kmalloc(sizeof(struct join_bss_param), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006604 if (pNewJoinBssParam != NULL) {
Leo Kime0a12212015-10-12 16:55:49 +09006605 memset(pNewJoinBssParam, 0, sizeof(struct join_bss_param));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006606 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
6607 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
6608 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006609 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006610 /*for(i=0; i<6;i++)
6611 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006612 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006613 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006614 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
6615 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006616 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
6617 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
6618
6619 /* parse supported rates: */
6620 while (index < u16IEsLen) {
6621 /* supportedRates IE */
6622 if (pu8IEs[index] == SUPP_RATES_IE) {
6623 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
6624 suppRatesNo = pu8IEs[index + 1];
6625 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
6626 index += 2; /* skipping ID and length bytes; */
6627
6628 for (i = 0; i < suppRatesNo; i++) {
6629 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
6630 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
6631 }
6632 index += suppRatesNo;
6633 continue;
6634 }
6635 /* Ext SupportedRates IE */
6636 else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
6637 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
6638 /* checking if no of ext. supp and supp rates < max limit */
6639 extSuppRatesNo = pu8IEs[index + 1];
6640 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
6641 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
6642 else
6643 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
6644 index += 2;
6645 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
6646 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
6647 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
6648 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
6649 }
6650 index += extSuppRatesNo;
6651 continue;
6652 }
6653 /* HT Cap. IE */
6654 else if (pu8IEs[index] == HT_CAPABILITY_IE) {
6655 /* if IE found set the flag */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09006656 pNewJoinBssParam->ht_capable = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006657 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6658 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
6659 continue;
6660 } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
6661 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
6662 (pu8IEs[index + 4] == 0xF2) && /* OUI */
6663 (pu8IEs[index + 5] == 0x02) && /* OUI Type */
6664 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
6665 (pu8IEs[index + 7] == 0x01)) {
6666 /* Presence of WMM Info/Param element indicates WMM capability */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09006667 pNewJoinBssParam->wmm_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006668
6669 /* Check if Bit 7 is set indicating U-APSD capability */
Anish Bhattffda2032015-09-29 12:15:49 -07006670 if (pu8IEs[index + 8] & BIT(7))
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09006671 pNewJoinBssParam->uapsd_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006672 index += pu8IEs[index + 1] + 2;
6673 continue;
6674 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006675 else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
6676 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
6677 (pu8IEs[index + 4] == 0x9a) && /* OUI */
6678 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
Chaehyun Limd85f5322015-06-11 14:35:54 +09006679 u16 u16P2P_count;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006680
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006681 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
6682 pNewJoinBssParam->u8NoaEnbaled = 1;
6683 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
6684
6685 /* Check if Bit 7 is set indicating Opss capability */
Anish Bhattffda2032015-09-29 12:15:49 -07006686 if (pu8IEs[index + 10] & BIT(7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006687 pNewJoinBssParam->u8OppEnable = 1;
6688 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
6689 } else
6690 pNewJoinBssParam->u8OppEnable = 0;
6691 /* HOSTINF_DBG */
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006692 PRINT_D(GENERIC_DBG, "P2P Dump\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006693 for (i = 0; i < pu8IEs[index + 7]; i++)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006694 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006695
6696 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
6697 u16P2P_count = index + 12;
6698
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006699 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006700 u16P2P_count += 4;
6701
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006702 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006703 u16P2P_count += 4;
6704
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006705 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006706
6707 index += pu8IEs[index + 1] + 2;
6708 continue;
6709
6710 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006711 else if ((pu8IEs[index] == RSN_IE) ||
6712 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
6713 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
6714 (pu8IEs[index + 5] == 0x01))) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09006715 u16 rsnIndex = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006716 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
6717 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
6718 * {
6719 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
6720 * }*/
6721 if (pu8IEs[rsnIndex] == RSN_IE) {
6722 pNewJoinBssParam->mode_802_11i = 2;
6723 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
6724 } else { /* check if rsn was previously parsed */
6725 if (pNewJoinBssParam->mode_802_11i == 0)
6726 pNewJoinBssParam->mode_802_11i = 1;
6727 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
6728 rsnIndex += 4;
6729 }
6730 rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
6731 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
6732 rsnIndex++;
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006733 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006734 /* initialize policies with invalid values */
6735
6736 jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
6737
6738 /*parsing pairwise cipher*/
6739
6740 /* saving 3 pcipher max. */
6741 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
6742 rsnIndex += 2; /* jump 2 bytes of pcipher count */
6743
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006744 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006745 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
6746 /* each count corresponds to 4 bytes, only last byte is saved */
6747 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
6748 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
6749 }
6750 pcipherTotalCount += pcipherCount;
6751 rsnIndex += jumpOffset;
6752
6753 jumpOffset = pu8IEs[rsnIndex] * 4;
6754
6755 /*parsing AKM suite (auth_policy)*/
6756 /* saving 3 auth policies max. */
6757 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
6758 rsnIndex += 2; /* jump 2 bytes of pcipher count */
6759
6760 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
6761 /* each count corresponds to 4 bytes, only last byte is saved */
6762 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
6763 }
6764 authTotalCount += authCount;
6765 rsnIndex += jumpOffset;
6766 /*pasring rsn cap. only if rsn IE*/
6767 if (pu8IEs[index] == RSN_IE) {
6768 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
6769 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
6770 rsnIndex += 2;
6771 }
Abdul Hussainf717c0eb2015-06-16 09:49:49 +00006772 pNewJoinBssParam->rsn_found = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006773 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6774 continue;
6775 } else
6776 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6777
6778 }
6779
6780
6781 }
6782
6783 return (void *)pNewJoinBssParam;
6784
6785}
6786
6787void host_int_freeJoinParams(void *pJoinParams)
6788{
Leo Kime0a12212015-10-12 16:55:49 +09006789 if ((struct bss_param *)pJoinParams != NULL)
6790 kfree((struct bss_param *)pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006791 else
6792 PRINT_ER("Unable to FREE null pointer\n");
6793}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006794
Tony Choa4ab1ad2015-10-12 16:56:05 +09006795s32 host_int_delBASession(struct host_if_drv *hif_drv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006796{
Leo Kime6e12662015-09-16 18:36:03 +09006797 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006798 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09006799 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006800
Tony Choa4ab1ad2015-10-12 16:56:05 +09006801 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006802 PRINT_ER("driver is null\n");
6803 return -EFAULT;
6804 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006805
Tony Cho143eb952015-09-21 12:16:32 +09006806 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006807
6808 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006809 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006810
6811 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
6812 pBASessionInfo->u8Ted = TID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006813 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006814
Tony Cho143eb952015-09-21 12:16:32 +09006815 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006816 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006817 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006818
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006819 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006820
6821 return s32Error;
6822}
6823
Tony Choa4ab1ad2015-10-12 16:56:05 +09006824s32 host_int_del_All_Rx_BASession(struct host_if_drv *hif_drv,
6825 char *pBSSID,
6826 char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006827{
Leo Kime6e12662015-09-16 18:36:03 +09006828 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006829 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09006830 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006831
Tony Choa4ab1ad2015-10-12 16:56:05 +09006832 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006833 PRINT_ER("driver is null\n");
6834 return -EFAULT;
6835 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006836
Tony Cho143eb952015-09-21 12:16:32 +09006837 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006838
6839 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006840 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006841
6842 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
6843 pBASessionInfo->u8Ted = TID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006844 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006845
Tony Cho143eb952015-09-21 12:16:32 +09006846 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006847 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006848 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006849
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006850 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006851
6852 return s32Error;
6853}
6854
6855/**
6856 * @brief host_int_setup_ipaddress
6857 * @details setup IP in firmware
6858 * @param[in] Handle to wifi driver
6859 * @return Error code.
6860 * @author Abdelrahman Sobhy
6861 * @date
6862 * @version 1.0*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09006863s32 host_int_setup_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006864{
Leo Kime6e12662015-09-16 18:36:03 +09006865 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006866 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006867
6868 /* TODO: Enable This feature on softap firmware */
6869 return 0;
6870
Tony Choa4ab1ad2015-10-12 16:56:05 +09006871 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006872 PRINT_ER("driver is null\n");
6873 return -EFAULT;
6874 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006875
Tony Cho143eb952015-09-21 12:16:32 +09006876 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006877
6878 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006879 msg.id = HOST_IF_MSG_SET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006880
Tony Chofb2d65e2015-09-30 18:44:39 +09006881 msg.body.ip_info.au8IPAddr = u16ipadd;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006882 msg.drv = hif_drv;
Tony Chofb2d65e2015-09-30 18:44:39 +09006883 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006884
Tony Cho143eb952015-09-21 12:16:32 +09006885 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006886 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006887 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006888
6889 return s32Error;
6890
6891
6892}
6893
6894/**
6895 * @brief host_int_get_ipaddress
6896 * @details Get IP from firmware
6897 * @param[in] Handle to wifi driver
6898 * @return Error code.
6899 * @author Abdelrahman Sobhy
6900 * @date
6901 * @version 1.0*/
Tony Choa4ab1ad2015-10-12 16:56:05 +09006902s32 host_int_get_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006903{
Leo Kime6e12662015-09-16 18:36:03 +09006904 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006905 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006906
Tony Choa4ab1ad2015-10-12 16:56:05 +09006907 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09006908 PRINT_ER("driver is null\n");
6909 return -EFAULT;
6910 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006911
Tony Cho143eb952015-09-21 12:16:32 +09006912 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006913
6914 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006915 msg.id = HOST_IF_MSG_GET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006916
Tony Chofb2d65e2015-09-30 18:44:39 +09006917 msg.body.ip_info.au8IPAddr = u16ipadd;
Tony Choa4ab1ad2015-10-12 16:56:05 +09006918 msg.drv = hif_drv;
Tony Chofb2d65e2015-09-30 18:44:39 +09006919 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006920
Tony Cho143eb952015-09-21 12:16:32 +09006921 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006922 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006923 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006924
6925 return s32Error;
6926
6927
6928}