blob: 7e53aa9468be8c0a8c57ffd9db2ab1351c7e0dd5 [file] [log] [blame]
Chaehyun Lime215a872015-09-30 08:15:41 +09001#include <linux/slab.h>
2#include <linux/time.h>
3#include <linux/kthread.h>
4#include <linux/delay.h>
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005#include "host_interface.h"
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006#include "coreconfigurator.h"
Chaehyun Lim53660122015-09-17 16:48:49 +09007#include "wilc_wlan_if.h"
Chaehyun Limf23eb982015-09-23 18:03:47 +09008#include "wilc_msgqueue.h"
Johnny Kimc5c77ba2015-05-11 14:30:56 +09009
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090010extern u8 connecting;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090011
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -070012extern struct timer_list hDuringIpTimer;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090013
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090014extern u8 g_wilc_initialized;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090015/*****************************************************************************/
16/* Macros */
17/*****************************************************************************/
18
19/* Message types of the Host IF Message Queue*/
Chaehyun Lim9eac3a12015-06-18 22:08:51 +090020#define HOST_IF_MSG_SCAN 0
21#define HOST_IF_MSG_CONNECT 1
22#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
23#define HOST_IF_MSG_KEY 3
24#define HOST_IF_MSG_RCVD_NTWRK_INFO 4
25#define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
26#define HOST_IF_MSG_CFG_PARAMS 6
27#define HOST_IF_MSG_SET_CHANNEL 7
28#define HOST_IF_MSG_DISCONNECT 8
29#define HOST_IF_MSG_GET_RSSI 9
30#define HOST_IF_MSG_GET_CHNL 10
31#define HOST_IF_MSG_ADD_BEACON 11
32#define HOST_IF_MSG_DEL_BEACON 12
33#define HOST_IF_MSG_ADD_STATION 13
34#define HOST_IF_MSG_DEL_STATION 14
35#define HOST_IF_MSG_EDIT_STATION 15
36#define HOST_IF_MSG_SCAN_TIMER_FIRED 16
37#define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
38#define HOST_IF_MSG_POWER_MGMT 18
39#define HOST_IF_MSG_GET_INACTIVETIME 19
40#define HOST_IF_MSG_REMAIN_ON_CHAN 20
41#define HOST_IF_MSG_REGISTER_FRAME 21
42#define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
43#define HOST_IF_MSG_GET_LINKSPEED 23
44#define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
45#define HOST_IF_MSG_SET_MAC_ADDRESS 25
46#define HOST_IF_MSG_GET_MAC_ADDRESS 26
47#define HOST_IF_MSG_SET_OPERATION_MODE 27
48#define HOST_IF_MSG_SET_IPADDRESS 28
49#define HOST_IF_MSG_GET_IPADDRESS 29
50#define HOST_IF_MSG_FLUSH_CONNECT 30
51#define HOST_IF_MSG_GET_STATISTICS 31
52#define HOST_IF_MSG_SET_MULTICAST_FILTER 32
53#define HOST_IF_MSG_ADD_BA_SESSION 33
54#define HOST_IF_MSG_DEL_BA_SESSION 34
55#define HOST_IF_MSG_Q_IDLE 35
56#define HOST_IF_MSG_DEL_ALL_STA 36
57#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
58#define HOST_IF_MSG_EXIT 100
Johnny Kimc5c77ba2015-05-11 14:30:56 +090059
Chaehyun Lime54d5b72015-06-18 22:08:50 +090060#define HOST_IF_SCAN_TIMEOUT 4000
61#define HOST_IF_CONNECT_TIMEOUT 9500
Johnny Kimc5c77ba2015-05-11 14:30:56 +090062
Chaehyun Lime54d5b72015-06-18 22:08:50 +090063#define BA_SESSION_DEFAULT_BUFFER_SIZE 16
64#define BA_SESSION_DEFAULT_TIMEOUT 1000
65#define BLOCK_ACK_REQ_SIZE 0x14
Johnny Kimc5c77ba2015-05-11 14:30:56 +090066/*****************************************************************************/
67/* Type Definitions */
68/*****************************************************************************/
69
70/*!
Tony Cho361ff842015-09-21 12:16:41 +090071 * @struct cfg_param_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +090072 * @brief Structure to hold Host IF CFG Params Attributes
73 * @details
74 * @todo
75 * @sa
76 * @author Mai Daftedar
77 * @date 02 April 2012
78 * @version 1.0
79 */
Tony Cho361ff842015-09-21 12:16:41 +090080struct cfg_param_attr {
Johnny Kimc5c77ba2015-05-11 14:30:56 +090081 tstrCfgParamVal pstrCfgParamVal;
Tony Cho361ff842015-09-21 12:16:41 +090082};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090083
84/*!
85 * @struct tstrHostIFwpaAttr
86 * @brief Structure to hold Host IF Scan Attributes
87 * @details
88 * @todo
89 * @sa
90 * @author Mai Daftedar
91 * @date 25 March 2012
92 * @version 1.0
93 */
94typedef struct _tstrHostIFwpaAttr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090095 u8 *pu8key;
96 const u8 *pu8macaddr;
97 u8 *pu8seq;
98 u8 u8seqlen;
99 u8 u8keyidx;
100 u8 u8Keylen;
101 u8 u8Ciphermode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900102} tstrHostIFwpaAttr;
103
104
105/*!
106 * @struct tstrHostIFwepAttr
107 * @brief Structure to hold Host IF Scan Attributes
108 * @details
109 * @todo
110 * @sa
111 * @author Mai Daftedar
112 * @date 25 March 2012
113 * @version 1.0
114 */
115typedef struct _tstrHostIFwepAttr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900116 u8 *pu8WepKey;
117 u8 u8WepKeylen;
118 u8 u8Wepidx;
119 u8 u8mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900120 AUTHTYPE_T tenuAuth_type;
121
122} tstrHostIFwepAttr;
123
124/*!
125 * @struct tuniHostIFkeyAttr
126 * @brief Structure to hold Host IF Scan Attributes
127 * @details
128 * @todo
129 * @sa
130 * @author Mai Daftedar
131 * @date 25 March 2012
132 * @version 1.0
133 */
134typedef union _tuniHostIFkeyAttr {
135 tstrHostIFwepAttr strHostIFwepAttr;
136 tstrHostIFwpaAttr strHostIFwpaAttr;
137 tstrHostIFpmkidAttr strHostIFpmkidAttr;
138} tuniHostIFkeyAttr;
139
140/*!
Tony Choc98387a2015-09-21 12:16:40 +0900141 * @struct key_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900142 * @brief Structure to hold Host IF Scan Attributes
143 * @details
144 * @todo
145 * @sa
146 * @author Mai Daftedar
147 * @date 25 March 2012
148 * @version 1.0
149 */
Tony Choc98387a2015-09-21 12:16:40 +0900150struct key_attr {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900151 tenuKeyType enuKeyType;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900152 u8 u8KeyAction;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900153 tuniHostIFkeyAttr uniHostIFkeyAttr;
Tony Choc98387a2015-09-21 12:16:40 +0900154};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900155
156
157
158
159/*!
Tony Choc476feb2015-09-21 12:16:36 +0900160 * @struct scan_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900161 * @brief Structure to hold Host IF Scan Attributes
162 * @details
163 * @todo
164 * @sa
165 * @author Mostafa Abu Bakr
166 * @date 25 March 2012
167 * @version 1.0
168 */
Tony Choc476feb2015-09-21 12:16:36 +0900169struct scan_attr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900170 u8 u8ScanSource;
171 u8 u8ScanType;
172 u8 *pu8ChnlFreqList;
173 u8 u8ChnlListLen;
174 u8 *pu8IEs;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900175 size_t IEsLen;
176 tWILCpfScanResult pfScanResult;
177 void *pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900178 tstrHiddenNetwork strHiddenNetwork;
Tony Choc476feb2015-09-21 12:16:36 +0900179};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900180
181/*!
Tony Cho120ae592015-09-21 12:16:37 +0900182 * @struct connect_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900183 * @brief Structure to hold Host IF Connect Attributes
184 * @details
185 * @todo
186 * @sa
187 * @author Mostafa Abu Bakr
188 * @date 25 March 2012
189 * @version 1.0
190 */
Tony Cho120ae592015-09-21 12:16:37 +0900191struct connect_attr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900192 u8 *pu8bssid;
193 u8 *pu8ssid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900194 size_t ssidLen;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900195 u8 *pu8IEs;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900196 size_t IEsLen;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900197 u8 u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900198 tWILCpfConnectResult pfConnectResult;
199 void *pvUserArg;
200 AUTHTYPE_T tenuAuth_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900201 u8 u8channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900202 void *pJoinParams;
Tony Cho120ae592015-09-21 12:16:37 +0900203};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900204
205/*!
Tony Chof23a9ea2015-09-21 12:16:39 +0900206 * @struct rcvd_async_info
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900207 * @brief Structure to hold Received General Asynchronous info
208 * @details
209 * @todo
210 * @sa
211 * @author Mostafa Abu Bakr
212 * @date 25 March 2012
213 * @version 1.0
214 */
Tony Chof23a9ea2015-09-21 12:16:39 +0900215struct rcvd_async_info {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900216 u8 *pu8Buffer;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900217 u32 u32Length;
Tony Chof23a9ea2015-09-21 12:16:39 +0900218};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900219
220/*!
Tony Cho94bdfe42015-09-30 18:44:27 +0900221 * @struct channel_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900222 * @brief Set Channel message body
223 * @details
224 * @todo
225 * @sa
226 * @author Mai Daftedar
227 * @date 25 March 2012
228 * @version 1.0
229 */
Tony Cho94bdfe42015-09-30 18:44:27 +0900230struct channel_attr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900231 u8 u8SetChan;
Tony Cho326b3232015-09-21 12:16:42 +0900232};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900233
234/*!
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900235 * @struct tstrScanComplete
236 * @brief hold received Async. Scan Complete message body
237 * @details
238 * @todo
239 * @sa
240 * @author zsalah
241 * @date 25 March 2012
242 * @version 1.0
243 */
244/*typedef struct _tstrScanComplete
245 * {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900246 * u8* pu8Buffer;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900247 * u32 u32Length;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900248 * } tstrScanComplete;*/
249
250/*!
Tony Cho7f33fec2015-09-30 18:44:30 +0900251 * @struct beacon_attr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900252 * @brief Set Beacon message body
253 * @details
254 * @todo
255 * @sa
256 * @author Adham Abozaeid
257 * @date 10 July 2012
258 * @version 1.0
259 */
Tony Cho7f33fec2015-09-30 18:44:30 +0900260struct beacon_attr {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900261 u32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */
262 u32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900263 * (including the current frame) appear before the next DTIM */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900264 u32 u32HeadLen; /*!< Length of the head buffer in bytes */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900265 u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900266 * from the beacon's start till the TIM element, NOT including the TIM */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900267 u32 u32TailLen; /*!< Length of the tail buffer in bytes */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900268 u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900269 * after the TIM inormation element */
Tony Cho902362b2015-09-21 12:16:44 +0900270};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900271
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900272/*!
Tony Cho641210a2015-09-21 12:16:52 +0900273 * @struct set_multicast
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900274 * @brief set Multicast filter Address
275 * @details
276 * @todo
277 * @sa
278 * @author Abdelrahman Sobhy
279 * @date 30 August 2013
280 * @version 1.0 Description
281 */
282
Tony Cho641210a2015-09-21 12:16:52 +0900283struct set_multicast {
Dean Lee72ed4dc2015-06-12 14:11:44 +0900284 bool bIsEnabled;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900285 u32 u32count;
Tony Cho641210a2015-09-21 12:16:52 +0900286};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900287
288/*!
Tony Chob4e644e2015-09-21 12:17:00 +0900289 * @struct del_all_sta
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900290 * @brief Deauth station message body
291 * @details
292 * @todo
293 * @sa
294 * @author Mai Daftedar
295 * @date 09 April 2014
296 * @version 1.0 Description
297 */
Tony Chob4e644e2015-09-21 12:17:00 +0900298struct del_all_sta {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900299 u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN];
300 u8 u8Num_AssocSta;
Tony Chob4e644e2015-09-21 12:17:00 +0900301};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900302
303/*!
Tony Chofb93a1e2015-09-21 12:16:57 +0900304 * @struct del_sta
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900305 * @brief Delete station message body
306 * @details
307 * @todo
308 * @sa
309 * @author Adham Abozaeid
310 * @date 15 July 2012
311 * @version 1.0 Description
312 */
Tony Chofb93a1e2015-09-21 12:16:57 +0900313struct del_sta {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900314 u8 au8MacAddr[ETH_ALEN];
Tony Chofb93a1e2015-09-21 12:16:57 +0900315};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900316
317/*!
Tony Cho52581932015-09-21 12:16:47 +0900318 * @struct timer_cb
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900319 * @brief Timer callback message body
320 * @details
321 * @todo
322 * @sa
323 * @author Mostafa Abu Bakr
324 * @date 25 March 2012
325 * @version 1.0
326 */
Tony Cho52581932015-09-21 12:16:47 +0900327struct timer_cb {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900328 void *pvUsrArg; /*!< Private data passed at timer start */
Tony Cho52581932015-09-21 12:16:47 +0900329};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900330
331/*!
Tony Cho5a008f12015-09-21 12:16:48 +0900332 * @struct power_mgmt_param
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900333 * @brief Power management message body
334 * @details
335 * @todo
336 * @sa
337 * @author Adham Abozaeid
338 * @date 24 November 2012
339 * @version 1.0
340 */
Tony Cho5a008f12015-09-21 12:16:48 +0900341struct power_mgmt_param {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900342
Dean Lee72ed4dc2015-06-12 14:11:44 +0900343 bool bIsEnabled;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900344 u32 u32Timeout;
Tony Cho5a008f12015-09-21 12:16:48 +0900345};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900346
347/*!
Tony Cho15191ea2015-09-21 12:16:50 +0900348 * @struct set_ip_addr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900349 * @brief set IP Address message body
350 * @details
351 * @todo
352 * @sa
353 * @author Abdelrahman Sobhy
354 * @date 30 August 2013
355 * @version 1.0 Description
356 */
Tony Cho15191ea2015-09-21 12:16:50 +0900357struct set_ip_addr {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900358 u8 *au8IPAddr;
359 u8 idx;
Tony Cho15191ea2015-09-21 12:16:50 +0900360};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900361
362/*!
Tony Cho3d1eac02015-09-21 12:16:49 +0900363 * @struct sta_inactive_t
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900364 * @brief Get station message body
365 * @details
366 * @todo
367 * @sa
368 * @author Mai Daftedar
369 * @date 16 April 2013
370 * @version 1.0
371 */
Tony Cho3d1eac02015-09-21 12:16:49 +0900372struct sta_inactive_t {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900373 u8 mac[6];
Tony Cho3d1eac02015-09-21 12:16:49 +0900374};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900375/**/
376/*!
Tony Chodfc76632015-09-21 12:16:34 +0900377 * @union message_body
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900378 * @brief Message body for the Host Interface message_q
379 * @details
380 * @todo
381 * @sa
382 * @author Mostafa Abu Bakr
383 * @date 25 March 2012
384 * @version 1.0
385 */
Tony Chodfc76632015-09-21 12:16:34 +0900386union message_body {
Tony Cho4528bdb2015-09-30 18:44:20 +0900387 struct scan_attr scan_info;
Tony Cho3f501972015-09-30 18:44:21 +0900388 struct connect_attr con_info;
Tony Cho02d19462015-09-30 18:44:22 +0900389 struct rcvd_net_info net_info;
Tony Cho66add622015-09-30 18:44:23 +0900390 struct rcvd_async_info async_info;
Tony Cho18990bf2015-09-30 18:44:24 +0900391 struct key_attr key_info;
Tony Choa2340c32015-09-30 18:44:25 +0900392 struct cfg_param_attr cfg_info;
Tony Choffd6dbc2015-09-30 18:44:28 +0900393 struct channel_attr channel_info;
Tony Choa98491e2015-09-30 18:44:31 +0900394 struct beacon_attr beacon_info;
Tony Choa5a45ba2015-09-21 12:17:03 +0900395 struct add_sta_param strAddStaParam;
396 struct del_sta strDelStaParam;
397 struct add_sta_param strEditStaParam;
398 struct timer_cb strTimerCb;
399 struct power_mgmt_param strPowerMgmtparam;
Tony Cho3d1eac02015-09-21 12:16:49 +0900400 struct sta_inactive_t strHostIfStaInactiveT;
Tony Cho15191ea2015-09-21 12:16:50 +0900401 struct set_ip_addr strHostIfSetIP;
Tony Cho127f9d92015-09-21 12:16:51 +0900402 struct drv_handler strHostIfSetDrvHandler;
Tony Cho641210a2015-09-21 12:16:52 +0900403 struct set_multicast strHostIfSetMulti;
Tony Cho801bee52015-09-21 12:16:53 +0900404 struct op_mode strHostIfSetOperationMode;
Tony Chob7611a82015-09-21 12:16:54 +0900405 struct set_mac_addr strHostIfSetMacAddress;
Tony Chofcd27c52015-09-21 12:16:55 +0900406 struct get_mac_addr strHostIfGetMacAddress;
Tony Cho54265472015-09-21 12:16:56 +0900407 struct ba_session_info strHostIfBASessionInfo;
Tony Cho2f9c03f2015-09-21 12:16:58 +0900408 struct remain_ch strHostIfRemainOnChan;
Tony Chobc37c5d2015-09-21 12:16:59 +0900409 struct reg_frame strHostIfRegisterFrame;
Dean Lee576917a2015-06-15 11:58:57 +0900410 char *pUserData;
Tony Chob4e644e2015-09-21 12:17:00 +0900411 struct del_all_sta strHostIFDelAllSta;
Tony Chodfc76632015-09-21 12:16:34 +0900412};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900413
414/*!
Tony Cho3a8c41b2015-09-18 18:11:04 +0900415 * @struct struct host_if_msg
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900416 * @brief Host Interface message
417 * @details
418 * @todo
419 * @sa
420 * @author Mostafa Abu Bakr
421 * @date 25 March 2012
422 * @version 1.0
423 */
Tony Cho3a8c41b2015-09-18 18:11:04 +0900424struct host_if_msg {
Tony Choa9f812a2015-09-21 12:16:33 +0900425 u16 id; /*!< Message ID */
Tony Cho410c2482015-09-21 12:16:35 +0900426 union message_body body; /*!< Message body */
Johnny Kim11f58c82015-08-13 13:41:20 +0900427 tstrWILC_WFIDrv *drvHandler;
Tony Cho3a8c41b2015-09-18 18:11:04 +0900428};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900429
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900430typedef struct _tstrWidJoinReqExt {
Dean Lee576917a2015-06-15 11:58:57 +0900431 char SSID[MAX_SSID_LEN];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900432 u8 u8channel;
433 u8 BSSID[6];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900434} tstrWidJoinReqExt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900435
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900436/*Struct containg joinParam of each AP*/
437typedef struct _tstrJoinBssParam {
438 BSSTYPE_T bss_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900439 u8 dtim_period;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900440 u16 beacon_period;
441 u16 cap_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900442 u8 au8bssid[6];
Dean Lee576917a2015-06-15 11:58:57 +0900443 char ssid[MAX_SSID_LEN];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900444 u8 ssidLen;
445 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
446 u8 ht_capable;
447 u8 wmm_cap;
448 u8 uapsd_cap;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900449 bool rsn_found;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900450 u8 rsn_grp_policy;
451 u8 mode_802_11i;
452 u8 rsn_pcip_policy[3];
453 u8 rsn_auth_policy[3];
454 u8 rsn_cap[2];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900455 struct _tstrJoinParam *nextJoinBss;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900456 u32 tsf;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900457 u8 u8NoaEnbaled;
458 u8 u8OppEnable;
459 u8 u8CtWindow;
460 u8 u8Count;
461 u8 u8Index;
462 u8 au8Duration[4];
463 u8 au8Interval[4];
464 u8 au8StartTime[4];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900465} tstrJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900466/*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
467typedef struct _tstrBssTable {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900468 u8 u8noBssEntries;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900469 tstrJoinBssParam *head;
470 tstrJoinBssParam *tail;
471} tstrBssTable;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900472
473typedef enum {
474 SCAN_TIMER = 0,
475 CONNECT_TIMER = 1,
476 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
477} tenuScanConnTimer;
478
479/*****************************************************************************/
480/* */
481/* Global Variabls */
482/* */
483/*****************************************************************************/
Johnny Kimd42ab082015-08-20 16:32:52 +0900484/* Zero is not used, because a zero ID means termination */
485static tstrWILC_WFIDrv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
Daniel Machon6fdb3022015-07-06 19:48:04 +0200486tstrWILC_WFIDrv *terminated_handle;
487tstrWILC_WFIDrv *gWFiDrvHandle;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900488bool g_obtainingIP = false;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900489u8 P2P_LISTEN_STATE;
Arnd Bergmann1999bd52015-05-29 22:52:14 +0200490static struct task_struct *HostIFthreadHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900491static WILC_MsgQueueHandle gMsgQHostIF;
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200492static struct semaphore hSemHostIFthrdEnd;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900493
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200494struct semaphore hSemDeinitDrvHandle;
495static struct semaphore hWaitResponse;
496struct semaphore hSemHostIntDeinit;
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -0700497struct timer_list g_hPeriodicRSSI;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900498
499
500
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900501u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900502
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900503static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900504
Dean Lee72ed4dc2015-06-12 14:11:44 +0900505bool gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900506
Chaehyun Limca356ad2015-06-11 14:35:57 +0900507static s8 gs8Rssi;
508static s8 gs8lnkspd;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900509static u8 gu8Chnl;
510static u8 gs8SetIP[2][4];
511static u8 gs8GetIP[2][4];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900512static u32 gu32InactiveTime;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900513static u8 gu8DelBcn;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900514static u32 gu32WidConnRstHack;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900515
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900516u8 *gu8FlushedJoinReq;
517u8 *gu8FlushedInfoElemAsoc;
518u8 gu8Flushed11iMode;
519u8 gu8FlushedAuthType;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900520u32 gu32FlushedJoinReqSize;
521u32 gu32FlushedInfoElemAsocSize;
Johnny Kim8a625ca2015-08-20 16:32:50 +0900522tstrWILC_WFIDrv *gu8FlushedJoinReqDrvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900523#define REAL_JOIN_REQ 0
524#define FLUSHED_JOIN_REQ 1
525#define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
526
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900527static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900528
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900529extern void chip_sleep_manually(u32 u32SleepTime);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900530extern int linux_wlan_get_num_conn_ifcs(void);
531
Johnny Kimd42ab082015-08-20 16:32:52 +0900532static int add_handler_in_list(tstrWILC_WFIDrv *handler)
533{
534 int i;
535
536 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
537 if (!wfidrv_list[i]) {
538 wfidrv_list[i] = handler;
539 return 0;
540 }
541 }
542
543 return -ENOBUFS;
544}
545
546static int remove_handler_in_list(tstrWILC_WFIDrv *handler)
547{
548 int i;
549
550 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
551 if (wfidrv_list[i] == handler) {
552 wfidrv_list[i] = NULL;
553 return 0;
554 }
555 }
556
557 return -EINVAL;
558}
559
560static int get_id_from_handler(tstrWILC_WFIDrv *handler)
561{
562 int i;
563
564 if (!handler)
565 return 0;
566
567 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
568 if (wfidrv_list[i] == handler)
569 return i;
570 }
571
572 return 0;
573}
574
575static tstrWILC_WFIDrv *get_handler_from_id(int id)
576{
Dan Carpenter6ae9ac02015-09-15 09:54:33 +0300577 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
Johnny Kimd42ab082015-08-20 16:32:52 +0900578 return NULL;
579 return wfidrv_list[id];
580}
581
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900582/**
583 * @brief Handle_SetChannel
584 * @details Sending config packet to firmware to set channel
Tony Cho94bdfe42015-09-30 18:44:27 +0900585 * @param[in] struct channel_attr *pstrHostIFSetChan
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900586 * @return Error code.
587 * @author
588 * @date
589 * @version 1.0
590 */
Tony Cho326b3232015-09-21 12:16:42 +0900591static s32 Handle_SetChannel(tstrWILC_WFIDrv *drvHandler,
Tony Cho94bdfe42015-09-30 18:44:27 +0900592 struct channel_attr *pstrHostIFSetChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900593{
594
Leo Kime6e12662015-09-16 18:36:03 +0900595 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900596 tstrWID strWID;
597 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
598
599 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900600 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900601 strWID.enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900602 strWID.ps8WidVal = (char *)&(pstrHostIFSetChan->u8SetChan);
603 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900604
605 PRINT_D(HOSTINF_DBG, "Setting channel\n");
606 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900607 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
608 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900609 if (s32Error) {
610 PRINT_ER("Failed to set channel\n");
Leo Kim24db7132015-09-16 18:36:01 +0900611 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900612 }
613
614 return s32Error;
615}
616/**
617 * @brief Handle_SetWfiDrvHandler
618 * @details Sending config packet to firmware to set driver handler
Tony Cho127f9d92015-09-21 12:16:51 +0900619 * @param[in] void * drvHandler,
620 * struct drv_handler *pstrHostIfSetDrvHandler
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900621 * @return Error code.
622 * @author
623 * @date
624 * @version 1.0
625 */
Johnny Kim53a84402015-08-20 16:32:51 +0900626static s32 Handle_SetWfiDrvHandler(tstrWILC_WFIDrv *drvHandler,
Tony Cho127f9d92015-09-21 12:16:51 +0900627 struct drv_handler *pstrHostIfSetDrvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900628{
629
Leo Kime6e12662015-09-16 18:36:03 +0900630 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900631 tstrWID strWID;
Johnny Kim53a84402015-08-20 16:32:51 +0900632 tstrWILC_WFIDrv *pstrWFIDrv = drvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900633
634
635 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900636 strWID.u16WIDid = (u16)WID_SET_DRV_HANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900637 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900638 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900639 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900640
641 /*Sending Cfg*/
642
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900643 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
644 pstrHostIfSetDrvHandler->u32Address);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900645
Johnny Kim53a84402015-08-20 16:32:51 +0900646 if (pstrWFIDrv == NULL)
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200647 up(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900648
649
650 if (s32Error) {
651 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900652 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900653 }
654
655 return s32Error;
656}
657
658/**
659 * @brief Handle_SetWfiAPDrvHandler
660 * @details Sending config packet to firmware to set driver handler
661 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
662 * @return Error code.
663 * @author
664 * @date
665 * @version 1.0
666 */
Tony Cho801bee52015-09-21 12:16:53 +0900667static s32 Handle_SetOperationMode(tstrWILC_WFIDrv *drvHandler,
668 struct op_mode *pstrHostIfSetOperationMode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900669{
670
Leo Kime6e12662015-09-16 18:36:03 +0900671 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900672 tstrWID strWID;
673 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
674
675
676 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900677 strWID.u16WIDid = (u16)WID_SET_OPERATION_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900678 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900679 strWID.ps8WidVal = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900680 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900681
682 /*Sending Cfg*/
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +0200683 PRINT_INFO(HOSTINF_DBG, "pstrWFIDrv= %p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900684
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900685 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
686 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900687
688
Johnny Kimc590b9a2015-09-08 17:07:59 +0900689 if ((pstrHostIfSetOperationMode->u32Mode) == IDLE_MODE)
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200690 up(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900691
692
693 if (s32Error) {
694 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900695 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900696 }
697
698 return s32Error;
699}
700
701/**
702 * @brief host_int_set_IPAddress
703 * @details Setting IP address params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900704 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900705 * @return Error code.
706 * @author
707 * @date
708 * @version 1.0
709 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900710s32 Handle_set_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900711{
712
Leo Kime6e12662015-09-16 18:36:03 +0900713 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900714 tstrWID strWID;
715 char firmwareIPAddress[4] = {0};
716 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
717
718 if (pu8IPAddr[0] < 192)
719 pu8IPAddr[0] = 0;
720
Luis de Bethencourtb3a02832015-06-26 17:40:25 +0200721 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900722
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900723 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900724
725 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900726 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900727 strWID.enuWIDtype = WID_STR;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900728 strWID.ps8WidVal = (u8 *)pu8IPAddr;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900729 strWID.s32ValueSize = IP_ALEN;
730
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900731 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
732 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900733
734
Johnny Kim218dc402015-08-13 13:41:19 +0900735 host_int_get_ipaddress(drvHandler, firmwareIPAddress, idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900736
737 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +0900738 PRINT_ER("Failed to set IP address\n");
739 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900740 }
741
Leo Kim24db7132015-09-16 18:36:01 +0900742 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900743
744 return s32Error;
745}
746
747
748/**
749 * @brief Handle_get_IPAddress
750 * @details Setting IP address params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900751 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900752 * @return Error code.
753 * @author
754 * @date
755 * @version 1.0
756 */
Johnny Kim2b05df52015-08-13 13:41:21 +0900757s32 Handle_get_IPAddress(tstrWILC_WFIDrv *drvHandler, u8 *pu8IPAddr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900758{
759
Leo Kime6e12662015-09-16 18:36:03 +0900760 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900761 tstrWID strWID;
762 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
763
764 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900765 strWID.u16WIDid = (u16)WID_IP_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900766 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +0900767 strWID.ps8WidVal = kmalloc(IP_ALEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900768 strWID.s32ValueSize = IP_ALEN;
769
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900770 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
771 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900772
Luis de Bethencourtb3a02832015-06-26 17:40:25 +0200773 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900774
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900775 memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900776
777 /*get the value by searching the local copy*/
Chaehyun Lim49188af2015-08-11 10:32:41 +0900778 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900779
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900780 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
Johnny Kim218dc402015-08-13 13:41:19 +0900781 host_int_setup_ipaddress(pstrWFIDrv, gs8SetIP[idx], idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900782
Leo Kime6e12662015-09-16 18:36:03 +0900783 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900784 PRINT_ER("Failed to get IP address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900785 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900786 }
787
Leo Kim24db7132015-09-16 18:36:01 +0900788 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
789 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
790 PRINT_INFO(HOSTINF_DBG, "\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900791
792 return s32Error;
793}
794
795
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900796/**
797 * @brief Handle_SetMacAddress
798 * @details Setting mac address
799 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
800 * @return Error code.
801 * @author Amr Abdel-Moghny
802 * @date November 2013
803 * @version 7.0
804 */
Tony Chob7611a82015-09-21 12:16:54 +0900805static s32 Handle_SetMacAddress(tstrWILC_WFIDrv *drvHandler,
806 struct set_mac_addr *pstrHostIfSetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900807{
808
Leo Kime6e12662015-09-16 18:36:03 +0900809 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900810 tstrWID strWID;
811 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Glen Leef3052582015-09-10 12:03:04 +0900812 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +0200813
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900814 if (mac_buf == NULL) {
815 PRINT_ER("No buffer to send mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +0900816 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900817 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900818 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900819
820 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900821 strWID.u16WIDid = (u16)WID_MAC_ADDR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900822 strWID.enuWIDtype = WID_STR;
823 strWID.ps8WidVal = mac_buf;
824 strWID.s32ValueSize = ETH_ALEN;
Alexander Kuleshov310a28f2015-09-04 00:48:14 +0600825 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900826 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900827 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
828 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900829 if (s32Error) {
830 PRINT_ER("Failed to set mac address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900831 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900832 }
833
Chaehyun Lim49188af2015-08-11 10:32:41 +0900834 kfree(mac_buf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900835 return s32Error;
836}
837
838
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900839/**
840 * @brief Handle_GetMacAddress
841 * @details Getting mac address
842 * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
843 * @return Error code.
844 * @author Amr Abdel-Moghny
845 * @date JAN 2013
846 * @version 8.0
847 */
Tony Chofcd27c52015-09-21 12:16:55 +0900848static s32 Handle_GetMacAddress(tstrWILC_WFIDrv *drvHandler,
849 struct get_mac_addr *pstrHostIfGetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900850{
851
Leo Kime6e12662015-09-16 18:36:03 +0900852 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900853 tstrWID strWID;
854
855 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +0900856 strWID.u16WIDid = (u16)WID_MAC_ADDR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900857 strWID.enuWIDtype = WID_STR;
858 strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress;
859 strWID.s32ValueSize = ETH_ALEN;
860
861 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900862 s32Error = send_config_pkt(GET_CFG, &strWID, 1, false,
863 get_id_from_handler(drvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900864 if (s32Error) {
865 PRINT_ER("Failed to get mac address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900866 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900867 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200868 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900869
870 return s32Error;
871}
872
873
874/**
875 * @brief Handle_CfgParam
876 * @details Sending config packet to firmware to set CFG params
Tony Cho361ff842015-09-21 12:16:41 +0900877 * @param[in] struct cfg_param_attr *strHostIFCfgParamAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900878 * @return Error code.
879 * @author
880 * @date
881 * @version 1.0
882 */
Tony Cho361ff842015-09-21 12:16:41 +0900883static s32 Handle_CfgParam(tstrWILC_WFIDrv *drvHandler,
884 struct cfg_param_attr *strHostIFCfgParamAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900885{
Leo Kime6e12662015-09-16 18:36:03 +0900886 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900887 tstrWID strWIDList[32];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900888 u8 u8WidCnt = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900889 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
890
891
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200892 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900893
894
895 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
896
897 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) {
898 /*----------------------------------------------------------*/
899 /*Input Value: INFRASTRUCTURE = 1, */
900 /* INDEPENDENT= 2, */
901 /* ANY_BSS= 3 */
902 /*----------------------------------------------------------*/
903 /* validate input then copy>> need to check value 4 and 5 */
904 if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) {
905 strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900906 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900907 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900908 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900909 pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900910 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900911 PRINT_ER("check value 6 over\n");
912 s32Error = -EINVAL;
913 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900914 }
915 u8WidCnt++;
916 }
917 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) {
918 /*------------------------------------------------------*/
919 /*Input Values: OPEN_SYSTEM = 0, */
920 /* SHARED_KEY = 1, */
921 /* ANY = 2 */
922 /*------------------------------------------------------*/
923 /*validate Possible values*/
924 if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) {
925 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900926 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900927 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900928 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900929 pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900930 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900931 PRINT_ER("Impossible value \n");
932 s32Error = -EINVAL;
933 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900934 }
935 u8WidCnt++;
936 }
937 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) {
938 /* range is 1 to 65535. */
939 if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) {
940 strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900941 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900942 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900943 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900944 pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
945 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900946 PRINT_ER("Range(1 ~ 65535) over\n");
947 s32Error = -EINVAL;
948 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900949 }
950 u8WidCnt++;
951 }
952 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) {
953 /*-----------------------------------------------------------*/
954 /*Input Values: NO_POWERSAVE = 0, */
955 /* MIN_FAST_PS = 1, */
956 /* MAX_FAST_PS = 2, */
957 /* MIN_PSPOLL_PS = 3, */
958 /* MAX_PSPOLL_PS = 4 */
959 /*----------------------------------------------------------*/
960 if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) {
961 strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900962 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900963 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +0900964 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900965 pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900966 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900967 PRINT_ER("Invalide power mode\n");
968 s32Error = -EINVAL;
969 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900970 }
971 u8WidCnt++;
972 }
973 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) {
974 /* range from 1 to 256 */
975 if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) {
976 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900977 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900978 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900979 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900980 pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
981 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900982 PRINT_ER("Range(1~256) over\n");
983 s32Error = -EINVAL;
984 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900985 }
986 u8WidCnt++;
987 }
988 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) {
989 /* range from 1 to 256 */
990 if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) {
991 strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT;
Chaehyun Limca356ad2015-06-11 14:35:57 +0900992 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900993
994 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900995 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900996 pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
997 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900998 PRINT_ER("Range(1~256) over\n");
999 s32Error = -EINVAL;
1000 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001001 }
1002 u8WidCnt++;
1003 }
1004 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) {
1005
1006 if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) {
1007 strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001008 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001009 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001010 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001011 pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
1012 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001013 PRINT_ER("Threshold Range fail\n");
1014 s32Error = -EINVAL;
1015 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001016 }
1017 u8WidCnt++;
1018 }
1019 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) {
1020 /* range 256 to 65535 */
1021 if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) {
1022 strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001023 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001024 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001025 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001026 pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
1027 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001028 PRINT_ER("Threshold Range fail\n");
1029 s32Error = -EINVAL;
1030 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001031 }
1032 u8WidCnt++;
1033 }
1034 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) {
1035 /*-----------------------------------------------------*/
1036 /*Input Values: Short= 0, */
1037 /* Long= 1, */
1038 /* Auto= 2 */
1039 /*------------------------------------------------------*/
1040 if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) {
1041 strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001042 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001043 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001044 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001045 pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
1046 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001047 PRINT_ER("Preamle Range(0~2) over\n");
1048 s32Error = -EINVAL;
1049 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001050 }
1051 u8WidCnt++;
1052 }
1053 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) {
1054 if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) {
1055 strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001056 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001057 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001058 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001059 pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001060 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001061 PRINT_ER("Short slot(2) over\n");
1062 s32Error = -EINVAL;
1063 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001064 }
1065 u8WidCnt++;
1066 }
1067 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) {
1068 /*Description: used to Disable RTS-CTS protection for TXOP burst*/
1069 /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
1070 /* this information is useful for external supplicant */
1071 /*Input Values: 1 for enable and 0 for disable. */
1072 if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) {
1073 strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001074 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001075 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001076 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001077 pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001078 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001079 PRINT_ER("TXOP prot disable\n");
1080 s32Error = -EINVAL;
1081 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001082 }
1083 u8WidCnt++;
1084 }
1085 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) {
1086 /* range is 1 to 65535. */
1087 if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) {
1088 strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001089 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001090 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001091 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001092 pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
1093 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001094 PRINT_ER("Beacon interval(1~65535) fail\n");
1095 s32Error = -EINVAL;
1096 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001097 }
1098 u8WidCnt++;
1099 }
1100 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) {
1101 /* range is 1 to 255. */
1102 if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) {
1103 strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001104 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001105 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001106 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001107 pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
1108 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001109 PRINT_ER("DTIM range(1~255) fail\n");
1110 s32Error = -EINVAL;
1111 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001112 }
1113 u8WidCnt++;
1114 }
1115 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) {
1116 /*----------------------------------------------------------------------*/
1117 /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
1118 /* SITE_SURVEY_ALL_CH = 1, */
1119 /* SITE_SURVEY_OFF = 2 */
1120 /*----------------------------------------------------------------------*/
1121 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) {
1122 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001123 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001124 strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001125 strWIDList[u8WidCnt].s32ValueSize = sizeof(char);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001126 pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001127 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001128 PRINT_ER("Site survey disable\n");
1129 s32Error = -EINVAL;
1130 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001131 }
1132 u8WidCnt++;
1133 }
1134 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) {
1135 /* range is 1 to 65535. */
1136 if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) {
1137 strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001138 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001139 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001140 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001141 pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
1142 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001143 PRINT_ER("Site survey scan time(1~65535) over\n");
1144 s32Error = -EINVAL;
1145 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001146 }
1147 u8WidCnt++;
1148 }
1149 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) {
1150 /* range is 1 to 65535. */
1151 if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) {
1152 strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001153 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001154 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001155 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001156 pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
1157 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001158 PRINT_ER("Active scan time(1~65535) over\n");
1159 s32Error = -EINVAL;
1160 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001161 }
1162 u8WidCnt++;
1163 }
1164 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) {
1165 /* range is 1 to 65535. */
1166 if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) {
1167 strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001168 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001169 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001170 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001171 pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
1172 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001173 PRINT_ER("Passive scan time(1~65535) over\n");
1174 s32Error = -EINVAL;
1175 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001176 }
1177 u8WidCnt++;
1178 }
1179 if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) {
1180 CURRENT_TX_RATE_T curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate;
1181 /*----------------------------------------------------------------------*/
1182 /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
1183 /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
1184 /*----------------------------------------------------------------------*/
1185 /* validate rate */
1186 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
1187 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
1188 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
1189 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
1190 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
1191 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
1192 strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001193 strWIDList[u8WidCnt].ps8WidVal = (s8 *)&curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001194 strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001195 strWIDList[u8WidCnt].s32ValueSize = sizeof(u16);
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001196 pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001197 } else {
Leo Kim24db7132015-09-16 18:36:01 +09001198 PRINT_ER("out of TX rate\n");
1199 s32Error = -EINVAL;
1200 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001201 }
1202 u8WidCnt++;
1203 }
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001204 s32Error = send_config_pkt(SET_CFG, strWIDList, u8WidCnt, false,
1205 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001206
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001207 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001208 PRINT_ER("Error in setting CFG params\n");
1209
Leo Kim24db7132015-09-16 18:36:01 +09001210ERRORHANDLER:
Arnd Bergmann83383ea2015-06-01 21:06:43 +02001211 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001212 return s32Error;
1213}
1214
1215
1216/**
1217 * @brief Handle_wait_msg_q_empty
1218 * @details this should be the last msg and then the msg Q becomes idle
1219 * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
1220 * @return Error code.
1221 * @author
1222 * @date
1223 * @version 1.0
1224 */
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001225static s32 Handle_wait_msg_q_empty(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001226{
Leo Kime6e12662015-09-16 18:36:03 +09001227 s32 s32Error = 0;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02001228
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001229 g_wilc_initialized = 0;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02001230 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001231 return s32Error;
1232}
1233
1234/**
1235 * @brief Handle_Scan
1236 * @details Sending config packet to firmware to set the scan params
Tony Choc476feb2015-09-21 12:16:36 +09001237 * @param[in] struct scan_attr *pstrHostIFscanAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001238 * @return Error code.
1239 * @author
1240 * @date
1241 * @version 1.0
1242 */
Tony Choc476feb2015-09-21 12:16:36 +09001243static s32 Handle_Scan(tstrWILC_WFIDrv *drvHandler,
1244 struct scan_attr *pstrHostIFscanAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001245{
Leo Kime6e12662015-09-16 18:36:03 +09001246 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001247 tstrWID strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001248 u32 u32WidsCount = 0;
1249 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001250 u8 *pu8Buffer;
1251 u8 valuesize = 0;
1252 u8 *pu8HdnNtwrksWidVal = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001253 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1254
1255 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001256 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", pstrWFIDrv->enuHostIFstate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001257
1258 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
1259 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
1260
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001261 if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) {
1262 /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
1263 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate);
Leo Kim24db7132015-09-16 18:36:01 +09001264 PRINT_ER("Already scan\n");
1265 s32Error = -EBUSY;
1266 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001267 }
1268
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001269 if (g_obtainingIP || connecting) {
1270 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +09001271 PRINT_ER("Don't do obss scan\n");
1272 s32Error = -EBUSY;
1273 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001274 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001275
1276 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
1277
1278
1279 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0;
1280
Chaehyun Limd85f5322015-06-11 14:35:54 +09001281 strWIDList[u32WidsCount].u16WIDid = (u16)WID_SSID_PROBE_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001282 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1283
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001284 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001285 valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
Glen Leef3052582015-09-10 12:03:04 +09001286 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001287 strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001288 if (strWIDList[u32WidsCount].ps8WidVal != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001289 pu8Buffer = strWIDList[u32WidsCount].ps8WidVal;
1290
1291 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
1292
1293 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
1294
1295 for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
1296 *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001297 memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001298 pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
1299 }
1300
1301
1302
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09001303 strWIDList[u32WidsCount].s32ValueSize = (s32)(valuesize + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001304 u32WidsCount++;
1305 }
1306
1307 /*filling cfg param array*/
1308
1309 /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
1310 {
1311 /* IEs to be inserted in Probe Request */
1312 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE;
1313 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1314 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs;
1315 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen;
1316 u32WidsCount++;
1317 }
1318
1319 /*Scan Type*/
1320 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE;
1321 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001322 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001323 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanType));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001324 u32WidsCount++;
1325
1326 /*list of channels to be scanned*/
1327 strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST;
1328 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1329
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001330 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
1331 int i;
1332
1333 for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001334 if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001335 pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001336 }
1337 }
1338
1339 strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList;
1340 strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen;
1341 u32WidsCount++;
1342
1343 /*Scan Request*/
1344 strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ;
1345 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001346 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001347 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrHostIFscanAttr->u8ScanSource));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001348 u32WidsCount++;
1349
1350 /*keep the state as is , no need to change it*/
1351 /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
1352
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301353 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001354 gbScanWhileConnected = true;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301355 else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE)
Dean Lee72ed4dc2015-06-12 14:11:44 +09001356 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001357
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001358 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount, false,
1359 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001360
Leo Kim24db7132015-09-16 18:36:01 +09001361 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001362 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09001363 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001364 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001365
Leo Kim24db7132015-09-16 18:36:01 +09001366ERRORHANDLER:
1367 if (s32Error) {
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07001368 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001369 /*if there is an ongoing scan request*/
1370 Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED);
1371 }
1372
1373 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1374 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001375 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001376 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1377 }
1378
1379 /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
1380 if (pstrHostIFscanAttr->pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001381 kfree(pstrHostIFscanAttr->pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001382 pstrHostIFscanAttr->pu8IEs = NULL;
1383 }
1384 if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001385 kfree(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001386 pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
1387 }
1388
1389 /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
1390 if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001391 kfree(pstrHostIFscanAttr->pu8ChnlFreqList);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001392 pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
1393 }
1394
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001395 if (pu8HdnNtwrksWidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001396 kfree(pu8HdnNtwrksWidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001397
1398 return s32Error;
1399}
1400
1401/**
1402 * @brief Handle_ScanDone
1403 * @details Call scan notification callback function
1404 * @param[in] NONE
1405 * @return Error code.
1406 * @author
1407 * @date
1408 * @version 1.0
1409 */
Johnny Kim2b05df52015-08-13 13:41:21 +09001410static s32 Handle_ScanDone(tstrWILC_WFIDrv *drvHandler, tenuScanEvent enuEvent)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001411{
Leo Kime6e12662015-09-16 18:36:03 +09001412 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001413
1414 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
1415
1416
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001417 u8 u8abort_running_scan;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001418 tstrWID strWID;
1419
1420
1421 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
1422
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001423 /*Ask FW to abort the running scan, if any*/
1424 if (enuEvent == SCAN_EVENT_ABORTED) {
1425 PRINT_D(GENERIC_DBG, "Abort running scan\n");
1426 u8abort_running_scan = 1;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001427 strWID.u16WIDid = (u16)WID_ABORT_RUNNING_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001428 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001429 strWID.ps8WidVal = (s8 *)&u8abort_running_scan;
Dean Lee576917a2015-06-15 11:58:57 +09001430 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001431
1432 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001433 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
1434 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09001435 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001436 PRINT_ER("Failed to set abort running scan\n");
Leo Kim24db7132015-09-16 18:36:01 +09001437 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001438 }
1439 }
1440
1441 if (pstrWFIDrv == NULL) {
1442 PRINT_ER("Driver handler is NULL\n");
1443 return s32Error;
1444 }
1445
1446 /*if there is an ongoing scan request*/
1447 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001448 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001449 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
1450 /*delete current scan request*/
1451 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
1452 }
1453
1454 return s32Error;
1455}
1456
1457/**
1458 * @brief Handle_Connect
1459 * @details Sending config packet to firmware to starting connection
Tony Cho120ae592015-09-21 12:16:37 +09001460 * @param[in] struct connect_attr *pstrHostIFconnectAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001461 * @return Error code.
1462 * @author
1463 * @date
1464 * @version 1.0
1465 */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001466u8 u8ConnectedSSID[6] = {0};
Tony Cho120ae592015-09-21 12:16:37 +09001467static s32 Handle_Connect(tstrWILC_WFIDrv *drvHandler,
1468 struct connect_attr *pstrHostIFconnectAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001469{
1470 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
Leo Kime6e12662015-09-16 18:36:03 +09001471 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001472 tstrWID strWIDList[8];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001473 u32 u32WidsCount = 0, dummyval = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001474 /* char passphrase[] = "12345678"; */
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001475 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001476 tstrJoinBssParam *ptstrJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001477
1478 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1479
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001480 /* if we try to connect to an already connected AP then discard the request */
1481
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001482 if (memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001483
Leo Kime6e12662015-09-16 18:36:03 +09001484 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001485 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1486 return s32Error;
1487 }
1488
1489 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1490
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001491 ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams;
1492 if (ptstrJoinBssParam == NULL) {
1493 PRINT_ER("Required BSSID not found\n");
Leo Kim24db7132015-09-16 18:36:01 +09001494 s32Error = -ENOENT;
1495 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001496 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001497
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001498 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001499 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001500 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001501 }
1502
1503 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
1504 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001505 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssidLen + 1, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001506 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001507 pstrHostIFconnectAttr->ssidLen);
1508 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
1509 }
1510
1511 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
1512 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Glen Leef3052582015-09-10 12:03:04 +09001513 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001514 memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001515 pstrHostIFconnectAttr->IEsLen);
1516 }
1517
1518 pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
1519 pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
1520 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
1521 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
1522
1523 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
1524 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001525 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001526 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001527 u32WidsCount++;
1528
1529 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
1530 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001531 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001532 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001533 u32WidsCount++;
1534
1535 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
1536 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001537 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001538 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001539 u32WidsCount++;
1540
1541 /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
1542 /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
1543 {
1544 /* IEs to be inserted in Association Request */
1545 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1546 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1547 strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
1548 strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
1549 u32WidsCount++;
1550
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001551 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001552
1553 gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001554 gu8FlushedInfoElemAsoc = kmalloc(gu32FlushedInfoElemAsocSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001555 memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1556 gu32FlushedInfoElemAsocSize);
1557 }
1558 }
Chaehyun Limd85f5322015-06-11 14:35:54 +09001559 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001560 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001561 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001562 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001563 u32WidsCount++;
1564
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001565 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001566 gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security;
1567
1568 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
1569
1570
Chaehyun Limd85f5322015-06-11 14:35:54 +09001571 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001572 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001573 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001574 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001575 u32WidsCount++;
1576
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001577 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001578 gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001579
1580 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
1581 /*
Chaehyun Limd85f5322015-06-11 14:35:54 +09001582 * strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001583 * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1584 * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001585 * strWIDList[u32WidsCount].ps8WidVal = (s8*)(passphrase);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001586 * u32WidsCount++;
1587 */
1588
1589 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
1590 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
1591
Chaehyun Limd85f5322015-06-11 14:35:54 +09001592 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001593 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1594
1595 /*Sending NoA attributes during connection*/
1596 strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */
Glen Leef3052582015-09-10 12:03:04 +09001597 strWIDList[u32WidsCount].ps8WidVal = kmalloc(strWIDList[u32WidsCount].s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001598
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001599 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001600 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize;
Glen Leef3052582015-09-10 12:03:04 +09001601 gu8FlushedJoinReq = kmalloc(gu32FlushedJoinReqSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001602 }
Leo Kim24db7132015-09-16 18:36:01 +09001603 if (strWIDList[u32WidsCount].ps8WidVal == NULL) {
1604 s32Error = -EFAULT;
1605 goto ERRORHANDLER;
1606 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001607
1608 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1609
1610
1611 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001612 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001613 pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
1614 }
1615 pu8CurrByte += MAX_SSID_LEN;
1616
1617 /* BSS type*/
1618 *(pu8CurrByte++) = INFRASTRUCTURE;
1619 /* Channel*/
1620 if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
1621 *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
1622 } else {
1623 PRINT_ER("Channel out of range\n");
1624 *(pu8CurrByte++) = 0xFF;
1625 }
1626 /* Cap Info*/
1627 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1628 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1629 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1630
1631 /* sa*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001632 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001633 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001634 pu8CurrByte += 6;
1635
1636 /* bssid*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001637 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001638 memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001639 pu8CurrByte += 6;
1640
1641 /* Beacon Period*/
1642 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1643 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1644 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1645 /* DTIM Period*/
1646 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1647 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
1648 /* Supported rates*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001649 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001650 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1651
1652 /* wmm cap*/
1653 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1654 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
1655 /* uapsd cap*/
1656 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1657
1658 /* ht cap*/
1659 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
1660 /* copy this information to the user request */
1661 pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
1662
1663 /* rsn found*/
1664 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1665 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
1666 /* rsn group policy*/
1667 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1668 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
1669 /* mode_802_11i*/
1670 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1671 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
1672 /* rsn pcip policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001673 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001674 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1675
1676 /* rsn auth policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001677 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001678 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1679
1680 /* rsn auth policy*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001681 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001682 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1683
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001684 *(pu8CurrByte++) = REAL_JOIN_REQ;
1685
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001686 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1687 if (ptstrJoinBssParam->u8NoaEnbaled) {
1688 PRINT_D(HOSTINF_DBG, "NOA present\n");
1689
1690 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1691 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1692 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1693 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1694
1695 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1696
1697 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1698
1699 if (ptstrJoinBssParam->u8OppEnable)
1700 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1701
1702 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1703
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001704 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001705
1706 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1707
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001708 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001709
1710 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1711
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001712 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001713
1714 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1715
1716 } else
1717 PRINT_D(HOSTINF_DBG, "NOA not present\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001718
1719 /* keep the buffer at the start of the allocated pointer to use it with the free*/
1720 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001721 u32WidsCount++;
1722
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001723 /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
1724 * firmware at chip reset when processing the WIDs of the Connect Request.
1725 * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
1726 /* ////////////////////// */
1727 gu32WidConnRstHack = 0;
1728 /* ////////////////////// */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001729
Chaehyun Lim1a646e72015-08-07 09:02:03 +09001730 if (memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001731 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
Johnny Kim8a625ca2015-08-20 16:32:50 +09001732 gu8FlushedJoinReqDrvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001733 }
1734
1735 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1736
1737 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001738 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001739
Alexander Kuleshov310a28f2015-09-04 00:48:14 +06001740 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->pu8bssid);
1741 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001742 }
1743
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001744 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount, false,
1745 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001746 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09001747 PRINT_ER("failed to send config packet\n");
1748 s32Error = -EFAULT;
1749 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001750 } else {
1751 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
1752 pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
1753 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001754
Leo Kim24db7132015-09-16 18:36:01 +09001755ERRORHANDLER:
1756 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001757 tstrConnectInfo strConnectInfo;
1758
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07001759 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001760
1761 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1762
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001763 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001764
1765 if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001766 if (pstrHostIFconnectAttr->pu8bssid != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001767 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001768
1769 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
1770 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001771 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->IEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001772 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001773 pstrHostIFconnectAttr->pu8IEs,
1774 pstrHostIFconnectAttr->IEsLen);
1775 }
1776
1777 pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1778 &strConnectInfo,
1779 MAC_DISCONNECTED,
1780 NULL,
1781 pstrHostIFconnectAttr->pvUserArg);
1782 /*Change state to idle*/
1783 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
1784 /* Deallocation */
1785 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001786 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001787 strConnectInfo.pu8ReqIEs = NULL;
1788 }
1789
1790 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001791 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001792 }
1793 }
1794
1795 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
1796 /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
1797 if (pstrHostIFconnectAttr->pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001798 kfree(pstrHostIFconnectAttr->pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001799 pstrHostIFconnectAttr->pu8bssid = NULL;
1800 }
1801
1802 /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
1803 if (pstrHostIFconnectAttr->pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001804 kfree(pstrHostIFconnectAttr->pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001805 pstrHostIFconnectAttr->pu8ssid = NULL;
1806 }
1807
1808 /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
1809 if (pstrHostIFconnectAttr->pu8IEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001810 kfree(pstrHostIFconnectAttr->pu8IEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001811 pstrHostIFconnectAttr->pu8IEs = NULL;
1812 }
1813
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001814 if (pu8CurrByte != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001815 kfree(pu8CurrByte);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001816 return s32Error;
1817}
1818
1819/**
1820 * @brief Handle_FlushConnect
1821 * @details Sending config packet to firmware to flush an old connection
1822 * after switching FW from station one to hybrid one
1823 * @param[in] void * drvHandler
1824 * @return Error code.
1825 * @author Amr Abdel-Moghny
1826 * @date 19 DEC 2013
1827 * @version 8.0
1828 */
1829
Johnny Kim2b05df52015-08-13 13:41:21 +09001830static s32 Handle_FlushConnect(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001831{
Leo Kime6e12662015-09-16 18:36:03 +09001832 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001833 tstrWID strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001834 u32 u32WidsCount = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001835 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001836
1837
1838 /* IEs to be inserted in Association Request */
1839 strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
1840 strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
1841 strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc;
1842 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize;
1843 u32WidsCount++;
1844
Chaehyun Limd85f5322015-06-11 14:35:54 +09001845 strWIDList[u32WidsCount].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001846 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001847 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001848 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(gu8Flushed11iMode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001849 u32WidsCount++;
1850
1851
1852
Chaehyun Limd85f5322015-06-11 14:35:54 +09001853 strWIDList[u32WidsCount].u16WIDid = (u16)WID_AUTH_TYPE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001854 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09001855 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09001856 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&gu8FlushedAuthType);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001857 u32WidsCount++;
1858
Chaehyun Limd85f5322015-06-11 14:35:54 +09001859 strWIDList[u32WidsCount].u16WIDid = (u16)WID_JOIN_REQ_EXTENDED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001860 strWIDList[u32WidsCount].enuWIDtype = WID_STR;
1861 strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001862 strWIDList[u32WidsCount].ps8WidVal = (s8 *)gu8FlushedJoinReq;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001863 pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
1864
1865 pu8CurrByte += FLUSHED_BYTE_POS;
1866 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1867
1868 u32WidsCount++;
1869
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001870 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount, false,
1871 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001872 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09001873 PRINT_ER("failed to send config packet\n");
1874 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001875 }
1876
1877 return s32Error;
1878}
1879
1880/**
1881 * @brief Handle_ConnectTimeout
1882 * @details Call connect notification callback function indicating connection failure
1883 * @param[in] NONE
1884 * @return Error code.
1885 * @author
1886 * @date
1887 * @version 1.0
1888 */
Johnny Kim2b05df52015-08-13 13:41:21 +09001889static s32 Handle_ConnectTimeout(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001890{
Leo Kime6e12662015-09-16 18:36:03 +09001891 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001892 tstrConnectInfo strConnectInfo;
1893 tstrWID strWID;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001894 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001895 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
1896
1897 if (pstrWFIDrv == NULL) {
1898 PRINT_ER("Driver handler is NULL\n");
1899 return s32Error;
1900 }
1901
1902 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
1903
Dean Lee72ed4dc2015-06-12 14:11:44 +09001904 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001905
1906
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001907 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001908
1909
1910 /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
1911 * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
1912 * WID_DISCONNECT} */
1913 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1914 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001915 memcpy(strConnectInfo.au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001916 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
1917 }
1918
1919 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1920 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001921 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001922 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001923 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
1924 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
1925 }
1926
1927 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
1928 &strConnectInfo,
1929 MAC_DISCONNECTED,
1930 NULL,
1931 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
1932
1933 /* Deallocation of strConnectInfo.pu8ReqIEs */
1934 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001935 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001936 strConnectInfo.pu8ReqIEs = NULL;
1937 }
1938 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001939 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001940 }
1941
1942 /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
1943 * WID_DISCONNECT} */
Chaehyun Limd85f5322015-06-11 14:35:54 +09001944 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001945 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001946 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
Dean Lee576917a2015-06-15 11:58:57 +09001947 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001948
1949 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1950
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001951 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
1952 get_id_from_handler(pstrWFIDrv));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001953 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001954 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001955
1956 /* Deallocation of the Saved Connect Request in the global Handle */
1957 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
1958 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001959 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001960 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
1961 }
1962
1963 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001964 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001965 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
1966 }
1967
1968 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1969 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001970 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001971 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
1972 }
1973
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001974 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001975 /*Freeing flushed join request params on connect timeout*/
Johnny Kim8a625ca2015-08-20 16:32:50 +09001976 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001977 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001978 gu8FlushedJoinReq = NULL;
1979 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09001980 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001981 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001982 gu8FlushedInfoElemAsoc = NULL;
1983 }
1984
1985 return s32Error;
1986}
1987
1988/**
1989 * @brief Handle_RcvdNtwrkInfo
1990 * @details Handling received network information
Tony Cho3bbd59f2015-09-21 12:16:38 +09001991 * @param[in] struct rcvd_net_info *pstrRcvdNetworkInfo
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001992 * @return Error code.
1993 * @author
1994 * @date
1995 * @version 1.0
1996 */
Tony Cho3bbd59f2015-09-21 12:16:38 +09001997static s32 Handle_RcvdNtwrkInfo(tstrWILC_WFIDrv *drvHandler,
1998 struct rcvd_net_info *pstrRcvdNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001999{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002000 u32 i;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002001 bool bNewNtwrkFound;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002002
2003
2004
Leo Kime6e12662015-09-16 18:36:03 +09002005 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002006 tstrNetworkInfo *pstrNetworkInfo = NULL;
2007 void *pJoinParams = NULL;
2008
2009 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2010
2011
2012
Dean Lee72ed4dc2015-06-12 14:11:44 +09002013 bNewNtwrkFound = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002014 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
2015
2016 /*if there is a an ongoing scan request*/
2017 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2018 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
Chaehyun Lima1f7f642015-09-22 22:47:44 +09002019 parse_network_info(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002020 if ((pstrNetworkInfo == NULL)
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002021 || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
Leo Kim24db7132015-09-16 18:36:01 +09002022 PRINT_ER("driver is null\n");
2023 s32Error = -EINVAL;
2024 goto done;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002025 }
2026
2027 /* check whether this network is discovered before */
2028 for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
2029
2030 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
2031 (pstrNetworkInfo->au8bssid != NULL)) {
Chaehyun Lim1a646e72015-08-07 09:02:03 +09002032 if (memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002033 pstrNetworkInfo->au8bssid, 6) == 0) {
2034 if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
2035 /*we have already found this network with better rssi, so keep the old cached one and don't
2036 * send anything to the upper layer */
2037 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
2038 goto done;
2039 } else {
2040 /* here the same already found network is found again but with a better rssi, so just update
2041 * the rssi for this cached network and send this updated network to the upper layer but
2042 * don't add a new record for it */
2043 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002044 bNewNtwrkFound = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002045 break;
2046 }
2047 }
2048 }
2049 }
2050
Dean Lee72ed4dc2015-06-12 14:11:44 +09002051 if (bNewNtwrkFound == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002052 /* here it is confirmed that it is a new discovered network,
2053 * so add its record then call the User CallBack function */
2054
2055 PRINT_D(HOSTINF_DBG, "New network found\n");
2056
2057 if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
2058 pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
2059
2060 if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
2061 && (pstrNetworkInfo->au8bssid != NULL)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002062 memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002063 pstrNetworkInfo->au8bssid, 6);
2064
2065 pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++;
2066
Dean Lee72ed4dc2015-06-12 14:11:44 +09002067 pstrNetworkInfo->bNewNetwork = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002068 /* add new BSS to JoinBssTable */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002069 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002070
2071 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2072 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid,
2073 pJoinParams);
2074
2075
2076 }
2077 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002078 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002079 }
2080 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002081 pstrNetworkInfo->bNewNetwork = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002082 /* just call the User CallBack function to send the same discovered network with its updated RSSI */
2083 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
2084 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2085 }
2086 }
2087
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002088done:
2089 /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2090 if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002091 kfree(pstrRcvdNetworkInfo->pu8Buffer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002092 pstrRcvdNetworkInfo->pu8Buffer = NULL;
2093 }
2094
2095 /*free structure allocated*/
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002096 if (pstrNetworkInfo != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002097 DeallocateNetworkInfo(pstrNetworkInfo);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002098 pstrNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002099 }
2100
2101 return s32Error;
2102}
2103
2104/**
2105 * @brief Handle_RcvdGnrlAsyncInfo
2106 * @details Handling received asynchrous general network information
Tony Chof23a9ea2015-09-21 12:16:39 +09002107 * @param[in] struct rcvd_async_info *pstrRcvdGnrlAsyncInfo
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002108 * @return Error code.
2109 * @author
2110 * @date
2111 * @version 1.0
2112 */
Tony Chof23a9ea2015-09-21 12:16:39 +09002113static s32 Handle_RcvdGnrlAsyncInfo(tstrWILC_WFIDrv *drvHandler,
2114 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002115{
2116 /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
2117 /* which carries only 1 WID which have WID ID = WID_STATUS */
Leo Kime6e12662015-09-16 18:36:03 +09002118 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002119 u8 u8MsgType = 0;
2120 u8 u8MsgID = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002121 u16 u16MsgLen = 0;
2122 u16 u16WidID = (u16)WID_NIL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002123 u8 u8WidLen = 0;
2124 u8 u8MacStatus;
2125 u8 u8MacStatusReasonCode;
2126 u8 u8MacStatusAdditionalInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002127 tstrConnectInfo strConnectInfo;
2128 tstrDisconnectNotifInfo strDisconnectNotifInfo;
Leo Kime6e12662015-09-16 18:36:03 +09002129 s32 s32Err = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002130 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002131
Leo Kim234837d2015-09-22 14:34:43 +09002132 if (!pstrWFIDrv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002133 PRINT_ER("Driver handler is NULL\n");
Leo Kim234837d2015-09-22 14:34:43 +09002134 return -ENODEV;
2135 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002136 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
2137 pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
2138
2139 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
2140 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) ||
2141 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
2142 if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002143 (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
Leo Kim24db7132015-09-16 18:36:01 +09002144 PRINT_ER("driver is null\n");
2145 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002146 }
2147
2148 u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
2149
2150 /* Check whether the received message type is 'I' */
2151 if ('I' != u8MsgType) {
2152 PRINT_ER("Received Message format incorrect.\n");
Leo Kim24db7132015-09-16 18:36:01 +09002153 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002154 }
2155
2156 /* Extract message ID */
2157 u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
2158
2159 /* Extract message Length */
2160 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
2161
2162 /* Extract WID ID [expected to be = WID_STATUS] */
2163 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
2164
2165 /* Extract WID Length [expected to be = 1] */
2166 u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
2167
2168 /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
2169 u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
2170 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
2171 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
2172 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2173 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2174 /* 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 +09002175 u32 u32RcvdAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002176 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
2177
2178 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
2179
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002180 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002181
2182 if (u8MacStatus == MAC_CONNECTED) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002183 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002184
Johnny Kim218dc402015-08-13 13:41:19 +09002185 host_int_get_assoc_res_info(pstrWFIDrv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002186 gapu8RcvdAssocResp,
2187 MAX_ASSOC_RESP_FRAME_SIZE,
2188 &u32RcvdAssocRespInfoLen);
2189
2190 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
2191
2192 if (u32RcvdAssocRespInfoLen != 0) {
2193
2194 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
2195 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
2196 &pstrConnectRespInfo);
2197 if (s32Err) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002198 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002199 } else {
2200 /* use the necessary parsed Info from the Received Association Response */
2201 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
2202
2203 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
2204 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
2205 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
2206 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
2207
2208
Glen Leef3052582015-09-10 12:03:04 +09002209 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002210 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002211 pstrConnectRespInfo->u16RespIEsLen);
2212 }
2213 }
2214
2215 /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
2216 if (pstrConnectRespInfo != NULL) {
2217 DeallocateAssocRespInfo(pstrConnectRespInfo);
2218 pstrConnectRespInfo = NULL;
2219 }
2220 }
2221 }
2222 }
2223
2224 /* The station has just received mac status and it also received assoc. response which
2225 * it was waiting for.
2226 * So check first the matching between the received mac status and the received status code in Asoc Resp */
2227 if ((u8MacStatus == MAC_CONNECTED) &&
2228 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002229 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002230 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002231
2232 } else if (u8MacStatus == MAC_DISCONNECTED) {
2233 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002234 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002235 }
2236
2237 /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
2238 /* through a structure of type tstrConnectRespInfo */
2239 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
2240 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002241 memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002242
2243 if ((u8MacStatus == MAC_CONNECTED) &&
2244 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002245 memcpy(pstrWFIDrv->au8AssociatedBSSID,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002246 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
2247 }
2248 }
2249
2250
2251 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
2252 strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09002253 strConnectInfo.pu8ReqIEs = kmalloc(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002254 memcpy(strConnectInfo.pu8ReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002255 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
2256 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
2257 }
2258
2259
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002260 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002261 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
2262 &strConnectInfo,
2263 u8MacStatus,
2264 NULL,
2265 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2266
2267
2268 /* if received mac status is MAC_CONNECTED and
2269 * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
2270 * else change state to IDLE */
2271 if ((u8MacStatus == MAC_CONNECTED) &&
2272 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Johnny Kim218dc402015-08-13 13:41:19 +09002273 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002274
2275 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
2276 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED;
2277
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002278 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +09002279 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002280 mod_timer(&hDuringIpTimer,
2281 jiffies + msecs_to_jiffies(10000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002282
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002283 /* open a BA session if possible */
2284 /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002285 /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
2286 /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
2287 } else {
2288 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
2289 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002290 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002291 }
2292
2293 /* Deallocation */
2294 if (strConnectInfo.pu8RespIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002295 kfree(strConnectInfo.pu8RespIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002296 strConnectInfo.pu8RespIEs = NULL;
2297 }
2298
2299 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002300 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002301 strConnectInfo.pu8ReqIEs = NULL;
2302 }
2303
2304
2305 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2306 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002307 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002308 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2309 }
2310
2311 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002312 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002313 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2314 }
2315
2316 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2317 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002318 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002319 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2320 }
2321
2322 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2323 (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) {
2324 /* Disassociation or Deauthentication frame has been received */
2325 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
2326
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002327 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002328
2329 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002330 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002331 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002332 Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
2333 }
2334
2335 strDisconnectNotifInfo.u16reason = 0;
2336 strDisconnectNotifInfo.ie = NULL;
2337 strDisconnectNotifInfo.ie_len = 0;
2338
2339 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002340 g_obtainingIP = false;
Johnny Kim218dc402015-08-13 13:41:19 +09002341 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002342
2343 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2344 NULL,
2345 0,
2346 &strDisconnectNotifInfo,
2347 pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2348
2349 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002350 PRINT_ER("Connect result callback function is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002351 }
2352
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002353 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002354
2355
2356 /* Deallocation */
2357
2358 /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
2359 * should be deallocated here */
2360 /*
2361 * if(strDisconnectNotifInfo.ie != NULL)
2362 * {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002363 * kfree(strDisconnectNotifInfo.ie);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002364 * strDisconnectNotifInfo.ie = NULL;
2365 * }
2366 */
2367
2368 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2369 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002370 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002371 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2372 }
2373
2374 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002375 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002376 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2377 }
2378
2379 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2380 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002381 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002382 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2383 }
2384
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002385 /*Freeing flushed join request params on receiving*/
2386 /*MAC_DISCONNECTED while connected*/
Johnny Kim8a625ca2015-08-20 16:32:50 +09002387 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002388 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002389 gu8FlushedJoinReq = NULL;
2390 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09002391 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002392 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002393 gu8FlushedInfoElemAsoc = NULL;
2394 }
2395
2396 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09002397 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002398
2399 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
2400 (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
2401 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002402 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002403 /*Abort the running scan*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002404 del_timer(&pstrWFIDrv->hScanTimer);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002405 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult)
Johnny Kim2b05df52015-08-13 13:41:21 +09002406 Handle_ScanDone(pstrWFIDrv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002407
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002408 }
2409
2410 }
2411
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002412 /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
2413 if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002414 kfree(pstrRcvdGnrlAsyncInfo->pu8Buffer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002415 pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
2416 }
2417
2418 return s32Error;
2419}
2420
2421/**
2422 * @brief Handle_Key
2423 * @details Sending config packet to firmware to set key
Tony Choc98387a2015-09-21 12:16:40 +09002424 * @param[in] struct key_attr *pstrHostIFkeyAttr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002425 * @return Error code.
2426 * @author
2427 * @date
2428 * @version 1.0
2429 */
Tony Choc98387a2015-09-21 12:16:40 +09002430static int Handle_Key(tstrWILC_WFIDrv *drvHandler,
2431 struct key_attr *pstrHostIFkeyAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002432{
Leo Kime6e12662015-09-16 18:36:03 +09002433 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002434 tstrWID strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002435 tstrWID strWIDList[5];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002436 u8 i;
2437 u8 *pu8keybuf;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002438 s8 s8idxarray[1];
2439 s8 ret = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002440 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2441
2442
2443 switch (pstrHostIFkeyAttr->enuKeyType) {
2444
2445
2446 case WEP:
2447
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002448 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2449
2450 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
2451 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Chaehyun Limd85f5322015-06-11 14:35:54 +09002452 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002453 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002454 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002455 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002456
2457 strWIDList[1].u16WIDid = WID_AUTH_TYPE;
2458 strWIDList[1].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002459 strWIDList[1].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002460 strWIDList[1].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002461
Chaehyun Limd85f5322015-06-11 14:35:54 +09002462 strWIDList[2].u16WIDid = (u16)WID_KEY_ID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002463 strWIDList[2].enuWIDtype = WID_CHAR;
2464
Chaehyun Limca356ad2015-06-11 14:35:57 +09002465 strWIDList[2].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Dean Lee576917a2015-06-15 11:58:57 +09002466 strWIDList[2].s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002467
2468
Glen Leef3052582015-09-10 12:03:04 +09002469 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002470
2471
2472 if (pu8keybuf == NULL) {
2473 PRINT_ER("No buffer to send Key\n");
2474 return -1;
2475 }
2476
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002477 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002478 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2479
2480
Chaehyun Lim49188af2015-08-11 10:32:41 +09002481 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002482
Chaehyun Limd85f5322015-06-11 14:35:54 +09002483 strWIDList[3].u16WIDid = (u16)WID_WEP_KEY_VALUE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002484 strWIDList[3].enuWIDtype = WID_STR;
2485 strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002486 strWIDList[3].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002487
2488
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002489 s32Error = send_config_pkt(SET_CFG, strWIDList, 4, true,
2490 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002491 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002492
2493
2494 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002495
2496 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2497 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Glen Leef3052582015-09-10 12:03:04 +09002498 pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002499 if (pu8keybuf == NULL) {
2500 PRINT_ER("No buffer to send Key\n");
2501 return -1;
2502 }
2503 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
2504
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002505 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002506
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002507 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002508 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
2509
Chaehyun Lim49188af2015-08-11 10:32:41 +09002510 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002511
Chaehyun Limd85f5322015-06-11 14:35:54 +09002512 strWID.u16WIDid = (u16)WID_ADD_WEP_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002513 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002514 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002515 strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2;
2516
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002517 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2518 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002519 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002520 } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) {
2521
2522 PRINT_D(HOSTINF_DBG, "Removing key\n");
Chaehyun Limd85f5322015-06-11 14:35:54 +09002523 strWID.u16WIDid = (u16)WID_REMOVE_WEP_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002524 strWID.enuWIDtype = WID_STR;
2525
Chaehyun Limca356ad2015-06-11 14:35:57 +09002526 s8idxarray[0] = (s8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002527 strWID.ps8WidVal = s8idxarray;
2528 strWID.s32ValueSize = 1;
2529
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002530 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2531 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002532 } else {
Chaehyun Limd85f5322015-06-11 14:35:54 +09002533 strWID.u16WIDid = (u16)WID_KEY_ID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002534 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002535 strWID.ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
Dean Lee576917a2015-06-15 11:58:57 +09002536 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002537
2538 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
2539
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002540 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2541 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002542 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002543 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002544 break;
2545
2546 case WPARxGtk:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002547 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
Glen Leef3052582015-09-10 12:03:04 +09002548 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002549 if (pu8keybuf == NULL) {
2550 PRINT_ER("No buffer to send RxGTK Key\n");
2551 ret = -1;
2552 goto _WPARxGtk_end_case_;
2553 }
2554
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002555 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002556
2557
2558 /*|----------------------------------------------------------------------------|
2559 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2560 * |------------|---------|-------|------------|---------------|----------------|
2561 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2562
2563
2564
2565 if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002566 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002567
2568
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002569 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002570
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002571 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002572
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002573 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002574 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2575 /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
Chaehyun Limd85f5322015-06-11 14:35:54 +09002576 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002577 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002578 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002579 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002580
Chaehyun Limd85f5322015-06-11 14:35:54 +09002581 strWIDList[1].u16WIDid = (u16)WID_ADD_RX_GTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002582 strWIDList[1].enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002583 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002584 strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN;
2585
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002586 s32Error = send_config_pkt(SET_CFG, strWIDList, 2, true,
2587 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002588
Chaehyun Lim49188af2015-08-11 10:32:41 +09002589 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002590
2591 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002592 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002593 /* ///////////////////////// */
2594 }
2595
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002596 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2597 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
2598
Glen Leef3052582015-09-10 12:03:04 +09002599 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002600 if (pu8keybuf == NULL) {
2601 PRINT_ER("No buffer to send RxGTK Key\n");
2602 ret = -1;
2603 goto _WPARxGtk_end_case_;
2604 }
2605
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002606 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002607
2608
2609 /*|----------------------------------------------------------------------------|
2610 * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
2611 * |------------|---------|-------|------------|---------------|----------------|
2612 | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
2613
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302614 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002615 memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302616 else
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002617 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002618
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002619 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002620
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002621 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002622
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002623 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
2624 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002625 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2626
Chaehyun Limd85f5322015-06-11 14:35:54 +09002627 strWID.u16WIDid = (u16)WID_ADD_RX_GTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002628 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002629 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002630 strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN;
2631
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002632 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2633 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002634
Chaehyun Lim49188af2015-08-11 10:32:41 +09002635 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002636
2637 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002638 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002639 /* ///////////////////////// */
2640 }
2641_WPARxGtk_end_case_:
Chaehyun Lim49188af2015-08-11 10:32:41 +09002642 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
2643 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002644 if (ret == -1)
2645 return ret;
2646
2647 break;
2648
2649 case WPAPtk:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002650 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
2651
2652
Glen Leef3052582015-09-10 12:03:04 +09002653 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002654
2655
2656
2657 if (pu8keybuf == NULL) {
2658 PRINT_ER("No buffer to send PTK Key\n");
2659 ret = -1;
2660 goto _WPAPtk_end_case_;
2661
2662 }
2663
2664 /*|-----------------------------------------------------------------------------|
2665 * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
2666 * |----------------|------------ |--------------|----------------|---------------|
2667 | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
2668 |-----------------------------------------------------------------------------|*/
2669
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002670 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002671
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002672 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
2673 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002674 /*16 byte TK*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002675 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002676 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2677
2678
Chaehyun Limd85f5322015-06-11 14:35:54 +09002679 strWIDList[0].u16WIDid = (u16)WID_11I_MODE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002680 strWIDList[0].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09002681 strWIDList[0].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09002682 strWIDList[0].ps8WidVal = (s8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002683
Chaehyun Limd85f5322015-06-11 14:35:54 +09002684 strWIDList[1].u16WIDid = (u16)WID_ADD_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002685 strWIDList[1].enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002686 strWIDList[1].ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002687 strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1;
2688
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002689 s32Error = send_config_pkt(SET_CFG, strWIDList, 2, true,
2690 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002691 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002692
2693 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002694 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002695 /* ///////////////////////// */
2696 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002697 if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
2698
2699
Glen Leef3052582015-09-10 12:03:04 +09002700 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002701
2702
2703
2704 if (pu8keybuf == NULL) {
2705 PRINT_ER("No buffer to send PTK Key\n");
2706 ret = -1;
2707 goto _WPAPtk_end_case_;
2708
2709 }
2710
2711 /*|-----------------------------------------------------------------------------|
2712 * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
2713 * |----------------|------------|--------------|----------------|---------------|
2714 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
2715 |-----------------------------------------------------------------------------|*/
2716
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002717 memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002718
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002719 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002720 /*16 byte TK*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002721 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002722 pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
2723
2724
Chaehyun Limd85f5322015-06-11 14:35:54 +09002725 strWID.u16WIDid = (u16)WID_ADD_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002726 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002727 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002728 strWID.s32ValueSize = PTK_KEY_MSG_LEN;
2729
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002730 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2731 get_id_from_handler(pstrWFIDrv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002732 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002733
2734 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002735 up(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002736 /* ///////////////////////// */
2737 }
2738
2739_WPAPtk_end_case_:
Chaehyun Lim49188af2015-08-11 10:32:41 +09002740 kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002741 if (ret == -1)
2742 return ret;
2743
2744 break;
2745
2746
2747 case PMKSA:
2748
2749 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
2750
Glen Leef3052582015-09-10 12:03:04 +09002751 pu8keybuf = kmalloc((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002752 if (pu8keybuf == NULL) {
2753 PRINT_ER("No buffer to send PMKSA Key\n");
2754 return -1;
2755 }
2756
2757 pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
2758
2759 for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
2760
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002761 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
2762 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002763 }
2764
Chaehyun Limd85f5322015-06-11 14:35:54 +09002765 strWID.u16WIDid = (u16)WID_PMKID_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002766 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002767 strWID.ps8WidVal = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002768 strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1;
2769
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002770 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2771 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002772
Chaehyun Lim49188af2015-08-11 10:32:41 +09002773 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002774 break;
2775 }
2776
2777 if (s32Error)
2778 PRINT_ER("Failed to send key config packet\n");
2779
2780
2781 return s32Error;
2782}
2783
2784
2785/**
2786 * @brief Handle_Disconnect
2787 * @details Sending config packet to firmware to disconnect
2788 * @param[in] NONE
2789 * @return NONE
2790 * @author
2791 * @date
2792 * @version 1.0
2793 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002794static void Handle_Disconnect(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002795{
2796 tstrWID strWID;
2797
Leo Kime6e12662015-09-16 18:36:03 +09002798 s32 s32Error = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002799 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002800 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2801
2802
Chaehyun Limd85f5322015-06-11 14:35:54 +09002803 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002804 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002805 strWID.ps8WidVal = (s8 *)&u16DummyReasonCode;
Dean Lee576917a2015-06-15 11:58:57 +09002806 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002807
2808
2809
2810 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2811
Dean Lee72ed4dc2015-06-12 14:11:44 +09002812 g_obtainingIP = false;
Johnny Kim218dc402015-08-13 13:41:19 +09002813 host_int_set_power_mgmt(pstrWFIDrv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002814
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002815 memset(u8ConnectedSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002816
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002817 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
2818 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002819
2820 if (s32Error) {
2821 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002822 } else {
2823 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2824
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002825 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002826
2827 strDisconnectNotifInfo.u16reason = 0;
2828 strDisconnectNotifInfo.ie = NULL;
2829 strDisconnectNotifInfo.ie_len = 0;
2830
2831 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002832 del_timer(&pstrWFIDrv->hScanTimer);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002833 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002834 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
2835
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002836 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002837 }
2838
2839 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
2840
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002841 /*Stop connect timer, if connection in progress*/
2842 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
2843 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07002844 del_timer(&pstrWFIDrv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002845 }
2846
2847 pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
2848 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
2849 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002850 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002851 }
2852
Dean Lee72ed4dc2015-06-12 14:11:44 +09002853 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002854
2855 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
2856
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002857 memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002858
2859
2860 /* Deallocation */
2861 pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
2862 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002863 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002864 pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
2865 }
2866
2867 if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002868 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002869 pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
2870 }
2871
2872 pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2873 if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002874 kfree(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002875 pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
2876 }
2877
2878
Johnny Kim8a625ca2015-08-20 16:32:50 +09002879 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002880 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002881 gu8FlushedJoinReq = NULL;
2882 }
Johnny Kim8a625ca2015-08-20 16:32:50 +09002883 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == drvHandler) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002884 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002885 gu8FlushedInfoElemAsoc = NULL;
2886 }
2887
2888 }
2889
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002890 /* ////////////////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002891 up(&(pstrWFIDrv->hSemTestDisconnectBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002892 /* ///////////////////////// */
2893
2894}
2895
2896
Johnny Kim2b05df52015-08-13 13:41:21 +09002897void resolve_disconnect_aberration(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002898{
2899 tstrWILC_WFIDrv *pstrWFIDrv;
2900
2901 pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09002902 if (pstrWFIDrv == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002903 return;
2904 if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
2905 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
Johnny Kim218dc402015-08-13 13:41:19 +09002906 host_int_disconnect(pstrWFIDrv, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002907 }
2908}
Johnny Kim2b05df52015-08-13 13:41:21 +09002909static s32 Switch_Log_Terminal(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002910{
2911
2912
Leo Kime6e12662015-09-16 18:36:03 +09002913 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002914 tstrWID strWID;
2915 static char dummy = 9;
2916 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2917
Chaehyun Limd85f5322015-06-11 14:35:54 +09002918 strWID.u16WIDid = (u16)WID_LOGTerminal_Switch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002919 strWID.enuWIDtype = WID_CHAR;
2920 strWID.ps8WidVal = &dummy;
Dean Lee576917a2015-06-15 11:58:57 +09002921 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002922
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002923 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
2924 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002925
2926
2927 if (s32Error) {
2928 PRINT_D(HOSTINF_DBG, "Failed to switch log terminal\n");
Leo Kim24db7132015-09-16 18:36:01 +09002929 PRINT_ER("Failed to switch log terminal\n");
2930 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002931 }
2932
Leo Kim24db7132015-09-16 18:36:01 +09002933 PRINT_INFO(HOSTINF_DBG, "MAC address set ::\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002934
2935 return s32Error;
2936}
2937
2938/**
2939 * @brief Handle_GetChnl
2940 * @details Sending config packet to get channel
2941 * @param[in] NONE
2942 * @return NONE
2943 *
2944 * @author
2945 * @date
2946 * @version 1.0
2947 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002948static s32 Handle_GetChnl(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002949{
2950
Leo Kime6e12662015-09-16 18:36:03 +09002951 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002952 tstrWID strWID;
2953 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
2954 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002955
Chaehyun Limd85f5322015-06-11 14:35:54 +09002956 strWID.u16WIDid = (u16)WID_CURRENT_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002957 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002958 strWID.ps8WidVal = (s8 *)&gu8Chnl;
Dean Lee576917a2015-06-15 11:58:57 +09002959 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002960
2961 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2962
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09002963 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
2964 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002965 /*get the value by searching the local copy*/
2966 if (s32Error) {
2967 PRINT_ER("Failed to get channel number\n");
Leo Kim24db7132015-09-16 18:36:01 +09002968 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002969 }
2970
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002971 up(&(pstrWFIDrv->hSemGetCHNL));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002972
2973 return s32Error;
2974
2975
2976
2977}
2978
2979
2980/**
2981 * @brief Handle_GetRssi
2982 * @details Sending config packet to get RSSI
2983 * @param[in] NONE
2984 * @return NONE
2985 * @author
2986 * @date
2987 * @version 1.0
2988 */
Johnny Kim2b05df52015-08-13 13:41:21 +09002989static void Handle_GetRssi(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002990{
Leo Kime6e12662015-09-16 18:36:03 +09002991 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002992 tstrWID strWID;
2993 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
2994
Chaehyun Limd85f5322015-06-11 14:35:54 +09002995 strWID.u16WIDid = (u16)WID_RSSI;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002996 strWID.enuWIDtype = WID_CHAR;
2997 strWID.ps8WidVal = &gs8Rssi;
Dean Lee576917a2015-06-15 11:58:57 +09002998 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002999
3000 /*Sending Cfg*/
3001 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
3002
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003003 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
3004 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003005 if (s32Error) {
3006 PRINT_ER("Failed to get RSSI value\n");
Leo Kim24db7132015-09-16 18:36:01 +09003007 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003008 }
3009
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003010 up(&(pstrWFIDrv->hSemGetRSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003011
3012
3013}
3014
3015
Johnny Kim2b05df52015-08-13 13:41:21 +09003016static void Handle_GetLinkspeed(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003017{
Leo Kime6e12662015-09-16 18:36:03 +09003018 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003019 tstrWID strWID;
3020 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3021
3022 gs8lnkspd = 0;
3023
Chaehyun Limd85f5322015-06-11 14:35:54 +09003024 strWID.u16WIDid = (u16)WID_LINKSPEED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003025 strWID.enuWIDtype = WID_CHAR;
3026 strWID.ps8WidVal = &gs8lnkspd;
Dean Lee576917a2015-06-15 11:58:57 +09003027 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003028 /*Sending Cfg*/
3029 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
3030
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003031 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
3032 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003033 if (s32Error) {
3034 PRINT_ER("Failed to get LINKSPEED value\n");
Leo Kim24db7132015-09-16 18:36:01 +09003035 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003036 }
3037
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003038 up(&(pstrWFIDrv->hSemGetLINKSPEED));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003039
3040
3041}
3042
Johnny Kim2b05df52015-08-13 13:41:21 +09003043s32 Handle_GetStatistics(tstrWILC_WFIDrv *drvHandler, tstrStatistics *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003044{
3045 tstrWID strWIDList[5];
Chaehyun Limfbc2fe12015-09-15 14:06:16 +09003046 u32 u32WidsCount = 0, s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003047
3048 strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED;
3049 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003050 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003051 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u8LinkSpeed));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003052 u32WidsCount++;
3053
3054 strWIDList[u32WidsCount].u16WIDid = WID_RSSI;
3055 strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003056 strWIDList[u32WidsCount].s32ValueSize = sizeof(char);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003057 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->s8RSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003058 u32WidsCount++;
3059
3060 strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
3061 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003062 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003063 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003064 u32WidsCount++;
3065
3066 strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
3067 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003068 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003069 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32RxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003070 u32WidsCount++;
3071
3072 strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
3073 strWIDList[u32WidsCount].enuWIDtype = WID_INT;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003074 strWIDList[u32WidsCount].s32ValueSize = sizeof(u32);
Chaehyun Limca356ad2015-06-11 14:35:57 +09003075 strWIDList[u32WidsCount].ps8WidVal = (s8 *)(&(pstrStatistics->u32TxFailureCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003076 u32WidsCount++;
3077
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003078 s32Error = send_config_pkt(GET_CFG, strWIDList, u32WidsCount, false,
3079 get_id_from_handler(drvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003080
Leo Kim24db7132015-09-16 18:36:01 +09003081 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003082 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09003083
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003084 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003085 return 0;
3086
3087}
3088
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003089/**
3090 * @brief Handle_Get_InActiveTime
3091 * @details Sending config packet to set mac adddress for station and
3092 * get inactive time
3093 * @param[in] NONE
3094 * @return NONE
3095 *
3096 * @author
3097 * @date
3098 * @version 1.0
3099 */
Tony Cho3d1eac02015-09-21 12:16:49 +09003100static s32 Handle_Get_InActiveTime(tstrWILC_WFIDrv *drvHandler,
3101 struct sta_inactive_t *strHostIfStaInactiveT)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003102{
3103
Leo Kime6e12662015-09-16 18:36:03 +09003104 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003105 u8 *stamac;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003106 tstrWID strWID;
3107 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3108
3109
Chaehyun Limd85f5322015-06-11 14:35:54 +09003110 strWID.u16WIDid = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003111 strWID.enuWIDtype = WID_STR;
3112 strWID.s32ValueSize = ETH_ALEN;
Glen Leef3052582015-09-10 12:03:04 +09003113 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003114
3115
3116 stamac = strWID.ps8WidVal;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003117 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003118
3119
3120 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
3121
3122
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003123 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3124 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003125 /*get the value by searching the local copy*/
3126 if (s32Error) {
3127 PRINT_ER("Failed to SET incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09003128 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003129 }
3130
3131
Chaehyun Limd85f5322015-06-11 14:35:54 +09003132 strWID.u16WIDid = (u16)WID_GET_INACTIVE_TIME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003133 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003134 strWID.ps8WidVal = (s8 *)&gu32InactiveTime;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003135 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003136
3137
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003138 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
3139 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003140 /*get the value by searching the local copy*/
3141 if (s32Error) {
3142 PRINT_ER("Failed to get incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09003143 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003144 }
3145
3146
3147 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
3148
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003149 up(&(pstrWFIDrv->hSemInactiveTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003150
3151 return s32Error;
3152
3153
3154
3155}
3156
3157
3158/**
3159 * @brief Handle_AddBeacon
3160 * @details Sending config packet to add beacon
Tony Cho7f33fec2015-09-30 18:44:30 +09003161 * @param[in] struct beacon_attr *pstrSetBeaconParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003162 * @return NONE
3163 * @author
3164 * @date
3165 * @version 1.0
3166 */
Tony Cho902362b2015-09-21 12:16:44 +09003167static void Handle_AddBeacon(tstrWILC_WFIDrv *drvHandler,
Tony Cho7f33fec2015-09-30 18:44:30 +09003168 struct beacon_attr *pstrSetBeaconParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003169{
Leo Kime6e12662015-09-16 18:36:03 +09003170 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003171 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003172 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003173 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003174
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003175 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
3176
Chaehyun Limd85f5322015-06-11 14:35:54 +09003177 strWID.u16WIDid = (u16)WID_ADD_BEACON;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003178 strWID.enuWIDtype = WID_BIN;
3179 strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
Glen Leef3052582015-09-10 12:03:04 +09003180 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003181 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003182 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003183
3184 pu8CurrByte = strWID.ps8WidVal;
3185 *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
3186 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
3187 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
3188 *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
3189
3190 *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
3191 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
3192 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
3193 *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
3194
3195 *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
3196 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
3197 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
3198 *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
3199
3200 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
3201 pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
3202
3203 *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
3204 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
3205 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
3206 *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
3207
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003208 if (pstrSetBeaconParam->pu8Tail > 0)
3209 memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
3210 pu8CurrByte += pstrSetBeaconParam->u32TailLen;
3211
3212
3213
3214 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003215 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3216 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003217 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003218 PRINT_ER("Failed to send add beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003219
Leo Kim24db7132015-09-16 18:36:01 +09003220ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003221 kfree(strWID.ps8WidVal);
3222 kfree(pstrSetBeaconParam->pu8Head);
3223 kfree(pstrSetBeaconParam->pu8Tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003224}
3225
3226
3227/**
3228 * @brief Handle_AddBeacon
3229 * @details Sending config packet to delete beacon
Tony Cho80bf88362015-09-30 18:44:29 +09003230 * @param[in] tstrWILC_WFIDrv *drvHandler
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003231 * @return NONE
3232 * @author
3233 * @date
3234 * @version 1.0
3235 */
Tony Cho80bf88362015-09-30 18:44:29 +09003236static void Handle_DelBeacon(tstrWILC_WFIDrv *drvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003237{
Leo Kime6e12662015-09-16 18:36:03 +09003238 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003239 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003240 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003241 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003242
Chaehyun Limd85f5322015-06-11 14:35:54 +09003243 strWID.u16WIDid = (u16)WID_DEL_BEACON;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003244 strWID.enuWIDtype = WID_CHAR;
Dean Lee576917a2015-06-15 11:58:57 +09003245 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003246 strWID.ps8WidVal = &gu8DelBcn;
3247
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003248 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003249 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003250
3251 pu8CurrByte = strWID.ps8WidVal;
3252
3253 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
3254 /* TODO: build del beacon message*/
3255
3256 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003257 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3258 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003259 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003260 PRINT_ER("Failed to send delete beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003261}
3262
3263
3264/**
3265 * @brief WILC_HostIf_PackStaParam
3266 * @details Handling packing of the station params in a buffer
Tony Cho6a89ba92015-09-21 12:16:46 +09003267 * @param[in] u8* pu8Buffer, struct add_sta_param *pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003268 * @return NONE
3269 * @author
3270 * @date
3271 * @version 1.0
3272 */
Tony Cho6a89ba92015-09-21 12:16:46 +09003273static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
3274 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003275{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003276 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003277
3278 pu8CurrByte = pu8Buffer;
3279
3280 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003281 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003282 pu8CurrByte += ETH_ALEN;
3283
3284 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
3285 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
3286
3287 *pu8CurrByte++ = pstrStationParam->u8NumRates;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003288 if (pstrStationParam->u8NumRates > 0)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003289 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003290 pu8CurrByte += pstrStationParam->u8NumRates;
3291
3292 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
3293 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
3294 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
3295
3296 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003297 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003298 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
3299
3300 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
3301 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
3302
3303 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
3304 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
3305 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
3306 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
3307
3308 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
3309
3310 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
3311 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
3312
3313 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
3314 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
3315
3316 return pu8CurrByte - pu8Buffer;
3317}
3318
3319/**
3320 * @brief Handle_AddStation
3321 * @details Sending config packet to add station
Tony Cho6a89ba92015-09-21 12:16:46 +09003322 * @param[in] struct add_sta_param *pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003323 * @return NONE
3324 * @author
3325 * @date
3326 * @version 1.0
3327 */
Tony Cho6a89ba92015-09-21 12:16:46 +09003328static void Handle_AddStation(tstrWILC_WFIDrv *drvHandler,
3329 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003330{
Leo Kime6e12662015-09-16 18:36:03 +09003331 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003332 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003333 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003334 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003335
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003336 PRINT_D(HOSTINF_DBG, "Handling add station\n");
Chaehyun Limd85f5322015-06-11 14:35:54 +09003337 strWID.u16WIDid = (u16)WID_ADD_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003338 strWID.enuWIDtype = WID_BIN;
3339 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3340
Glen Leef3052582015-09-10 12:03:04 +09003341 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003342 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003343 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003344
3345 pu8CurrByte = strWID.ps8WidVal;
3346 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3347
3348 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003349 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3350 get_id_from_handler(pstrWFIDrv));
Leo Kime6e12662015-09-16 18:36:03 +09003351 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003352 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003353
Leo Kim24db7132015-09-16 18:36:01 +09003354ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003355 kfree(pstrStationParam->pu8Rates);
3356 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003357}
3358
3359/**
3360 * @brief Handle_DelAllSta
3361 * @details Sending config packet to delete station
3362 * @param[in] tstrHostIFDelSta* pstrDelStaParam
3363 * @return NONE
3364 * @author
3365 * @date
3366 * @version 1.0
3367 */
Tony Chob4e644e2015-09-21 12:17:00 +09003368static void Handle_DelAllSta(tstrWILC_WFIDrv *drvHandler,
3369 struct del_all_sta *pstrDelAllStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003370{
Leo Kime6e12662015-09-16 18:36:03 +09003371 s32 s32Error = 0;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003372
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003373 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003374 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003375 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003376 u8 i;
Chaehyun Lim37034802015-06-11 14:34:32 +09003377 u8 au8Zero_Buff[6] = {0};
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003378
Chaehyun Limd85f5322015-06-11 14:35:54 +09003379 strWID.u16WIDid = (u16)WID_DEL_ALL_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003380 strWID.enuWIDtype = WID_STR;
3381 strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
3382
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003383 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003384
Glen Leef3052582015-09-10 12:03:04 +09003385 strWID.ps8WidVal = kmalloc((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003386 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003387 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003388
3389 pu8CurrByte = strWID.ps8WidVal;
3390
3391 *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
3392
3393 for (i = 0; i < MAX_NUM_STA; i++) {
3394 if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003395 memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003396 else
3397 continue;
3398
3399 pu8CurrByte += ETH_ALEN;
3400 }
3401
3402 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003403 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3404 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003405 if (s32Error)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02003406 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003407
Leo Kim24db7132015-09-16 18:36:01 +09003408ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003409 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003410
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003411 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003412}
3413
3414
3415/**
3416 * @brief Handle_DelStation
3417 * @details Sending config packet to delete station
Tony Chofb93a1e2015-09-21 12:16:57 +09003418 * @param[in] struct del_sta *pstrDelStaParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003419 * @return NONE
3420 * @author
3421 * @date
3422 * @version 1.0
3423 */
Tony Chofb93a1e2015-09-21 12:16:57 +09003424static void Handle_DelStation(tstrWILC_WFIDrv *drvHandler,
3425 struct del_sta *pstrDelStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003426{
Leo Kime6e12662015-09-16 18:36:03 +09003427 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003428 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003429 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003430 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3431
Chaehyun Limd85f5322015-06-11 14:35:54 +09003432 strWID.u16WIDid = (u16)WID_REMOVE_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003433 strWID.enuWIDtype = WID_BIN;
3434 strWID.s32ValueSize = ETH_ALEN;
3435
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003436 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003437
Glen Leef3052582015-09-10 12:03:04 +09003438 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003439 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003440 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003441
3442 pu8CurrByte = strWID.ps8WidVal;
3443
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003444 memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003445
3446 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003447 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3448 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003449 if (s32Error)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02003450 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003451
Leo Kim24db7132015-09-16 18:36:01 +09003452ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003453 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003454}
3455
3456
3457/**
3458 * @brief Handle_EditStation
3459 * @details Sending config packet to edit station
Tony Cho6a89ba92015-09-21 12:16:46 +09003460 * @param[in] struct add_sta_param *pstrStationParam
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003461 * @return NONE
3462 * @author
3463 * @date
3464 * @version 1.0
3465 */
Tony Cho6a89ba92015-09-21 12:16:46 +09003466static void Handle_EditStation(tstrWILC_WFIDrv *drvHandler,
3467 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003468{
Leo Kime6e12662015-09-16 18:36:03 +09003469 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003470 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003471 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003472 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3473
Chaehyun Limd85f5322015-06-11 14:35:54 +09003474 strWID.u16WIDid = (u16)WID_EDIT_STA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003475 strWID.enuWIDtype = WID_BIN;
3476 strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
3477
3478 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
Glen Leef3052582015-09-10 12:03:04 +09003479 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003480 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003481 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003482
3483 pu8CurrByte = strWID.ps8WidVal;
3484 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
3485
3486 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003487 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3488 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003489 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003490 PRINT_ER("Failed to send edit station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003491
Leo Kim24db7132015-09-16 18:36:01 +09003492ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003493 kfree(pstrStationParam->pu8Rates);
3494 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003495}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003496
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003497/**
3498 * @brief Handle_RemainOnChan
3499 * @details Sending config packet to edit station
3500 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3501 * @return NONE
3502 * @author
3503 * @date
3504 * @version 1.0
3505 */
Tony Cho2f9c03f2015-09-21 12:16:58 +09003506static int Handle_RemainOnChan(tstrWILC_WFIDrv *drvHandler,
3507 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003508{
Leo Kime6e12662015-09-16 18:36:03 +09003509 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003510 u8 u8remain_on_chan_flag;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003511 tstrWID strWID;
3512 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3513
3514 /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
3515 if (!pstrWFIDrv->u8RemainOnChan_pendingreq) {
3516 pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
3517 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
3518 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
3519 pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
3520 pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
3521 } else {
3522 /*Set the channel to use it as a wid val*/
3523 pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel;
3524 }
3525
3526 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
3527 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
3528 pstrWFIDrv->u8RemainOnChan_pendingreq = 1;
Leo Kim24db7132015-09-16 18:36:01 +09003529 s32Error = -EBUSY;
3530 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003531 }
3532 if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
3533 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
Leo Kim24db7132015-09-16 18:36:01 +09003534 s32Error = -EBUSY;
3535 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003536 }
3537
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003538 if (g_obtainingIP || connecting) {
3539 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +09003540 s32Error = -EBUSY;
3541 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003542 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003543
3544 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
3545
Dean Lee72ed4dc2015-06-12 14:11:44 +09003546 u8remain_on_chan_flag = true;
Chaehyun Limd85f5322015-06-11 14:35:54 +09003547 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003548 strWID.enuWIDtype = WID_STR;
3549 strWID.s32ValueSize = 2;
Glen Leef3052582015-09-10 12:03:04 +09003550 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003551
Leo Kim24db7132015-09-16 18:36:01 +09003552 if (strWID.ps8WidVal == NULL) {
3553 s32Error = -ENOMEM;
3554 goto ERRORHANDLER;
3555 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003556
3557 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003558 strWID.ps8WidVal[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003559
3560 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003561 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3562 get_id_from_handler(pstrWFIDrv));
Leo Kime6e12662015-09-16 18:36:03 +09003563 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003564 PRINT_ER("Failed to set remain on channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003565
Leo Kim24db7132015-09-16 18:36:01 +09003566ERRORHANDLER:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003567 {
3568 P2P_LISTEN_STATE = 1;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003569 pstrWFIDrv->hRemainOnChannel.data = (unsigned long)pstrWFIDrv;
3570 mod_timer(&pstrWFIDrv->hRemainOnChannel,
3571 jiffies +
3572 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003573
3574 /*Calling CFG ready_on_channel*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003575 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003576 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003577
3578 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
3579 pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
3580 }
3581 return s32Error;
3582}
3583
3584/**
3585 * @brief Handle_RegisterFrame
3586 * @details
3587 * @param[in]
3588 * @return NONE
3589 * @author
3590 * @date
3591 * @version 1.0
3592 */
Tony Chobc37c5d2015-09-21 12:16:59 +09003593static int Handle_RegisterFrame(tstrWILC_WFIDrv *drvHandler,
3594 struct reg_frame *pstrHostIfRegisterFrame)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003595{
Leo Kime6e12662015-09-16 18:36:03 +09003596 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003597 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003598 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003599 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3600
3601 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
3602
3603 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +09003604 strWID.u16WIDid = (u16)WID_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003605 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09003606 strWID.ps8WidVal = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003607 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003608 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003609
3610 pu8CurrByte = strWID.ps8WidVal;
3611
3612 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
3613 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003614 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003615
3616
Chaehyun Limd85f5322015-06-11 14:35:54 +09003617 strWID.s32ValueSize = sizeof(u16) + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003618
3619
3620 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003621 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3622 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003623 if (s32Error) {
3624 PRINT_ER("Failed to frame register config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09003625 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003626 }
3627
3628 return s32Error;
3629
3630}
3631
3632/**
3633 * @brief Handle_ListenStateExpired
3634 * @details Handle of listen state expiration
3635 * @param[in] NONE
3636 * @return Error code.
3637 * @author
3638 * @date
3639 * @version 1.0
3640 */
3641#define FALSE_FRMWR_CHANNEL 100
Tony Cho2f9c03f2015-09-21 12:16:58 +09003642static u32 Handle_ListenStateExpired(tstrWILC_WFIDrv *drvHandler,
3643 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003644{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003645 u8 u8remain_on_chan_flag;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003646 tstrWID strWID;
Leo Kime6e12662015-09-16 18:36:03 +09003647 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003648 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
3649
3650 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
3651
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003652 /*Make sure we are already in listen state*/
3653 /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
3654 if (P2P_LISTEN_STATE) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09003655 u8remain_on_chan_flag = false;
Chaehyun Limd85f5322015-06-11 14:35:54 +09003656 strWID.u16WIDid = (u16)WID_REMAIN_ON_CHAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003657 strWID.enuWIDtype = WID_STR;
3658 strWID.s32ValueSize = 2;
Glen Leef3052582015-09-10 12:03:04 +09003659 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003660
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003661 if (strWID.ps8WidVal == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003662 PRINT_ER("Failed to allocate memory\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003663
3664 strWID.ps8WidVal[0] = u8remain_on_chan_flag;
3665 strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL;
3666
3667 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003668 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3669 get_id_from_handler(pstrWFIDrv));
Leo Kime6e12662015-09-16 18:36:03 +09003670 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003671 PRINT_ER("Failed to set remain on channel\n");
3672 goto _done_;
3673 }
3674
3675 if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) {
3676 pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid
3677 , pstrHostIfRemainOnChan->u32ListenSessionID);
3678 }
3679 P2P_LISTEN_STATE = 0;
3680 } else {
3681 PRINT_D(GENERIC_DBG, "Not in listen state\n");
Leo Kime6e12662015-09-16 18:36:03 +09003682 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003683 }
3684
3685_done_:
3686 return s32Error;
3687}
3688
3689
3690/**
3691 * @brief ListenTimerCB
3692 * @details Callback function of remain-on-channel timer
3693 * @param[in] NONE
3694 * @return Error code.
3695 * @author
3696 * @date
3697 * @version 1.0
3698 */
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003699static void ListenTimerCB(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003700{
Leo Kime6e12662015-09-16 18:36:03 +09003701 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003702 struct host_if_msg msg;
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003703 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003704 /*Stopping remain-on-channel timer*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07003705 del_timer(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003706
3707 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09003708 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003709 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Cho143eb952015-09-21 12:16:32 +09003710 msg.drvHandler = pstrWFIDrv;
Tony Cho410c2482015-09-21 12:16:35 +09003711 msg.body.strHostIfRemainOnChan.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003712
3713 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09003714 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003715 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09003716 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003717}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003718
3719/**
3720 * @brief Handle_EditStation
3721 * @details Sending config packet to edit station
3722 * @param[in] tstrWILC_AddStaParam* pstrStationParam
3723 * @return NONE
3724 * @author
3725 * @date
3726 * @version 1.0
3727 */
Tony Cho5a008f12015-09-21 12:16:48 +09003728static void Handle_PowerManagement(tstrWILC_WFIDrv *drvHandler,
3729 struct power_mgmt_param *strPowerMgmtParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003730{
Leo Kime6e12662015-09-16 18:36:03 +09003731 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003732 tstrWID strWID;
Chaehyun Limca356ad2015-06-11 14:35:57 +09003733 s8 s8PowerMode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003734 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003735
Chaehyun Limd85f5322015-06-11 14:35:54 +09003736 strWID.u16WIDid = (u16)WID_POWER_MANAGEMENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003737
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05303738 if (strPowerMgmtParam->bIsEnabled == true)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003739 s8PowerMode = MIN_FAST_PS;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05303740 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003741 s8PowerMode = NO_POWERSAVE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003742 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
3743 strWID.ps8WidVal = &s8PowerMode;
Dean Lee576917a2015-06-15 11:58:57 +09003744 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003745
3746 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
3747
3748 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003749 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3750 get_id_from_handler(pstrWFIDrv));
Leo Kim24db7132015-09-16 18:36:01 +09003751 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003752 PRINT_ER("Failed to send power management config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003753}
3754
3755/**
3756 * @brief Handle_SetMulticastFilter
3757 * @details Set Multicast filter in firmware
Tony Cho641210a2015-09-21 12:16:52 +09003758 * @param[in] struct set_multicast *strHostIfSetMulti
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003759 * @return NONE
3760 * @author asobhy
3761 * @date
3762 * @version 1.0
3763 */
Tony Cho641210a2015-09-21 12:16:52 +09003764static void Handle_SetMulticastFilter(tstrWILC_WFIDrv *drvHandler,
3765 struct set_multicast *strHostIfSetMulti)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003766{
Leo Kime6e12662015-09-16 18:36:03 +09003767 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003768 tstrWID strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003769 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003770
3771 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
3772
Chaehyun Limd85f5322015-06-11 14:35:54 +09003773 strWID.u16WIDid = (u16)WID_SETUP_MULTICAST_FILTER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003774 strWID.enuWIDtype = WID_BIN;
Tony Cho641210a2015-09-21 12:16:52 +09003775 strWID.s32ValueSize = sizeof(struct set_multicast) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
Glen Leef3052582015-09-10 12:03:04 +09003776 strWID.ps8WidVal = kmalloc(strWID.s32ValueSize, GFP_KERNEL);
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003777 if (strWID.ps8WidVal == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09003778 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003779
3780 pu8CurrByte = strWID.ps8WidVal;
3781 *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
3782 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
3783 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
3784 *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
3785
3786 *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
3787 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
3788 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
3789 *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
3790
3791 if ((strHostIfSetMulti->u32count) > 0)
3792 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
3793
3794 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003795 s32Error = send_config_pkt(SET_CFG, &strWID, 1, false,
3796 get_id_from_handler(drvHandler));
Leo Kim24db7132015-09-16 18:36:01 +09003797 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003798 PRINT_ER("Failed to send setup multicast config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003799
Leo Kim24db7132015-09-16 18:36:01 +09003800ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07003801 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003802
3803}
3804
3805
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003806/**
3807 * @brief Handle_AddBASession
3808 * @details Add block ack session
3809 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
3810 * @return NONE
3811 * @author Amr Abdel-Moghny
3812 * @date Feb. 2014
3813 * @version 9.0
3814 */
Tony Cho54265472015-09-21 12:16:56 +09003815static s32 Handle_AddBASession(tstrWILC_WFIDrv *drvHandler,
3816 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003817{
Leo Kime6e12662015-09-16 18:36:03 +09003818 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003819 tstrWID strWID;
3820 int AddbaTimeout = 100;
3821 char *ptr = NULL;
3822 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3823
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003824 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 +09003825 strHostIfBASessionInfo->au8Bssid[0],
3826 strHostIfBASessionInfo->au8Bssid[1],
3827 strHostIfBASessionInfo->au8Bssid[2],
3828 strHostIfBASessionInfo->u16BufferSize,
3829 strHostIfBASessionInfo->u16SessionTimeout,
3830 strHostIfBASessionInfo->u8Ted);
3831
Chaehyun Limd85f5322015-06-11 14:35:54 +09003832 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003833 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09003834 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003835 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
3836 ptr = strWID.ps8WidVal;
3837 /* *ptr++ = 0x14; */
3838 *ptr++ = 0x14;
3839 *ptr++ = 0x3;
3840 *ptr++ = 0x0;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003841 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003842 ptr += ETH_ALEN;
3843 *ptr++ = strHostIfBASessionInfo->u8Ted;
3844 /* BA Policy*/
3845 *ptr++ = 1;
3846 /* Buffer size*/
3847 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
3848 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
3849 /* BA timeout*/
3850 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
3851 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
3852 /* ADDBA timeout*/
3853 *ptr++ = (AddbaTimeout & 0xFF);
3854 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
3855 /* Group Buffer Max Frames*/
3856 *ptr++ = 8;
3857 /* Group Buffer Timeout */
3858 *ptr++ = 0;
3859
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003860 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3861 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003862 if (s32Error)
3863 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
3864
3865
Chaehyun Limd85f5322015-06-11 14:35:54 +09003866 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003867 strWID.enuWIDtype = WID_STR;
3868 strWID.s32ValueSize = 15;
3869 ptr = strWID.ps8WidVal;
3870 /* *ptr++ = 0x14; */
3871 *ptr++ = 15;
3872 *ptr++ = 7;
3873 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003874 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003875 ptr += ETH_ALEN;
3876 /* TID*/
3877 *ptr++ = strHostIfBASessionInfo->u8Ted;
3878 /* Max Num MSDU */
3879 *ptr++ = 8;
3880 /* BA timeout*/
3881 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
3882 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
3883 /*Ack-Policy */
3884 *ptr++ = 3;
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003885 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3886 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003887
3888 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09003889 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003890
3891 return s32Error;
3892
3893}
3894
3895
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003896/**
3897 * @brief Handle_DelBASession
3898 * @details Delete block ack session
3899 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
3900 * @return NONE
3901 * @author Amr Abdel-Moghny
3902 * @date Feb. 2013
3903 * @version 9.0
3904 */
Tony Cho54265472015-09-21 12:16:56 +09003905static s32 Handle_DelBASession(tstrWILC_WFIDrv *drvHandler,
3906 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003907{
Leo Kime6e12662015-09-16 18:36:03 +09003908 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003909 tstrWID strWID;
3910 char *ptr = NULL;
3911 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3912
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003913 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003914 strHostIfBASessionInfo->au8Bssid[0],
3915 strHostIfBASessionInfo->au8Bssid[1],
3916 strHostIfBASessionInfo->au8Bssid[2],
3917 strHostIfBASessionInfo->u8Ted);
3918
Chaehyun Limd85f5322015-06-11 14:35:54 +09003919 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003920 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09003921 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003922 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
3923 ptr = strWID.ps8WidVal;
3924 /* *ptr++ = 0x14; */
3925 *ptr++ = 0x14;
3926 *ptr++ = 0x3;
3927 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003928 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003929 ptr += ETH_ALEN;
3930 *ptr++ = strHostIfBASessionInfo->u8Ted;
3931 /* BA direction = recipent*/
3932 *ptr++ = 0;
3933 /* Delba Reason */
3934 *ptr++ = 32; /* Unspecific QOS reason */
3935
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003936 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3937 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003938 if (s32Error)
3939 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
3940
3941
Chaehyun Limd85f5322015-06-11 14:35:54 +09003942 strWID.u16WIDid = (u16)WID_11E_P_ACTION_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003943 strWID.enuWIDtype = WID_STR;
3944 strWID.s32ValueSize = 15;
3945 ptr = strWID.ps8WidVal;
3946 /* *ptr++ = 0x14; */
3947 *ptr++ = 15;
3948 *ptr++ = 7;
3949 *ptr++ = 0x3;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003950 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003951 ptr += ETH_ALEN;
3952 /* TID*/
3953 *ptr++ = strHostIfBASessionInfo->u8Ted;
3954
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09003955 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
3956 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003957
3958 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09003959 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003960
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003961 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003962
3963 return s32Error;
3964
3965}
3966
3967
3968/**
3969 * @brief Handle_DelAllRxBASessions
3970 * @details Delete all Rx BA sessions
3971 * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
3972 * @return NONE
3973 * @author Abdelrahman Sobhy
3974 * @date Feb. 2013
3975 * @version 9.0
3976 */
Tony Cho54265472015-09-21 12:16:56 +09003977static s32 Handle_DelAllRxBASessions(tstrWILC_WFIDrv *drvHandler,
3978 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003979{
Leo Kime6e12662015-09-16 18:36:03 +09003980 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003981 tstrWID strWID;
3982 char *ptr = NULL;
3983 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
3984
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003985 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003986 strHostIfBASessionInfo->au8Bssid[0],
3987 strHostIfBASessionInfo->au8Bssid[1],
3988 strHostIfBASessionInfo->au8Bssid[2],
3989 strHostIfBASessionInfo->u8Ted);
3990
Chaehyun Limd85f5322015-06-11 14:35:54 +09003991 strWID.u16WIDid = (u16)WID_DEL_ALL_RX_BA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003992 strWID.enuWIDtype = WID_STR;
Glen Leef3052582015-09-10 12:03:04 +09003993 strWID.ps8WidVal = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003994 strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
3995 ptr = strWID.ps8WidVal;
3996 *ptr++ = 0x14;
3997 *ptr++ = 0x3;
3998 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09003999 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004000 ptr += ETH_ALEN;
4001 *ptr++ = strHostIfBASessionInfo->u8Ted;
4002 /* BA direction = recipent*/
4003 *ptr++ = 0;
4004 /* Delba Reason */
4005 *ptr++ = 32; /* Unspecific QOS reason */
4006
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09004007 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
4008 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004009 if (s32Error)
4010 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
4011
4012
4013 if (strWID.ps8WidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09004014 kfree(strWID.ps8WidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004015
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004016 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004017
4018 return s32Error;
4019
4020}
4021
4022/**
4023 * @brief hostIFthread
4024 * @details Main thread to handle message queue requests
4025 * @param[in] void* pvArg
4026 * @return NONE
4027 * @author
4028 * @date
4029 * @version 1.0
4030 */
Arnd Bergmann1999bd52015-05-29 22:52:14 +02004031static int hostIFthread(void *pvArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004032{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004033 u32 u32Ret;
Tony Cho143eb952015-09-21 12:16:32 +09004034 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004035 tstrWILC_WFIDrv *pstrWFIDrv;
4036
Tony Cho143eb952015-09-21 12:16:32 +09004037 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004038
4039 while (1) {
Tony Cho143eb952015-09-21 12:16:32 +09004040 wilc_mq_recv(&gMsgQHostIF, &msg, sizeof(struct host_if_msg), &u32Ret);
4041 pstrWFIDrv = (tstrWILC_WFIDrv *)msg.drvHandler;
Tony Choa9f812a2015-09-21 12:16:33 +09004042 if (msg.id == HOST_IF_MSG_EXIT) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004043 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
4044 break;
4045 }
4046
4047
4048 /*Re-Queue HIF message*/
4049 if ((!g_wilc_initialized)) {
4050 PRINT_D(GENERIC_DBG, "--WAIT--");
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07004051 usleep_range(200 * 1000, 200 * 1000);
Tony Cho143eb952015-09-21 12:16:32 +09004052 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004053 continue;
4054 }
4055
Tony Choa9f812a2015-09-21 12:16:33 +09004056 if (msg.id == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004057 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
Tony Cho143eb952015-09-21 12:16:32 +09004058 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07004059 usleep_range(2 * 1000, 2 * 1000);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004060 continue;
4061 }
4062
Tony Choa9f812a2015-09-21 12:16:33 +09004063 switch (msg.id) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004064 case HOST_IF_MSG_Q_IDLE:
4065 Handle_wait_msg_q_empty();
4066 break;
4067
4068 case HOST_IF_MSG_SCAN:
Tony Cho4528bdb2015-09-30 18:44:20 +09004069 Handle_Scan(msg.drvHandler, &msg.body.scan_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004070 break;
4071
4072 case HOST_IF_MSG_CONNECT:
Tony Cho3f501972015-09-30 18:44:21 +09004073 Handle_Connect(msg.drvHandler, &msg.body.con_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004074 break;
4075
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004076 case HOST_IF_MSG_FLUSH_CONNECT:
Tony Cho143eb952015-09-21 12:16:32 +09004077 Handle_FlushConnect(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004078 break;
4079
4080 case HOST_IF_MSG_RCVD_NTWRK_INFO:
Tony Cho02d19462015-09-30 18:44:22 +09004081 Handle_RcvdNtwrkInfo(msg.drvHandler, &msg.body.net_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004082 break;
4083
4084 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
Tony Cho66add622015-09-30 18:44:23 +09004085 Handle_RcvdGnrlAsyncInfo(msg.drvHandler, &msg.body.async_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004086 break;
4087
4088 case HOST_IF_MSG_KEY:
Tony Cho18990bf2015-09-30 18:44:24 +09004089 Handle_Key(msg.drvHandler, &msg.body.key_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004090 break;
4091
4092 case HOST_IF_MSG_CFG_PARAMS:
4093
Tony Choa2340c32015-09-30 18:44:25 +09004094 Handle_CfgParam(msg.drvHandler, &msg.body.cfg_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004095 break;
4096
4097 case HOST_IF_MSG_SET_CHANNEL:
Tony Choffd6dbc2015-09-30 18:44:28 +09004098 Handle_SetChannel(msg.drvHandler, &msg.body.channel_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004099 break;
4100
4101 case HOST_IF_MSG_DISCONNECT:
Tony Cho143eb952015-09-21 12:16:32 +09004102 Handle_Disconnect(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004103 break;
4104
4105 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07004106 del_timer(&pstrWFIDrv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004107 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
4108
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004109 /*Allow chip sleep, only if both interfaces are not connected*/
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004110 if (!linux_wlan_get_num_conn_ifcs())
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004111 chip_sleep_manually(INFINITE_SLEEP_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004112
Tony Cho143eb952015-09-21 12:16:32 +09004113 Handle_ScanDone(msg.drvHandler, SCAN_EVENT_DONE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004114
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004115 if (pstrWFIDrv->u8RemainOnChan_pendingreq)
Tony Cho410c2482015-09-21 12:16:35 +09004116 Handle_RemainOnChan(msg.drvHandler, &msg.body.strHostIfRemainOnChan);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004117
4118 break;
4119
4120 case HOST_IF_MSG_GET_RSSI:
Tony Cho143eb952015-09-21 12:16:32 +09004121 Handle_GetRssi(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004122 break;
4123
4124 case HOST_IF_MSG_GET_LINKSPEED:
Tony Cho143eb952015-09-21 12:16:32 +09004125 Handle_GetLinkspeed(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004126 break;
4127
4128 case HOST_IF_MSG_GET_STATISTICS:
Tony Cho410c2482015-09-21 12:16:35 +09004129 Handle_GetStatistics(msg.drvHandler, (tstrStatistics *)msg.body.pUserData);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004130 break;
4131
4132 case HOST_IF_MSG_GET_CHNL:
Tony Cho143eb952015-09-21 12:16:32 +09004133 Handle_GetChnl(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004134 break;
4135
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004136 case HOST_IF_MSG_ADD_BEACON:
Tony Choa98491e2015-09-30 18:44:31 +09004137 Handle_AddBeacon(msg.drvHandler, &msg.body.beacon_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004138 break;
4139
4140 case HOST_IF_MSG_DEL_BEACON:
Tony Cho80bf88362015-09-30 18:44:29 +09004141 Handle_DelBeacon(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004142 break;
4143
4144 case HOST_IF_MSG_ADD_STATION:
Tony Cho410c2482015-09-21 12:16:35 +09004145 Handle_AddStation(msg.drvHandler, &msg.body.strAddStaParam);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004146 break;
4147
4148 case HOST_IF_MSG_DEL_STATION:
Tony Cho410c2482015-09-21 12:16:35 +09004149 Handle_DelStation(msg.drvHandler, &msg.body.strDelStaParam);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004150 break;
4151
4152 case HOST_IF_MSG_EDIT_STATION:
Tony Cho410c2482015-09-21 12:16:35 +09004153 Handle_EditStation(msg.drvHandler, &msg.body.strEditStaParam);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004154 break;
4155
4156 case HOST_IF_MSG_GET_INACTIVETIME:
Tony Cho410c2482015-09-21 12:16:35 +09004157 Handle_Get_InActiveTime(msg.drvHandler, &msg.body.strHostIfStaInactiveT);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004158 break;
4159
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004160 case HOST_IF_MSG_SCAN_TIMER_FIRED:
4161 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
4162
Tony Cho143eb952015-09-21 12:16:32 +09004163 Handle_ScanDone(msg.drvHandler, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004164 break;
4165
4166 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004167 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
Tony Cho143eb952015-09-21 12:16:32 +09004168 Handle_ConnectTimeout(msg.drvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004169 break;
4170
4171 case HOST_IF_MSG_POWER_MGMT:
Tony Cho410c2482015-09-21 12:16:35 +09004172 Handle_PowerManagement(msg.drvHandler, &msg.body.strPowerMgmtparam);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004173 break;
4174
4175 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
Tony Cho143eb952015-09-21 12:16:32 +09004176 Handle_SetWfiDrvHandler(msg.drvHandler,
Tony Cho410c2482015-09-21 12:16:35 +09004177 &msg.body.strHostIfSetDrvHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004178 break;
4179
4180 case HOST_IF_MSG_SET_OPERATION_MODE:
Tony Cho410c2482015-09-21 12:16:35 +09004181 Handle_SetOperationMode(msg.drvHandler, &msg.body.strHostIfSetOperationMode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004182 break;
4183
4184 case HOST_IF_MSG_SET_IPADDRESS:
4185 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Tony Cho410c2482015-09-21 12:16:35 +09004186 Handle_set_IPAddress(msg.drvHandler, msg.body.strHostIfSetIP.au8IPAddr, msg.body.strHostIfSetIP.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004187 break;
4188
4189 case HOST_IF_MSG_GET_IPADDRESS:
4190 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Tony Cho410c2482015-09-21 12:16:35 +09004191 Handle_get_IPAddress(msg.drvHandler, msg.body.strHostIfSetIP.au8IPAddr, msg.body.strHostIfSetIP.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004192 break;
4193
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004194 case HOST_IF_MSG_SET_MAC_ADDRESS:
Tony Cho410c2482015-09-21 12:16:35 +09004195 Handle_SetMacAddress(msg.drvHandler, &msg.body.strHostIfSetMacAddress);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004196 break;
4197
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004198 case HOST_IF_MSG_GET_MAC_ADDRESS:
Tony Cho410c2482015-09-21 12:16:35 +09004199 Handle_GetMacAddress(msg.drvHandler, &msg.body.strHostIfGetMacAddress);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004200 break;
4201
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004202 case HOST_IF_MSG_REMAIN_ON_CHAN:
4203 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
Tony Cho410c2482015-09-21 12:16:35 +09004204 Handle_RemainOnChan(msg.drvHandler, &msg.body.strHostIfRemainOnChan);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004205 break;
4206
4207 case HOST_IF_MSG_REGISTER_FRAME:
4208 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
Tony Cho410c2482015-09-21 12:16:35 +09004209 Handle_RegisterFrame(msg.drvHandler, &msg.body.strHostIfRegisterFrame);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004210 break;
4211
4212 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
Tony Cho410c2482015-09-21 12:16:35 +09004213 Handle_ListenStateExpired(msg.drvHandler, &msg.body.strHostIfRemainOnChan);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004214 break;
4215
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004216 case HOST_IF_MSG_SET_MULTICAST_FILTER:
4217 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
Tony Cho410c2482015-09-21 12:16:35 +09004218 Handle_SetMulticastFilter(msg.drvHandler, &msg.body.strHostIfSetMulti);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004219 break;
4220
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004221 case HOST_IF_MSG_ADD_BA_SESSION:
Tony Cho410c2482015-09-21 12:16:35 +09004222 Handle_AddBASession(msg.drvHandler, &msg.body.strHostIfBASessionInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004223 break;
4224
4225 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
Tony Cho410c2482015-09-21 12:16:35 +09004226 Handle_DelAllRxBASessions(msg.drvHandler, &msg.body.strHostIfBASessionInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004227 break;
4228
4229 case HOST_IF_MSG_DEL_ALL_STA:
Tony Cho410c2482015-09-21 12:16:35 +09004230 Handle_DelAllSta(msg.drvHandler, &msg.body.strHostIFDelAllSta);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004231 break;
4232
4233 default:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004234 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004235 break;
4236 }
4237 }
4238
4239 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004240 up(&hSemHostIFthrdEnd);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02004241 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004242}
4243
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004244static void TimerCB_Scan(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004245{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004246 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09004247 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004248
4249 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09004250 memset(&msg, 0, sizeof(struct host_if_msg));
4251 msg.drvHandler = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09004252 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004253
4254 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004255 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004256}
4257
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004258static void TimerCB_Connect(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004259{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004260 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09004261 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004262
4263 /* prepare the Timer Callback message */
Tony Cho143eb952015-09-21 12:16:32 +09004264 memset(&msg, 0, sizeof(struct host_if_msg));
4265 msg.drvHandler = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09004266 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004267
4268 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004269 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004270}
4271
4272
4273/**
4274 * @brief removes wpa/wpa2 keys
4275 * @details only in BSS STA mode if External Supplicant support is enabled.
4276 * removes all WPA/WPA2 station key entries from MAC hardware.
4277 * @param[in,out] handle to the wifi driver
4278 * @param[in] 6 bytes of Station Adress in the station entry table
4279 * @return Error code indicating success/failure
4280 * @note
4281 * @author zsalah
4282 * @date 8 March 2012
4283 * @version 1.0
4284 */
4285/* Check implementation in core adding 9 bytes to the input! */
Johnny Kim218dc402015-08-13 13:41:19 +09004286s32 host_int_remove_key(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8StaAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004287{
Leo Kime6e12662015-09-16 18:36:03 +09004288 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004289 tstrWID strWID;
4290 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4291
Chaehyun Limd85f5322015-06-11 14:35:54 +09004292 strWID.u16WIDid = (u16)WID_REMOVE_KEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004293 strWID.enuWIDtype = WID_STR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09004294 strWID.ps8WidVal = (s8 *)pu8StaAddress;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004295 strWID.s32ValueSize = 6;
4296
4297 return s32Error;
4298
4299}
4300
4301/**
4302 * @brief removes WEP key
4303 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4304 * remove a WEP key entry from MAC HW.
4305 * The BSS Station automatically finds the index of the entry using its
4306 * BSS ID and removes that entry from the MAC hardware.
4307 * @param[in,out] handle to the wifi driver
4308 * @param[in] 6 bytes of Station Adress in the station entry table
4309 * @return Error code indicating success/failure
4310 * @note NO need for the STA add since it is not used for processing
4311 * @author zsalah
4312 * @date 8 March 2012
4313 * @version 1.0
4314 */
Johnny Kim218dc402015-08-13 13:41:19 +09004315s32 host_int_remove_wep_key(tstrWILC_WFIDrv *hWFIDrv, u8 u8keyIdx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004316{
Leo Kime6e12662015-09-16 18:36:03 +09004317 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004318 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004319 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004320
4321
Leo Kim24db7132015-09-16 18:36:01 +09004322 if (pstrWFIDrv == NULL) {
4323 s32Error = -EFAULT;
4324 PRINT_ER("Failed to send setup multicast config packet\n");
4325 return s32Error;
4326 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004327
4328 /* prepare the Remove Wep Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004329 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004330
4331
Tony Choa9f812a2015-09-21 12:16:33 +09004332 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004333 msg.body.key_info.enuKeyType = WEP;
4334 msg.body.key_info.u8KeyAction = REMOVEKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004335 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004336
4337
4338
Tony Cho18990bf2015-09-30 18:44:24 +09004339 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004340 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8keyIdx;
4341
4342 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004343 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004344 if (s32Error)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004345 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004346 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004347
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004348 return s32Error;
4349}
4350
4351/**
4352 * @brief sets WEP default key
4353 * @details Sets the index of the WEP encryption key in use,
4354 * in the key table
4355 * @param[in,out] handle to the wifi driver
4356 * @param[in] key index ( 0, 1, 2, 3)
4357 * @return Error code indicating success/failure
4358 * @note
4359 * @author zsalah
4360 * @date 8 March 2012
4361 * @version 1.0
4362 */
Johnny Kim218dc402015-08-13 13:41:19 +09004363s32 host_int_set_WEPDefaultKeyID(tstrWILC_WFIDrv *hWFIDrv, u8 u8Index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004364{
Leo Kime6e12662015-09-16 18:36:03 +09004365 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004366 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004367 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004368
4369
Leo Kim24db7132015-09-16 18:36:01 +09004370 if (pstrWFIDrv == NULL) {
4371 s32Error = -EFAULT;
4372 PRINT_ER("driver is null\n");
4373 return s32Error;
4374 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004375
4376 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004377 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004378
4379
Tony Choa9f812a2015-09-21 12:16:33 +09004380 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004381 msg.body.key_info.enuKeyType = WEP;
4382 msg.body.key_info.u8KeyAction = DEFAULTKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004383 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004384
4385
Tony Cho18990bf2015-09-30 18:44:24 +09004386 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004387 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
4388
4389 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004390 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004391 if (s32Error)
4392 PRINT_ER("Error in sending message queue : Default key index\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004393 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004394
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004395 return s32Error;
4396}
4397
4398/**
4399 * @brief sets WEP deafault key
4400 * @details valid only in BSS STA mode if External Supplicant support is enabled.
4401 * sets WEP key entry into MAC hardware when it receives the
4402 * corresponding request from NDIS.
4403 * @param[in,out] handle to the wifi driver
4404 * @param[in] message containing WEP Key in the following format
4405 *|---------------------------------------|
4406 *|Key ID Value | Key Length | Key |
4407 *|-------------|------------|------------|
4408 | 1byte | 1byte | Key Length |
4409 ||---------------------------------------|
4410 |
4411 * @return Error code indicating success/failure
4412 * @note
4413 * @author zsalah
4414 * @date 8 March 2012
4415 * @version 1.0
4416 */
Johnny Kim218dc402015-08-13 13:41:19 +09004417s32 host_int_add_wep_key_bss_sta(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004418{
4419
Leo Kime6e12662015-09-16 18:36:03 +09004420 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004421 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004422 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004423
Leo Kim24db7132015-09-16 18:36:01 +09004424 if (pstrWFIDrv == NULL) {
4425 s32Error = -EFAULT;
4426 PRINT_ER("driver is null\n");
4427 return s32Error;
4428 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004429
4430 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004431 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004432
4433
Tony Choa9f812a2015-09-21 12:16:33 +09004434 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004435 msg.body.key_info.enuKeyType = WEP;
4436 msg.body.key_info.u8KeyAction = ADDKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004437 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004438
4439
Tony Cho18990bf2015-09-30 18:44:24 +09004440 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004441 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004442
Tony Cho18990bf2015-09-30 18:44:24 +09004443 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004444 pu8WepKey, u8WepKeylen);
4445
4446
Tony Cho18990bf2015-09-30 18:44:24 +09004447 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004448 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4449
Tony Cho18990bf2015-09-30 18:44:24 +09004450 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004451 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4452
4453 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004454 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004455 if (s32Error)
4456 PRINT_ER("Error in sending message queue :WEP Key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004457 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004458
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004459 return s32Error;
4460
4461}
4462
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004463/**
4464 *
4465 * @brief host_int_add_wep_key_bss_ap
4466 * @details valid only in BSS AP mode if External Supplicant support is enabled.
4467 * sets WEP key entry into MAC hardware when it receives the
4468 *
4469 * corresponding request from NDIS.
4470 * @param[in,out] handle to the wifi driver
4471 *
4472 *
4473 * @return Error code indicating success/failure
4474 * @note
4475 * @author mdaftedar
4476 * @date 28 FEB 2013
4477 * @version 1.0
4478 */
Johnny Kim218dc402015-08-13 13:41:19 +09004479s32 host_int_add_wep_key_bss_ap(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, AUTHTYPE_T tenuAuth_type)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004480{
4481
Leo Kime6e12662015-09-16 18:36:03 +09004482 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004483 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004484 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004485 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004486
Leo Kim24db7132015-09-16 18:36:01 +09004487 if (pstrWFIDrv == NULL) {
4488 s32Error = -EFAULT;
4489 PRINT_ER("driver is null\n");
4490 return s32Error;
4491 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004492
4493 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004494 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004495
4496 if (INFO) {
4497 for (i = 0; i < u8WepKeylen; i++)
4498 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
4499 }
Tony Choa9f812a2015-09-21 12:16:33 +09004500 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004501 msg.body.key_info.enuKeyType = WEP;
4502 msg.body.key_info.u8KeyAction = ADDKEY_AP;
Tony Cho143eb952015-09-21 12:16:32 +09004503 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004504
4505
Tony Cho18990bf2015-09-30 18:44:24 +09004506 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004507 uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = kmalloc(u8WepKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004508
4509
Tony Cho18990bf2015-09-30 18:44:24 +09004510 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004511 pu8WepKey, (u8WepKeylen));
4512
4513
Tony Cho18990bf2015-09-30 18:44:24 +09004514 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004515 uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
4516
Tony Cho18990bf2015-09-30 18:44:24 +09004517 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004518 uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
4519
Tony Cho18990bf2015-09-30 18:44:24 +09004520 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004521 uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
4522
Tony Cho18990bf2015-09-30 18:44:24 +09004523 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004524 uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
4525 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004526 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004527
4528 if (s32Error)
4529 PRINT_ER("Error in sending message queue :WEP Key\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004530 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004531
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004532 return s32Error;
4533
4534}
Glen Lee108b3432015-09-16 18:53:20 +09004535
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004536/**
4537 * @brief adds ptk Key
4538 * @details
4539 * @param[in,out] handle to the wifi driver
4540 * @param[in] message containing PTK Key in the following format
4541 *|-----------------------------------------------------------------------------|
4542 *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
4543 *|----------------|------------|--------------|----------------|---------------|
4544 | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
4545 ||-----------------------------------------------------------------------------|
4546 * @return Error code indicating success/failure
4547 * @note
4548 * @author zsalah
4549 * @date 8 March 2012
4550 * @version 1.0
4551 */
Johnny Kim218dc402015-08-13 13:41:19 +09004552s32 host_int_add_ptk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004553 const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004554{
Leo Kime6e12662015-09-16 18:36:03 +09004555 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004556 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004557 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004558 u8 u8KeyLen = u8PtkKeylen;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004559 u32 i;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004560
Leo Kim24db7132015-09-16 18:36:01 +09004561 if (pstrWFIDrv == NULL) {
4562 s32Error = -EFAULT;
4563 PRINT_ER("driver is null\n");
4564 return s32Error;
4565 }
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004566 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004567 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004568 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004569 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004570
4571 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004572 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004573
4574
Tony Choa9f812a2015-09-21 12:16:33 +09004575 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004576 msg.body.key_info.enuKeyType = WPAPtk;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004577 if (mode == AP_MODE) {
Tony Cho18990bf2015-09-30 18:44:24 +09004578 msg.body.key_info.u8KeyAction = ADDKEY_AP;
4579 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004580 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
4581 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004582 if (mode == STATION_MODE)
Tony Cho18990bf2015-09-30 18:44:24 +09004583 msg.body.key_info.u8KeyAction = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004584
4585
Tony Cho18990bf2015-09-30 18:44:24 +09004586 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004587 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8PtkKeylen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004588
4589
Tony Cho18990bf2015-09-30 18:44:24 +09004590 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004591 pu8Ptk, u8PtkKeylen);
4592
4593 if (pu8RxMic != NULL) {
4594
Tony Cho18990bf2015-09-30 18:44:24 +09004595 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004596 pu8RxMic, RX_MIC_KEY_LEN);
4597 if (INFO) {
4598 for (i = 0; i < RX_MIC_KEY_LEN; i++)
4599 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
4600 }
4601 }
4602 if (pu8TxMic != NULL) {
4603
Tony Cho18990bf2015-09-30 18:44:24 +09004604 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004605 pu8TxMic, TX_MIC_KEY_LEN);
4606 if (INFO) {
4607 for (i = 0; i < TX_MIC_KEY_LEN; i++)
4608 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
4609 }
4610 }
4611
Tony Cho18990bf2015-09-30 18:44:24 +09004612 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004613 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4614
Tony Cho18990bf2015-09-30 18:44:24 +09004615 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004616 uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
Tony Cho18990bf2015-09-30 18:44:24 +09004617 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004618 uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
Tony Cho143eb952015-09-21 12:16:32 +09004619 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004620
4621 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004622 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004623
4624 if (s32Error)
4625 PRINT_ER("Error in sending message queue: PTK Key\n");
4626
4627 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004628 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004629 /* /////// */
4630
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004631 return s32Error;
4632}
4633
4634/**
4635 * @brief adds Rx GTk Key
4636 * @details
4637 * @param[in,out] handle to the wifi driver
4638 * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
4639 * u8GtkKeylen :The total key length
4640 *
4641 * @return Error code indicating success/failure
4642 * @note
4643 * @author zsalah
4644 * @date 8 March 2012
4645 * @version 1.0
4646 */
Johnny Kim218dc402015-08-13 13:41:19 +09004647s32 host_int_add_rx_gtk(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004648 u8 u8KeyIdx, u32 u32KeyRSClen, const u8 *KeyRSC,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004649 const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004650{
Leo Kime6e12662015-09-16 18:36:03 +09004651 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004652 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004653 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004654 u8 u8KeyLen = u8GtkKeylen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004655
Leo Kim24db7132015-09-16 18:36:01 +09004656 if (pstrWFIDrv == NULL) {
4657 s32Error = -EFAULT;
4658 PRINT_ER("driver is null\n");
4659 return s32Error;
4660 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004661 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004662 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004663
4664
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004665 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004666 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004667 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004668 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004669 if (KeyRSC != NULL) {
Tony Cho18990bf2015-09-30 18:44:24 +09004670 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004671 uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004672
Tony Cho18990bf2015-09-30 18:44:24 +09004673 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004674 KeyRSC, u32KeyRSClen);
4675 }
4676
4677
Tony Choa9f812a2015-09-21 12:16:33 +09004678 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004679 msg.body.key_info.enuKeyType = WPARxGtk;
Tony Cho143eb952015-09-21 12:16:32 +09004680 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004681
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004682 if (mode == AP_MODE) {
Tony Cho18990bf2015-09-30 18:44:24 +09004683 msg.body.key_info.u8KeyAction = ADDKEY_AP;
4684 msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004685 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004686 if (mode == STATION_MODE)
Tony Cho18990bf2015-09-30 18:44:24 +09004687 msg.body.key_info.u8KeyAction = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004688
4689
Tony Cho18990bf2015-09-30 18:44:24 +09004690 msg.body.key_info.
Glen Leef3052582015-09-10 12:03:04 +09004691 uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = kmalloc(u8KeyLen, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004692
Tony Cho18990bf2015-09-30 18:44:24 +09004693 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004694 pu8RxGtk, u8GtkKeylen);
4695
4696 if (pu8RxMic != NULL) {
4697
Tony Cho18990bf2015-09-30 18:44:24 +09004698 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004699 pu8RxMic, RX_MIC_KEY_LEN);
4700
4701 }
4702 if (pu8TxMic != NULL) {
4703
Tony Cho18990bf2015-09-30 18:44:24 +09004704 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004705 pu8TxMic, TX_MIC_KEY_LEN);
4706
4707 }
4708
Tony Cho18990bf2015-09-30 18:44:24 +09004709 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004710 uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
Tony Cho18990bf2015-09-30 18:44:24 +09004711 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004712 uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
4713
Tony Cho18990bf2015-09-30 18:44:24 +09004714 msg.body.key_info.
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004715 uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
4716
4717
4718
4719 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004720 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004721 if (s32Error)
4722 PRINT_ER("Error in sending message queue: RX GTK\n");
4723 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004724 down(&(pstrWFIDrv->hSemTestKeyBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004725 /* /////// */
4726
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004727 return s32Error;
4728}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004729
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004730/**
4731 * @brief host_int_set_pmkid_info
4732 * @details caches the pmkid valid only in BSS STA mode if External Supplicant
4733 * support is enabled. This Function sets the PMKID in firmware
4734 * when host drivr receives the corresponding request from NDIS.
4735 * The firmware then includes theset PMKID in the appropriate
4736 * management frames
4737 * @param[in,out] handle to the wifi driver
4738 * @param[in] message containing PMKID Info in the following format
4739 *|-----------------------------------------------------------------|
4740 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
4741 *|-----------|------------|----------|-------|----------|----------|
4742 | 1 | 6 | 16 | ... | 6 | 16 |
4743 ||-----------------------------------------------------------------|
4744 * @return Error code indicating success/failure
4745 * @note
4746 * @author zsalah
4747 * @date 8 March 2012
4748 * @version 1.0
4749 */
Johnny Kim218dc402015-08-13 13:41:19 +09004750s32 host_int_set_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004751{
Leo Kime6e12662015-09-16 18:36:03 +09004752 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004753 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09004754 struct host_if_msg msg;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004755 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004756
4757
Leo Kim24db7132015-09-16 18:36:01 +09004758 if (pstrWFIDrv == NULL) {
4759 s32Error = -EFAULT;
4760 PRINT_ER("driver is null\n");
4761 return s32Error;
4762 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004763
4764 /* prepare the Key Message */
Tony Cho143eb952015-09-21 12:16:32 +09004765 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004766
Tony Choa9f812a2015-09-21 12:16:33 +09004767 msg.id = HOST_IF_MSG_KEY;
Tony Cho18990bf2015-09-30 18:44:24 +09004768 msg.body.key_info.enuKeyType = PMKSA;
4769 msg.body.key_info.u8KeyAction = ADDKEY;
Tony Cho143eb952015-09-21 12:16:32 +09004770 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004771
4772 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
4773
Tony Cho18990bf2015-09-30 18:44:24 +09004774 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004775 ETH_ALEN);
4776
Tony Cho18990bf2015-09-30 18:44:24 +09004777 memcpy(msg.body.key_info.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004778 PMKID_LEN);
4779 }
4780
4781 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004782 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004783 if (s32Error)
4784 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
4785
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004786 return s32Error;
4787}
4788
4789/**
4790 * @brief gets the cached the pmkid info
4791 * @details valid only in BSS STA mode if External Supplicant
4792 * support is enabled. This Function sets the PMKID in firmware
4793 * when host drivr receives the corresponding request from NDIS.
4794 * The firmware then includes theset PMKID in the appropriate
4795 * management frames
4796 * @param[in,out] handle to the wifi driver,
4797 * message containing PMKID Info in the following format
4798 *|-----------------------------------------------------------------|
4799 *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
4800 *|-----------|------------|----------|-------|----------|----------|
4801 | 1 | 6 | 16 | ... | 6 | 16 |
4802 ||-----------------------------------------------------------------|
4803 * @param[in]
4804 * @return Error code indicating success/failure
4805 * @note
4806 * @author zsalah
4807 * @date 8 March 2012
4808 * @version 1.0
4809 */
Johnny Kim218dc402015-08-13 13:41:19 +09004810s32 host_int_get_pmkid_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PmkidInfoArray,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004811 u32 u32PmkidInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004812{
Leo Kime6e12662015-09-16 18:36:03 +09004813 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004814 tstrWID strWID;
4815 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4816
Chaehyun Limd85f5322015-06-11 14:35:54 +09004817 strWID.u16WIDid = (u16)WID_PMKID_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004818 strWID.enuWIDtype = WID_STR;
4819 strWID.s32ValueSize = u32PmkidInfoLen;
4820 strWID.ps8WidVal = pu8PmkidInfoArray;
4821
4822 return s32Error;
4823}
4824
4825/**
4826 * @brief sets the pass phrase
4827 * @details AP/STA mode. This function gives the pass phrase used to
4828 * generate the Pre-Shared Key when WPA/WPA2 is enabled
4829 * The length of the field can vary from 8 to 64 bytes,
4830 * the lower layer should get the
4831 * @param[in,out] handle to the wifi driver,
4832 * @param[in] String containing PSK
4833 * @return Error code indicating success/failure
4834 * @note
4835 * @author zsalah
4836 * @date 8 March 2012
4837 * @version 1.0
4838 */
Johnny Kim218dc402015-08-13 13:41:19 +09004839s32 host_int_set_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8PassPhrase,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004840 u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004841{
Leo Kime6e12662015-09-16 18:36:03 +09004842 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004843 tstrWID strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004844
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004845 /*validating psk length*/
4846 if ((u8Psklength > 7) && (u8Psklength < 65)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09004847 strWID.u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004848 strWID.enuWIDtype = WID_STR;
4849 strWID.ps8WidVal = pu8PassPhrase;
4850 strWID.s32ValueSize = u8Psklength;
4851 }
4852
4853 return s32Error;
4854}
4855/**
4856 * @brief host_int_get_MacAddress
4857 * @details gets mac address
4858 * @param[in,out] handle to the wifi driver,
4859 *
4860 * @return Error code indicating success/failure
4861 * @note
4862 * @author mdaftedar
4863 * @date 19 April 2012
4864 * @version 1.0
4865 */
Johnny Kim218dc402015-08-13 13:41:19 +09004866s32 host_int_get_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004867{
Leo Kime6e12662015-09-16 18:36:03 +09004868 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004869 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004870
4871
4872 /* prepare the Message */
Tony Cho143eb952015-09-21 12:16:32 +09004873 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004874
Tony Choa9f812a2015-09-21 12:16:33 +09004875 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
Tony Cho410c2482015-09-21 12:16:35 +09004876 msg.body.strHostIfGetMacAddress.u8MacAddress = pu8MacAddress;
Tony Cho143eb952015-09-21 12:16:32 +09004877 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004878 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09004879 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004880 if (s32Error) {
4881 PRINT_ER("Failed to send get mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +09004882 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004883 }
4884
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004885 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004886 return s32Error;
4887}
4888
4889/**
4890 * @brief host_int_set_MacAddress
4891 * @details sets mac address
4892 * @param[in,out] handle to the wifi driver,
4893 *
4894 * @return Error code indicating success/failure
4895 * @note
4896 * @author mabubakr
4897 * @date 16 July 2012
4898 * @version 1.0
4899 */
Johnny Kim218dc402015-08-13 13:41:19 +09004900s32 host_int_set_MacAddress(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004901{
Leo Kime6e12662015-09-16 18:36:03 +09004902 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004903 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004904
4905 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
4906
4907 /* prepare setting mac address message */
Tony Cho143eb952015-09-21 12:16:32 +09004908 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09004909 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
Tony Cho410c2482015-09-21 12:16:35 +09004910 memcpy(msg.body.strHostIfSetMacAddress.u8MacAddress, pu8MacAddress, ETH_ALEN);
Tony Cho143eb952015-09-21 12:16:32 +09004911 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004912
Tony Cho143eb952015-09-21 12:16:32 +09004913 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09004914 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004915 PRINT_ER("Failed to send message queue: Set mac address\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004916
4917 return s32Error;
4918
4919}
4920
4921/**
4922 * @brief host_int_get_RSNAConfigPSKPassPhrase
4923 * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
4924 * generate the Pre-Shared Key when WPA/WPA2 is enabled
4925 * The length of the field can vary from 8 to 64 bytes,
4926 * the lower layer should get the
4927 * @param[in,out] handle to the wifi driver,
4928 * String containing PSK
4929 * @return Error code indicating success/failure
4930 * @note
4931 * @author zsalah
4932 * @date 8 March 2012
4933 * @version 1.0
4934 */
Johnny Kim218dc402015-08-13 13:41:19 +09004935s32 host_int_get_RSNAConfigPSKPassPhrase(tstrWILC_WFIDrv *hWFIDrv,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004936 u8 *pu8PassPhrase, u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004937{
Leo Kime6e12662015-09-16 18:36:03 +09004938 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004939 tstrWID strWID;
4940 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4941
Chaehyun Limd85f5322015-06-11 14:35:54 +09004942 strWID.u16WIDid = (u16)WID_11I_PSK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004943 strWID.enuWIDtype = WID_STR;
4944 strWID.s32ValueSize = u8Psklength;
4945 strWID.ps8WidVal = pu8PassPhrase;
4946
4947 return s32Error;
4948}
4949
4950/**
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004951 * @brief sets a start scan request
4952 * @details
4953 * @param[in,out] handle to the wifi driver,
4954 * @param[in] Scan Source one of the following values
4955 * DEFAULT_SCAN 0
4956 * USER_SCAN BIT0
4957 * OBSS_PERIODIC_SCAN BIT1
4958 * OBSS_ONETIME_SCAN BIT2
4959 * @return Error code indicating success/failure
4960 * @note
4961 * @author zsalah
4962 * @date 8 March 2012
4963 * @version 1.0
4964 */
Johnny Kim218dc402015-08-13 13:41:19 +09004965s32 host_int_set_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 scanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004966{
Leo Kime6e12662015-09-16 18:36:03 +09004967 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004968 tstrWID strWID;
4969 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
4970
Chaehyun Limd85f5322015-06-11 14:35:54 +09004971 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004972 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09004973 strWID.ps8WidVal = (s8 *)&scanSource;
Dean Lee576917a2015-06-15 11:58:57 +09004974 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004975
4976 return s32Error;
4977}
4978
4979/**
4980 * @brief host_int_get_start_scan_req
4981 * @details gets a start scan request
4982 * @param[in,out] handle to the wifi driver,
4983 * @param[in] Scan Source one of the following values
4984 * DEFAULT_SCAN 0
4985 * USER_SCAN BIT0
4986 * OBSS_PERIODIC_SCAN BIT1
4987 * OBSS_ONETIME_SCAN BIT2
4988 * @return Error code indicating success/failure
4989 * @note
4990 * @author zsalah
4991 * @date 8 March 2012
4992 * @version 1.0
4993 */
4994
Johnny Kim218dc402015-08-13 13:41:19 +09004995s32 host_int_get_start_scan_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ScanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004996{
Leo Kime6e12662015-09-16 18:36:03 +09004997 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004998 tstrWID strWID;
4999 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5000
Chaehyun Limd85f5322015-06-11 14:35:54 +09005001 strWID.u16WIDid = (u16)WID_START_SCAN_REQ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005002 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005003 strWID.ps8WidVal = (s8 *)pu8ScanSource;
Dean Lee576917a2015-06-15 11:58:57 +09005004 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005005
5006 return s32Error;
5007}
5008
5009/**
5010 * @brief host_int_set_join_req
5011 * @details sets a join request
5012 * @param[in,out] handle to the wifi driver,
5013 * @param[in] Index of the bss descriptor
5014 * @return Error code indicating success/failure
5015 * @note
5016 * @author zsalah
5017 * @date 8 March 2012
5018 * @version 1.0
5019 */
Johnny Kim218dc402015-08-13 13:41:19 +09005020s32 host_int_set_join_req(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8bssid,
Arnd Bergmann057d1e92015-06-01 21:06:44 +02005021 const u8 *pu8ssid, size_t ssidLen,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005022 const u8 *pu8IEs, size_t IEsLen,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005023 tWILCpfConnectResult pfConnectResult, void *pvUserArg,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005024 u8 u8security, AUTHTYPE_T tenuAuth_type,
5025 u8 u8channel,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005026 void *pJoinParams)
5027{
Leo Kime6e12662015-09-16 18:36:03 +09005028 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005029 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005030 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005031 tenuScanConnTimer enuScanConnTimer;
5032
Leo Kim24db7132015-09-16 18:36:01 +09005033 if (pstrWFIDrv == NULL || pfConnectResult == NULL) {
5034 s32Error = -EFAULT;
5035 PRINT_ER("Driver is null\n");
5036 return s32Error;
5037 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005038
5039 if (hWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005040 PRINT_ER("Driver is null\n");
5041 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005042 }
5043
5044 if (pJoinParams == NULL) {
5045 PRINT_ER("Unable to Join - JoinParams is NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09005046 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005047 }
Leo Kim24db7132015-09-16 18:36:01 +09005048
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005049 /* prepare the Connect Message */
Tony Cho143eb952015-09-21 12:16:32 +09005050 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005051
Tony Choa9f812a2015-09-21 12:16:33 +09005052 msg.id = HOST_IF_MSG_CONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005053
Tony Cho3f501972015-09-30 18:44:21 +09005054 msg.body.con_info.u8security = u8security;
5055 msg.body.con_info.tenuAuth_type = tenuAuth_type;
5056 msg.body.con_info.u8channel = u8channel;
5057 msg.body.con_info.pfConnectResult = pfConnectResult;
5058 msg.body.con_info.pvUserArg = pvUserArg;
5059 msg.body.con_info.pJoinParams = pJoinParams;
Tony Cho143eb952015-09-21 12:16:32 +09005060 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005061
5062 if (pu8bssid != NULL) {
Tony Cho3f501972015-09-30 18:44:21 +09005063 msg.body.con_info.pu8bssid = kmalloc(6, GFP_KERNEL); /* will be deallocated by the receiving thread */
5064 memcpy(msg.body.con_info.pu8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005065 pu8bssid, 6);
5066 }
5067
5068 if (pu8ssid != NULL) {
Tony Cho3f501972015-09-30 18:44:21 +09005069 msg.body.con_info.ssidLen = ssidLen;
5070 msg.body.con_info.pu8ssid = kmalloc(ssidLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5071 memcpy(msg.body.con_info.pu8ssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005072
5073 pu8ssid, ssidLen);
5074 }
5075
5076 if (pu8IEs != NULL) {
Tony Cho3f501972015-09-30 18:44:21 +09005077 msg.body.con_info.IEsLen = IEsLen;
5078 msg.body.con_info.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5079 memcpy(msg.body.con_info.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005080 pu8IEs, IEsLen);
5081 }
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05305082 if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005083 pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05305084 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005085 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate);
5086
5087 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005088 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005089 if (s32Error) {
5090 PRINT_ER("Failed to send message queue: Set join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09005091 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005092 }
5093
5094 enuScanConnTimer = CONNECT_TIMER;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005095 pstrWFIDrv->hConnectTimer.data = (unsigned long)hWFIDrv;
5096 mod_timer(&pstrWFIDrv->hConnectTimer,
5097 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005098
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005099 return s32Error;
5100}
5101
5102/**
5103 * @brief Flush a join request parameters to FW, but actual connection
5104 * @details The function is called in situation where WILC is connected to AP and
5105 * required to switch to hybrid FW for P2P connection
5106 * @param[in] handle to the wifi driver,
5107 * @return Error code indicating success/failure
5108 * @note
5109 * @author Amr Abdel-Moghny
5110 * @date 19 DEC 2013
5111 * @version 8.0
5112 */
5113
Johnny Kim218dc402015-08-13 13:41:19 +09005114s32 host_int_flush_join_req(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005115{
Leo Kime6e12662015-09-16 18:36:03 +09005116 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005117 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005118
5119 if (!gu8FlushedJoinReq) {
Leo Kime6e12662015-09-16 18:36:03 +09005120 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005121 return s32Error;
5122 }
5123
5124
Leo Kim24db7132015-09-16 18:36:01 +09005125 if (hWFIDrv == NULL) {
5126 s32Error = -EFAULT;
5127 PRINT_ER("Driver is null\n");
5128 return s32Error;
5129 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005130
Tony Choa9f812a2015-09-21 12:16:33 +09005131 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
Tony Cho143eb952015-09-21 12:16:32 +09005132 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005133
5134 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005135 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005136 if (s32Error) {
5137 PRINT_ER("Failed to send message queue: Flush join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09005138 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005139 }
5140
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005141 return s32Error;
5142}
5143
5144/**
5145 * @brief host_int_disconnect
5146 * @details disconnects from the currently associated network
5147 * @param[in,out] handle to the wifi driver,
5148 * @param[in] Reason Code of the Disconnection
5149 * @return Error code indicating success/failure
5150 * @note
5151 * @author zsalah
5152 * @date 8 March 2012
5153 * @version 1.0
5154 */
Johnny Kim218dc402015-08-13 13:41:19 +09005155s32 host_int_disconnect(tstrWILC_WFIDrv *hWFIDrv, u16 u16ReasonCode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005156{
Leo Kime6e12662015-09-16 18:36:03 +09005157 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005158 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005159 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5160
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005161 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005162 PRINT_ER("Driver is null\n");
5163 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005164 }
5165
5166 /* prepare the Disconnect Message */
Tony Cho143eb952015-09-21 12:16:32 +09005167 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005168
Tony Choa9f812a2015-09-21 12:16:33 +09005169 msg.id = HOST_IF_MSG_DISCONNECT;
Tony Cho143eb952015-09-21 12:16:32 +09005170 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005171
5172 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005173 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005174 if (s32Error)
5175 PRINT_ER("Failed to send message queue: disconnect\n");
5176 /* ////////////// */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005177 down(&(pstrWFIDrv->hSemTestDisconnectBlock));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005178 /* /////// */
5179
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005180 return s32Error;
5181}
5182
5183/**
5184 * @brief host_int_disconnect_station
5185 * @details disconnects a sta
5186 * @param[in,out] handle to the wifi driver,
5187 * @param[in] Association Id of the station to be disconnected
5188 * @return Error code indicating success/failure
5189 * @note
5190 * @author zsalah
5191 * @date 8 March 2012
5192 * @version 1.0
5193 */
Johnny Kim218dc402015-08-13 13:41:19 +09005194s32 host_int_disconnect_station(tstrWILC_WFIDrv *hWFIDrv, u8 assoc_id)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005195{
Leo Kime6e12662015-09-16 18:36:03 +09005196 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005197 tstrWID strWID;
5198 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5199
Chaehyun Limd85f5322015-06-11 14:35:54 +09005200 strWID.u16WIDid = (u16)WID_DISCONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005201 strWID.enuWIDtype = WID_CHAR;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005202 strWID.ps8WidVal = (s8 *)&assoc_id;
Dean Lee576917a2015-06-15 11:58:57 +09005203 strWID.s32ValueSize = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005204
5205 return s32Error;
5206}
5207
5208/**
5209 * @brief host_int_get_assoc_req_info
5210 * @details gets a Association request info
5211 * @param[in,out] handle to the wifi driver,
5212 * Message containg assoc. req info in the following format
5213 * ------------------------------------------------------------------------
5214 | Management Frame Format |
5215 ||-------------------------------------------------------------------|
5216 ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
5217 ||-------------|--------|--|--|-----|----------------|----------|----|
5218 | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
5219 ||-------------------------------------------------------------------|
5220 | |
5221 | Association Request Frame - Frame Body |
5222 ||-------------------------------------------------------------------|
5223 | Capability Information | Listen Interval | SSID | Supported Rates |
5224 ||------------------------|-----------------|------|-----------------|
5225 | 2 | 2 | 2-34 | 3-10 |
5226 | ---------------------------------------------------------------------
5227 * @return Error code indicating success/failure
5228 * @note
5229 * @author zsalah
5230 * @date 8 March 2012
5231 * @version 1.0
5232 */
5233
Johnny Kim218dc402015-08-13 13:41:19 +09005234s32 host_int_get_assoc_req_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocReqInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005235 u32 u32AssocReqInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005236{
Leo Kime6e12662015-09-16 18:36:03 +09005237 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005238 tstrWID strWID;
5239 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5240
Chaehyun Limd85f5322015-06-11 14:35:54 +09005241 strWID.u16WIDid = (u16)WID_ASSOC_REQ_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005242 strWID.enuWIDtype = WID_STR;
5243 strWID.ps8WidVal = pu8AssocReqInfo;
5244 strWID.s32ValueSize = u32AssocReqInfoLen;
5245
5246
5247 return s32Error;
5248}
5249
5250/**
5251 * @brief gets a Association Response info
5252 * @details
5253 * @param[in,out] handle to the wifi driver,
5254 * Message containg assoc. resp info
5255 * @return Error code indicating success/failure
5256 * @note
5257 * @author zsalah
5258 * @date 8 March 2012
5259 * @version 1.0
5260 */
Johnny Kim218dc402015-08-13 13:41:19 +09005261s32 host_int_get_assoc_res_info(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8AssocRespInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005262 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005263{
Leo Kime6e12662015-09-16 18:36:03 +09005264 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005265 tstrWID strWID;
5266 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5267
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005268 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005269 PRINT_ER("Driver is null\n");
5270 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005271 }
5272
Chaehyun Limd85f5322015-06-11 14:35:54 +09005273 strWID.u16WIDid = (u16)WID_ASSOC_RES_INFO;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005274 strWID.enuWIDtype = WID_STR;
5275 strWID.ps8WidVal = pu8AssocRespInfo;
5276 strWID.s32ValueSize = u32MaxAssocRespInfoLen;
5277
5278
5279 /* Sending Configuration packet */
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09005280 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
5281 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005282 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005283 *pu32RcvdAssocRespInfoLen = 0;
Leo Kim24db7132015-09-16 18:36:01 +09005284 PRINT_ER("Failed to send association response config packet\n");
5285 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005286 } else {
5287 *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize;
5288 }
5289
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005290 return s32Error;
5291}
5292
5293/**
5294 * @brief gets a Association Response info
5295 * @details Valid only in STA mode. This function gives the RSSI
5296 * values observed in all the channels at the time of scanning.
5297 * The length of the field is 1 greater that the total number of
5298 * channels supported. Byte 0 contains the number of channels while
5299 * each of Byte N contains the observed RSSI value for the channel index N.
5300 * @param[in,out] handle to the wifi driver,
5301 * array of scanned channels' RSSI
5302 * @return Error code indicating success/failure
5303 * @note
5304 * @author zsalah
5305 * @date 8 March 2012
5306 * @version 1.0
5307 */
Johnny Kim218dc402015-08-13 13:41:19 +09005308s32 host_int_get_rx_power_level(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8RxPowerLevel,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005309 u32 u32RxPowerLevelLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005310{
Leo Kime6e12662015-09-16 18:36:03 +09005311 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005312 tstrWID strWID;
5313 /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
5314
Chaehyun Limd85f5322015-06-11 14:35:54 +09005315 strWID.u16WIDid = (u16)WID_RX_POWER_LEVEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005316 strWID.enuWIDtype = WID_STR;
5317 strWID.ps8WidVal = pu8RxPowerLevel;
5318 strWID.s32ValueSize = u32RxPowerLevelLen;
5319
5320
5321 return s32Error;
5322}
5323
5324/**
5325 * @brief sets a channel
5326 * @details
5327 * @param[in,out] handle to the wifi driver,
5328 * @param[in] Index of the channel to be set
5329 *|-------------------------------------------------------------------|
5330 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5331 | Input: 1 2 14 |
5332 ||-------------------------------------------------------------------|
5333 * @return Error code indicating success/failure
5334 * @note
5335 * @author zsalah
5336 * @date 8 March 2012
5337 * @version 1.0
5338 */
Johnny Kim218dc402015-08-13 13:41:19 +09005339s32 host_int_set_mac_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 u8ChNum)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005340{
Leo Kime6e12662015-09-16 18:36:03 +09005341 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005342 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005343 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005344
Leo Kim24db7132015-09-16 18:36:01 +09005345 if (pstrWFIDrv == NULL) {
5346 PRINT_ER("driver is null\n");
5347 return -EFAULT;
5348 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005349
5350 /* prepare the set channel message */
Tony Cho143eb952015-09-21 12:16:32 +09005351 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005352 msg.id = HOST_IF_MSG_SET_CHANNEL;
Tony Choffd6dbc2015-09-30 18:44:28 +09005353 msg.body.channel_info.u8SetChan = u8ChNum;
Tony Cho143eb952015-09-21 12:16:32 +09005354 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005355
Tony Cho143eb952015-09-21 12:16:32 +09005356 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005357 if (s32Error) {
5358 PRINT_ER("wilc mq send fail\n");
5359 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005360 }
5361
5362 return s32Error;
5363}
5364
5365
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +09005366s32 host_int_wait_msg_queue_idle(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005367{
Leo Kime6e12662015-09-16 18:36:03 +09005368 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005369
Tony Cho143eb952015-09-21 12:16:32 +09005370 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005371
5372 /* prepare the set driver handler message */
5373
Tony Cho143eb952015-09-21 12:16:32 +09005374 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005375 msg.id = HOST_IF_MSG_Q_IDLE;
Tony Cho143eb952015-09-21 12:16:32 +09005376 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005377 if (s32Error) {
5378 PRINT_ER("wilc mq send fail\n");
5379 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005380 }
5381
5382 /* wait untill MSG Q is empty */
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005383 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005384
5385 return s32Error;
5386
5387}
5388
Johnny Kim218dc402015-08-13 13:41:19 +09005389s32 host_int_set_wfi_drv_handler(tstrWILC_WFIDrv *u32address)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005390{
Leo Kime6e12662015-09-16 18:36:03 +09005391 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005392
Tony Cho143eb952015-09-21 12:16:32 +09005393 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005394
5395
5396 /* prepare the set driver handler message */
5397
Tony Cho143eb952015-09-21 12:16:32 +09005398 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005399 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
Tony Cho410c2482015-09-21 12:16:35 +09005400 msg.body.strHostIfSetDrvHandler.u32Address = get_id_from_handler(u32address);
Tony Cho143eb952015-09-21 12:16:32 +09005401 msg.drvHandler = u32address;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005402
Tony Cho143eb952015-09-21 12:16:32 +09005403 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005404 if (s32Error) {
5405 PRINT_ER("wilc mq send fail\n");
5406 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005407 }
5408
5409 return s32Error;
5410}
5411
5412
5413
Johnny Kim218dc402015-08-13 13:41:19 +09005414s32 host_int_set_operation_mode(tstrWILC_WFIDrv *hWFIDrv, u32 u32mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005415{
Leo Kime6e12662015-09-16 18:36:03 +09005416 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005417
Tony Cho143eb952015-09-21 12:16:32 +09005418 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005419
5420
5421 /* prepare the set driver handler message */
5422
Tony Cho143eb952015-09-21 12:16:32 +09005423 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005424 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
Tony Cho410c2482015-09-21 12:16:35 +09005425 msg.body.strHostIfSetOperationMode.u32Mode = u32mode;
Tony Cho143eb952015-09-21 12:16:32 +09005426 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005427
Tony Cho143eb952015-09-21 12:16:32 +09005428 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09005429 if (s32Error) {
5430 PRINT_ER("wilc mq send fail\n");
5431 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005432 }
5433
5434 return s32Error;
5435}
5436
5437/**
5438 * @brief gets the current channel index
5439 * @details
5440 * @param[in,out] handle to the wifi driver,
5441 * current channel index
5442 *|-----------------------------------------------------------------------|
5443 | CHANNEL1 CHANNEL2 .... CHANNEL14 |
5444 | Input: 1 2 14 |
5445 ||-----------------------------------------------------------------------|
5446 * @return Error code indicating success/failure
5447 * @note
5448 * @author zsalah
5449 * @date 8 March 2012
5450 * @version 1.0
5451 */
Johnny Kim218dc402015-08-13 13:41:19 +09005452s32 host_int_get_host_chnl_num(tstrWILC_WFIDrv *hWFIDrv, u8 *pu8ChNo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005453{
Leo Kime6e12662015-09-16 18:36:03 +09005454 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005455 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005456 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005457
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005458 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005459 PRINT_ER("driver is null\n");
5460 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005461 }
5462
5463 /* prepare the Get Channel Message */
Tony Cho143eb952015-09-21 12:16:32 +09005464 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005465
Tony Choa9f812a2015-09-21 12:16:33 +09005466 msg.id = HOST_IF_MSG_GET_CHNL;
Tony Cho143eb952015-09-21 12:16:32 +09005467 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005468
5469 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005470 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005471 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09005472 PRINT_ER("wilc mq send fail\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005473 down(&(pstrWFIDrv->hSemGetCHNL));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005474 /* gu8Chnl = 11; */
5475
5476 *pu8ChNo = gu8Chnl;
5477
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005478 return s32Error;
5479
5480
5481}
5482
5483
5484/**
5485 * @brief host_int_test_set_int_wid
5486 * @details Test function for setting wids
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005487 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32 u32TestMemAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005488 * @return Error code indicating success/failure
5489 * @note
5490 * @author zsalah
5491 * @date 8 March 2012
5492 * @version 1.0
5493 */
Johnny Kim218dc402015-08-13 13:41:19 +09005494s32 host_int_test_set_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 u32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005495{
Leo Kime6e12662015-09-16 18:36:03 +09005496 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005497 tstrWID strWID;
5498 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5499
5500
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005501 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005502 PRINT_ER("driver is null\n");
5503 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005504 }
5505
5506 /*prepare configuration packet*/
Chaehyun Limd85f5322015-06-11 14:35:54 +09005507 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005508 strWID.enuWIDtype = WID_INT;
Dean Lee576917a2015-06-15 11:58:57 +09005509 strWID.ps8WidVal = (char *)&u32TestMemAddr;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005510 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005511
5512 /*Sending Cfg*/
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09005513 s32Error = send_config_pkt(SET_CFG, &strWID, 1, true,
5514 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005515 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09005516 PRINT_ER("Failed to set wid value\n");
5517 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005518 } else {
5519 PRINT_D(HOSTINF_DBG, "Successfully set wid value\n");
5520
5521 }
5522
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005523 return s32Error;
5524}
5525
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005526/**
5527 * @brief host_int_get_inactive_time
5528 * @details
5529 * @param[in,out] handle to the wifi driver,
5530 * current sta macaddress, inactive_time
5531 * @return
5532 * @note
5533 * @author
5534 * @date
5535 * @version 1.0
5536 */
Johnny Kim218dc402015-08-13 13:41:19 +09005537s32 host_int_get_inactive_time(tstrWILC_WFIDrv *hWFIDrv, const u8 *mac, u32 *pu32InactiveTime)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005538{
Leo Kime6e12662015-09-16 18:36:03 +09005539 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005540 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005541 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005542
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005543 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005544 PRINT_ER("driver is null\n");
5545 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005546 }
5547
Tony Cho143eb952015-09-21 12:16:32 +09005548 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005549
5550
Tony Cho410c2482015-09-21 12:16:35 +09005551 memcpy(msg.body.strHostIfStaInactiveT.mac,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005552 mac, ETH_ALEN);
5553
Tony Choa9f812a2015-09-21 12:16:33 +09005554 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
Tony Cho143eb952015-09-21 12:16:32 +09005555 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005556
5557 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005558 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005559 if (s32Error)
5560 PRINT_ER("Failed to send get host channel param's message queue ");
5561
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005562 down(&(pstrWFIDrv->hSemInactiveTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005563
5564 *pu32InactiveTime = gu32InactiveTime;
5565
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005566 return s32Error;
5567}
Glen Lee108b3432015-09-16 18:53:20 +09005568
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005569/**
5570 * @brief host_int_test_get_int_wid
5571 * @details Test function for getting wids
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005572 * @param[in,out] WILC_WFIDrvHandle hWFIDrv, u32* pu32TestMemAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005573 * @return Error code indicating success/failure
5574 * @note
5575 * @author zsalah
5576 * @date 8 March 2012
5577 * @version 1.0
5578 */
Johnny Kim218dc402015-08-13 13:41:19 +09005579s32 host_int_test_get_int_wid(tstrWILC_WFIDrv *hWFIDrv, u32 *pu32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005580{
5581
Leo Kime6e12662015-09-16 18:36:03 +09005582 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005583 tstrWID strWID;
5584 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5585
5586
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005587 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005588 PRINT_ER("driver is null\n");
5589 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005590 }
5591
Chaehyun Limd85f5322015-06-11 14:35:54 +09005592 strWID.u16WIDid = (u16)WID_MEMORY_ADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005593 strWID.enuWIDtype = WID_INT;
Chaehyun Limca356ad2015-06-11 14:35:57 +09005594 strWID.ps8WidVal = (s8 *)pu32TestMemAddr;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09005595 strWID.s32ValueSize = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005596
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09005597 s32Error = send_config_pkt(GET_CFG, &strWID, 1, true,
5598 get_id_from_handler(pstrWFIDrv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005599 /*get the value by searching the local copy*/
5600 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09005601 PRINT_ER("Failed to get wid value\n");
5602 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005603 } else {
5604 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
5605
5606 }
5607
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005608 return s32Error;
5609}
5610
5611
5612/**
5613 * @brief host_int_get_rssi
5614 * @details gets the currently maintained RSSI value for the station.
5615 * The received signal strength value in dB.
5616 * The range of valid values is -128 to 0.
5617 * @param[in,out] handle to the wifi driver,
5618 * rssi value in dB
5619 * @return Error code indicating success/failure
5620 * @note
5621 * @author zsalah
5622 * @date 8 March 2012
5623 * @version 1.0
5624 */
Johnny Kim218dc402015-08-13 13:41:19 +09005625s32 host_int_get_rssi(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005626{
Leo Kime6e12662015-09-16 18:36:03 +09005627 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005628 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005629 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5630
5631
5632 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09005633 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005634
Tony Choa9f812a2015-09-21 12:16:33 +09005635 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Cho143eb952015-09-21 12:16:32 +09005636 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005637
5638 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005639 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005640 if (s32Error) {
5641 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005642 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005643 }
5644
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005645 down(&(pstrWFIDrv->hSemGetRSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005646
5647
5648 if (ps8Rssi == NULL) {
5649 PRINT_ER("RSS pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09005650 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005651 }
5652
5653
5654 *ps8Rssi = gs8Rssi;
5655
5656
5657 return s32Error;
5658}
5659
Johnny Kim218dc402015-08-13 13:41:19 +09005660s32 host_int_get_link_speed(tstrWILC_WFIDrv *hWFIDrv, s8 *ps8lnkspd)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005661{
Tony Cho143eb952015-09-21 12:16:32 +09005662 struct host_if_msg msg;
Leo Kime6e12662015-09-16 18:36:03 +09005663 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005664
5665 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5666
5667
5668
5669 /* prepare the Get LINKSPEED Message */
Tony Cho143eb952015-09-21 12:16:32 +09005670 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005671
Tony Choa9f812a2015-09-21 12:16:33 +09005672 msg.id = HOST_IF_MSG_GET_LINKSPEED;
Tony Cho143eb952015-09-21 12:16:32 +09005673 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005674
5675 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005676 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005677 if (s32Error) {
5678 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005679 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005680 }
5681
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005682 down(&(pstrWFIDrv->hSemGetLINKSPEED));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005683
5684
5685 if (ps8lnkspd == NULL) {
5686 PRINT_ER("LINKSPEED pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09005687 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005688 }
5689
5690
5691 *ps8lnkspd = gs8lnkspd;
5692
5693
5694 return s32Error;
5695}
5696
Johnny Kim218dc402015-08-13 13:41:19 +09005697s32 host_int_get_statistics(tstrWILC_WFIDrv *hWFIDrv, tstrStatistics *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005698{
Leo Kime6e12662015-09-16 18:36:03 +09005699 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005700 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005701
5702
5703 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09005704 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005705
Tony Choa9f812a2015-09-21 12:16:33 +09005706 msg.id = HOST_IF_MSG_GET_STATISTICS;
Tony Cho410c2482015-09-21 12:16:35 +09005707 msg.body.pUserData = (char *)pstrStatistics;
Tony Cho143eb952015-09-21 12:16:32 +09005708 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005709 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005710 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005711 if (s32Error) {
5712 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09005713 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005714 }
5715
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005716 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005717 return s32Error;
5718}
5719
5720
5721/**
5722 * @brief host_int_scan
5723 * @details scans a set of channels
5724 * @param[in,out] handle to the wifi driver,
5725 * @param[in] Scan source
5726 * Scan Type PASSIVE_SCAN = 0,
5727 * ACTIVE_SCAN = 1
5728 * Channels Array
5729 * Channels Array length
5730 * Scan Callback function
5731 * @return Error code indicating success/failure
5732 * @note
5733 * @author zsalah
5734 * @date 8 March 2012
5735 * @version 1.0
5736 */
Johnny Kim218dc402015-08-13 13:41:19 +09005737s32 host_int_scan(tstrWILC_WFIDrv *hWFIDrv, u8 u8ScanSource,
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09005738 u8 u8ScanType, u8 *pu8ChnlFreqList,
5739 u8 u8ChnlListLen, const u8 *pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005740 size_t IEsLen, tWILCpfScanResult ScanResult,
5741 void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork)
5742{
Leo Kime6e12662015-09-16 18:36:03 +09005743 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005744 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09005745 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005746 tenuScanConnTimer enuScanConnTimer;
5747
Leo Kim24db7132015-09-16 18:36:01 +09005748 if (pstrWFIDrv == NULL || ScanResult == NULL) {
5749 PRINT_ER("pstrWFIDrv or ScanResult = NULL\n");
5750 return -EFAULT;
5751 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005752
5753 /* prepare the Scan Message */
Tony Cho143eb952015-09-21 12:16:32 +09005754 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005755
Tony Choa9f812a2015-09-21 12:16:33 +09005756 msg.id = HOST_IF_MSG_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005757
5758 if (pstrHiddenNetwork != NULL) {
Tony Cho4528bdb2015-09-30 18:44:20 +09005759 msg.body.scan_info.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
5760 msg.body.scan_info.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005761
5762 } else
5763 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
5764
Tony Cho143eb952015-09-21 12:16:32 +09005765 msg.drvHandler = hWFIDrv;
Tony Cho4528bdb2015-09-30 18:44:20 +09005766 msg.body.scan_info.u8ScanSource = u8ScanSource;
5767 msg.body.scan_info.u8ScanType = u8ScanType;
5768 msg.body.scan_info.pfScanResult = ScanResult;
5769 msg.body.scan_info.pvUserArg = pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005770
Tony Cho4528bdb2015-09-30 18:44:20 +09005771 msg.body.scan_info.u8ChnlListLen = u8ChnlListLen;
5772 msg.body.scan_info.pu8ChnlFreqList = kmalloc(u8ChnlListLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5773 memcpy(msg.body.scan_info.pu8ChnlFreqList,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005774 pu8ChnlFreqList, u8ChnlListLen);
5775
Tony Cho4528bdb2015-09-30 18:44:20 +09005776 msg.body.scan_info.IEsLen = IEsLen;
5777 msg.body.scan_info.pu8IEs = kmalloc(IEsLen, GFP_KERNEL); /* will be deallocated by the receiving thread */
5778 memcpy(msg.body.scan_info.pu8IEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005779 pu8IEs, IEsLen);
5780
5781 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005782 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005783 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09005784 PRINT_ER("Error in sending message queue\n");
5785 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005786 }
5787
5788 enuScanConnTimer = SCAN_TIMER;
5789 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07005790 pstrWFIDrv->hScanTimer.data = (unsigned long)hWFIDrv;
5791 mod_timer(&pstrWFIDrv->hScanTimer,
5792 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005793
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005794 return s32Error;
5795
5796}
5797/**
5798 * @brief hif_set_cfg
5799 * @details sets configuration wids values
5800 * @param[in,out] handle to the wifi driver,
5801 * @param[in] WID, WID value
5802 * @return Error code indicating success/failure
5803 * @note
5804 * @author zsalah
5805 * @date 8 March 2012
5806 * @version 1.0
5807 */
Johnny Kim218dc402015-08-13 13:41:19 +09005808s32 hif_set_cfg(tstrWILC_WFIDrv *hWFIDrv, tstrCfgParamVal *pstrCfgParamVal)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005809{
5810
Leo Kime6e12662015-09-16 18:36:03 +09005811 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005812 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5813
Tony Cho143eb952015-09-21 12:16:32 +09005814 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005815
5816
Leo Kim24db7132015-09-16 18:36:01 +09005817 if (pstrWFIDrv == NULL) {
5818 PRINT_ER("pstrWFIDrv NULL\n");
5819 return -EFAULT;
5820 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005821 /* prepare the WiphyParams Message */
Tony Cho143eb952015-09-21 12:16:32 +09005822 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09005823 msg.id = HOST_IF_MSG_CFG_PARAMS;
Tony Choa2340c32015-09-30 18:44:25 +09005824 msg.body.cfg_info.pstrCfgParamVal = *pstrCfgParamVal;
Tony Cho143eb952015-09-21 12:16:32 +09005825 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005826
Tony Cho143eb952015-09-21 12:16:32 +09005827 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005828
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005829 return s32Error;
5830
5831}
5832
5833
5834/**
5835 * @brief hif_get_cfg
5836 * @details gets configuration wids values
5837 * @param[in,out] handle to the wifi driver,
5838 * WID value
5839 * @param[in] WID,
5840 * @return Error code indicating success/failure
5841 * @note
5842 * @author zsalah
5843 *
5844 * @date 8 March 2012
5845 * @version 1.0
5846 */
Johnny Kim218dc402015-08-13 13:41:19 +09005847s32 hif_get_cfg(tstrWILC_WFIDrv *hWFIDrv, u16 u16WID, u16 *pu16WID_Value)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005848{
Leo Kime6e12662015-09-16 18:36:03 +09005849 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005850 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
5851
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005852 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005853
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09005854 if (pstrWFIDrv == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09005855 PRINT_ER("pstrWFIDrv NULL\n");
5856 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005857 }
5858 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
5859 switch (u16WID) {
5860
5861 case WID_BSS_TYPE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005862 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005863 break;
5864
5865 case WID_AUTH_TYPE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005866 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005867 break;
5868
5869 case WID_AUTH_TIMEOUT:
5870 *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout;
5871 break;
5872
5873 case WID_POWER_MANAGEMENT:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005874 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005875 break;
5876
5877 case WID_SHORT_RETRY_LIMIT:
5878 *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit;
5879 break;
5880
5881 case WID_LONG_RETRY_LIMIT:
5882 *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit;
5883 break;
5884
5885 case WID_FRAG_THRESHOLD:
5886 *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold;
5887 break;
5888
5889 case WID_RTS_THRESHOLD:
5890 *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold;
5891 break;
5892
5893 case WID_PREAMBLE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005894 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005895 break;
5896
5897 case WID_SHORT_SLOT_ALLOWED:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005898 *pu16WID_Value = (u16) pstrWFIDrv->strCfgValues.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005899 break;
5900
5901 case WID_11N_TXOP_PROT_DISABLE:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005902 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005903 break;
5904
5905 case WID_BEACON_INTERVAL:
5906 *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval;
5907 break;
5908
5909 case WID_DTIM_PERIOD:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005910 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005911 break;
5912
5913 case WID_SITE_SURVEY:
Chaehyun Limd85f5322015-06-11 14:35:54 +09005914 *pu16WID_Value = (u16)pstrWFIDrv->strCfgValues.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005915 break;
5916
5917 case WID_SITE_SURVEY_SCAN_TIME:
5918 *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time;
5919 break;
5920
5921 case WID_ACTIVE_SCAN_TIME:
5922 *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time;
5923 break;
5924
5925 case WID_PASSIVE_SCAN_TIME:
5926 *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time;
5927 break;
5928
5929 case WID_CURRENT_TX_RATE:
5930 *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate;
5931 break;
5932
5933 default:
5934 break;
5935 }
5936
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005937 up(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005938
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005939 return s32Error;
5940
5941}
5942
5943/*****************************************************************************/
5944/* Notification Functions */
5945/*****************************************************************************/
5946/**
5947 * @brief notifies host with join and leave requests
5948 * @details This function prepares an Information frame having the
5949 * information about a joining/leaving station.
5950 * @param[in,out] handle to the wifi driver,
5951 * @param[in] 6 byte Sta Adress
5952 * Join or leave flag:
5953 * Join = 1,
5954 * Leave =0
5955 * @return Error code indicating success/failure
5956 * @note
5957 * @author zsalah
5958 * @date 8 March 2012
5959 * @version 1.0
5960 */
5961void host_int_send_join_leave_info_to_host
Dean Lee72ed4dc2015-06-12 14:11:44 +09005962 (u16 assocId, u8 *stationAddr, bool joining)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005963{
5964}
5965/**
5966 * @brief notifies host with stations found in scan
5967 * @details sends the beacon/probe response from scan
5968 * @param[in,out] handle to the wifi driver,
5969 * @param[in] Sta Address,
5970 * Frame length,
5971 * Rssi of the Station found
5972 * @return Error code indicating success/failure
5973 * @note
5974 * @author zsalah
5975 * @date 8 March 2012
5976 * @version 1.0
5977 */
5978
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07005979static void GetPeriodicRSSI(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005980{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07005981 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)arg;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02005982
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005983 if (pstrWFIDrv == NULL) {
5984 PRINT_ER("Driver handler is NULL\n");
5985 return;
5986 }
5987
5988 if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
Leo Kime6e12662015-09-16 18:36:03 +09005989 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005990 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005991
5992 /* prepare the Get RSSI Message */
Tony Cho143eb952015-09-21 12:16:32 +09005993 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005994
Tony Choa9f812a2015-09-21 12:16:33 +09005995 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Cho143eb952015-09-21 12:16:32 +09005996 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005997
5998 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09005999 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006000 if (s32Error) {
6001 PRINT_ER("Failed to send get host channel param's message queue ");
6002 return;
6003 }
6004 }
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07006005 g_hPeriodicRSSI.data = (unsigned long)pstrWFIDrv;
6006 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006007}
6008
6009
6010void host_int_send_network_info_to_host
Chaehyun Limca356ad2015-06-11 14:35:57 +09006011 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006012{
6013}
6014/**
6015 * @brief host_int_init
6016 * @details host interface initialization function
6017 * @param[in,out] handle to the wifi driver,
6018 * @note
6019 * @author zsalah
6020 * @date 8 March 2012
6021 * @version 1.0
6022 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006023static u32 clients_count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006024
Johnny Kim218dc402015-08-13 13:41:19 +09006025s32 host_int_init(tstrWILC_WFIDrv **phWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006026{
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006027 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006028 tstrWILC_WFIDrv *pstrWFIDrv;
Johnny Kimd42ab082015-08-20 16:32:52 +09006029 int err;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006030
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006031 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
6032
Dean Lee72ed4dc2015-06-12 14:11:44 +09006033 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006034
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006035 sema_init(&hWaitResponse, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006036
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006037 /*Allocate host interface private structure*/
Chaehyun Lim27a82eb2015-09-22 18:34:55 +09006038 pstrWFIDrv = kzalloc(sizeof(tstrWILC_WFIDrv), GFP_KERNEL);
Chaehyun Lim16042962015-09-22 18:34:56 +09006039 if (!pstrWFIDrv) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006040 result = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006041 goto _fail_timer_2;
6042 }
Johnny Kim218dc402015-08-13 13:41:19 +09006043 *phWFIDrv = pstrWFIDrv;
Johnny Kimd42ab082015-08-20 16:32:52 +09006044 err = add_handler_in_list(pstrWFIDrv);
6045 if (err) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006046 result = -EFAULT;
Johnny Kimd42ab082015-08-20 16:32:52 +09006047 goto _fail_timer_2;
6048 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006049
Dean Lee72ed4dc2015-06-12 14:11:44 +09006050 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006051
Johnny Kim8a143302015-06-10 17:06:46 +09006052 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006053 if (clients_count == 0) {
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006054 sema_init(&hSemHostIFthrdEnd, 0);
6055 sema_init(&hSemDeinitDrvHandle, 0);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006056 sema_init(&hSemHostIntDeinit, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006057 }
6058
Chaehyun Limdddaba12015-09-22 18:35:01 +09006059 sema_init(&pstrWFIDrv->hSemTestKeyBlock, 0);
6060 sema_init(&pstrWFIDrv->hSemTestDisconnectBlock, 0);
6061 sema_init(&pstrWFIDrv->hSemGetRSSI, 0);
6062 sema_init(&pstrWFIDrv->hSemGetLINKSPEED, 0);
6063 sema_init(&pstrWFIDrv->hSemGetCHNL, 0);
6064 sema_init(&pstrWFIDrv->hSemInactiveTime, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006065
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006066 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
6067
6068 if (clients_count == 0) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006069 result = wilc_mq_create(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006070
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006071 if (result < 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006072 PRINT_ER("Failed to creat MQ\n");
6073 goto _fail_;
6074 }
Arnd Bergmann1999bd52015-05-29 22:52:14 +02006075 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
6076 if (IS_ERR(HostIFthreadHandler)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006077 PRINT_ER("Failed to creat Thread\n");
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006078 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006079 goto _fail_mq_;
6080 }
Greg Kroah-Hartman507d7fc2015-08-17 12:59:42 -07006081 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
6082 (unsigned long)pstrWFIDrv);
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07006083 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006084 }
6085
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006086 setup_timer(&pstrWFIDrv->hScanTimer, TimerCB_Scan, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006087
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006088 setup_timer(&pstrWFIDrv->hConnectTimer, TimerCB_Connect, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006089
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006090 /*Remain on channel timer*/
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07006091 setup_timer(&pstrWFIDrv->hRemainOnChannel, ListenTimerCB, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006092
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006093 sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1);
Chaehyun Limdddaba12015-09-22 18:35:01 +09006094 down(&pstrWFIDrv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006095
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006096 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006097
6098 /*Initialize CFG WIDS Defualt Values*/
6099
6100 pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
6101 pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN;
6102 pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
6103 pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
6104 pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE;
6105
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006106 pstrWFIDrv->u64P2p_MgmtTimeout = 0;
6107
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006108 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",
6109
6110 pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source,
6111 pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time,
6112 pstrWFIDrv->strCfgValues.curr_tx_rate);
6113
Chaehyun Limdddaba12015-09-22 18:35:01 +09006114 up(&pstrWFIDrv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006115
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006116 clients_count++; /* increase number of created entities */
6117
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006118 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006119
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006120_fail_timer_2:
Chaehyun Limdddaba12015-09-22 18:35:01 +09006121 up(&pstrWFIDrv->gtOsCfgValuesSem);
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006122 del_timer_sync(&pstrWFIDrv->hConnectTimer);
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006123 del_timer_sync(&pstrWFIDrv->hScanTimer);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02006124 kthread_stop(HostIFthreadHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006125_fail_mq_:
Chaehyun Lim1b128f62015-08-19 15:59:08 +09006126 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006127_fail_:
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09006128 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006129}
6130/**
6131 * @brief host_int_deinit
6132 * @details host interface initialization function
6133 * @param[in,out] handle to the wifi driver,
6134 * @note
6135 * @author zsalah
6136 * @date 8 March 2012
6137 * @version 1.0
6138 */
6139
Johnny Kim218dc402015-08-13 13:41:19 +09006140s32 host_int_deinit(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006141{
Leo Kime6e12662015-09-16 18:36:03 +09006142 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006143 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006144 int ret;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006145
6146 /*obtain driver handle*/
6147 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006148
6149 if (pstrWFIDrv == NULL) {
6150 PRINT_ER("pstrWFIDrv = NULL\n");
6151 return 0;
6152 }
6153
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006154 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006155
6156 terminated_handle = pstrWFIDrv;
6157 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
6158
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006159 /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
6160 /*to guarantee handling all messages befor proceeding*/
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006161 if (del_timer_sync(&pstrWFIDrv->hScanTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006162 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006163 /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
6164 }
6165
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006166 if (del_timer_sync(&pstrWFIDrv->hConnectTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006167 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006168 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6169 }
6170
6171
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006172 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006173 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006174 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6175 }
6176
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006177 /*Destroy Remain-onchannel Timer*/
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006178 del_timer_sync(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006179
Johnny Kim218dc402015-08-13 13:41:19 +09006180 host_int_set_wfi_drv_handler(NULL);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006181 down(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006182
6183
6184 /*Calling the CFG80211 scan done function with the abort flag set to true*/
6185 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006186 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006187 pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
6188
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006189 pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006190 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006191
6192 pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
6193
Dean Lee72ed4dc2015-06-12 14:11:44 +09006194 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006195
Tony Cho143eb952015-09-21 12:16:32 +09006196 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006197
6198 if (clients_count == 1) {
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07006199 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006200 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006201 /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
6202 }
Tony Choa9f812a2015-09-21 12:16:33 +09006203 msg.id = HOST_IF_MSG_EXIT;
Tony Cho143eb952015-09-21 12:16:32 +09006204 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006205
6206
Tony Cho143eb952015-09-21 12:16:32 +09006207 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kime6e12662015-09-16 18:36:03 +09006208 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006209 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006210
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006211 down(&hSemHostIFthrdEnd);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006212
Chaehyun Lim1b128f62015-08-19 15:59:08 +09006213 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006214 }
6215
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006216 down(&(pstrWFIDrv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006217
6218 /*Setting the gloabl driver handler with NULL*/
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006219 /* gWFiDrvHandle = NULL; */
Johnny Kimd42ab082015-08-20 16:32:52 +09006220 ret = remove_handler_in_list(pstrWFIDrv);
6221 if (ret)
Leo Kime6e12662015-09-16 18:36:03 +09006222 s32Error = -ENOENT;
Johnny Kimd42ab082015-08-20 16:32:52 +09006223
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006224 if (pstrWFIDrv != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09006225 kfree(pstrWFIDrv);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006226 /* pstrWFIDrv=NULL; */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006227
6228 }
6229
6230 clients_count--; /* Decrease number of created entities */
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006231 terminated_handle = NULL;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006232 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006233 return s32Error;
6234}
6235
6236
6237/**
6238 * @brief NetworkInfoReceived
6239 * @details function to to be called when network info packet is received
6240 * @param[in] pu8Buffer the received packet
6241 * @param[in] u32Length length of the received packet
6242 * @return none
6243 * @note
6244 * @author
6245 * @date 1 Mar 2012
6246 * @version 1.0
6247 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006248void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006249{
Leo Kime6e12662015-09-16 18:36:03 +09006250 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006251 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006252 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006253 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006254
Johnny Kimd42ab082015-08-20 16:32:52 +09006255 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6256 pstrWFIDrv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006257
6258
6259
6260
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006261 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
Johnny Kim8a143302015-06-10 17:06:46 +09006262 PRINT_ER("NetworkInfo received but driver not init[%p]\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006263 return;
6264 }
6265
6266 /* prepare the Asynchronous Network Info message */
Tony Cho143eb952015-09-21 12:16:32 +09006267 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006268
Tony Choa9f812a2015-09-21 12:16:33 +09006269 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
Tony Cho143eb952015-09-21 12:16:32 +09006270 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006271
Tony Cho02d19462015-09-30 18:44:22 +09006272 msg.body.net_info.u32Length = u32Length;
6273 msg.body.net_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
6274 memcpy(msg.body.net_info.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006275 pu8Buffer, u32Length);
6276
6277 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006278 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006279 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006280 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006281}
6282
6283/**
6284 * @brief GnrlAsyncInfoReceived
6285 * @details function to be called when general Asynchronous info packet is received
6286 * @param[in] pu8Buffer the received packet
6287 * @param[in] u32Length length of the received packet
6288 * @return none
6289 * @note
6290 * @author
6291 * @date 15 Mar 2012
6292 * @version 1.0
6293 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006294void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006295{
Leo Kime6e12662015-09-16 18:36:03 +09006296 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006297 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006298 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006299 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006300
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006301 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006302
Johnny Kimd42ab082015-08-20 16:32:52 +09006303 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6304 pstrWFIDrv = get_handler_from_id(id);
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006305 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006306
6307
6308 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
6309 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006310 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006311 return;
6312 }
6313
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006314 if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006315 /* received mac status is not needed when there is no current Connect Request */
6316 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006317 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006318 return;
6319 }
6320
6321 /* prepare the General Asynchronous Info message */
Tony Cho143eb952015-09-21 12:16:32 +09006322 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006323
6324
Tony Choa9f812a2015-09-21 12:16:33 +09006325 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
Tony Cho143eb952015-09-21 12:16:32 +09006326 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006327
6328
Tony Cho66add622015-09-30 18:44:23 +09006329 msg.body.async_info.u32Length = u32Length;
6330 msg.body.async_info.pu8Buffer = kmalloc(u32Length, GFP_KERNEL); /* will be deallocated by the receiving thread */
6331 memcpy(msg.body.async_info.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006332 pu8Buffer, u32Length);
6333
6334 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006335 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006336 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006337 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006338
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006339 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006340}
6341
6342/**
6343 * @brief host_int_ScanCompleteReceived
6344 * @details Setting scan complete received notifcation in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006345 * @param[in] u8* pu8Buffer, u32 u32Length
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006346 * @return Error code.
6347 * @author
6348 * @date
6349 * @version 1.0
6350 */
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006351void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006352{
Leo Kime6e12662015-09-16 18:36:03 +09006353 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09006354 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09006355 int id;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006356 tstrWILC_WFIDrv *pstrWFIDrv = NULL;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006357
Johnny Kimd42ab082015-08-20 16:32:52 +09006358 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
6359 pstrWFIDrv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006360
6361
Johnny Kim8a143302015-06-10 17:06:46 +09006362 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", pstrWFIDrv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006363
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006364 if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006365 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006366
6367 /*if there is an ongoing scan request*/
6368 if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
6369 /* prepare theScan Done message */
Tony Cho143eb952015-09-21 12:16:32 +09006370 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006371
Tony Choa9f812a2015-09-21 12:16:33 +09006372 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
Tony Cho143eb952015-09-21 12:16:32 +09006373 msg.drvHandler = pstrWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006374
6375
6376 /* will be deallocated by the receiving thread */
6377 /*no need to send message body*/
6378
Tony Cho410c2482015-09-21 12:16:35 +09006379 /*msg.body.strScanComplete.u32Length = u32Length;
6380 * msg.body.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
6381 * memcpy(msg.body.strScanComplete.pu8Buffer,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006382 * pu8Buffer, u32Length); */
6383
6384 /* send the message */
Tony Cho143eb952015-09-21 12:16:32 +09006385 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006386 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006387 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006388 }
6389
6390
6391 return;
6392
6393}
6394
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006395/**
6396 * @brief host_int_remain_on_channel
6397 * @details
6398 * @param[in] Handle to wifi driver
6399 * Duration to remain on channel
6400 * Channel to remain on
6401 * Pointer to fn to be called on receive frames in listen state
6402 * Pointer to remain-on-channel expired fn
6403 * Priv
6404 * @return Error code.
6405 * @author
6406 * @date
6407 * @version 1.0
6408 */
Johnny Kim218dc402015-08-13 13:41:19 +09006409s32 host_int_remain_on_channel(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID, u32 u32duration, u16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006410{
Leo Kime6e12662015-09-16 18:36:03 +09006411 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006412 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006413 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006414
Leo Kim24db7132015-09-16 18:36:01 +09006415 if (pstrWFIDrv == NULL) {
6416 PRINT_ER("driver is null\n");
6417 return -EFAULT;
6418 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006419
6420 /* prepare the remainonchan Message */
Tony Cho143eb952015-09-21 12:16:32 +09006421 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006422
6423 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006424 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
Tony Cho410c2482015-09-21 12:16:35 +09006425 msg.body.strHostIfRemainOnChan.u16Channel = chan;
6426 msg.body.strHostIfRemainOnChan.pRemainOnChanExpired = RemainOnChanExpired;
6427 msg.body.strHostIfRemainOnChan.pRemainOnChanReady = RemainOnChanReady;
6428 msg.body.strHostIfRemainOnChan.pVoid = pvUserArg;
6429 msg.body.strHostIfRemainOnChan.u32duration = u32duration;
6430 msg.body.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
Tony Cho143eb952015-09-21 12:16:32 +09006431 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006432
Tony Cho143eb952015-09-21 12:16:32 +09006433 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006434 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006435 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006436
6437 return s32Error;
6438}
6439
6440/**
6441 * @brief host_int_ListenStateExpired
6442 * @details
6443 * @param[in] Handle to wifi driver
6444 * Duration to remain on channel
6445 * Channel to remain on
6446 * Pointer to fn to be called on receive frames in listen state
6447 * Pointer to remain-on-channel expired fn
6448 * Priv
6449 * @return Error code.
6450 * @author
6451 * @date
6452 * @version 1.0
6453 */
Johnny Kim218dc402015-08-13 13:41:19 +09006454s32 host_int_ListenStateExpired(tstrWILC_WFIDrv *hWFIDrv, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006455{
Leo Kime6e12662015-09-16 18:36:03 +09006456 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006457 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006458 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006459
Leo Kim24db7132015-09-16 18:36:01 +09006460 if (pstrWFIDrv == NULL) {
6461 PRINT_ER("driver is null\n");
6462 return -EFAULT;
6463 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006464
6465 /*Stopping remain-on-channel timer*/
Greg Kroah-Hartman8972d0f2015-08-14 20:04:13 -07006466 del_timer(&pstrWFIDrv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006467
6468 /* prepare the timer fire Message */
Tony Cho143eb952015-09-21 12:16:32 +09006469 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09006470 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Cho143eb952015-09-21 12:16:32 +09006471 msg.drvHandler = hWFIDrv;
Tony Cho410c2482015-09-21 12:16:35 +09006472 msg.body.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006473
Tony Cho143eb952015-09-21 12:16:32 +09006474 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006475 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006476 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006477
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006478 return s32Error;
6479}
6480
6481/**
6482 * @brief host_int_frame_register
6483 * @details
6484 * @param[in] Handle to wifi driver
6485 * @return Error code.
6486 * @author
6487 * @date
6488 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09006489s32 host_int_frame_register(tstrWILC_WFIDrv *hWFIDrv, u16 u16FrameType, bool bReg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006490{
Leo Kime6e12662015-09-16 18:36:03 +09006491 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006492 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006493 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006494
Leo Kim24db7132015-09-16 18:36:01 +09006495 if (pstrWFIDrv == NULL) {
6496 PRINT_ER("driver is null\n");
6497 return -EFAULT;
6498 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006499
Tony Cho143eb952015-09-21 12:16:32 +09006500 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006501
6502 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006503 msg.id = HOST_IF_MSG_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006504 switch (u16FrameType) {
6505 case ACTION:
6506 PRINT_D(HOSTINF_DBG, "ACTION\n");
Tony Cho410c2482015-09-21 12:16:35 +09006507 msg.body.strHostIfRegisterFrame.u8Regid = ACTION_FRM_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006508 break;
6509
6510 case PROBE_REQ:
6511 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
Tony Cho410c2482015-09-21 12:16:35 +09006512 msg.body.strHostIfRegisterFrame.u8Regid = PROBE_REQ_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006513 break;
6514
6515 default:
6516 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
6517 break;
6518 }
Tony Cho410c2482015-09-21 12:16:35 +09006519 msg.body.strHostIfRegisterFrame.u16FrameType = u16FrameType;
6520 msg.body.strHostIfRegisterFrame.bReg = bReg;
Tony Cho143eb952015-09-21 12:16:32 +09006521 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006522
Tony Cho143eb952015-09-21 12:16:32 +09006523 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006524 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006525 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006526
6527 return s32Error;
6528
6529
6530}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006531
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006532/**
6533 * @brief host_int_add_beacon
6534 * @details Setting add beacon params in message queue
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006535 * @param[in] WILC_WFIDrvHandle hWFIDrv, u32 u32Interval,
6536 * u32 u32DTIMPeriod,u32 u32HeadLen, u8* pu8Head,
6537 * u32 u32TailLen, u8* pu8Tail
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006538 * @return Error code.
6539 * @author
6540 * @date
6541 * @version 1.0
6542 */
Johnny Kim218dc402015-08-13 13:41:19 +09006543s32 host_int_add_beacon(tstrWILC_WFIDrv *hWFIDrv, u32 u32Interval,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006544 u32 u32DTIMPeriod,
6545 u32 u32HeadLen, u8 *pu8Head,
6546 u32 u32TailLen, u8 *pu8Tail)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006547{
Leo Kime6e12662015-09-16 18:36:03 +09006548 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006549 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006550 struct host_if_msg msg;
Tony Choa98491e2015-09-30 18:44:31 +09006551 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006552
Leo Kim24db7132015-09-16 18:36:01 +09006553 if (pstrWFIDrv == NULL) {
6554 PRINT_ER("driver is null\n");
6555 return -EFAULT;
6556 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006557
Tony Cho143eb952015-09-21 12:16:32 +09006558 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006559
6560 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
6561
6562
6563 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006564 msg.id = HOST_IF_MSG_ADD_BEACON;
Tony Cho143eb952015-09-21 12:16:32 +09006565 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006566 pstrSetBeaconParam->u32Interval = u32Interval;
6567 pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
6568 pstrSetBeaconParam->u32HeadLen = u32HeadLen;
Glen Leef3052582015-09-10 12:03:04 +09006569 pstrSetBeaconParam->pu8Head = kmalloc(u32HeadLen, GFP_KERNEL);
Leo Kim24db7132015-09-16 18:36:01 +09006570 if (pstrSetBeaconParam->pu8Head == NULL) {
6571 s32Error = -ENOMEM;
6572 goto ERRORHANDLER;
6573 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006574 memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006575 pstrSetBeaconParam->u32TailLen = u32TailLen;
6576
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006577 if (u32TailLen > 0) {
Glen Leef3052582015-09-10 12:03:04 +09006578 pstrSetBeaconParam->pu8Tail = kmalloc(u32TailLen, GFP_KERNEL);
Leo Kim24db7132015-09-16 18:36:01 +09006579 if (pstrSetBeaconParam->pu8Tail == NULL) {
6580 s32Error = -ENOMEM;
6581 goto ERRORHANDLER;
6582 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006583 memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006584 } else {
6585 pstrSetBeaconParam->pu8Tail = NULL;
6586 }
6587
Tony Cho143eb952015-09-21 12:16:32 +09006588 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006589 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006590 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006591
Leo Kim24db7132015-09-16 18:36:01 +09006592ERRORHANDLER:
6593 if (s32Error) {
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006594 if (pstrSetBeaconParam->pu8Head != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006595 kfree(pstrSetBeaconParam->pu8Head);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006596
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006597 if (pstrSetBeaconParam->pu8Tail != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09006598 kfree(pstrSetBeaconParam->pu8Tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006599 }
6600
6601 return s32Error;
6602
6603}
6604
6605
6606/**
6607 * @brief host_int_del_beacon
6608 * @details Setting add beacon params in message queue
6609 * @param[in] WILC_WFIDrvHandle hWFIDrv
6610 * @return Error code.
6611 * @author
6612 * @date
6613 * @version 1.0
6614 */
Johnny Kim218dc402015-08-13 13:41:19 +09006615s32 host_int_del_beacon(tstrWILC_WFIDrv *hWFIDrv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006616{
Leo Kime6e12662015-09-16 18:36:03 +09006617 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006618 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006619 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006620
Leo Kim24db7132015-09-16 18:36:01 +09006621 if (pstrWFIDrv == NULL) {
6622 PRINT_ER("driver is null\n");
6623 return -EFAULT;
6624 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006625
6626 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006627 msg.id = HOST_IF_MSG_DEL_BEACON;
Tony Cho143eb952015-09-21 12:16:32 +09006628 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006629 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
6630
Tony Cho143eb952015-09-21 12:16:32 +09006631 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim7dc1d0c2015-09-16 18:36:00 +09006632 if (s32Error)
6633 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006634
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006635 return s32Error;
6636}
6637
6638
6639/**
6640 * @brief host_int_add_station
6641 * @details Setting add station params in message queue
Tony Cho6a89ba92015-09-21 12:16:46 +09006642 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006643 * @return Error code.
6644 * @author
6645 * @date
6646 * @version 1.0
6647 */
Tony Cho6a89ba92015-09-21 12:16:46 +09006648s32 host_int_add_station(tstrWILC_WFIDrv *hWFIDrv,
6649 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006650{
Leo Kime6e12662015-09-16 18:36:03 +09006651 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006652 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006653 struct host_if_msg msg;
Tony Cho6a89ba92015-09-21 12:16:46 +09006654 struct add_sta_param *pstrAddStationMsg = &msg.body.strAddStaParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006655
6656
Leo Kim24db7132015-09-16 18:36:01 +09006657 if (pstrWFIDrv == NULL) {
6658 PRINT_ER("driver is null\n");
6659 return -EFAULT;
6660 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006661
Tony Cho143eb952015-09-21 12:16:32 +09006662 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006663
6664 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
6665
6666
6667 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006668 msg.id = HOST_IF_MSG_ADD_STATION;
Tony Cho143eb952015-09-21 12:16:32 +09006669 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006670
Tony Cho6a89ba92015-09-21 12:16:46 +09006671 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006672 if (pstrAddStationMsg->u8NumRates > 0) {
Glen Leef3052582015-09-10 12:03:04 +09006673 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006674
Leo Kim7ae43362015-09-16 18:35:59 +09006675 if (!rates)
6676 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006677
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006678 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02006679 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006680 }
6681
6682
Tony Cho143eb952015-09-21 12:16:32 +09006683 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006684 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006685 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006686 return s32Error;
6687}
6688
6689/**
6690 * @brief host_int_del_station
6691 * @details Setting delete station params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006692 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006693 * @return Error code.
6694 * @author
6695 * @date
6696 * @version 1.0
6697 */
Johnny Kim218dc402015-08-13 13:41:19 +09006698s32 host_int_del_station(tstrWILC_WFIDrv *hWFIDrv, const u8 *pu8MacAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006699{
Leo Kime6e12662015-09-16 18:36:03 +09006700 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006701 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006702 struct host_if_msg msg;
Tony Chofb93a1e2015-09-21 12:16:57 +09006703 struct del_sta *pstrDelStationMsg = &msg.body.strDelStaParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006704
Leo Kim24db7132015-09-16 18:36:01 +09006705 if (pstrWFIDrv == NULL) {
6706 PRINT_ER("driver is null\n");
6707 return -EFAULT;
6708 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006709
Tony Cho143eb952015-09-21 12:16:32 +09006710 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006711
6712 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
6713
6714
6715
6716 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006717 msg.id = HOST_IF_MSG_DEL_STATION;
Tony Cho143eb952015-09-21 12:16:32 +09006718 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006719
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09006720 if (pu8MacAddr == NULL)
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006721 memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006722 else
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006723 memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006724
Tony Cho143eb952015-09-21 12:16:32 +09006725 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006726 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006727 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006728 return s32Error;
6729}
6730/**
6731 * @brief host_int_del_allstation
6732 * @details Setting del station params in message queue
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006733 * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006734 * @return Error code.
6735 * @author
6736 * @date
6737 * @version 1.0
6738 */
Johnny Kim218dc402015-08-13 13:41:19 +09006739s32 host_int_del_allstation(tstrWILC_WFIDrv *hWFIDrv, u8 pu8MacAddr[][ETH_ALEN])
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006740{
Leo Kime6e12662015-09-16 18:36:03 +09006741 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006742 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006743 struct host_if_msg msg;
Tony Chob4e644e2015-09-21 12:17:00 +09006744 struct del_all_sta *pstrDelAllStationMsg = &msg.body.strHostIFDelAllSta;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006745 u8 au8Zero_Buff[ETH_ALEN] = {0};
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09006746 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006747 u8 u8AssocNumb = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006748
6749
Leo Kim24db7132015-09-16 18:36:01 +09006750 if (pstrWFIDrv == NULL) {
6751 PRINT_ER("driver is null\n");
6752 return -EFAULT;
6753 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006754
Tony Cho143eb952015-09-21 12:16:32 +09006755 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006756
6757 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
6758
6759 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006760 msg.id = HOST_IF_MSG_DEL_ALL_STA;
Tony Cho143eb952015-09-21 12:16:32 +09006761 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006762
6763 /* Handling situation of deauthenticing all associated stations*/
6764 for (i = 0; i < MAX_NUM_STA; i++) {
6765 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006766 memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006767 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],
6768 pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
6769 u8AssocNumb++;
6770 }
6771 }
6772 if (!u8AssocNumb) {
6773 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
6774 return s32Error;
6775 }
6776
6777 pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
Tony Cho143eb952015-09-21 12:16:32 +09006778 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006779
6780
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006781 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006782 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006783
Arnd Bergmann83383ea2015-06-01 21:06:43 +02006784 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006785
6786 return s32Error;
6787
6788}
6789
6790/**
6791 * @brief host_int_edit_station
6792 * @details Setting edit station params in message queue
Tony Cho6a89ba92015-09-21 12:16:46 +09006793 * @param[in] WILC_WFIDrvHandle hWFIDrv, struct add_sta_param *pstrStaParams
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006794 * @return Error code.
6795 * @author
6796 * @date
6797 * @version 1.0
6798 */
Tony Cho6a89ba92015-09-21 12:16:46 +09006799s32 host_int_edit_station(tstrWILC_WFIDrv *hWFIDrv,
6800 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006801{
Leo Kime6e12662015-09-16 18:36:03 +09006802 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006803 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006804 struct host_if_msg msg;
Tony Cho6a89ba92015-09-21 12:16:46 +09006805 struct add_sta_param *pstrAddStationMsg = &msg.body.strAddStaParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006806
Leo Kim24db7132015-09-16 18:36:01 +09006807 if (pstrWFIDrv == NULL) {
6808 PRINT_ER("driver is null\n");
6809 return -EFAULT;
6810 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006811
6812 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
6813
Tony Cho143eb952015-09-21 12:16:32 +09006814 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006815
6816
6817 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006818 msg.id = HOST_IF_MSG_EDIT_STATION;
Tony Cho143eb952015-09-21 12:16:32 +09006819 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006820
Tony Cho6a89ba92015-09-21 12:16:46 +09006821 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006822 if (pstrAddStationMsg->u8NumRates > 0) {
Glen Leef3052582015-09-10 12:03:04 +09006823 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02006824
Leo Kim7ae43362015-09-16 18:35:59 +09006825 if (!rates)
6826 return -ENOMEM;
6827
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006828 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02006829 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006830 }
6831
Tony Cho143eb952015-09-21 12:16:32 +09006832 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006833 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006834 PRINT_ER("wilc_mq_send fail\n");
6835
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006836 return s32Error;
6837}
Glen Lee108b3432015-09-16 18:53:20 +09006838
Johnny Kim218dc402015-08-13 13:41:19 +09006839s32 host_int_set_power_mgmt(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32Timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006840{
Leo Kime6e12662015-09-16 18:36:03 +09006841 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006842 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006843 struct host_if_msg msg;
Tony Cho5a008f12015-09-21 12:16:48 +09006844 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.strPowerMgmtparam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006845
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02006846 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006847
Leo Kim24db7132015-09-16 18:36:01 +09006848 if (pstrWFIDrv == NULL) {
6849 PRINT_ER("driver is null\n");
6850 return -EFAULT;
6851 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006852
6853 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
6854
Tony Cho143eb952015-09-21 12:16:32 +09006855 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006856
6857
6858 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006859 msg.id = HOST_IF_MSG_POWER_MGMT;
Tony Cho143eb952015-09-21 12:16:32 +09006860 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006861
6862 pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
6863 pstrPowerMgmtParam->u32Timeout = u32Timeout;
6864
6865
Tony Cho143eb952015-09-21 12:16:32 +09006866 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006867 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006868 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006869 return s32Error;
6870}
6871
Johnny Kim218dc402015-08-13 13:41:19 +09006872s32 host_int_setup_multicast_filter(tstrWILC_WFIDrv *hWFIDrv, bool bIsEnabled, u32 u32count)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006873{
Leo Kime6e12662015-09-16 18:36:03 +09006874 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006875
6876 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09006877 struct host_if_msg msg;
Tony Cho641210a2015-09-21 12:16:52 +09006878 struct set_multicast *pstrMulticastFilterParam = &msg.body.strHostIfSetMulti;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006879
6880
Leo Kim24db7132015-09-16 18:36:01 +09006881 if (pstrWFIDrv == NULL) {
6882 PRINT_ER("driver is null\n");
6883 return -EFAULT;
6884 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006885
6886 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
6887
Tony Cho143eb952015-09-21 12:16:32 +09006888 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006889
6890
6891 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09006892 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
Tony Cho143eb952015-09-21 12:16:32 +09006893 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006894
6895 pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
6896 pstrMulticastFilterParam->u32count = u32count;
6897
Tony Cho143eb952015-09-21 12:16:32 +09006898 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02006899 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09006900 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006901 return s32Error;
6902}
6903
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006904/**
6905 * @brief host_int_ParseJoinBssParam
6906 * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
6907 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
6908 * @return
6909 * @author zsalah
6910 * @date
6911 * @version 1.0**/
6912static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
6913{
6914 tstrJoinBssParam *pNewJoinBssParam = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006915 u8 *pu8IEs;
Chaehyun Limd85f5322015-06-11 14:35:54 +09006916 u16 u16IEsLen;
6917 u16 index = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006918 u8 suppRatesNo = 0;
6919 u8 extSuppRatesNo;
Chaehyun Limd85f5322015-06-11 14:35:54 +09006920 u16 jumpOffset;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09006921 u8 pcipherCount;
6922 u8 authCount;
6923 u8 pcipherTotalCount = 0;
6924 u8 authTotalCount = 0;
6925 u8 i, j;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006926
6927 pu8IEs = ptstrNetworkInfo->pu8IEs;
6928 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
6929
Glen Leef3052582015-09-10 12:03:04 +09006930 pNewJoinBssParam = kmalloc(sizeof(tstrJoinBssParam), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006931 if (pNewJoinBssParam != NULL) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006932 memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006933 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
6934 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
6935 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006936 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006937 /*for(i=0; i<6;i++)
6938 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09006939 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006940 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
Chaehyun Lim2cc46832015-08-07 09:02:01 +09006941 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
6942 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006943 /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
6944 * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
6945
6946 /* parse supported rates: */
6947 while (index < u16IEsLen) {
6948 /* supportedRates IE */
6949 if (pu8IEs[index] == SUPP_RATES_IE) {
6950 /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
6951 suppRatesNo = pu8IEs[index + 1];
6952 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
6953 index += 2; /* skipping ID and length bytes; */
6954
6955 for (i = 0; i < suppRatesNo; i++) {
6956 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
6957 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
6958 }
6959 index += suppRatesNo;
6960 continue;
6961 }
6962 /* Ext SupportedRates IE */
6963 else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
6964 /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
6965 /* checking if no of ext. supp and supp rates < max limit */
6966 extSuppRatesNo = pu8IEs[index + 1];
6967 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
6968 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
6969 else
6970 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
6971 index += 2;
6972 /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
6973 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
6974 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
6975 /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
6976 }
6977 index += extSuppRatesNo;
6978 continue;
6979 }
6980 /* HT Cap. IE */
6981 else if (pu8IEs[index] == HT_CAPABILITY_IE) {
6982 /* if IE found set the flag */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09006983 pNewJoinBssParam->ht_capable = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006984 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
6985 /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
6986 continue;
6987 } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
6988 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
6989 (pu8IEs[index + 4] == 0xF2) && /* OUI */
6990 (pu8IEs[index + 5] == 0x02) && /* OUI Type */
6991 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
6992 (pu8IEs[index + 7] == 0x01)) {
6993 /* Presence of WMM Info/Param element indicates WMM capability */
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09006994 pNewJoinBssParam->wmm_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006995
6996 /* Check if Bit 7 is set indicating U-APSD capability */
Anish Bhattffda2032015-09-29 12:15:49 -07006997 if (pu8IEs[index + 8] & BIT(7))
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09006998 pNewJoinBssParam->uapsd_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006999 index += pu8IEs[index + 1] + 2;
7000 continue;
7001 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007002 else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
7003 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
7004 (pu8IEs[index + 4] == 0x9a) && /* OUI */
7005 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
Chaehyun Limd85f5322015-06-11 14:35:54 +09007006 u16 u16P2P_count;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02007007
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007008 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
7009 pNewJoinBssParam->u8NoaEnbaled = 1;
7010 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
7011
7012 /* Check if Bit 7 is set indicating Opss capability */
Anish Bhattffda2032015-09-29 12:15:49 -07007013 if (pu8IEs[index + 10] & BIT(7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007014 pNewJoinBssParam->u8OppEnable = 1;
7015 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
7016 } else
7017 pNewJoinBssParam->u8OppEnable = 0;
7018 /* HOSTINF_DBG */
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007019 PRINT_D(GENERIC_DBG, "P2P Dump\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007020 for (i = 0; i < pu8IEs[index + 7]; i++)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007021 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007022
7023 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
7024 u16P2P_count = index + 12;
7025
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007026 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007027 u16P2P_count += 4;
7028
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007029 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007030 u16P2P_count += 4;
7031
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09007032 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007033
7034 index += pu8IEs[index + 1] + 2;
7035 continue;
7036
7037 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007038 else if ((pu8IEs[index] == RSN_IE) ||
7039 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
7040 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
7041 (pu8IEs[index + 5] == 0x01))) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09007042 u16 rsnIndex = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007043 /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
7044 * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
7045 * {
7046 * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
7047 * }*/
7048 if (pu8IEs[rsnIndex] == RSN_IE) {
7049 pNewJoinBssParam->mode_802_11i = 2;
7050 /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
7051 } else { /* check if rsn was previously parsed */
7052 if (pNewJoinBssParam->mode_802_11i == 0)
7053 pNewJoinBssParam->mode_802_11i = 1;
7054 /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
7055 rsnIndex += 4;
7056 }
7057 rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
7058 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
7059 rsnIndex++;
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007060 /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x\n",pNewJoinBssParam->rsn_grp_policy); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007061 /* initialize policies with invalid values */
7062
7063 jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
7064
7065 /*parsing pairwise cipher*/
7066
7067 /* saving 3 pcipher max. */
7068 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7069 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7070
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02007071 /* PRINT_D(HOSTINF_DBG,"\npcipher:%d\n",pcipherCount); */
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007072 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
7073 /* each count corresponds to 4 bytes, only last byte is saved */
7074 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7075 /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
7076 }
7077 pcipherTotalCount += pcipherCount;
7078 rsnIndex += jumpOffset;
7079
7080 jumpOffset = pu8IEs[rsnIndex] * 4;
7081
7082 /*parsing AKM suite (auth_policy)*/
7083 /* saving 3 auth policies max. */
7084 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
7085 rsnIndex += 2; /* jump 2 bytes of pcipher count */
7086
7087 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
7088 /* each count corresponds to 4 bytes, only last byte is saved */
7089 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
7090 }
7091 authTotalCount += authCount;
7092 rsnIndex += jumpOffset;
7093 /*pasring rsn cap. only if rsn IE*/
7094 if (pu8IEs[index] == RSN_IE) {
7095 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
7096 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
7097 rsnIndex += 2;
7098 }
Abdul Hussainf717c0eb2015-06-16 09:49:49 +00007099 pNewJoinBssParam->rsn_found = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007100 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7101 continue;
7102 } else
7103 index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
7104
7105 }
7106
7107
7108 }
7109
7110 return (void *)pNewJoinBssParam;
7111
7112}
7113
7114void host_int_freeJoinParams(void *pJoinParams)
7115{
7116 if ((tstrJoinBssParam *)pJoinParams != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09007117 kfree((tstrJoinBssParam *)pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007118 else
7119 PRINT_ER("Unable to FREE null pointer\n");
7120}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007121
7122/**
7123 * @brief host_int_addBASession
7124 * @details Open a block Ack session with the given parameters
7125 * @param[in] tstrNetworkInfo* ptstrNetworkInfo
7126 * @return
7127 * @author anoureldin
7128 * @date
7129 * @version 1.0**/
7130
Johnny Kim2b05df52015-08-13 13:41:21 +09007131static int host_int_addBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID, short int BufferSize,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007132 short int SessionTimeout, void *drvHandler)
7133{
Leo Kime6e12662015-09-16 18:36:03 +09007134 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007135 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007136 struct host_if_msg msg;
Tony Cho54265472015-09-21 12:16:56 +09007137 struct ba_session_info *pBASessionInfo = &msg.body.strHostIfBASessionInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007138
Leo Kim24db7132015-09-16 18:36:01 +09007139 if (pstrWFIDrv == NULL) {
7140 PRINT_ER("driver is null\n");
7141 return -EFAULT;
7142 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007143
Tony Cho143eb952015-09-21 12:16:32 +09007144 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007145
7146 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007147 msg.id = HOST_IF_MSG_ADD_BA_SESSION;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007148
7149 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7150 pBASessionInfo->u8Ted = TID;
7151 pBASessionInfo->u16BufferSize = BufferSize;
7152 pBASessionInfo->u16SessionTimeout = SessionTimeout;
Tony Cho143eb952015-09-21 12:16:32 +09007153 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007154
Tony Cho143eb952015-09-21 12:16:32 +09007155 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007156 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007157 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007158
7159 return s32Error;
7160}
7161
7162
Johnny Kim218dc402015-08-13 13:41:19 +09007163s32 host_int_delBASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007164{
Leo Kime6e12662015-09-16 18:36:03 +09007165 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007166 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007167 struct host_if_msg msg;
Tony Cho54265472015-09-21 12:16:56 +09007168 struct ba_session_info *pBASessionInfo = &msg.body.strHostIfBASessionInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007169
Leo Kim24db7132015-09-16 18:36:01 +09007170 if (pstrWFIDrv == NULL) {
7171 PRINT_ER("driver is null\n");
7172 return -EFAULT;
7173 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007174
Tony Cho143eb952015-09-21 12:16:32 +09007175 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007176
7177 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007178 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007179
7180 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7181 pBASessionInfo->u8Ted = TID;
Tony Cho143eb952015-09-21 12:16:32 +09007182 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007183
Tony Cho143eb952015-09-21 12:16:32 +09007184 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007185 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007186 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007187
Arnd Bergmann83383ea2015-06-01 21:06:43 +02007188 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007189
7190 return s32Error;
7191}
7192
Johnny Kim218dc402015-08-13 13:41:19 +09007193s32 host_int_del_All_Rx_BASession(tstrWILC_WFIDrv *hWFIDrv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007194{
Leo Kime6e12662015-09-16 18:36:03 +09007195 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007196 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007197 struct host_if_msg msg;
Tony Cho54265472015-09-21 12:16:56 +09007198 struct ba_session_info *pBASessionInfo = &msg.body.strHostIfBASessionInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007199
Leo Kim24db7132015-09-16 18:36:01 +09007200 if (pstrWFIDrv == NULL) {
7201 PRINT_ER("driver is null\n");
7202 return -EFAULT;
7203 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007204
Tony Cho143eb952015-09-21 12:16:32 +09007205 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007206
7207 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007208 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007209
7210 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
7211 pBASessionInfo->u8Ted = TID;
Tony Cho143eb952015-09-21 12:16:32 +09007212 msg.drvHandler = hWFIDrv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007213
Tony Cho143eb952015-09-21 12:16:32 +09007214 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007215 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007216 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007217
Arnd Bergmann83383ea2015-06-01 21:06:43 +02007218 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007219
7220 return s32Error;
7221}
7222
7223/**
7224 * @brief host_int_setup_ipaddress
7225 * @details setup IP in firmware
7226 * @param[in] Handle to wifi driver
7227 * @return Error code.
7228 * @author Abdelrahman Sobhy
7229 * @date
7230 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09007231s32 host_int_setup_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007232{
Leo Kime6e12662015-09-16 18:36:03 +09007233 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007234 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007235 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007236
7237 /* TODO: Enable This feature on softap firmware */
7238 return 0;
7239
Leo Kim24db7132015-09-16 18:36:01 +09007240 if (pstrWFIDrv == NULL) {
7241 PRINT_ER("driver is null\n");
7242 return -EFAULT;
7243 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007244
Tony Cho143eb952015-09-21 12:16:32 +09007245 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007246
7247 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007248 msg.id = HOST_IF_MSG_SET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007249
Tony Cho410c2482015-09-21 12:16:35 +09007250 msg.body.strHostIfSetIP.au8IPAddr = u16ipadd;
Tony Cho143eb952015-09-21 12:16:32 +09007251 msg.drvHandler = hWFIDrv;
Tony Cho410c2482015-09-21 12:16:35 +09007252 msg.body.strHostIfSetIP.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007253
Tony Cho143eb952015-09-21 12:16:32 +09007254 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007255 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007256 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007257
7258 return s32Error;
7259
7260
7261}
7262
7263/**
7264 * @brief host_int_get_ipaddress
7265 * @details Get IP from firmware
7266 * @param[in] Handle to wifi driver
7267 * @return Error code.
7268 * @author Abdelrahman Sobhy
7269 * @date
7270 * @version 1.0*/
Johnny Kim218dc402015-08-13 13:41:19 +09007271s32 host_int_get_ipaddress(tstrWILC_WFIDrv *hWFIDrv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007272{
Leo Kime6e12662015-09-16 18:36:03 +09007273 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007274 tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
Tony Cho143eb952015-09-21 12:16:32 +09007275 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007276
Leo Kim24db7132015-09-16 18:36:01 +09007277 if (pstrWFIDrv == NULL) {
7278 PRINT_ER("driver is null\n");
7279 return -EFAULT;
7280 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007281
Tony Cho143eb952015-09-21 12:16:32 +09007282 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007283
7284 /* prepare the WiphyParams Message */
Tony Choa9f812a2015-09-21 12:16:33 +09007285 msg.id = HOST_IF_MSG_GET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007286
Tony Cho410c2482015-09-21 12:16:35 +09007287 msg.body.strHostIfSetIP.au8IPAddr = u16ipadd;
Tony Cho143eb952015-09-21 12:16:32 +09007288 msg.drvHandler = hWFIDrv;
Tony Cho410c2482015-09-21 12:16:35 +09007289 msg.body.strHostIfSetIP.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007290
Tony Cho143eb952015-09-21 12:16:32 +09007291 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02007292 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09007293 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09007294
7295 return s32Error;
7296
7297
7298}