blob: 432b2752702d9597a3f63d8bccc11cb8259ca3a3 [file] [log] [blame]
Chaehyun Lime215a872015-09-30 08:15:41 +09001#include <linux/slab.h>
2#include <linux/time.h>
3#include <linux/kthread.h>
4#include <linux/delay.h>
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005#include "host_interface.h"
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006#include "coreconfigurator.h"
Chaehyun Lim53660122015-09-17 16:48:49 +09007#include "wilc_wlan_if.h"
Chaehyun Limf23eb982015-09-23 18:03:47 +09008#include "wilc_msgqueue.h"
Shraddha Barke281dd5a2015-10-05 17:00:33 +05309#include <linux/etherdevice.h>
Johnny Kimc5c77ba2015-05-11 14:30:56 +090010
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090011extern u8 connecting;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090012
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -070013extern struct timer_list hDuringIpTimer;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090014
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090015extern u8 g_wilc_initialized;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090016
Chaehyun Lim9eac3a12015-06-18 22:08:51 +090017#define HOST_IF_MSG_SCAN 0
18#define HOST_IF_MSG_CONNECT 1
19#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
20#define HOST_IF_MSG_KEY 3
21#define HOST_IF_MSG_RCVD_NTWRK_INFO 4
22#define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
23#define HOST_IF_MSG_CFG_PARAMS 6
24#define HOST_IF_MSG_SET_CHANNEL 7
25#define HOST_IF_MSG_DISCONNECT 8
26#define HOST_IF_MSG_GET_RSSI 9
27#define HOST_IF_MSG_GET_CHNL 10
28#define HOST_IF_MSG_ADD_BEACON 11
29#define HOST_IF_MSG_DEL_BEACON 12
30#define HOST_IF_MSG_ADD_STATION 13
31#define HOST_IF_MSG_DEL_STATION 14
32#define HOST_IF_MSG_EDIT_STATION 15
33#define HOST_IF_MSG_SCAN_TIMER_FIRED 16
34#define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
35#define HOST_IF_MSG_POWER_MGMT 18
36#define HOST_IF_MSG_GET_INACTIVETIME 19
37#define HOST_IF_MSG_REMAIN_ON_CHAN 20
38#define HOST_IF_MSG_REGISTER_FRAME 21
39#define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
40#define HOST_IF_MSG_GET_LINKSPEED 23
41#define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
42#define HOST_IF_MSG_SET_MAC_ADDRESS 25
43#define HOST_IF_MSG_GET_MAC_ADDRESS 26
44#define HOST_IF_MSG_SET_OPERATION_MODE 27
45#define HOST_IF_MSG_SET_IPADDRESS 28
46#define HOST_IF_MSG_GET_IPADDRESS 29
47#define HOST_IF_MSG_FLUSH_CONNECT 30
48#define HOST_IF_MSG_GET_STATISTICS 31
49#define HOST_IF_MSG_SET_MULTICAST_FILTER 32
50#define HOST_IF_MSG_ADD_BA_SESSION 33
51#define HOST_IF_MSG_DEL_BA_SESSION 34
52#define HOST_IF_MSG_Q_IDLE 35
53#define HOST_IF_MSG_DEL_ALL_STA 36
54#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
55#define HOST_IF_MSG_EXIT 100
Johnny Kimc5c77ba2015-05-11 14:30:56 +090056
Chaehyun Lime54d5b72015-06-18 22:08:50 +090057#define HOST_IF_SCAN_TIMEOUT 4000
58#define HOST_IF_CONNECT_TIMEOUT 9500
Johnny Kimc5c77ba2015-05-11 14:30:56 +090059
Chaehyun Lime54d5b72015-06-18 22:08:50 +090060#define BA_SESSION_DEFAULT_BUFFER_SIZE 16
61#define BA_SESSION_DEFAULT_TIMEOUT 1000
62#define BLOCK_ACK_REQ_SIZE 0x14
Johnny Kimc5c77ba2015-05-11 14:30:56 +090063
Tony Cho361ff842015-09-21 12:16:41 +090064struct cfg_param_attr {
Tony Cho221371e2015-10-12 16:56:06 +090065 struct cfg_param_val cfg_attr_info;
Tony Cho361ff842015-09-21 12:16:41 +090066};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090067
Leo Kim4372d3d2015-10-05 15:25:43 +090068struct host_if_wpa_attr {
Leo Kim124968fc2015-10-13 19:49:30 +090069 u8 *key;
Leo Kim248080a2015-10-13 19:49:31 +090070 const u8 *mac_addr;
Leo Kim0e74c002015-10-13 19:49:32 +090071 u8 *seq;
Leo Kimdacc5942015-10-13 19:49:33 +090072 u8 seq_len;
Leo Kime2dfbac2015-10-13 19:49:34 +090073 u8 index;
Leo Kim6acf2912015-10-13 19:49:35 +090074 u8 key_len;
Leo Kim7b2ebb22015-10-13 19:49:36 +090075 u8 mode;
Leo Kim4372d3d2015-10-05 15:25:43 +090076};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090077
Leo Kimc276c442015-10-05 15:25:42 +090078struct host_if_wep_attr {
Tony Choe5538d32015-10-12 16:56:11 +090079 u8 *key;
Tony Chod520e352015-10-12 16:56:12 +090080 u8 key_len;
Tony Cho259b3aa2015-10-12 16:56:13 +090081 u8 index;
Tony Chob5eaff12015-10-12 16:56:14 +090082 u8 mode;
Tony Cho7fa252e2015-10-12 16:56:15 +090083 enum AUTHTYPE auth_type;
Leo Kimc276c442015-10-05 15:25:42 +090084};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090085
Leo Kim40cc2c92015-10-05 15:25:41 +090086union host_if_key_attr {
Tony Cho2ed7a2f2015-10-12 16:56:08 +090087 struct host_if_wep_attr wep;
Tony Choe3501a42015-10-12 16:56:09 +090088 struct host_if_wpa_attr wpa;
Tony Cho610e3862015-10-12 16:56:10 +090089 struct host_if_pmkid_attr pmkid;
Leo Kim40cc2c92015-10-05 15:25:41 +090090};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090091
Tony Choc98387a2015-09-21 12:16:40 +090092struct key_attr {
Leo Kim8e9f4272015-10-13 19:49:27 +090093 enum KEY_TYPE type;
Leo Kim0d17e382015-10-13 19:49:28 +090094 u8 action;
Leo Kim73b2e382015-10-13 19:49:29 +090095 union host_if_key_attr attr;
Tony Choc98387a2015-09-21 12:16:40 +090096};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090097
Tony Choc476feb2015-09-21 12:16:36 +090098struct scan_attr {
Leo Kim42568892015-10-13 19:49:37 +090099 u8 src;
Leo Kim1e276c82015-10-13 19:49:38 +0900100 u8 type;
Leo Kim82eeb0a2015-10-13 19:49:40 +0900101 u8 *ch_freq_list;
Leo Kimf97bd9c2015-10-13 19:49:41 +0900102 u8 ch_list_len;
Leo Kimd6f19aa2015-10-13 19:49:42 +0900103 u8 *ies;
Leo Kim7b1f76c2015-10-13 19:49:43 +0900104 size_t ies_len;
Leo Kimc17c6da2015-10-13 19:49:44 +0900105 wilc_scan_result result;
Leo Kim5f2b50c2015-10-13 19:49:45 +0900106 void *arg;
Leo Kim629b9ca2015-10-13 19:49:46 +0900107 struct hidden_network hidden_network;
Tony Choc476feb2015-09-21 12:16:36 +0900108};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900109
Tony Cho120ae592015-09-21 12:16:37 +0900110struct connect_attr {
Leo Kim9254db02015-10-13 19:49:49 +0900111 u8 *bssid;
Leo Kimf7bbd9c2015-10-13 19:49:50 +0900112 u8 *ssid;
Leo Kim8b3c9fa2015-10-13 19:49:51 +0900113 size_t ssid_len;
Leo Kim2ea158c2015-10-13 19:49:52 +0900114 u8 *ies;
Leo Kimb59d5c52015-10-13 19:49:53 +0900115 size_t ies_len;
Leo Kima64fd672015-10-13 19:49:54 +0900116 u8 security;
Leo Kim6abcc112015-10-13 19:49:55 +0900117 wilc_connect_result result;
Leo Kim8f38db82015-10-13 19:49:56 +0900118 void *arg;
Leo Kim61b4fd02015-10-13 19:49:57 +0900119 enum AUTHTYPE auth_type;
Leo Kim0d1527e2015-10-13 19:49:58 +0900120 u8 ch;
Leo Kimf2bed2c2015-10-13 19:49:59 +0900121 void *params;
Tony Cho120ae592015-09-21 12:16:37 +0900122};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900123
Tony Chof23a9ea2015-09-21 12:16:39 +0900124struct rcvd_async_info {
Leo Kim33722ac72015-10-13 19:50:00 +0900125 u8 *buffer;
Leo Kimf94f4882015-10-13 19:50:01 +0900126 u32 len;
Tony Chof23a9ea2015-09-21 12:16:39 +0900127};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900128
Tony Cho94bdfe42015-09-30 18:44:27 +0900129struct channel_attr {
Leo Kim730ee052015-10-13 19:50:02 +0900130 u8 set_ch;
Tony Cho326b3232015-09-21 12:16:42 +0900131};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900132
Tony Cho7f33fec2015-09-30 18:44:30 +0900133struct beacon_attr {
Leo Kim12262dd2015-10-13 19:50:03 +0900134 u32 interval;
Leo Kime76ab772015-10-13 19:50:04 +0900135 u32 dtim_period;
Leo Kim51c66182015-10-13 19:50:05 +0900136 u32 head_len;
Leo Kim8ce528b2015-10-13 19:50:06 +0900137 u8 *head;
Leo Kim030c57e2015-10-13 19:50:07 +0900138 u32 tail_len;
Leo Kim7dbcb6d32015-10-13 19:50:08 +0900139 u8 *tail;
Tony Cho902362b2015-09-21 12:16:44 +0900140};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900141
Tony Cho641210a2015-09-21 12:16:52 +0900142struct set_multicast {
Leo Kimbae636eb2015-10-13 20:02:04 +0900143 bool enabled;
Leo Kimadab2f72015-10-13 20:02:05 +0900144 u32 cnt;
Tony Cho641210a2015-09-21 12:16:52 +0900145};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900146
Tony Chob4e644e2015-09-21 12:17:00 +0900147struct del_all_sta {
Leo Kime51b9212015-10-13 19:50:09 +0900148 u8 del_all_sta[MAX_NUM_STA][ETH_ALEN];
Leo Kim8ba18032015-10-13 19:50:10 +0900149 u8 assoc_sta;
Tony Chob4e644e2015-09-21 12:17:00 +0900150};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900151
Tony Chofb93a1e2015-09-21 12:16:57 +0900152struct del_sta {
Leo Kime4839d32015-10-13 20:02:06 +0900153 u8 mac_addr[ETH_ALEN];
Tony Chofb93a1e2015-09-21 12:16:57 +0900154};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900155
Tony Cho5a008f12015-09-21 12:16:48 +0900156struct power_mgmt_param {
Leo Kim33c70c12015-10-13 20:02:07 +0900157 bool enabled;
Leo Kim937918f2015-10-13 20:02:08 +0900158 u32 timeout;
Tony Cho5a008f12015-09-21 12:16:48 +0900159};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900160
Tony Cho15191ea2015-09-21 12:16:50 +0900161struct set_ip_addr {
Leo Kim78675be2015-10-13 20:02:09 +0900162 u8 *ip_addr;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900163 u8 idx;
Tony Cho15191ea2015-09-21 12:16:50 +0900164};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900165
Tony Cho3d1eac02015-09-21 12:16:49 +0900166struct sta_inactive_t {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900167 u8 mac[6];
Tony Cho3d1eac02015-09-21 12:16:49 +0900168};
Leo Kimae4dfa52015-10-13 19:49:26 +0900169
Tony Chodfc76632015-09-21 12:16:34 +0900170union message_body {
Tony Cho4528bdb2015-09-30 18:44:20 +0900171 struct scan_attr scan_info;
Tony Cho3f501972015-09-30 18:44:21 +0900172 struct connect_attr con_info;
Tony Cho02d19462015-09-30 18:44:22 +0900173 struct rcvd_net_info net_info;
Tony Cho66add622015-09-30 18:44:23 +0900174 struct rcvd_async_info async_info;
Tony Cho18990bf2015-09-30 18:44:24 +0900175 struct key_attr key_info;
Tony Choa2340c32015-09-30 18:44:25 +0900176 struct cfg_param_attr cfg_info;
Tony Choffd6dbc2015-09-30 18:44:28 +0900177 struct channel_attr channel_info;
Tony Choa98491e2015-09-30 18:44:31 +0900178 struct beacon_attr beacon_info;
Tony Choca8f47f2015-09-30 18:44:32 +0900179 struct add_sta_param add_sta_info;
Tony Cho889c25b2015-09-30 18:44:33 +0900180 struct del_sta del_sta_info;
Tony Cho4a930962015-09-30 18:44:34 +0900181 struct add_sta_param edit_sta_info;
Tony Cho49e1f812015-09-30 18:44:36 +0900182 struct power_mgmt_param pwr_mgmt_info;
Tony Cho66bac7f2015-09-30 18:44:37 +0900183 struct sta_inactive_t mac_info;
Tony Chofb2d65e2015-09-30 18:44:39 +0900184 struct set_ip_addr ip_info;
Tony Cho5e4377e2015-09-30 18:44:38 +0900185 struct drv_handler drv;
Tony Choa079cf4d2015-09-30 18:55:05 +0900186 struct set_multicast multicast_info;
Tony Cho00c46302015-09-30 18:55:06 +0900187 struct op_mode mode;
Tony Cho15326e22015-09-30 18:55:07 +0900188 struct set_mac_addr set_mac_info;
Tony Choa5848692015-09-30 18:55:08 +0900189 struct get_mac_addr get_mac_info;
Tony Choc833b472015-09-30 18:55:09 +0900190 struct ba_session_info session_info;
Tony Cho070d3652015-09-30 18:55:10 +0900191 struct remain_ch remain_on_ch;
Tony Cho5c4008d2015-10-05 13:50:44 +0900192 struct reg_frame reg_frame;
Tony Choe60831e2015-10-05 13:50:45 +0900193 char *data;
Tony Chob0c1e802015-10-05 13:50:46 +0900194 struct del_all_sta del_all_sta_info;
Tony Chodfc76632015-09-21 12:16:34 +0900195};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900196
Tony Cho3a8c41b2015-09-18 18:11:04 +0900197struct host_if_msg {
Leo Kimae4dfa52015-10-13 19:49:26 +0900198 u16 id;
199 union message_body body;
Leo Kim2482a792015-10-12 16:55:36 +0900200 struct host_if_drv *drv;
Tony Cho3a8c41b2015-09-18 18:11:04 +0900201};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900202
Leo Kime0a12212015-10-12 16:55:49 +0900203struct join_bss_param {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900204 BSSTYPE_T bss_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900205 u8 dtim_period;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900206 u16 beacon_period;
207 u16 cap_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900208 u8 au8bssid[6];
Dean Lee576917a2015-06-15 11:58:57 +0900209 char ssid[MAX_SSID_LEN];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900210 u8 ssidLen;
211 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
212 u8 ht_capable;
213 u8 wmm_cap;
214 u8 uapsd_cap;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900215 bool rsn_found;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900216 u8 rsn_grp_policy;
217 u8 mode_802_11i;
218 u8 rsn_pcip_policy[3];
219 u8 rsn_auth_policy[3];
220 u8 rsn_cap[2];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900221 u32 tsf;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900222 u8 u8NoaEnbaled;
223 u8 u8OppEnable;
224 u8 u8CtWindow;
225 u8 u8Count;
226 u8 u8Index;
227 u8 au8Duration[4];
228 u8 au8Interval[4];
229 u8 au8StartTime[4];
Leo Kime0a12212015-10-12 16:55:49 +0900230};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900231
Leo Kim7696edf2015-10-12 16:56:02 +0900232enum scan_conn_timer {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900233 SCAN_TIMER = 0,
234 CONNECT_TIMER = 1,
235 SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
Leo Kim7696edf2015-10-12 16:56:02 +0900236};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900237
Leo Kim441dc602015-10-12 16:55:35 +0900238static struct host_if_drv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
239struct host_if_drv *terminated_handle;
240struct host_if_drv *gWFiDrvHandle;
Leo Kimf2fc9f62015-10-13 19:49:47 +0900241bool g_obtainingIP;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900242u8 P2P_LISTEN_STATE;
Arnd Bergmann1999bd52015-05-29 22:52:14 +0200243static struct task_struct *HostIFthreadHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900244static WILC_MsgQueueHandle gMsgQHostIF;
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200245static struct semaphore hSemHostIFthrdEnd;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900246
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200247struct semaphore hSemDeinitDrvHandle;
248static struct semaphore hWaitResponse;
249struct semaphore hSemHostIntDeinit;
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -0700250struct timer_list g_hPeriodicRSSI;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900251
252
253
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900254u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900255
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900256static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900257
Leo Kimf2fc9f62015-10-13 19:49:47 +0900258bool gbScanWhileConnected;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900259
Chaehyun Limca356ad2015-06-11 14:35:57 +0900260static s8 gs8Rssi;
261static s8 gs8lnkspd;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900262static u8 gu8Chnl;
263static u8 gs8SetIP[2][4];
264static u8 gs8GetIP[2][4];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900265static u32 gu32InactiveTime;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900266static u8 gu8DelBcn;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900267static u32 gu32WidConnRstHack;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900268
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900269u8 *gu8FlushedJoinReq;
270u8 *gu8FlushedInfoElemAsoc;
271u8 gu8Flushed11iMode;
272u8 gu8FlushedAuthType;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900273u32 gu32FlushedJoinReqSize;
274u32 gu32FlushedInfoElemAsocSize;
Leo Kim441dc602015-10-12 16:55:35 +0900275struct host_if_drv *gu8FlushedJoinReqDrvHandler;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900276#define REAL_JOIN_REQ 0
277#define FLUSHED_JOIN_REQ 1
Leo Kimae4dfa52015-10-13 19:49:26 +0900278#define FLUSHED_BYTE_POS 79
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900279
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900280static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900281
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900282extern void chip_sleep_manually(u32 u32SleepTime);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900283extern int linux_wlan_get_num_conn_ifcs(void);
284
Leo Kim441dc602015-10-12 16:55:35 +0900285static int add_handler_in_list(struct host_if_drv *handler)
Johnny Kimd42ab082015-08-20 16:32:52 +0900286{
287 int i;
288
289 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
290 if (!wfidrv_list[i]) {
291 wfidrv_list[i] = handler;
292 return 0;
293 }
294 }
295
296 return -ENOBUFS;
297}
298
Leo Kim441dc602015-10-12 16:55:35 +0900299static int remove_handler_in_list(struct host_if_drv *handler)
Johnny Kimd42ab082015-08-20 16:32:52 +0900300{
301 int i;
302
303 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
304 if (wfidrv_list[i] == handler) {
305 wfidrv_list[i] = NULL;
306 return 0;
307 }
308 }
309
310 return -EINVAL;
311}
312
Leo Kim441dc602015-10-12 16:55:35 +0900313static int get_id_from_handler(struct host_if_drv *handler)
Johnny Kimd42ab082015-08-20 16:32:52 +0900314{
315 int i;
316
317 if (!handler)
318 return 0;
319
320 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
321 if (wfidrv_list[i] == handler)
322 return i;
323 }
324
325 return 0;
326}
327
Leo Kim441dc602015-10-12 16:55:35 +0900328static struct host_if_drv *get_handler_from_id(int id)
Johnny Kimd42ab082015-08-20 16:32:52 +0900329{
Dan Carpenter6ae9ac02015-09-15 09:54:33 +0300330 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
Johnny Kimd42ab082015-08-20 16:32:52 +0900331 return NULL;
332 return wfidrv_list[id];
333}
334
Tony Choa4ab1ad2015-10-12 16:56:05 +0900335static s32 Handle_SetChannel(struct host_if_drv *hif_drv,
Tony Cho94bdfe42015-09-30 18:44:27 +0900336 struct channel_attr *pstrHostIFSetChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900337{
338
Leo Kime6e12662015-09-16 18:36:03 +0900339 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900340 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900341
Leo Kimdaaf16b2015-10-12 16:55:44 +0900342 strWID.id = (u16)WID_CURRENT_CHANNEL;
Leo Kim416d8322015-10-12 16:55:43 +0900343 strWID.type = WID_CHAR;
Leo Kim730ee052015-10-13 19:50:02 +0900344 strWID.val = (char *)&(pstrHostIFSetChan->set_ch);
Leo Kim2fd3e442015-10-12 16:55:45 +0900345 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900346
347 PRINT_D(HOSTINF_DBG, "Setting channel\n");
Leo Kimae4dfa52015-10-13 19:49:26 +0900348
Tony Cho03362282015-10-12 16:55:39 +0900349 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +0900350 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900351 if (s32Error) {
352 PRINT_ER("Failed to set channel\n");
Leo Kim24db7132015-09-16 18:36:01 +0900353 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900354 }
355
356 return s32Error;
357}
Leo Kimae4dfa52015-10-13 19:49:26 +0900358
Tony Choa4ab1ad2015-10-12 16:56:05 +0900359static s32 Handle_SetWfiDrvHandler(struct host_if_drv *hif_drv,
Tony Cho127f9d92015-09-21 12:16:51 +0900360 struct drv_handler *pstrHostIfSetDrvHandler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900361{
362
Leo Kime6e12662015-09-16 18:36:03 +0900363 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900364 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900365
Leo Kimdaaf16b2015-10-12 16:55:44 +0900366 strWID.id = (u16)WID_SET_DRV_HANDLER;
Leo Kim416d8322015-10-12 16:55:43 +0900367 strWID.type = WID_INT;
Leo Kim900bb4a2015-10-12 16:55:46 +0900368 strWID.val = (s8 *)&(pstrHostIfSetDrvHandler->u32Address);
Leo Kim2fd3e442015-10-12 16:55:45 +0900369 strWID.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900370
Tony Cho03362282015-10-12 16:55:39 +0900371 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Chaehyun Limcf32c3c2015-09-22 22:47:38 +0900372 pstrHostIfSetDrvHandler->u32Address);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900373
Tony Choa4ab1ad2015-10-12 16:56:05 +0900374 if (!hif_drv)
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200375 up(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900376
377
378 if (s32Error) {
379 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900380 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900381 }
382
383 return s32Error;
384}
385
Tony Choa4ab1ad2015-10-12 16:56:05 +0900386static s32 Handle_SetOperationMode(struct host_if_drv *hif_drv,
Tony Cho801bee52015-09-21 12:16:53 +0900387 struct op_mode *pstrHostIfSetOperationMode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900388{
389
Leo Kime6e12662015-09-16 18:36:03 +0900390 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900391 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900392
Leo Kimdaaf16b2015-10-12 16:55:44 +0900393 strWID.id = (u16)WID_SET_OPERATION_MODE;
Leo Kim416d8322015-10-12 16:55:43 +0900394 strWID.type = WID_INT;
Leo Kim900bb4a2015-10-12 16:55:46 +0900395 strWID.val = (s8 *)&(pstrHostIfSetOperationMode->u32Mode);
Leo Kim2fd3e442015-10-12 16:55:45 +0900396 strWID.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900397
Tony Cho03362282015-10-12 16:55:39 +0900398 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +0900399 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900400
401
Johnny Kimc590b9a2015-09-08 17:07:59 +0900402 if ((pstrHostIfSetOperationMode->u32Mode) == IDLE_MODE)
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200403 up(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900404
405
406 if (s32Error) {
407 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900408 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900409 }
410
411 return s32Error;
412}
413
Tony Choa4ab1ad2015-10-12 16:56:05 +0900414s32 Handle_set_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900415{
416
Leo Kime6e12662015-09-16 18:36:03 +0900417 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900418 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900419 char firmwareIPAddress[4] = {0};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900420
421 if (pu8IPAddr[0] < 192)
422 pu8IPAddr[0] = 0;
423
Luis de Bethencourtb3a02832015-06-26 17:40:25 +0200424 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900425
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900426 memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900427
Leo Kimdaaf16b2015-10-12 16:55:44 +0900428 strWID.id = (u16)WID_IP_ADDRESS;
Leo Kim416d8322015-10-12 16:55:43 +0900429 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +0900430 strWID.val = (u8 *)pu8IPAddr;
Leo Kim2fd3e442015-10-12 16:55:45 +0900431 strWID.size = IP_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900432
Tony Cho03362282015-10-12 16:55:39 +0900433 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +0900434 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900435
436
Tony Choa4ab1ad2015-10-12 16:56:05 +0900437 host_int_get_ipaddress(hif_drv, firmwareIPAddress, idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900438
439 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +0900440 PRINT_ER("Failed to set IP address\n");
441 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900442 }
443
Leo Kim24db7132015-09-16 18:36:01 +0900444 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900445
446 return s32Error;
447}
448
Tony Choa4ab1ad2015-10-12 16:56:05 +0900449s32 Handle_get_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900450{
451
Leo Kime6e12662015-09-16 18:36:03 +0900452 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900453 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900454
Leo Kimdaaf16b2015-10-12 16:55:44 +0900455 strWID.id = (u16)WID_IP_ADDRESS;
Leo Kim416d8322015-10-12 16:55:43 +0900456 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +0900457 strWID.val = kmalloc(IP_ALEN, GFP_KERNEL);
Leo Kim2fd3e442015-10-12 16:55:45 +0900458 strWID.size = IP_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900459
Tony Cho03362282015-10-12 16:55:39 +0900460 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +0900461 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900462
Leo Kim900bb4a2015-10-12 16:55:46 +0900463 PRINT_INFO(HOSTINF_DBG, "%pI4\n", strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900464
Leo Kim900bb4a2015-10-12 16:55:46 +0900465 memcpy(gs8GetIP[idx], strWID.val, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900466
Leo Kim900bb4a2015-10-12 16:55:46 +0900467 kfree(strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900468
Chaehyun Lim1a646e72015-08-07 09:02:03 +0900469 if (memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
Tony Choa4ab1ad2015-10-12 16:56:05 +0900470 host_int_setup_ipaddress(hif_drv, gs8SetIP[idx], idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900471
Leo Kime6e12662015-09-16 18:36:03 +0900472 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900473 PRINT_ER("Failed to get IP address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900474 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900475 }
476
Leo Kim24db7132015-09-16 18:36:01 +0900477 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
478 PRINT_INFO(HOSTINF_DBG, "%pI4\n", gs8GetIP[idx]);
479 PRINT_INFO(HOSTINF_DBG, "\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900480
481 return s32Error;
482}
483
Tony Choa4ab1ad2015-10-12 16:56:05 +0900484static s32 Handle_SetMacAddress(struct host_if_drv *hif_drv,
Tony Chob7611a82015-09-21 12:16:54 +0900485 struct set_mac_addr *pstrHostIfSetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900486{
487
Leo Kime6e12662015-09-16 18:36:03 +0900488 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900489 struct wid strWID;
Glen Leef3052582015-09-10 12:03:04 +0900490 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +0200491
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900492 if (mac_buf == NULL) {
493 PRINT_ER("No buffer to send mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +0900494 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900495 }
Chaehyun Limd00d2ba2015-08-10 11:33:19 +0900496 memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900497
Leo Kimdaaf16b2015-10-12 16:55:44 +0900498 strWID.id = (u16)WID_MAC_ADDR;
Leo Kim416d8322015-10-12 16:55:43 +0900499 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +0900500 strWID.val = mac_buf;
Leo Kim2fd3e442015-10-12 16:55:45 +0900501 strWID.size = ETH_ALEN;
Leo Kim900bb4a2015-10-12 16:55:46 +0900502 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", strWID.val);
Leo Kimae4dfa52015-10-13 19:49:26 +0900503
Tony Cho03362282015-10-12 16:55:39 +0900504 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +0900505 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900506 if (s32Error) {
507 PRINT_ER("Failed to set mac address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900508 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900509 }
510
Chaehyun Lim49188af2015-08-11 10:32:41 +0900511 kfree(mac_buf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900512 return s32Error;
513}
514
Tony Choa4ab1ad2015-10-12 16:56:05 +0900515static s32 Handle_GetMacAddress(struct host_if_drv *hif_drv,
Tony Chofcd27c52015-09-21 12:16:55 +0900516 struct get_mac_addr *pstrHostIfGetMacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900517{
518
Leo Kime6e12662015-09-16 18:36:03 +0900519 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900520 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900521
Leo Kimdaaf16b2015-10-12 16:55:44 +0900522 strWID.id = (u16)WID_MAC_ADDR;
Leo Kim416d8322015-10-12 16:55:43 +0900523 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +0900524 strWID.val = pstrHostIfGetMacAddress->u8MacAddress;
Leo Kim2fd3e442015-10-12 16:55:45 +0900525 strWID.size = ETH_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900526
Tony Cho03362282015-10-12 16:55:39 +0900527 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +0900528 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900529 if (s32Error) {
530 PRINT_ER("Failed to get mac address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900531 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900532 }
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200533 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900534
535 return s32Error;
536}
537
Tony Choa4ab1ad2015-10-12 16:56:05 +0900538static s32 Handle_CfgParam(struct host_if_drv *hif_drv,
Tony Cho361ff842015-09-21 12:16:41 +0900539 struct cfg_param_attr *strHostIFCfgParamAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900540{
Leo Kime6e12662015-09-16 18:36:03 +0900541 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900542 struct wid strWIDList[32];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900543 u8 u8WidCnt = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900544
Tony Choa4ab1ad2015-10-12 16:56:05 +0900545 down(&hif_drv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900546
547
548 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
549
Tony Cho87c05b22015-10-12 16:56:07 +0900550 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BSS_TYPE) {
Tony Cho221371e2015-10-12 16:56:06 +0900551 if (strHostIFCfgParamAttr->cfg_attr_info.bss_type < 6) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900552 strWIDList[u8WidCnt].id = WID_BSS_TYPE;
Tony Cho221371e2015-10-12 16:56:06 +0900553 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.bss_type;
Leo Kim416d8322015-10-12 16:55:43 +0900554 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900555 strWIDList[u8WidCnt].size = sizeof(char);
Tony Cho221371e2015-10-12 16:56:06 +0900556 hif_drv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900557 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900558 PRINT_ER("check value 6 over\n");
559 s32Error = -EINVAL;
560 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900561 }
562 u8WidCnt++;
563 }
Tony Cho87c05b22015-10-12 16:56:07 +0900564 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTH_TYPE) {
Tony Cho221371e2015-10-12 16:56:06 +0900565 if ((strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 1 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 2 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 5) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900566 strWIDList[u8WidCnt].id = WID_AUTH_TYPE;
Tony Cho221371e2015-10-12 16:56:06 +0900567 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_type;
Leo Kim416d8322015-10-12 16:55:43 +0900568 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900569 strWIDList[u8WidCnt].size = sizeof(char);
Tony Cho221371e2015-10-12 16:56:06 +0900570 hif_drv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900571 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900572 PRINT_ER("Impossible value \n");
573 s32Error = -EINVAL;
574 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900575 }
576 u8WidCnt++;
577 }
Tony Cho87c05b22015-10-12 16:56:07 +0900578 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTHEN_TIMEOUT) {
Tony Cho221371e2015-10-12 16:56:06 +0900579 if (strHostIFCfgParamAttr->cfg_attr_info.auth_timeout > 0 && strHostIFCfgParamAttr->cfg_attr_info.auth_timeout < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900580 strWIDList[u8WidCnt].id = WID_AUTH_TIMEOUT;
Tony Cho221371e2015-10-12 16:56:06 +0900581 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
Leo Kim416d8322015-10-12 16:55:43 +0900582 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900583 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +0900584 hif_drv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900585 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900586 PRINT_ER("Range(1 ~ 65535) over\n");
587 s32Error = -EINVAL;
588 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900589 }
590 u8WidCnt++;
591 }
Tony Cho87c05b22015-10-12 16:56:07 +0900592 if (strHostIFCfgParamAttr->cfg_attr_info.flag & POWER_MANAGEMENT) {
Tony Cho221371e2015-10-12 16:56:06 +0900593 if (strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode < 5) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900594 strWIDList[u8WidCnt].id = WID_POWER_MANAGEMENT;
Tony Cho221371e2015-10-12 16:56:06 +0900595 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
Leo Kim416d8322015-10-12 16:55:43 +0900596 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900597 strWIDList[u8WidCnt].size = sizeof(char);
Tony Cho221371e2015-10-12 16:56:06 +0900598 hif_drv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900599 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900600 PRINT_ER("Invalide power mode\n");
601 s32Error = -EINVAL;
602 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900603 }
604 u8WidCnt++;
605 }
Tony Cho87c05b22015-10-12 16:56:07 +0900606 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_SHORT) {
Tony Cho221371e2015-10-12 16:56:06 +0900607 if ((strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit < 256)) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900608 strWIDList[u8WidCnt].id = WID_SHORT_RETRY_LIMIT;
Tony Cho221371e2015-10-12 16:56:06 +0900609 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
Leo Kim416d8322015-10-12 16:55:43 +0900610 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900611 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +0900612 hif_drv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900613 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900614 PRINT_ER("Range(1~256) over\n");
615 s32Error = -EINVAL;
616 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900617 }
618 u8WidCnt++;
619 }
Tony Cho87c05b22015-10-12 16:56:07 +0900620 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_LONG) {
Tony Cho221371e2015-10-12 16:56:06 +0900621 if ((strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit < 256)) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900622 strWIDList[u8WidCnt].id = WID_LONG_RETRY_LIMIT;
Tony Cho221371e2015-10-12 16:56:06 +0900623 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900624
Leo Kim416d8322015-10-12 16:55:43 +0900625 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900626 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +0900627 hif_drv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900628 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900629 PRINT_ER("Range(1~256) over\n");
630 s32Error = -EINVAL;
631 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900632 }
633 u8WidCnt++;
634 }
Tony Cho87c05b22015-10-12 16:56:07 +0900635 if (strHostIFCfgParamAttr->cfg_attr_info.flag & FRAG_THRESHOLD) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900636
Tony Cho221371e2015-10-12 16:56:06 +0900637 if (strHostIFCfgParamAttr->cfg_attr_info.frag_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.frag_threshold < 7937) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900638 strWIDList[u8WidCnt].id = WID_FRAG_THRESHOLD;
Tony Cho221371e2015-10-12 16:56:06 +0900639 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
Leo Kim416d8322015-10-12 16:55:43 +0900640 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900641 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +0900642 hif_drv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900643 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900644 PRINT_ER("Threshold Range fail\n");
645 s32Error = -EINVAL;
646 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900647 }
648 u8WidCnt++;
649 }
Tony Cho87c05b22015-10-12 16:56:07 +0900650 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RTS_THRESHOLD) {
Tony Cho221371e2015-10-12 16:56:06 +0900651 if (strHostIFCfgParamAttr->cfg_attr_info.rts_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.rts_threshold < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900652 strWIDList[u8WidCnt].id = WID_RTS_THRESHOLD;
Tony Cho221371e2015-10-12 16:56:06 +0900653 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
Leo Kim416d8322015-10-12 16:55:43 +0900654 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900655 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +0900656 hif_drv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900657 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900658 PRINT_ER("Threshold Range fail\n");
659 s32Error = -EINVAL;
660 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900661 }
662 u8WidCnt++;
663 }
Tony Cho87c05b22015-10-12 16:56:07 +0900664 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PREAMBLE) {
Tony Cho221371e2015-10-12 16:56:06 +0900665 if (strHostIFCfgParamAttr->cfg_attr_info.preamble_type < 3) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900666 strWIDList[u8WidCnt].id = WID_PREAMBLE;
Tony Cho221371e2015-10-12 16:56:06 +0900667 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
Leo Kim416d8322015-10-12 16:55:43 +0900668 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900669 strWIDList[u8WidCnt].size = sizeof(char);
Tony Cho221371e2015-10-12 16:56:06 +0900670 hif_drv->strCfgValues.preamble_type = strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900671 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900672 PRINT_ER("Preamle Range(0~2) over\n");
673 s32Error = -EINVAL;
674 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900675 }
676 u8WidCnt++;
677 }
Tony Cho87c05b22015-10-12 16:56:07 +0900678 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SHORT_SLOT_ALLOWED) {
Tony Cho221371e2015-10-12 16:56:06 +0900679 if (strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed < 2) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900680 strWIDList[u8WidCnt].id = WID_SHORT_SLOT_ALLOWED;
Tony Cho221371e2015-10-12 16:56:06 +0900681 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
Leo Kim416d8322015-10-12 16:55:43 +0900682 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900683 strWIDList[u8WidCnt].size = sizeof(char);
Tony Cho221371e2015-10-12 16:56:06 +0900684 hif_drv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900685 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900686 PRINT_ER("Short slot(2) over\n");
687 s32Error = -EINVAL;
688 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900689 }
690 u8WidCnt++;
691 }
Tony Cho87c05b22015-10-12 16:56:07 +0900692 if (strHostIFCfgParamAttr->cfg_attr_info.flag & TXOP_PROT_DISABLE) {
Tony Cho221371e2015-10-12 16:56:06 +0900693 if (strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled < 2) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900694 strWIDList[u8WidCnt].id = WID_11N_TXOP_PROT_DISABLE;
Tony Cho221371e2015-10-12 16:56:06 +0900695 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
Leo Kim416d8322015-10-12 16:55:43 +0900696 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900697 strWIDList[u8WidCnt].size = sizeof(char);
Tony Cho221371e2015-10-12 16:56:06 +0900698 hif_drv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900699 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900700 PRINT_ER("TXOP prot disable\n");
701 s32Error = -EINVAL;
702 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900703 }
704 u8WidCnt++;
705 }
Tony Cho87c05b22015-10-12 16:56:07 +0900706 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BEACON_INTERVAL) {
Tony Cho221371e2015-10-12 16:56:06 +0900707 if (strHostIFCfgParamAttr->cfg_attr_info.beacon_interval > 0 && strHostIFCfgParamAttr->cfg_attr_info.beacon_interval < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900708 strWIDList[u8WidCnt].id = WID_BEACON_INTERVAL;
Tony Cho221371e2015-10-12 16:56:06 +0900709 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
Leo Kim416d8322015-10-12 16:55:43 +0900710 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900711 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +0900712 hif_drv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900713 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900714 PRINT_ER("Beacon interval(1~65535) fail\n");
715 s32Error = -EINVAL;
716 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900717 }
718 u8WidCnt++;
719 }
Tony Cho87c05b22015-10-12 16:56:07 +0900720 if (strHostIFCfgParamAttr->cfg_attr_info.flag & DTIM_PERIOD) {
Tony Cho221371e2015-10-12 16:56:06 +0900721 if (strHostIFCfgParamAttr->cfg_attr_info.dtim_period > 0 && strHostIFCfgParamAttr->cfg_attr_info.dtim_period < 256) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900722 strWIDList[u8WidCnt].id = WID_DTIM_PERIOD;
Tony Cho221371e2015-10-12 16:56:06 +0900723 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
Leo Kim416d8322015-10-12 16:55:43 +0900724 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900725 strWIDList[u8WidCnt].size = sizeof(char);
Tony Cho221371e2015-10-12 16:56:06 +0900726 hif_drv->strCfgValues.dtim_period = strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900727 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900728 PRINT_ER("DTIM range(1~255) fail\n");
729 s32Error = -EINVAL;
730 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900731 }
732 u8WidCnt++;
733 }
Tony Cho87c05b22015-10-12 16:56:07 +0900734 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY) {
Tony Cho221371e2015-10-12 16:56:06 +0900735 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled < 3) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900736 strWIDList[u8WidCnt].id = WID_SITE_SURVEY;
Tony Cho221371e2015-10-12 16:56:06 +0900737 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
Leo Kim416d8322015-10-12 16:55:43 +0900738 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900739 strWIDList[u8WidCnt].size = sizeof(char);
Tony Cho221371e2015-10-12 16:56:06 +0900740 hif_drv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900741 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900742 PRINT_ER("Site survey disable\n");
743 s32Error = -EINVAL;
744 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900745 }
746 u8WidCnt++;
747 }
Tony Cho87c05b22015-10-12 16:56:07 +0900748 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) {
Tony Cho221371e2015-10-12 16:56:06 +0900749 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900750 strWIDList[u8WidCnt].id = WID_SITE_SURVEY_SCAN_TIME;
Tony Cho221371e2015-10-12 16:56:06 +0900751 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
Leo Kim416d8322015-10-12 16:55:43 +0900752 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900753 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +0900754 hif_drv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900755 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900756 PRINT_ER("Site survey scan time(1~65535) over\n");
757 s32Error = -EINVAL;
758 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900759 }
760 u8WidCnt++;
761 }
Tony Cho87c05b22015-10-12 16:56:07 +0900762 if (strHostIFCfgParamAttr->cfg_attr_info.flag & ACTIVE_SCANTIME) {
Tony Cho221371e2015-10-12 16:56:06 +0900763 if (strHostIFCfgParamAttr->cfg_attr_info.active_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.active_scan_time < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900764 strWIDList[u8WidCnt].id = WID_ACTIVE_SCAN_TIME;
Tony Cho221371e2015-10-12 16:56:06 +0900765 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
Leo Kim416d8322015-10-12 16:55:43 +0900766 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900767 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +0900768 hif_drv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900769 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900770 PRINT_ER("Active scan time(1~65535) over\n");
771 s32Error = -EINVAL;
772 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900773 }
774 u8WidCnt++;
775 }
Tony Cho87c05b22015-10-12 16:56:07 +0900776 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PASSIVE_SCANTIME) {
Tony Cho221371e2015-10-12 16:56:06 +0900777 if (strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900778 strWIDList[u8WidCnt].id = WID_PASSIVE_SCAN_TIME;
Tony Cho221371e2015-10-12 16:56:06 +0900779 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
Leo Kim416d8322015-10-12 16:55:43 +0900780 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900781 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Cho221371e2015-10-12 16:56:06 +0900782 hif_drv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900783 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900784 PRINT_ER("Passive scan time(1~65535) over\n");
785 s32Error = -EINVAL;
786 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900787 }
788 u8WidCnt++;
789 }
Tony Cho87c05b22015-10-12 16:56:07 +0900790 if (strHostIFCfgParamAttr->cfg_attr_info.flag & CURRENT_TX_RATE) {
Tony Cho221371e2015-10-12 16:56:06 +0900791 enum CURRENT_TXRATE curr_tx_rate = strHostIFCfgParamAttr->cfg_attr_info.curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900792 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
793 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
794 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
795 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
796 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
797 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900798 strWIDList[u8WidCnt].id = WID_CURRENT_TX_RATE;
Leo Kim900bb4a2015-10-12 16:55:46 +0900799 strWIDList[u8WidCnt].val = (s8 *)&curr_tx_rate;
Leo Kim416d8322015-10-12 16:55:43 +0900800 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900801 strWIDList[u8WidCnt].size = sizeof(u16);
Tony Choa4ab1ad2015-10-12 16:56:05 +0900802 hif_drv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900803 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900804 PRINT_ER("out of TX rate\n");
805 s32Error = -EINVAL;
806 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900807 }
808 u8WidCnt++;
809 }
Tony Cho03362282015-10-12 16:55:39 +0900810 s32Error = send_config_pkt(SET_CFG, strWIDList, u8WidCnt,
Tony Choa4ab1ad2015-10-12 16:56:05 +0900811 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900812
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +0200813 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900814 PRINT_ER("Error in setting CFG params\n");
815
Leo Kim24db7132015-09-16 18:36:01 +0900816ERRORHANDLER:
Tony Choa4ab1ad2015-10-12 16:56:05 +0900817 up(&hif_drv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900818 return s32Error;
819}
820
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900821static s32 Handle_wait_msg_q_empty(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900822{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900823 g_wilc_initialized = 0;
Arnd Bergmann83383ea2015-06-01 21:06:43 +0200824 up(&hWaitResponse);
Leo Kimb68d820b2015-10-12 16:55:37 +0900825 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900826}
827
Tony Choa4ab1ad2015-10-12 16:56:05 +0900828static s32 Handle_Scan(struct host_if_drv *hif_drv,
Tony Choc476feb2015-09-21 12:16:36 +0900829 struct scan_attr *pstrHostIFscanAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900830{
Leo Kime6e12662015-09-16 18:36:03 +0900831 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900832 struct wid strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900833 u32 u32WidsCount = 0;
834 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900835 u8 *pu8Buffer;
836 u8 valuesize = 0;
837 u8 *pu8HdnNtwrksWidVal = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900838
839 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +0900840 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", hif_drv->enuHostIFstate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900841
Leo Kimc17c6da2015-10-13 19:49:44 +0900842 hif_drv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->result;
Leo Kim5f2b50c2015-10-13 19:49:45 +0900843 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900844
Tony Choa4ab1ad2015-10-12 16:56:05 +0900845 if ((hif_drv->enuHostIFstate >= HOST_IF_SCANNING) && (hif_drv->enuHostIFstate < HOST_IF_CONNECTED)) {
Tony Choa4ab1ad2015-10-12 16:56:05 +0900846 PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", hif_drv->enuHostIFstate);
Leo Kim24db7132015-09-16 18:36:01 +0900847 PRINT_ER("Already scan\n");
848 s32Error = -EBUSY;
849 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900850 }
851
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900852 if (g_obtainingIP || connecting) {
853 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +0900854 PRINT_ER("Don't do obss scan\n");
855 s32Error = -EBUSY;
856 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900857 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900858
859 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
860
861
Tony Choa4ab1ad2015-10-12 16:56:05 +0900862 hif_drv->strWILC_UsrScanReq.u32RcvdChCount = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900863
Leo Kimdaaf16b2015-10-12 16:55:44 +0900864 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
Leo Kim416d8322015-10-12 16:55:43 +0900865 strWIDList[u32WidsCount].type = WID_STR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900866
Leo Kim629b9ca2015-10-13 19:49:46 +0900867 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++)
868 valuesize += ((pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
Glen Leef3052582015-09-10 12:03:04 +0900869 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
Leo Kim900bb4a2015-10-12 16:55:46 +0900870 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
871 if (strWIDList[u32WidsCount].val != NULL) {
872 pu8Buffer = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900873
Leo Kim629b9ca2015-10-13 19:49:46 +0900874 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900875
Leo Kim629b9ca2015-10-13 19:49:46 +0900876 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->hidden_network.u8ssidnum);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900877
Leo Kim629b9ca2015-10-13 19:49:46 +0900878 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++) {
879 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
880 memcpy(pu8Buffer, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen);
881 pu8Buffer += pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900882 }
883
884
885
Leo Kim2fd3e442015-10-12 16:55:45 +0900886 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900887 u32WidsCount++;
888 }
889
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900890 {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900891 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
Leo Kim416d8322015-10-12 16:55:43 +0900892 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kimd6f19aa2015-10-13 19:49:42 +0900893 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ies;
Leo Kim7b1f76c2015-10-13 19:49:43 +0900894 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ies_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900895 u32WidsCount++;
896 }
897
Leo Kimdaaf16b2015-10-12 16:55:44 +0900898 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +0900899 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900900 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim1e276c82015-10-13 19:49:38 +0900901 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->type));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900902 u32WidsCount++;
903
Leo Kimdaaf16b2015-10-12 16:55:44 +0900904 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
Leo Kim416d8322015-10-12 16:55:43 +0900905 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900906
Leo Kimf97bd9c2015-10-13 19:49:41 +0900907 if (pstrHostIFscanAttr->ch_freq_list != NULL && pstrHostIFscanAttr->ch_list_len > 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900908 int i;
909
Leo Kimf97bd9c2015-10-13 19:49:41 +0900910 for (i = 0; i < pstrHostIFscanAttr->ch_list_len; i++) {
Leo Kim82eeb0a2015-10-13 19:49:40 +0900911 if (pstrHostIFscanAttr->ch_freq_list[i] > 0)
912 pstrHostIFscanAttr->ch_freq_list[i] = pstrHostIFscanAttr->ch_freq_list[i] - 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900913 }
914 }
915
Leo Kim82eeb0a2015-10-13 19:49:40 +0900916 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
Leo Kimf97bd9c2015-10-13 19:49:41 +0900917 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900918 u32WidsCount++;
919
Leo Kimdaaf16b2015-10-12 16:55:44 +0900920 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
Leo Kim416d8322015-10-12 16:55:43 +0900921 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900922 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim42568892015-10-13 19:49:37 +0900923 strWIDList[u32WidsCount].val = (s8 *)(&(pstrHostIFscanAttr->src));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900924 u32WidsCount++;
925
Tony Choa4ab1ad2015-10-12 16:56:05 +0900926 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
Dean Lee72ed4dc2015-06-12 14:11:44 +0900927 gbScanWhileConnected = true;
Tony Choa4ab1ad2015-10-12 16:56:05 +0900928 else if (hif_drv->enuHostIFstate == HOST_IF_IDLE)
Dean Lee72ed4dc2015-06-12 14:11:44 +0900929 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900930
Tony Cho03362282015-10-12 16:55:39 +0900931 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
Tony Choa4ab1ad2015-10-12 16:56:05 +0900932 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900933
Leo Kim24db7132015-09-16 18:36:01 +0900934 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900935 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +0900936 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900937 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900938
Leo Kim24db7132015-09-16 18:36:01 +0900939ERRORHANDLER:
940 if (s32Error) {
Tony Choa4ab1ad2015-10-12 16:56:05 +0900941 del_timer(&hif_drv->hScanTimer);
Tony Choa4ab1ad2015-10-12 16:56:05 +0900942 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900943 }
944
Leo Kim82eeb0a2015-10-13 19:49:40 +0900945 if (pstrHostIFscanAttr->ch_freq_list != NULL) {
946 kfree(pstrHostIFscanAttr->ch_freq_list);
947 pstrHostIFscanAttr->ch_freq_list = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900948 }
949
Leo Kimd6f19aa2015-10-13 19:49:42 +0900950 if (pstrHostIFscanAttr->ies != NULL) {
951 kfree(pstrHostIFscanAttr->ies);
952 pstrHostIFscanAttr->ies = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900953 }
Leo Kim629b9ca2015-10-13 19:49:46 +0900954 if (pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo != NULL) {
955 kfree(pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo);
956 pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900957 }
958
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +0200959 if (pu8HdnNtwrksWidVal != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +0900960 kfree(pu8HdnNtwrksWidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900961
962 return s32Error;
963}
964
Tony Choa4ab1ad2015-10-12 16:56:05 +0900965static s32 Handle_ScanDone(struct host_if_drv *hif_drv,
966 enum scan_event enuEvent)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900967{
Leo Kime6e12662015-09-16 18:36:03 +0900968 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900969 u8 u8abort_running_scan;
Leo Kime9e0c262015-10-12 16:55:41 +0900970 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900971
972
973 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
974
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900975 if (enuEvent == SCAN_EVENT_ABORTED) {
976 PRINT_D(GENERIC_DBG, "Abort running scan\n");
977 u8abort_running_scan = 1;
Leo Kimdaaf16b2015-10-12 16:55:44 +0900978 strWID.id = (u16)WID_ABORT_RUNNING_SCAN;
Leo Kim416d8322015-10-12 16:55:43 +0900979 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +0900980 strWID.val = (s8 *)&u8abort_running_scan;
Leo Kim2fd3e442015-10-12 16:55:45 +0900981 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900982
Tony Cho03362282015-10-12 16:55:39 +0900983 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +0900984 get_id_from_handler(hif_drv));
Leo Kim24db7132015-09-16 18:36:01 +0900985 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900986 PRINT_ER("Failed to set abort running scan\n");
Leo Kim24db7132015-09-16 18:36:01 +0900987 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900988 }
989 }
990
Tony Choa4ab1ad2015-10-12 16:56:05 +0900991 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900992 PRINT_ER("Driver handler is NULL\n");
993 return s32Error;
994 }
995
Tony Choa4ab1ad2015-10-12 16:56:05 +0900996 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
997 hif_drv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
998 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
Tony Choa4ab1ad2015-10-12 16:56:05 +0900999 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001000 }
1001
1002 return s32Error;
1003}
1004
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001005u8 u8ConnectedSSID[6] = {0};
Tony Choa4ab1ad2015-10-12 16:56:05 +09001006static s32 Handle_Connect(struct host_if_drv *hif_drv,
Tony Cho120ae592015-09-21 12:16:37 +09001007 struct connect_attr *pstrHostIFconnectAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001008{
Leo Kime6e12662015-09-16 18:36:03 +09001009 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09001010 struct wid strWIDList[8];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001011 u32 u32WidsCount = 0, dummyval = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001012 u8 *pu8CurrByte = NULL;
Leo Kime0a12212015-10-12 16:55:49 +09001013 struct join_bss_param *ptstrJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001014
1015 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1016
Leo Kim9254db02015-10-13 19:49:49 +09001017 if (memcmp(pstrHostIFconnectAttr->bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001018
Leo Kime6e12662015-09-16 18:36:03 +09001019 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001020 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
1021 return s32Error;
1022 }
1023
1024 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1025
Leo Kimf2bed2c2015-10-13 19:49:59 +09001026 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->params;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001027 if (ptstrJoinBssParam == NULL) {
1028 PRINT_ER("Required BSSID not found\n");
Leo Kim24db7132015-09-16 18:36:01 +09001029 s32Error = -ENOENT;
1030 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001031 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001032
Leo Kim9254db02015-10-13 19:49:49 +09001033 if (pstrHostIFconnectAttr->bssid != NULL) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09001034 hif_drv->strWILC_UsrConnReq.pu8bssid = kmalloc(6, GFP_KERNEL);
Leo Kim9254db02015-10-13 19:49:49 +09001035 memcpy(hif_drv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001036 }
1037
Leo Kim8b3c9fa2015-10-13 19:49:51 +09001038 hif_drv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssid_len;
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001039 if (pstrHostIFconnectAttr->ssid != NULL) {
Leo Kim8b3c9fa2015-10-13 19:49:51 +09001040 hif_drv->strWILC_UsrConnReq.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001041 memcpy(hif_drv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->ssid,
Leo Kim8b3c9fa2015-10-13 19:49:51 +09001042 pstrHostIFconnectAttr->ssid_len);
1043 hif_drv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001044 }
1045
Leo Kimb59d5c52015-10-13 19:49:53 +09001046 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->ies_len;
Leo Kim2ea158c2015-10-13 19:49:52 +09001047 if (pstrHostIFconnectAttr->ies != NULL) {
Leo Kimb59d5c52015-10-13 19:49:53 +09001048 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
Leo Kim2ea158c2015-10-13 19:49:52 +09001049 memcpy(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->ies,
Leo Kimb59d5c52015-10-13 19:49:53 +09001050 pstrHostIFconnectAttr->ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001051 }
1052
Leo Kima64fd672015-10-13 19:49:54 +09001053 hif_drv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->security;
Leo Kim61b4fd02015-10-13 19:49:57 +09001054 hif_drv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->auth_type;
Leo Kim6abcc112015-10-13 19:49:55 +09001055 hif_drv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->result;
Leo Kim8f38db82015-10-13 19:49:56 +09001056 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001057
Leo Kimdaaf16b2015-10-12 16:55:44 +09001058 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001059 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001060 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001061 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001062 u32WidsCount++;
1063
Leo Kimdaaf16b2015-10-12 16:55:44 +09001064 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001065 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001066 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001067 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001068 u32WidsCount++;
1069
Leo Kimdaaf16b2015-10-12 16:55:44 +09001070 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001071 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001072 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001073 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001074 u32WidsCount++;
1075
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001076 {
Leo Kimdaaf16b2015-10-12 16:55:44 +09001077 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
Leo Kim416d8322015-10-12 16:55:43 +09001078 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Tony Choa4ab1ad2015-10-12 16:56:05 +09001079 strWIDList[u32WidsCount].val = hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs;
1080 strWIDList[u32WidsCount].size = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001081 u32WidsCount++;
1082
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001083 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001084
Tony Choa4ab1ad2015-10-12 16:56:05 +09001085 gu32FlushedInfoElemAsocSize = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001086 gu8FlushedInfoElemAsoc = kmalloc(gu32FlushedInfoElemAsocSize, GFP_KERNEL);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001087 memcpy(gu8FlushedInfoElemAsoc, hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001088 gu32FlushedInfoElemAsocSize);
1089 }
1090 }
Leo Kimdaaf16b2015-10-12 16:55:44 +09001091 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001092 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001093 strWIDList[u32WidsCount].size = sizeof(char);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001094 strWIDList[u32WidsCount].val = (s8 *)(&(hif_drv->strWILC_UsrConnReq.u8security));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001095 u32WidsCount++;
1096
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001097 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
Tony Choa4ab1ad2015-10-12 16:56:05 +09001098 gu8Flushed11iMode = hif_drv->strWILC_UsrConnReq.u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001099
Tony Choa4ab1ad2015-10-12 16:56:05 +09001100 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", hif_drv->strWILC_UsrConnReq.u8security);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001101
1102
Leo Kimdaaf16b2015-10-12 16:55:44 +09001103 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001104 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001105 strWIDList[u32WidsCount].size = sizeof(char);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001106 strWIDList[u32WidsCount].val = (s8 *)(&hif_drv->strWILC_UsrConnReq.tenuAuth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001107 u32WidsCount++;
1108
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001109 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
Tony Choa4ab1ad2015-10-12 16:56:05 +09001110 gu8FlushedAuthType = (u8)hif_drv->strWILC_UsrConnReq.tenuAuth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001111
Tony Choa4ab1ad2015-10-12 16:56:05 +09001112 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", hif_drv->strWILC_UsrConnReq.tenuAuth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001113 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
Leo Kim0d1527e2015-10-13 19:49:58 +09001114 hif_drv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001115
Leo Kimdaaf16b2015-10-12 16:55:44 +09001116 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
Leo Kim416d8322015-10-12 16:55:43 +09001117 strWIDList[u32WidsCount].type = WID_STR;
Leo Kimae4dfa52015-10-13 19:49:26 +09001118 strWIDList[u32WidsCount].size = 112;
Leo Kim900bb4a2015-10-12 16:55:46 +09001119 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001120
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001121 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Leo Kim2fd3e442015-10-12 16:55:45 +09001122 gu32FlushedJoinReqSize = strWIDList[u32WidsCount].size;
Glen Leef3052582015-09-10 12:03:04 +09001123 gu8FlushedJoinReq = kmalloc(gu32FlushedJoinReqSize, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001124 }
Leo Kim900bb4a2015-10-12 16:55:46 +09001125 if (strWIDList[u32WidsCount].val == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09001126 s32Error = -EFAULT;
1127 goto ERRORHANDLER;
1128 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001129
Leo Kim900bb4a2015-10-12 16:55:46 +09001130 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001131
1132
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001133 if (pstrHostIFconnectAttr->ssid != NULL) {
Leo Kim8b3c9fa2015-10-13 19:49:51 +09001134 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1135 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001136 }
1137 pu8CurrByte += MAX_SSID_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001138 *(pu8CurrByte++) = INFRASTRUCTURE;
Leo Kimae4dfa52015-10-13 19:49:26 +09001139
Leo Kim0d1527e2015-10-13 19:49:58 +09001140 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1141 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001142 } else {
1143 PRINT_ER("Channel out of range\n");
1144 *(pu8CurrByte++) = 0xFF;
1145 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001146 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1147 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1148 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1149
Leo Kim9254db02015-10-13 19:49:49 +09001150 if (pstrHostIFconnectAttr->bssid != NULL)
1151 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001152 pu8CurrByte += 6;
1153
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001154 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1155 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1156 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001157 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1158 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
Leo Kimae4dfa52015-10-13 19:49:26 +09001159
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001160 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001161 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1162
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001163 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1164 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001165 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1166
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001167 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
Tony Choa4ab1ad2015-10-12 16:56:05 +09001168 hif_drv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001169
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001170 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1171 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001172 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1173 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001174 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1175 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
Leo Kimae4dfa52015-10-13 19:49:26 +09001176
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001177 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001178 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1179
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001180 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001181 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1182
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001183 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001184 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1185
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001186 *(pu8CurrByte++) = REAL_JOIN_REQ;
1187
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001188 *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
1189 if (ptstrJoinBssParam->u8NoaEnbaled) {
1190 PRINT_D(HOSTINF_DBG, "NOA present\n");
1191
1192 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1193 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1194 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1195 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1196
1197 *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
1198
1199 *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
1200
1201 if (ptstrJoinBssParam->u8OppEnable)
1202 *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
1203
1204 *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
1205
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001206 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001207
1208 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
1209
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001210 memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001211
1212 pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
1213
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001214 memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001215
1216 pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
1217
1218 } else
1219 PRINT_D(HOSTINF_DBG, "NOA not present\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001220
Leo Kim900bb4a2015-10-12 16:55:46 +09001221 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001222 u32WidsCount++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001223 gu32WidConnRstHack = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001224
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001225 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001226 memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001227 gu8FlushedJoinReqDrvHandler = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001228 }
1229
1230 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1231
Leo Kim9254db02015-10-13 19:49:49 +09001232 if (pstrHostIFconnectAttr->bssid != NULL) {
1233 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001234
Leo Kim9254db02015-10-13 19:49:49 +09001235 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->bssid);
Alexander Kuleshov310a28f2015-09-04 00:48:14 +06001236 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001237 }
1238
Tony Cho03362282015-10-12 16:55:39 +09001239 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001240 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001241 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09001242 PRINT_ER("failed to send config packet\n");
1243 s32Error = -EFAULT;
1244 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001245 } else {
1246 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09001247 hif_drv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001248 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001249
Leo Kim24db7132015-09-16 18:36:01 +09001250ERRORHANDLER:
1251 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001252 tstrConnectInfo strConnectInfo;
1253
Tony Choa4ab1ad2015-10-12 16:56:05 +09001254 del_timer(&hif_drv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001255
1256 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1257
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001258 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001259
Leo Kim6abcc112015-10-13 19:49:55 +09001260 if (pstrHostIFconnectAttr->result != NULL) {
Leo Kim9254db02015-10-13 19:49:49 +09001261 if (pstrHostIFconnectAttr->bssid != NULL)
1262 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001263
Leo Kim2ea158c2015-10-13 19:49:52 +09001264 if (pstrHostIFconnectAttr->ies != NULL) {
Leo Kimb59d5c52015-10-13 19:49:53 +09001265 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->ies_len;
1266 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001267 memcpy(strConnectInfo.pu8ReqIEs,
Leo Kim2ea158c2015-10-13 19:49:52 +09001268 pstrHostIFconnectAttr->ies,
Leo Kimb59d5c52015-10-13 19:49:53 +09001269 pstrHostIFconnectAttr->ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001270 }
1271
Leo Kim6abcc112015-10-13 19:49:55 +09001272 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001273 &strConnectInfo,
1274 MAC_DISCONNECTED,
1275 NULL,
Leo Kim8f38db82015-10-13 19:49:56 +09001276 pstrHostIFconnectAttr->arg);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001277 hif_drv->enuHostIFstate = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001278 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001279 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001280 strConnectInfo.pu8ReqIEs = NULL;
1281 }
1282
1283 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001284 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001285 }
1286 }
1287
1288 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
Leo Kim9254db02015-10-13 19:49:49 +09001289 if (pstrHostIFconnectAttr->bssid != NULL) {
1290 kfree(pstrHostIFconnectAttr->bssid);
1291 pstrHostIFconnectAttr->bssid = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001292 }
1293
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001294 if (pstrHostIFconnectAttr->ssid != NULL) {
1295 kfree(pstrHostIFconnectAttr->ssid);
1296 pstrHostIFconnectAttr->ssid = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001297 }
1298
Leo Kim2ea158c2015-10-13 19:49:52 +09001299 if (pstrHostIFconnectAttr->ies != NULL) {
1300 kfree(pstrHostIFconnectAttr->ies);
1301 pstrHostIFconnectAttr->ies = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001302 }
1303
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001304 if (pu8CurrByte != NULL)
Chaehyun Lim49188af2015-08-11 10:32:41 +09001305 kfree(pu8CurrByte);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001306 return s32Error;
1307}
1308
Tony Choa4ab1ad2015-10-12 16:56:05 +09001309static s32 Handle_FlushConnect(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001310{
Leo Kime6e12662015-09-16 18:36:03 +09001311 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09001312 struct wid strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001313 u32 u32WidsCount = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001314 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001315
Leo Kimdaaf16b2015-10-12 16:55:44 +09001316 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
Leo Kim416d8322015-10-12 16:55:43 +09001317 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kim900bb4a2015-10-12 16:55:46 +09001318 strWIDList[u32WidsCount].val = gu8FlushedInfoElemAsoc;
Leo Kim2fd3e442015-10-12 16:55:45 +09001319 strWIDList[u32WidsCount].size = gu32FlushedInfoElemAsocSize;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001320 u32WidsCount++;
1321
Leo Kimdaaf16b2015-10-12 16:55:44 +09001322 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001323 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001324 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim900bb4a2015-10-12 16:55:46 +09001325 strWIDList[u32WidsCount].val = (s8 *)(&(gu8Flushed11iMode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001326 u32WidsCount++;
1327
1328
1329
Leo Kimdaaf16b2015-10-12 16:55:44 +09001330 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001331 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001332 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim900bb4a2015-10-12 16:55:46 +09001333 strWIDList[u32WidsCount].val = (s8 *)(&gu8FlushedAuthType);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001334 u32WidsCount++;
1335
Leo Kimdaaf16b2015-10-12 16:55:44 +09001336 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
Leo Kim416d8322015-10-12 16:55:43 +09001337 strWIDList[u32WidsCount].type = WID_STR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001338 strWIDList[u32WidsCount].size = gu32FlushedJoinReqSize;
Leo Kim900bb4a2015-10-12 16:55:46 +09001339 strWIDList[u32WidsCount].val = (s8 *)gu8FlushedJoinReq;
1340 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001341
1342 pu8CurrByte += FLUSHED_BYTE_POS;
1343 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1344
1345 u32WidsCount++;
1346
Tony Cho03362282015-10-12 16:55:39 +09001347 s32Error = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
Chaehyun Limcf32c3c2015-09-22 22:47:38 +09001348 get_id_from_handler(gu8FlushedJoinReqDrvHandler));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001349 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09001350 PRINT_ER("failed to send config packet\n");
1351 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001352 }
1353
1354 return s32Error;
1355}
1356
Tony Choa4ab1ad2015-10-12 16:56:05 +09001357static s32 Handle_ConnectTimeout(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001358{
Leo Kime6e12662015-09-16 18:36:03 +09001359 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001360 tstrConnectInfo strConnectInfo;
Leo Kime9e0c262015-10-12 16:55:41 +09001361 struct wid strWID;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001362 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001363
Tony Choa4ab1ad2015-10-12 16:56:05 +09001364 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001365 PRINT_ER("Driver handler is NULL\n");
1366 return s32Error;
1367 }
1368
Tony Choa4ab1ad2015-10-12 16:56:05 +09001369 hif_drv->enuHostIFstate = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001370
Dean Lee72ed4dc2015-06-12 14:11:44 +09001371 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001372
1373
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001374 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001375
Tony Choa4ab1ad2015-10-12 16:56:05 +09001376 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
1377 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001378 memcpy(strConnectInfo.au8bssid,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001379 hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001380 }
1381
Tony Choa4ab1ad2015-10-12 16:56:05 +09001382 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1383 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1384 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001385 memcpy(strConnectInfo.pu8ReqIEs,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001386 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1387 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001388 }
1389
Tony Choa4ab1ad2015-10-12 16:56:05 +09001390 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001391 &strConnectInfo,
1392 MAC_DISCONNECTED,
1393 NULL,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001394 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001395
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001396 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001397 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001398 strConnectInfo.pu8ReqIEs = NULL;
1399 }
1400 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001401 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001402 }
1403
Leo Kimdaaf16b2015-10-12 16:55:44 +09001404 strWID.id = (u16)WID_DISCONNECT;
Leo Kim416d8322015-10-12 16:55:43 +09001405 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09001406 strWID.val = (s8 *)&u16DummyReasonCode;
Leo Kim2fd3e442015-10-12 16:55:45 +09001407 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001408
1409 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1410
Tony Cho03362282015-10-12 16:55:39 +09001411 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001412 get_id_from_handler(hif_drv));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02001413 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001414 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001415
Tony Choa4ab1ad2015-10-12 16:56:05 +09001416 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1417 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1418 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1419 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1420 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001421
Shraddha Barke281dd5a2015-10-05 17:00:33 +05301422 eth_zero_addr(u8ConnectedSSID);
Leo Kimae4dfa52015-10-13 19:49:26 +09001423
Tony Choa4ab1ad2015-10-12 16:56:05 +09001424 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001425 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001426 gu8FlushedJoinReq = NULL;
1427 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09001428 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001429 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001430 gu8FlushedInfoElemAsoc = NULL;
1431 }
1432
1433 return s32Error;
1434}
1435
Tony Choa4ab1ad2015-10-12 16:56:05 +09001436static s32 Handle_RcvdNtwrkInfo(struct host_if_drv *hif_drv,
Tony Cho3bbd59f2015-09-21 12:16:38 +09001437 struct rcvd_net_info *pstrRcvdNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001438{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001439 u32 i;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001440 bool bNewNtwrkFound;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001441
1442
1443
Leo Kime6e12662015-09-16 18:36:03 +09001444 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001445 tstrNetworkInfo *pstrNetworkInfo = NULL;
1446 void *pJoinParams = NULL;
1447
Dean Lee72ed4dc2015-06-12 14:11:44 +09001448 bNewNtwrkFound = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001449 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1450
Tony Choa4ab1ad2015-10-12 16:56:05 +09001451 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001452 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
Leo Kimb021b802015-10-13 20:02:10 +09001453 parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001454 if ((pstrNetworkInfo == NULL)
Tony Choa4ab1ad2015-10-12 16:56:05 +09001455 || (hif_drv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
Leo Kim24db7132015-09-16 18:36:01 +09001456 PRINT_ER("driver is null\n");
1457 s32Error = -EINVAL;
1458 goto done;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001459 }
1460
Tony Choa4ab1ad2015-10-12 16:56:05 +09001461 for (i = 0; i < hif_drv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001462
Tony Choa4ab1ad2015-10-12 16:56:05 +09001463 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001464 (pstrNetworkInfo->au8bssid != NULL)) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09001465 if (memcmp(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001466 pstrNetworkInfo->au8bssid, 6) == 0) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09001467 if (pstrNetworkInfo->s8rssi <= hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001468 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
1469 goto done;
1470 } else {
Tony Choa4ab1ad2015-10-12 16:56:05 +09001471 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001472 bNewNtwrkFound = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001473 break;
1474 }
1475 }
1476 }
1477 }
1478
Dean Lee72ed4dc2015-06-12 14:11:44 +09001479 if (bNewNtwrkFound == true) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001480 PRINT_D(HOSTINF_DBG, "New network found\n");
1481
Tony Choa4ab1ad2015-10-12 16:56:05 +09001482 if (hif_drv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
1483 hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001484
Tony Choa4ab1ad2015-10-12 16:56:05 +09001485 if ((hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001486 && (pstrNetworkInfo->au8bssid != NULL)) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09001487 memcpy(hif_drv->strWILC_UsrScanReq.astrFoundNetworkInfo[hif_drv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001488 pstrNetworkInfo->au8bssid, 6);
1489
Tony Choa4ab1ad2015-10-12 16:56:05 +09001490 hif_drv->strWILC_UsrScanReq.u32RcvdChCount++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001491
Dean Lee72ed4dc2015-06-12 14:11:44 +09001492 pstrNetworkInfo->bNewNetwork = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001493 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001494
Tony Choa4ab1ad2015-10-12 16:56:05 +09001495 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1496 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001497 pJoinParams);
1498
1499
1500 }
1501 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001502 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001503 }
1504 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001505 pstrNetworkInfo->bNewNetwork = false;
Tony Choa4ab1ad2015-10-12 16:56:05 +09001506 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
1507 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001508 }
1509 }
1510
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001511done:
Leo Kimb021b802015-10-13 20:02:10 +09001512 if (pstrRcvdNetworkInfo->buffer != NULL) {
1513 kfree(pstrRcvdNetworkInfo->buffer);
1514 pstrRcvdNetworkInfo->buffer = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001515 }
1516
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001517 if (pstrNetworkInfo != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001518 DeallocateNetworkInfo(pstrNetworkInfo);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001519 pstrNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001520 }
1521
1522 return s32Error;
1523}
1524
Tony Choa4ab1ad2015-10-12 16:56:05 +09001525static s32 Handle_RcvdGnrlAsyncInfo(struct host_if_drv *hif_drv,
Tony Chof23a9ea2015-09-21 12:16:39 +09001526 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001527{
Leo Kime6e12662015-09-16 18:36:03 +09001528 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001529 u8 u8MsgType = 0;
1530 u8 u8MsgID = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001531 u16 u16MsgLen = 0;
1532 u16 u16WidID = (u16)WID_NIL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001533 u8 u8WidLen = 0;
1534 u8 u8MacStatus;
1535 u8 u8MacStatusReasonCode;
1536 u8 u8MacStatusAdditionalInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001537 tstrConnectInfo strConnectInfo;
1538 tstrDisconnectNotifInfo strDisconnectNotifInfo;
Leo Kime6e12662015-09-16 18:36:03 +09001539 s32 s32Err = 0;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02001540
Tony Choa4ab1ad2015-10-12 16:56:05 +09001541 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001542 PRINT_ER("Driver handler is NULL\n");
Leo Kim234837d2015-09-22 14:34:43 +09001543 return -ENODEV;
1544 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09001545 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", hif_drv->enuHostIFstate,
Leo Kim33722ac72015-10-13 19:50:00 +09001546 pstrRcvdGnrlAsyncInfo->buffer[7]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001547
Tony Choa4ab1ad2015-10-12 16:56:05 +09001548 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
1549 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) ||
1550 hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
Leo Kim33722ac72015-10-13 19:50:00 +09001551 if ((pstrRcvdGnrlAsyncInfo->buffer == NULL) ||
Tony Choa4ab1ad2015-10-12 16:56:05 +09001552 (hif_drv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
Leo Kim24db7132015-09-16 18:36:01 +09001553 PRINT_ER("driver is null\n");
1554 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001555 }
1556
Leo Kim33722ac72015-10-13 19:50:00 +09001557 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001558
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001559 if ('I' != u8MsgType) {
1560 PRINT_ER("Received Message format incorrect.\n");
Leo Kim24db7132015-09-16 18:36:01 +09001561 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001562 }
1563
Leo Kim33722ac72015-10-13 19:50:00 +09001564 u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1];
1565 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]);
1566 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]);
1567 u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6];
1568 u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7];
1569 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8];
1570 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001571 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001572 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001573 u32 u32RcvdAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001574 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
1575
1576 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1577
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001578 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001579
1580 if (u8MacStatus == MAC_CONNECTED) {
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001581 memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001582
Tony Choa4ab1ad2015-10-12 16:56:05 +09001583 host_int_get_assoc_res_info(hif_drv,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001584 gapu8RcvdAssocResp,
1585 MAX_ASSOC_RESP_FRAME_SIZE,
1586 &u32RcvdAssocRespInfoLen);
1587
1588 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
1589
1590 if (u32RcvdAssocRespInfoLen != 0) {
1591
1592 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
1593 s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
1594 &pstrConnectRespInfo);
1595 if (s32Err) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001596 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001597 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001598 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
1599
1600 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
1601 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
1602 if (pstrConnectRespInfo->pu8RespIEs != NULL) {
1603 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
1604
1605
Glen Leef3052582015-09-10 12:03:04 +09001606 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001607 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001608 pstrConnectRespInfo->u16RespIEsLen);
1609 }
1610 }
1611
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001612 if (pstrConnectRespInfo != NULL) {
1613 DeallocateAssocRespInfo(pstrConnectRespInfo);
1614 pstrConnectRespInfo = NULL;
1615 }
1616 }
1617 }
1618 }
1619
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001620 if ((u8MacStatus == MAC_CONNECTED) &&
1621 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001622 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
Shraddha Barke281dd5a2015-10-05 17:00:33 +05301623 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001624
1625 } else if (u8MacStatus == MAC_DISCONNECTED) {
1626 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
Shraddha Barke281dd5a2015-10-05 17:00:33 +05301627 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001628 }
1629
Tony Choa4ab1ad2015-10-12 16:56:05 +09001630 if (hif_drv->strWILC_UsrConnReq.pu8bssid != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001631 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09001632 memcpy(strConnectInfo.au8bssid, hif_drv->strWILC_UsrConnReq.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001633
1634 if ((u8MacStatus == MAC_CONNECTED) &&
1635 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09001636 memcpy(hif_drv->au8AssociatedBSSID,
1637 hif_drv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001638 }
1639 }
1640
1641
Tony Choa4ab1ad2015-10-12 16:56:05 +09001642 if (hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
1643 strConnectInfo.ReqIEsLen = hif_drv->strWILC_UsrConnReq.ConnReqIEsLen;
1644 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->strWILC_UsrConnReq.ConnReqIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001645 memcpy(strConnectInfo.pu8ReqIEs,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001646 hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs,
1647 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001648 }
1649
1650
Tony Choa4ab1ad2015-10-12 16:56:05 +09001651 del_timer(&hif_drv->hConnectTimer);
1652 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001653 &strConnectInfo,
1654 u8MacStatus,
1655 NULL,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001656 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001657
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001658 if ((u8MacStatus == MAC_CONNECTED) &&
1659 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09001660 host_int_set_power_mgmt(hif_drv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001661
1662 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09001663 hif_drv->enuHostIFstate = HOST_IF_CONNECTED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001664
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001665 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +09001666 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07001667 mod_timer(&hDuringIpTimer,
1668 jiffies + msecs_to_jiffies(10000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001669 } else {
1670 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001671 hif_drv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001672 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001673 }
1674
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001675 if (strConnectInfo.pu8RespIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001676 kfree(strConnectInfo.pu8RespIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001677 strConnectInfo.pu8RespIEs = NULL;
1678 }
1679
1680 if (strConnectInfo.pu8ReqIEs != NULL) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001681 kfree(strConnectInfo.pu8ReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001682 strConnectInfo.pu8ReqIEs = NULL;
1683 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09001684 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1685 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1686 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1687 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1688 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001689 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
Tony Choa4ab1ad2015-10-12 16:56:05 +09001690 (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001691 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
1692
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001693 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001694
Tony Choa4ab1ad2015-10-12 16:56:05 +09001695 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001696 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09001697 del_timer(&hif_drv->hScanTimer);
1698 Handle_ScanDone((void *)hif_drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001699 }
1700
1701 strDisconnectNotifInfo.u16reason = 0;
1702 strDisconnectNotifInfo.ie = NULL;
1703 strDisconnectNotifInfo.ie_len = 0;
1704
Tony Choa4ab1ad2015-10-12 16:56:05 +09001705 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001706 g_obtainingIP = false;
Tony Choa4ab1ad2015-10-12 16:56:05 +09001707 host_int_set_power_mgmt(hif_drv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001708
Tony Choa4ab1ad2015-10-12 16:56:05 +09001709 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001710 NULL,
1711 0,
1712 &strDisconnectNotifInfo,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001713 hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001714
1715 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001716 PRINT_ER("Connect result callback function is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001717 }
1718
Tony Choa4ab1ad2015-10-12 16:56:05 +09001719 eth_zero_addr(hif_drv->au8AssociatedBSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001720
Tony Choa4ab1ad2015-10-12 16:56:05 +09001721 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
1722 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
1723 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
1724 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
1725 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001726
Tony Choa4ab1ad2015-10-12 16:56:05 +09001727 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001728 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001729 gu8FlushedJoinReq = NULL;
1730 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09001731 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09001732 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001733 gu8FlushedInfoElemAsoc = NULL;
1734 }
1735
Tony Choa4ab1ad2015-10-12 16:56:05 +09001736 hif_drv->enuHostIFstate = HOST_IF_IDLE;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001737 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001738
1739 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
Tony Choa4ab1ad2015-10-12 16:56:05 +09001740 (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001741 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001742 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09001743
Tony Choa4ab1ad2015-10-12 16:56:05 +09001744 del_timer(&hif_drv->hScanTimer);
1745 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult)
1746 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001747
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001748 }
1749
1750 }
1751
Leo Kim33722ac72015-10-13 19:50:00 +09001752 if (pstrRcvdGnrlAsyncInfo->buffer != NULL) {
1753 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1754 pstrRcvdGnrlAsyncInfo->buffer = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001755 }
1756
1757 return s32Error;
1758}
1759
Tony Choa4ab1ad2015-10-12 16:56:05 +09001760static int Handle_Key(struct host_if_drv *hif_drv,
Tony Choc98387a2015-09-21 12:16:40 +09001761 struct key_attr *pstrHostIFkeyAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001762{
Leo Kime6e12662015-09-16 18:36:03 +09001763 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09001764 struct wid strWID;
1765 struct wid strWIDList[5];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001766 u8 i;
1767 u8 *pu8keybuf;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001768 s8 s8idxarray[1];
1769 s8 ret = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001770
Leo Kim8e9f4272015-10-13 19:49:27 +09001771 switch (pstrHostIFkeyAttr->type) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001772
1773
1774 case WEP:
1775
Leo Kim0d17e382015-10-13 19:49:28 +09001776 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001777
1778 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Leo Kim73b2e382015-10-13 19:49:29 +09001779 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->attr.wep.index));
Leo Kimdaaf16b2015-10-12 16:55:44 +09001780 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001781 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001782 strWIDList[0].size = sizeof(char);
Leo Kim73b2e382015-10-13 19:49:29 +09001783 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.mode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001784
Leo Kimdaaf16b2015-10-12 16:55:44 +09001785 strWIDList[1].id = WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001786 strWIDList[1].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001787 strWIDList[1].size = sizeof(char);
Leo Kim73b2e382015-10-13 19:49:29 +09001788 strWIDList[1].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.auth_type));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001789
Leo Kimdaaf16b2015-10-12 16:55:44 +09001790 strWIDList[2].id = (u16)WID_KEY_ID;
Leo Kim416d8322015-10-12 16:55:43 +09001791 strWIDList[2].type = WID_CHAR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001792
Leo Kim73b2e382015-10-13 19:49:29 +09001793 strWIDList[2].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
Leo Kim2fd3e442015-10-12 16:55:45 +09001794 strWIDList[2].size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001795
Leo Kim73b2e382015-10-13 19:49:29 +09001796 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001797
1798 if (pu8keybuf == NULL) {
1799 PRINT_ER("No buffer to send Key\n");
1800 return -1;
1801 }
1802
Leo Kim73b2e382015-10-13 19:49:29 +09001803 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wep.key,
1804 pstrHostIFkeyAttr->attr.wep.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001805
Leo Kim73b2e382015-10-13 19:49:29 +09001806 kfree(pstrHostIFkeyAttr->attr.wep.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001807
Leo Kimdaaf16b2015-10-12 16:55:44 +09001808 strWIDList[3].id = (u16)WID_WEP_KEY_VALUE;
Leo Kim416d8322015-10-12 16:55:43 +09001809 strWIDList[3].type = WID_STR;
Leo Kim73b2e382015-10-13 19:49:29 +09001810 strWIDList[3].size = pstrHostIFkeyAttr->attr.wep.key_len;
Leo Kim900bb4a2015-10-12 16:55:46 +09001811 strWIDList[3].val = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001812
1813
Tony Cho03362282015-10-12 16:55:39 +09001814 s32Error = send_config_pkt(SET_CFG, strWIDList, 4,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001815 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001816 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001817
1818
1819 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001820
Leo Kim0d17e382015-10-13 19:49:28 +09001821 if (pstrHostIFkeyAttr->action & ADDKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001822 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Leo Kim73b2e382015-10-13 19:49:29 +09001823 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001824 if (pu8keybuf == NULL) {
1825 PRINT_ER("No buffer to send Key\n");
1826 return -1;
1827 }
Leo Kim73b2e382015-10-13 19:49:29 +09001828 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1829 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1830 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
1831 pstrHostIFkeyAttr->attr.wep.key_len);
1832 kfree(pstrHostIFkeyAttr->attr.wep.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001833
Leo Kimdaaf16b2015-10-12 16:55:44 +09001834 strWID.id = (u16)WID_ADD_WEP_KEY;
Leo Kim416d8322015-10-12 16:55:43 +09001835 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09001836 strWID.val = (s8 *)pu8keybuf;
Leo Kim73b2e382015-10-13 19:49:29 +09001837 strWID.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001838
Tony Cho03362282015-10-12 16:55:39 +09001839 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001840 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001841 kfree(pu8keybuf);
Leo Kim0d17e382015-10-13 19:49:28 +09001842 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001843
1844 PRINT_D(HOSTINF_DBG, "Removing key\n");
Leo Kimdaaf16b2015-10-12 16:55:44 +09001845 strWID.id = (u16)WID_REMOVE_WEP_KEY;
Leo Kim416d8322015-10-12 16:55:43 +09001846 strWID.type = WID_STR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001847
Leo Kim73b2e382015-10-13 19:49:29 +09001848 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
Leo Kim900bb4a2015-10-12 16:55:46 +09001849 strWID.val = s8idxarray;
Leo Kim2fd3e442015-10-12 16:55:45 +09001850 strWID.size = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001851
Tony Cho03362282015-10-12 16:55:39 +09001852 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001853 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001854 } else {
Leo Kimdaaf16b2015-10-12 16:55:44 +09001855 strWID.id = (u16)WID_KEY_ID;
Leo Kim416d8322015-10-12 16:55:43 +09001856 strWID.type = WID_CHAR;
Leo Kim73b2e382015-10-13 19:49:29 +09001857 strWID.val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
Leo Kim2fd3e442015-10-12 16:55:45 +09001858 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001859
1860 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
1861
Tony Cho03362282015-10-12 16:55:39 +09001862 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001863 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001864 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09001865 up(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001866 break;
1867
1868 case WPARxGtk:
Leo Kim0d17e382015-10-13 19:49:28 +09001869 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Glen Leef3052582015-09-10 12:03:04 +09001870 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001871 if (pu8keybuf == NULL) {
1872 PRINT_ER("No buffer to send RxGTK Key\n");
1873 ret = -1;
1874 goto _WPARxGtk_end_case_;
1875 }
1876
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001877 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001878
Leo Kim0e74c002015-10-13 19:49:32 +09001879 if (pstrHostIFkeyAttr->attr.wpa.seq != NULL)
1880 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001881
Leo Kime2dfbac2015-10-13 19:49:34 +09001882 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
Leo Kim6acf2912015-10-13 19:49:35 +09001883 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001884 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim6acf2912015-10-13 19:49:35 +09001885 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001886
Leo Kimdaaf16b2015-10-12 16:55:44 +09001887 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001888 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001889 strWIDList[0].size = sizeof(char);
Leo Kim7b2ebb22015-10-13 19:49:36 +09001890 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001891
Leo Kimdaaf16b2015-10-12 16:55:44 +09001892 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
Leo Kim416d8322015-10-12 16:55:43 +09001893 strWIDList[1].type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09001894 strWIDList[1].val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09001895 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001896
Tony Cho03362282015-10-12 16:55:39 +09001897 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001898 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001899
Chaehyun Lim49188af2015-08-11 10:32:41 +09001900 kfree(pu8keybuf);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001901 up(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001902 }
1903
Leo Kim0d17e382015-10-13 19:49:28 +09001904 if (pstrHostIFkeyAttr->action & ADDKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001905 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
1906
Glen Leef3052582015-09-10 12:03:04 +09001907 pu8keybuf = kmalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001908 if (pu8keybuf == NULL) {
1909 PRINT_ER("No buffer to send RxGTK Key\n");
1910 ret = -1;
1911 goto _WPARxGtk_end_case_;
1912 }
1913
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001914 memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001915
Tony Choa4ab1ad2015-10-12 16:56:05 +09001916 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED)
1917 memcpy(pu8keybuf, hif_drv->au8AssociatedBSSID, ETH_ALEN);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301918 else
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001919 PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001920
Leo Kim0e74c002015-10-13 19:49:32 +09001921 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
Leo Kime2dfbac2015-10-13 19:49:34 +09001922 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
Leo Kim6acf2912015-10-13 19:49:35 +09001923 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001924 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim6acf2912015-10-13 19:49:35 +09001925 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001926
Leo Kimdaaf16b2015-10-12 16:55:44 +09001927 strWID.id = (u16)WID_ADD_RX_GTK;
Leo Kim416d8322015-10-12 16:55:43 +09001928 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09001929 strWID.val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09001930 strWID.size = RX_MIC_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001931
Tony Cho03362282015-10-12 16:55:39 +09001932 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001933 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001934
Chaehyun Lim49188af2015-08-11 10:32:41 +09001935 kfree(pu8keybuf);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001936 up(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001937 }
1938_WPARxGtk_end_case_:
Leo Kim124968fc2015-10-13 19:49:30 +09001939 kfree(pstrHostIFkeyAttr->attr.wpa.key);
Leo Kim0e74c002015-10-13 19:49:32 +09001940 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001941 if (ret == -1)
1942 return ret;
1943
1944 break;
1945
1946 case WPAPtk:
Leo Kim0d17e382015-10-13 19:49:28 +09001947 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001948
1949
Glen Leef3052582015-09-10 12:03:04 +09001950 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001951
1952
1953
1954 if (pu8keybuf == NULL) {
1955 PRINT_ER("No buffer to send PTK Key\n");
1956 ret = -1;
1957 goto _WPAPtk_end_case_;
1958
1959 }
1960
Leo Kim248080a2015-10-13 19:49:31 +09001961 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
Leo Kime2dfbac2015-10-13 19:49:34 +09001962 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
Leo Kim6acf2912015-10-13 19:49:35 +09001963 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001964 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim6acf2912015-10-13 19:49:35 +09001965 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001966
Leo Kimdaaf16b2015-10-12 16:55:44 +09001967 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001968 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001969 strWIDList[0].size = sizeof(char);
Leo Kim7b2ebb22015-10-13 19:49:36 +09001970 strWIDList[0].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wpa.mode));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001971
Leo Kimdaaf16b2015-10-12 16:55:44 +09001972 strWIDList[1].id = (u16)WID_ADD_PTK;
Leo Kim416d8322015-10-12 16:55:43 +09001973 strWIDList[1].type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09001974 strWIDList[1].val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09001975 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001976
Tony Cho03362282015-10-12 16:55:39 +09001977 s32Error = send_config_pkt(SET_CFG, strWIDList, 2,
Tony Choa4ab1ad2015-10-12 16:56:05 +09001978 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001979 kfree(pu8keybuf);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001980 up(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001981 }
Leo Kim0d17e382015-10-13 19:49:28 +09001982 if (pstrHostIFkeyAttr->action & ADDKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001983
1984
Glen Leef3052582015-09-10 12:03:04 +09001985 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001986
1987
1988
1989 if (pu8keybuf == NULL) {
1990 PRINT_ER("No buffer to send PTK Key\n");
1991 ret = -1;
1992 goto _WPAPtk_end_case_;
1993
1994 }
1995
Leo Kim248080a2015-10-13 19:49:31 +09001996 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
Leo Kim6acf2912015-10-13 19:49:35 +09001997 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001998 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim6acf2912015-10-13 19:49:35 +09001999 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002000
Leo Kimdaaf16b2015-10-12 16:55:44 +09002001 strWID.id = (u16)WID_ADD_PTK;
Leo Kim416d8322015-10-12 16:55:43 +09002002 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002003 strWID.val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09002004 strWID.size = PTK_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002005
Tony Cho03362282015-10-12 16:55:39 +09002006 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002007 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09002008 kfree(pu8keybuf);
Tony Choa4ab1ad2015-10-12 16:56:05 +09002009 up(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002010 }
2011
2012_WPAPtk_end_case_:
Leo Kim124968fc2015-10-13 19:49:30 +09002013 kfree(pstrHostIFkeyAttr->attr.wpa.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002014 if (ret == -1)
2015 return ret;
2016
2017 break;
2018
2019
2020 case PMKSA:
2021
2022 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
2023
Leo Kim73b2e382015-10-13 19:49:29 +09002024 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002025 if (pu8keybuf == NULL) {
2026 PRINT_ER("No buffer to send PMKSA Key\n");
2027 return -1;
2028 }
2029
Leo Kim73b2e382015-10-13 19:49:29 +09002030 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002031
Leo Kim73b2e382015-10-13 19:49:29 +09002032 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
2033 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
2034 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002035 }
2036
Leo Kimdaaf16b2015-10-12 16:55:44 +09002037 strWID.id = (u16)WID_PMKID_INFO;
Leo Kim416d8322015-10-12 16:55:43 +09002038 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002039 strWID.val = (s8 *)pu8keybuf;
Leo Kim73b2e382015-10-13 19:49:29 +09002040 strWID.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002041
Tony Cho03362282015-10-12 16:55:39 +09002042 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002043 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002044
Chaehyun Lim49188af2015-08-11 10:32:41 +09002045 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002046 break;
2047 }
2048
2049 if (s32Error)
2050 PRINT_ER("Failed to send key config packet\n");
2051
2052
2053 return s32Error;
2054}
2055
Tony Choa4ab1ad2015-10-12 16:56:05 +09002056static void Handle_Disconnect(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002057{
Leo Kime9e0c262015-10-12 16:55:41 +09002058 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002059
Leo Kime6e12662015-09-16 18:36:03 +09002060 s32 s32Error = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09002061 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002062
Leo Kimdaaf16b2015-10-12 16:55:44 +09002063 strWID.id = (u16)WID_DISCONNECT;
Leo Kim416d8322015-10-12 16:55:43 +09002064 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002065 strWID.val = (s8 *)&u16DummyReasonCode;
Leo Kim2fd3e442015-10-12 16:55:45 +09002066 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002067
2068
2069
2070 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
2071
Dean Lee72ed4dc2015-06-12 14:11:44 +09002072 g_obtainingIP = false;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002073 host_int_set_power_mgmt(hif_drv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002074
Shraddha Barke281dd5a2015-10-05 17:00:33 +05302075 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002076
Tony Cho03362282015-10-12 16:55:39 +09002077 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002078 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002079
2080 if (s32Error) {
2081 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002082 } else {
2083 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2084
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002085 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002086
2087 strDisconnectNotifInfo.u16reason = 0;
2088 strDisconnectNotifInfo.ie = NULL;
2089 strDisconnectNotifInfo.ie_len = 0;
2090
Tony Choa4ab1ad2015-10-12 16:56:05 +09002091 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
2092 del_timer(&hif_drv->hScanTimer);
2093 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
2094 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002095
Tony Choa4ab1ad2015-10-12 16:56:05 +09002096 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002097 }
2098
Tony Choa4ab1ad2015-10-12 16:56:05 +09002099 if (hif_drv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09002100 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002101 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09002102 del_timer(&hif_drv->hConnectTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002103 }
2104
Tony Choa4ab1ad2015-10-12 16:56:05 +09002105 hif_drv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
2106 0, &strDisconnectNotifInfo, hif_drv->strWILC_UsrConnReq.u32UserConnectPvoid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002107 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002108 PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002109 }
2110
Dean Lee72ed4dc2015-06-12 14:11:44 +09002111 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002112
Tony Choa4ab1ad2015-10-12 16:56:05 +09002113 hif_drv->enuHostIFstate = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002114
Tony Choa4ab1ad2015-10-12 16:56:05 +09002115 eth_zero_addr(hif_drv->au8AssociatedBSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002116
Tony Choa4ab1ad2015-10-12 16:56:05 +09002117 hif_drv->strWILC_UsrConnReq.ssidLen = 0;
2118 kfree(hif_drv->strWILC_UsrConnReq.pu8ssid);
2119 kfree(hif_drv->strWILC_UsrConnReq.pu8bssid);
2120 hif_drv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
2121 kfree(hif_drv->strWILC_UsrConnReq.pu8ConnReqIEs);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002122
Tony Choa4ab1ad2015-10-12 16:56:05 +09002123 if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002124 kfree(gu8FlushedJoinReq);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002125 gu8FlushedJoinReq = NULL;
2126 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09002127 if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == hif_drv) {
Chaehyun Lim49188af2015-08-11 10:32:41 +09002128 kfree(gu8FlushedInfoElemAsoc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002129 gu8FlushedInfoElemAsoc = NULL;
2130 }
2131
2132 }
2133
Tony Choa4ab1ad2015-10-12 16:56:05 +09002134 up(&hif_drv->hSemTestDisconnectBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002135}
2136
2137
Tony Choa4ab1ad2015-10-12 16:56:05 +09002138void resolve_disconnect_aberration(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002139{
Tony Choa4ab1ad2015-10-12 16:56:05 +09002140 if (!hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002141 return;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002142 if ((hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (hif_drv->enuHostIFstate == HOST_IF_CONNECTING)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002143 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09002144 host_int_disconnect(hif_drv, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002145 }
2146}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002147
Tony Choa4ab1ad2015-10-12 16:56:05 +09002148static s32 Handle_GetChnl(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002149{
2150
Leo Kime6e12662015-09-16 18:36:03 +09002151 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09002152 struct wid strWID;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002153
Leo Kimdaaf16b2015-10-12 16:55:44 +09002154 strWID.id = (u16)WID_CURRENT_CHANNEL;
Leo Kim416d8322015-10-12 16:55:43 +09002155 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002156 strWID.val = (s8 *)&gu8Chnl;
Leo Kim2fd3e442015-10-12 16:55:45 +09002157 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002158
2159 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2160
Tony Cho03362282015-10-12 16:55:39 +09002161 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002162 get_id_from_handler(hif_drv));
Leo Kimae4dfa52015-10-13 19:49:26 +09002163
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002164 if (s32Error) {
2165 PRINT_ER("Failed to get channel number\n");
Leo Kim24db7132015-09-16 18:36:01 +09002166 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002167 }
2168
Tony Choa4ab1ad2015-10-12 16:56:05 +09002169 up(&hif_drv->hSemGetCHNL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002170
2171 return s32Error;
2172
2173
2174
2175}
2176
Tony Choa4ab1ad2015-10-12 16:56:05 +09002177static void Handle_GetRssi(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002178{
Leo Kime6e12662015-09-16 18:36:03 +09002179 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09002180 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002181
Leo Kimdaaf16b2015-10-12 16:55:44 +09002182 strWID.id = (u16)WID_RSSI;
Leo Kim416d8322015-10-12 16:55:43 +09002183 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002184 strWID.val = &gs8Rssi;
Leo Kim2fd3e442015-10-12 16:55:45 +09002185 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002186
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002187 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2188
Tony Cho03362282015-10-12 16:55:39 +09002189 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002190 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002191 if (s32Error) {
2192 PRINT_ER("Failed to get RSSI value\n");
Leo Kim24db7132015-09-16 18:36:01 +09002193 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002194 }
2195
Tony Choa4ab1ad2015-10-12 16:56:05 +09002196 up(&hif_drv->hSemGetRSSI);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002197
2198
2199}
2200
2201
Tony Choa4ab1ad2015-10-12 16:56:05 +09002202static void Handle_GetLinkspeed(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002203{
Leo Kime6e12662015-09-16 18:36:03 +09002204 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09002205 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002206
2207 gs8lnkspd = 0;
2208
Leo Kimdaaf16b2015-10-12 16:55:44 +09002209 strWID.id = (u16)WID_LINKSPEED;
Leo Kim416d8322015-10-12 16:55:43 +09002210 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002211 strWID.val = &gs8lnkspd;
Leo Kim2fd3e442015-10-12 16:55:45 +09002212 strWID.size = sizeof(char);
Leo Kimae4dfa52015-10-13 19:49:26 +09002213
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002214 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2215
Tony Cho03362282015-10-12 16:55:39 +09002216 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002217 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002218 if (s32Error) {
2219 PRINT_ER("Failed to get LINKSPEED value\n");
Leo Kim24db7132015-09-16 18:36:01 +09002220 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002221 }
2222
Tony Choa4ab1ad2015-10-12 16:56:05 +09002223 up(&(hif_drv->hSemGetLINKSPEED));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002224
2225
2226}
2227
Tony Choa4ab1ad2015-10-12 16:56:05 +09002228s32 Handle_GetStatistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002229{
Leo Kime9e0c262015-10-12 16:55:41 +09002230 struct wid strWIDList[5];
Chaehyun Limfbc2fe12015-09-15 14:06:16 +09002231 u32 u32WidsCount = 0, s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002232
Leo Kimdaaf16b2015-10-12 16:55:44 +09002233 strWIDList[u32WidsCount].id = WID_LINKSPEED;
Leo Kim416d8322015-10-12 16:55:43 +09002234 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002235 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim900bb4a2015-10-12 16:55:46 +09002236 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u8LinkSpeed));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002237 u32WidsCount++;
2238
Leo Kimdaaf16b2015-10-12 16:55:44 +09002239 strWIDList[u32WidsCount].id = WID_RSSI;
Leo Kim416d8322015-10-12 16:55:43 +09002240 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002241 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim900bb4a2015-10-12 16:55:46 +09002242 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->s8RSSI));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002243 u32WidsCount++;
2244
Leo Kimdaaf16b2015-10-12 16:55:44 +09002245 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002246 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002247 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09002248 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002249 u32WidsCount++;
2250
Leo Kimdaaf16b2015-10-12 16:55:44 +09002251 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002252 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002253 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09002254 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32RxCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002255 u32WidsCount++;
2256
Leo Kimdaaf16b2015-10-12 16:55:44 +09002257 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002258 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002259 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09002260 strWIDList[u32WidsCount].val = (s8 *)(&(pstrStatistics->u32TxFailureCount));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002261 u32WidsCount++;
2262
Tony Cho03362282015-10-12 16:55:39 +09002263 s32Error = send_config_pkt(GET_CFG, strWIDList, u32WidsCount,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002264 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002265
Leo Kim24db7132015-09-16 18:36:01 +09002266 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002267 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09002268
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002269 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002270 return 0;
2271
2272}
2273
Tony Choa4ab1ad2015-10-12 16:56:05 +09002274static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,
Tony Cho3d1eac02015-09-21 12:16:49 +09002275 struct sta_inactive_t *strHostIfStaInactiveT)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002276{
2277
Leo Kime6e12662015-09-16 18:36:03 +09002278 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002279 u8 *stamac;
Leo Kime9e0c262015-10-12 16:55:41 +09002280 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002281
Leo Kimdaaf16b2015-10-12 16:55:44 +09002282 strWID.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
Leo Kim416d8322015-10-12 16:55:43 +09002283 strWID.type = WID_STR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002284 strWID.size = ETH_ALEN;
Leo Kim900bb4a2015-10-12 16:55:46 +09002285 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002286
2287
Leo Kim900bb4a2015-10-12 16:55:46 +09002288 stamac = strWID.val;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002289 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002290
2291
2292 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2293
2294
Tony Cho03362282015-10-12 16:55:39 +09002295 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002296 get_id_from_handler(hif_drv));
Leo Kimae4dfa52015-10-13 19:49:26 +09002297
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002298 if (s32Error) {
2299 PRINT_ER("Failed to SET incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09002300 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002301 }
2302
2303
Leo Kimdaaf16b2015-10-12 16:55:44 +09002304 strWID.id = (u16)WID_GET_INACTIVE_TIME;
Leo Kim416d8322015-10-12 16:55:43 +09002305 strWID.type = WID_INT;
Leo Kim900bb4a2015-10-12 16:55:46 +09002306 strWID.val = (s8 *)&gu32InactiveTime;
Leo Kim2fd3e442015-10-12 16:55:45 +09002307 strWID.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002308
2309
Tony Cho03362282015-10-12 16:55:39 +09002310 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002311 get_id_from_handler(hif_drv));
Leo Kimae4dfa52015-10-13 19:49:26 +09002312
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002313 if (s32Error) {
2314 PRINT_ER("Failed to get incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09002315 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002316 }
2317
2318
2319 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
2320
Tony Choa4ab1ad2015-10-12 16:56:05 +09002321 up(&hif_drv->hSemInactiveTime);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002322
2323 return s32Error;
2324
2325
2326
2327}
2328
Tony Choa4ab1ad2015-10-12 16:56:05 +09002329static void Handle_AddBeacon(struct host_if_drv *hif_drv,
Tony Cho7f33fec2015-09-30 18:44:30 +09002330 struct beacon_attr *pstrSetBeaconParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002331{
Leo Kime6e12662015-09-16 18:36:03 +09002332 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09002333 struct wid strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002334 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002335
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002336 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
2337
Leo Kimdaaf16b2015-10-12 16:55:44 +09002338 strWID.id = (u16)WID_ADD_BEACON;
Leo Kim416d8322015-10-12 16:55:43 +09002339 strWID.type = WID_BIN;
Leo Kim030c57e2015-10-13 19:50:07 +09002340 strWID.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
Leo Kim900bb4a2015-10-12 16:55:46 +09002341 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2342 if (strWID.val == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09002343 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002344
Leo Kim900bb4a2015-10-12 16:55:46 +09002345 pu8CurrByte = strWID.val;
Leo Kim12262dd2015-10-13 19:50:03 +09002346 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2347 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2348 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2349 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002350
Leo Kime76ab772015-10-13 19:50:04 +09002351 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2352 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2353 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2354 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002355
Leo Kim51c66182015-10-13 19:50:05 +09002356 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2357 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2358 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2359 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002360
Leo Kim8ce528b2015-10-13 19:50:06 +09002361 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
Leo Kim51c66182015-10-13 19:50:05 +09002362 pu8CurrByte += pstrSetBeaconParam->head_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002363
Leo Kim030c57e2015-10-13 19:50:07 +09002364 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2365 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2366 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2367 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002368
Leo Kim7dbcb6d32015-10-13 19:50:08 +09002369 if (pstrSetBeaconParam->tail > 0)
2370 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
Leo Kim030c57e2015-10-13 19:50:07 +09002371 pu8CurrByte += pstrSetBeaconParam->tail_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002372
Tony Cho03362282015-10-12 16:55:39 +09002373 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002374 get_id_from_handler(hif_drv));
Leo Kim24db7132015-09-16 18:36:01 +09002375 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002376 PRINT_ER("Failed to send add beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002377
Leo Kim24db7132015-09-16 18:36:01 +09002378ERRORHANDLER:
Leo Kim900bb4a2015-10-12 16:55:46 +09002379 kfree(strWID.val);
Leo Kim8ce528b2015-10-13 19:50:06 +09002380 kfree(pstrSetBeaconParam->head);
Leo Kim7dbcb6d32015-10-13 19:50:08 +09002381 kfree(pstrSetBeaconParam->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002382}
2383
Tony Choa4ab1ad2015-10-12 16:56:05 +09002384static void Handle_DelBeacon(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002385{
Leo Kime6e12662015-09-16 18:36:03 +09002386 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09002387 struct wid strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002388 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002389
Leo Kimdaaf16b2015-10-12 16:55:44 +09002390 strWID.id = (u16)WID_DEL_BEACON;
Leo Kim416d8322015-10-12 16:55:43 +09002391 strWID.type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002392 strWID.size = sizeof(char);
Leo Kim900bb4a2015-10-12 16:55:46 +09002393 strWID.val = &gu8DelBcn;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002394
Leo Kim900bb4a2015-10-12 16:55:46 +09002395 if (strWID.val == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09002396 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002397
Leo Kim900bb4a2015-10-12 16:55:46 +09002398 pu8CurrByte = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002399
2400 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002401
Tony Cho03362282015-10-12 16:55:39 +09002402 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002403 get_id_from_handler(hif_drv));
Leo Kim24db7132015-09-16 18:36:01 +09002404 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002405 PRINT_ER("Failed to send delete beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002406}
2407
Tony Cho6a89ba92015-09-21 12:16:46 +09002408static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2409 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002410{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002411 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002412
2413 pu8CurrByte = pu8Buffer;
2414
2415 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002416 memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002417 pu8CurrByte += ETH_ALEN;
2418
2419 *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
2420 *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
2421
2422 *pu8CurrByte++ = pstrStationParam->u8NumRates;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002423 if (pstrStationParam->u8NumRates > 0)
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002424 memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002425 pu8CurrByte += pstrStationParam->u8NumRates;
2426
2427 *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
2428 *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
2429 *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
2430
2431 *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002432 memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002433 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2434
2435 *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
2436 *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
2437
2438 *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
2439 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
2440 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
2441 *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
2442
2443 *pu8CurrByte++ = pstrStationParam->u8ASELCap;
2444
2445 *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
2446 *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
2447
2448 *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
2449 *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
2450
2451 return pu8CurrByte - pu8Buffer;
2452}
2453
Tony Choa4ab1ad2015-10-12 16:56:05 +09002454static void Handle_AddStation(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09002455 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002456{
Leo Kime6e12662015-09-16 18:36:03 +09002457 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09002458 struct wid strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002459 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002460
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002461 PRINT_D(HOSTINF_DBG, "Handling add station\n");
Leo Kimdaaf16b2015-10-12 16:55:44 +09002462 strWID.id = (u16)WID_ADD_STA;
Leo Kim416d8322015-10-12 16:55:43 +09002463 strWID.type = WID_BIN;
Leo Kim2fd3e442015-10-12 16:55:45 +09002464 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002465
Leo Kim900bb4a2015-10-12 16:55:46 +09002466 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2467 if (strWID.val == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09002468 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002469
Leo Kim900bb4a2015-10-12 16:55:46 +09002470 pu8CurrByte = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002471 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2472
Tony Cho03362282015-10-12 16:55:39 +09002473 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002474 get_id_from_handler(hif_drv));
Leo Kime6e12662015-09-16 18:36:03 +09002475 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002476 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002477
Leo Kim24db7132015-09-16 18:36:01 +09002478ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07002479 kfree(pstrStationParam->pu8Rates);
Leo Kim900bb4a2015-10-12 16:55:46 +09002480 kfree(strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002481}
2482
Tony Choa4ab1ad2015-10-12 16:56:05 +09002483static void Handle_DelAllSta(struct host_if_drv *hif_drv,
Tony Chob4e644e2015-09-21 12:17:00 +09002484 struct del_all_sta *pstrDelAllStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002485{
Leo Kime6e12662015-09-16 18:36:03 +09002486 s32 s32Error = 0;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002487
Leo Kime9e0c262015-10-12 16:55:41 +09002488 struct wid strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002489 u8 *pu8CurrByte;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002490 u8 i;
Chaehyun Lim37034802015-06-11 14:34:32 +09002491 u8 au8Zero_Buff[6] = {0};
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002492
Leo Kimdaaf16b2015-10-12 16:55:44 +09002493 strWID.id = (u16)WID_DEL_ALL_STA;
Leo Kim416d8322015-10-12 16:55:43 +09002494 strWID.type = WID_STR;
Leo Kim8ba18032015-10-13 19:50:10 +09002495 strWID.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002496
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002497 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002498
Leo Kim8ba18032015-10-13 19:50:10 +09002499 strWID.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
Leo Kim900bb4a2015-10-12 16:55:46 +09002500 if (strWID.val == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09002501 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002502
Leo Kim900bb4a2015-10-12 16:55:46 +09002503 pu8CurrByte = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002504
Leo Kim8ba18032015-10-13 19:50:10 +09002505 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002506
2507 for (i = 0; i < MAX_NUM_STA; i++) {
Leo Kime51b9212015-10-13 19:50:09 +09002508 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2509 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002510 else
2511 continue;
2512
2513 pu8CurrByte += ETH_ALEN;
2514 }
2515
Tony Cho03362282015-10-12 16:55:39 +09002516 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002517 get_id_from_handler(hif_drv));
Leo Kim24db7132015-09-16 18:36:01 +09002518 if (s32Error)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02002519 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002520
Leo Kim24db7132015-09-16 18:36:01 +09002521ERRORHANDLER:
Leo Kim900bb4a2015-10-12 16:55:46 +09002522 kfree(strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002523
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002524 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002525}
2526
Tony Choa4ab1ad2015-10-12 16:56:05 +09002527static void Handle_DelStation(struct host_if_drv *hif_drv,
Tony Chofb93a1e2015-09-21 12:16:57 +09002528 struct del_sta *pstrDelStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002529{
Leo Kime6e12662015-09-16 18:36:03 +09002530 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09002531 struct wid strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002532 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002533
Leo Kimdaaf16b2015-10-12 16:55:44 +09002534 strWID.id = (u16)WID_REMOVE_STA;
Leo Kim416d8322015-10-12 16:55:43 +09002535 strWID.type = WID_BIN;
Leo Kim2fd3e442015-10-12 16:55:45 +09002536 strWID.size = ETH_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002537
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002538 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002539
Leo Kim900bb4a2015-10-12 16:55:46 +09002540 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2541 if (strWID.val == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09002542 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002543
Leo Kim900bb4a2015-10-12 16:55:46 +09002544 pu8CurrByte = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002545
Leo Kime4839d32015-10-13 20:02:06 +09002546 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002547
Tony Cho03362282015-10-12 16:55:39 +09002548 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002549 get_id_from_handler(hif_drv));
Leo Kim24db7132015-09-16 18:36:01 +09002550 if (s32Error)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02002551 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002552
Leo Kim24db7132015-09-16 18:36:01 +09002553ERRORHANDLER:
Leo Kim900bb4a2015-10-12 16:55:46 +09002554 kfree(strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002555}
2556
Tony Choa4ab1ad2015-10-12 16:56:05 +09002557static void Handle_EditStation(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09002558 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002559{
Leo Kime6e12662015-09-16 18:36:03 +09002560 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09002561 struct wid strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002562 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002563
Leo Kimdaaf16b2015-10-12 16:55:44 +09002564 strWID.id = (u16)WID_EDIT_STA;
Leo Kim416d8322015-10-12 16:55:43 +09002565 strWID.type = WID_BIN;
Leo Kim2fd3e442015-10-12 16:55:45 +09002566 strWID.size = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002567
2568 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
Leo Kim900bb4a2015-10-12 16:55:46 +09002569 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2570 if (strWID.val == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09002571 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002572
Leo Kim900bb4a2015-10-12 16:55:46 +09002573 pu8CurrByte = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002574 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2575
Tony Cho03362282015-10-12 16:55:39 +09002576 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002577 get_id_from_handler(hif_drv));
Leo Kim24db7132015-09-16 18:36:01 +09002578 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002579 PRINT_ER("Failed to send edit station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002580
Leo Kim24db7132015-09-16 18:36:01 +09002581ERRORHANDLER:
Greg Kroah-Hartman969effe2015-08-14 19:15:34 -07002582 kfree(pstrStationParam->pu8Rates);
Leo Kim900bb4a2015-10-12 16:55:46 +09002583 kfree(strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002584}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002585
Tony Choa4ab1ad2015-10-12 16:56:05 +09002586static int Handle_RemainOnChan(struct host_if_drv *hif_drv,
Tony Cho2f9c03f2015-09-21 12:16:58 +09002587 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002588{
Leo Kime6e12662015-09-16 18:36:03 +09002589 s32 s32Error = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002590 u8 u8remain_on_chan_flag;
Leo Kime9e0c262015-10-12 16:55:41 +09002591 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002592
Tony Choa4ab1ad2015-10-12 16:56:05 +09002593 if (!hif_drv->u8RemainOnChan_pendingreq) {
2594 hif_drv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
2595 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
2596 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
2597 hif_drv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
2598 hif_drv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002599 } else {
Tony Choa4ab1ad2015-10-12 16:56:05 +09002600 pstrHostIfRemainOnChan->u16Channel = hif_drv->strHostIfRemainOnChan.u16Channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002601 }
2602
Tony Choa4ab1ad2015-10-12 16:56:05 +09002603 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002604 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09002605 hif_drv->u8RemainOnChan_pendingreq = 1;
Leo Kim24db7132015-09-16 18:36:01 +09002606 s32Error = -EBUSY;
2607 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002608 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09002609 if (hif_drv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002610 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
Leo Kim24db7132015-09-16 18:36:01 +09002611 s32Error = -EBUSY;
2612 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002613 }
2614
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002615 if (g_obtainingIP || connecting) {
2616 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +09002617 s32Error = -EBUSY;
2618 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002619 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002620
2621 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
2622
Dean Lee72ed4dc2015-06-12 14:11:44 +09002623 u8remain_on_chan_flag = true;
Leo Kimdaaf16b2015-10-12 16:55:44 +09002624 strWID.id = (u16)WID_REMAIN_ON_CHAN;
Leo Kim416d8322015-10-12 16:55:43 +09002625 strWID.type = WID_STR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002626 strWID.size = 2;
Leo Kim900bb4a2015-10-12 16:55:46 +09002627 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002628
Leo Kim900bb4a2015-10-12 16:55:46 +09002629 if (strWID.val == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09002630 s32Error = -ENOMEM;
2631 goto ERRORHANDLER;
2632 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002633
Leo Kim900bb4a2015-10-12 16:55:46 +09002634 strWID.val[0] = u8remain_on_chan_flag;
2635 strWID.val[1] = (s8)pstrHostIfRemainOnChan->u16Channel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002636
Tony Cho03362282015-10-12 16:55:39 +09002637 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002638 get_id_from_handler(hif_drv));
Leo Kime6e12662015-09-16 18:36:03 +09002639 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002640 PRINT_ER("Failed to set remain on channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002641
Leo Kim24db7132015-09-16 18:36:01 +09002642ERRORHANDLER:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002643 {
2644 P2P_LISTEN_STATE = 1;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002645 hif_drv->hRemainOnChannel.data = (unsigned long)hif_drv;
2646 mod_timer(&hif_drv->hRemainOnChannel,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002647 jiffies +
2648 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002649
Tony Choa4ab1ad2015-10-12 16:56:05 +09002650 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanReady)
2651 hif_drv->strHostIfRemainOnChan.pRemainOnChanReady(hif_drv->strHostIfRemainOnChan.pVoid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002652
Tony Choa4ab1ad2015-10-12 16:56:05 +09002653 if (hif_drv->u8RemainOnChan_pendingreq)
2654 hif_drv->u8RemainOnChan_pendingreq = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002655 }
2656 return s32Error;
2657}
2658
Tony Choa4ab1ad2015-10-12 16:56:05 +09002659static int Handle_RegisterFrame(struct host_if_drv *hif_drv,
Tony Chobc37c5d2015-09-21 12:16:59 +09002660 struct reg_frame *pstrHostIfRegisterFrame)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002661{
Leo Kime6e12662015-09-16 18:36:03 +09002662 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09002663 struct wid strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002664 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002665
2666 PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
2667
Leo Kimdaaf16b2015-10-12 16:55:44 +09002668 strWID.id = (u16)WID_REGISTER_FRAME;
Leo Kim416d8322015-10-12 16:55:43 +09002669 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002670 strWID.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2671 if (strWID.val == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09002672 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002673
Leo Kim900bb4a2015-10-12 16:55:46 +09002674 pu8CurrByte = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002675
2676 *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
2677 *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002678 memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(u16));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002679
2680
Leo Kim2fd3e442015-10-12 16:55:45 +09002681 strWID.size = sizeof(u16) + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002682
Tony Cho03362282015-10-12 16:55:39 +09002683 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002684 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002685 if (s32Error) {
2686 PRINT_ER("Failed to frame register config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09002687 s32Error = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002688 }
2689
2690 return s32Error;
2691
2692}
2693
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002694#define FALSE_FRMWR_CHANNEL 100
Tony Choa4ab1ad2015-10-12 16:56:05 +09002695static u32 Handle_ListenStateExpired(struct host_if_drv *hif_drv,
Tony Cho2f9c03f2015-09-21 12:16:58 +09002696 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002697{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002698 u8 u8remain_on_chan_flag;
Leo Kime9e0c262015-10-12 16:55:41 +09002699 struct wid strWID;
Leo Kime6e12662015-09-16 18:36:03 +09002700 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002701
2702 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
2703
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002704 if (P2P_LISTEN_STATE) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002705 u8remain_on_chan_flag = false;
Leo Kimdaaf16b2015-10-12 16:55:44 +09002706 strWID.id = (u16)WID_REMAIN_ON_CHAN;
Leo Kim416d8322015-10-12 16:55:43 +09002707 strWID.type = WID_STR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002708 strWID.size = 2;
Leo Kim900bb4a2015-10-12 16:55:46 +09002709 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002710
Leo Kim900bb4a2015-10-12 16:55:46 +09002711 if (strWID.val == NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002712 PRINT_ER("Failed to allocate memory\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002713
Leo Kim900bb4a2015-10-12 16:55:46 +09002714 strWID.val[0] = u8remain_on_chan_flag;
2715 strWID.val[1] = FALSE_FRMWR_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002716
Tony Cho03362282015-10-12 16:55:39 +09002717 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002718 get_id_from_handler(hif_drv));
Leo Kime6e12662015-09-16 18:36:03 +09002719 if (s32Error != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002720 PRINT_ER("Failed to set remain on channel\n");
2721 goto _done_;
2722 }
2723
Tony Choa4ab1ad2015-10-12 16:56:05 +09002724 if (hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired) {
2725 hif_drv->strHostIfRemainOnChan.pRemainOnChanExpired(hif_drv->strHostIfRemainOnChan.pVoid
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002726 , pstrHostIfRemainOnChan->u32ListenSessionID);
2727 }
2728 P2P_LISTEN_STATE = 0;
2729 } else {
2730 PRINT_D(GENERIC_DBG, "Not in listen state\n");
Leo Kime6e12662015-09-16 18:36:03 +09002731 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002732 }
2733
2734_done_:
2735 return s32Error;
2736}
2737
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07002738static void ListenTimerCB(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002739{
Leo Kime6e12662015-09-16 18:36:03 +09002740 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09002741 struct host_if_msg msg;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002742 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
Leo Kimae4dfa52015-10-13 19:49:26 +09002743
Tony Choa4ab1ad2015-10-12 16:56:05 +09002744 del_timer(&hif_drv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002745
Tony Cho143eb952015-09-21 12:16:32 +09002746 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09002747 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002748 msg.drv = hif_drv;
2749 msg.body.remain_on_ch.u32ListenSessionID = hif_drv->strHostIfRemainOnChan.u32ListenSessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002750
Tony Cho143eb952015-09-21 12:16:32 +09002751 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002752 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09002753 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002754}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002755
Tony Choa4ab1ad2015-10-12 16:56:05 +09002756static void Handle_PowerManagement(struct host_if_drv *hif_drv,
Tony Cho5a008f12015-09-21 12:16:48 +09002757 struct power_mgmt_param *strPowerMgmtParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002758{
Leo Kime6e12662015-09-16 18:36:03 +09002759 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09002760 struct wid strWID;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002761 s8 s8PowerMode;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002762
Leo Kimdaaf16b2015-10-12 16:55:44 +09002763 strWID.id = (u16)WID_POWER_MANAGEMENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002764
Leo Kim33c70c12015-10-13 20:02:07 +09002765 if (strPowerMgmtParam->enabled == true)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002766 s8PowerMode = MIN_FAST_PS;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302767 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002768 s8PowerMode = NO_POWERSAVE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002769 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
Leo Kim900bb4a2015-10-12 16:55:46 +09002770 strWID.val = &s8PowerMode;
Leo Kim2fd3e442015-10-12 16:55:45 +09002771 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002772
2773 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
2774
Tony Cho03362282015-10-12 16:55:39 +09002775 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002776 get_id_from_handler(hif_drv));
Leo Kim24db7132015-09-16 18:36:01 +09002777 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002778 PRINT_ER("Failed to send power management config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002779}
2780
Tony Choa4ab1ad2015-10-12 16:56:05 +09002781static void Handle_SetMulticastFilter(struct host_if_drv *hif_drv,
Tony Cho641210a2015-09-21 12:16:52 +09002782 struct set_multicast *strHostIfSetMulti)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002783{
Leo Kime6e12662015-09-16 18:36:03 +09002784 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09002785 struct wid strWID;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002786 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002787
2788 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
2789
Leo Kimdaaf16b2015-10-12 16:55:44 +09002790 strWID.id = (u16)WID_SETUP_MULTICAST_FILTER;
Leo Kim416d8322015-10-12 16:55:43 +09002791 strWID.type = WID_BIN;
Leo Kimadab2f72015-10-13 20:02:05 +09002792 strWID.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
Leo Kim900bb4a2015-10-12 16:55:46 +09002793 strWID.val = kmalloc(strWID.size, GFP_KERNEL);
2794 if (strWID.val == NULL)
Leo Kim24db7132015-09-16 18:36:01 +09002795 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002796
Leo Kim900bb4a2015-10-12 16:55:46 +09002797 pu8CurrByte = strWID.val;
Leo Kimbae636eb2015-10-13 20:02:04 +09002798 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
2799 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 8) & 0xFF);
2800 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 16) & 0xFF);
2801 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002802
Leo Kimadab2f72015-10-13 20:02:05 +09002803 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2804 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2805 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2806 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002807
Leo Kimadab2f72015-10-13 20:02:05 +09002808 if ((strHostIfSetMulti->cnt) > 0)
2809 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->cnt) * ETH_ALEN));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002810
Tony Cho03362282015-10-12 16:55:39 +09002811 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002812 get_id_from_handler(hif_drv));
Leo Kim24db7132015-09-16 18:36:01 +09002813 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002814 PRINT_ER("Failed to send setup multicast config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002815
Leo Kim24db7132015-09-16 18:36:01 +09002816ERRORHANDLER:
Leo Kim900bb4a2015-10-12 16:55:46 +09002817 kfree(strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002818
2819}
2820
Tony Choa4ab1ad2015-10-12 16:56:05 +09002821static s32 Handle_AddBASession(struct host_if_drv *hif_drv,
Tony Cho54265472015-09-21 12:16:56 +09002822 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002823{
Leo Kime6e12662015-09-16 18:36:03 +09002824 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09002825 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002826 int AddbaTimeout = 100;
2827 char *ptr = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002828
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002829 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 +09002830 strHostIfBASessionInfo->au8Bssid[0],
2831 strHostIfBASessionInfo->au8Bssid[1],
2832 strHostIfBASessionInfo->au8Bssid[2],
2833 strHostIfBASessionInfo->u16BufferSize,
2834 strHostIfBASessionInfo->u16SessionTimeout,
2835 strHostIfBASessionInfo->u8Ted);
2836
Leo Kimdaaf16b2015-10-12 16:55:44 +09002837 strWID.id = (u16)WID_11E_P_ACTION_REQ;
Leo Kim416d8322015-10-12 16:55:43 +09002838 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002839 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Leo Kim2fd3e442015-10-12 16:55:45 +09002840 strWID.size = BLOCK_ACK_REQ_SIZE;
Leo Kim900bb4a2015-10-12 16:55:46 +09002841 ptr = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002842 *ptr++ = 0x14;
2843 *ptr++ = 0x3;
2844 *ptr++ = 0x0;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002845 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002846 ptr += ETH_ALEN;
2847 *ptr++ = strHostIfBASessionInfo->u8Ted;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002848 *ptr++ = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002849 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2850 *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002851 *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
2852 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002853 *ptr++ = (AddbaTimeout & 0xFF);
2854 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002855 *ptr++ = 8;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002856 *ptr++ = 0;
2857
Tony Cho03362282015-10-12 16:55:39 +09002858 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002859 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002860 if (s32Error)
2861 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
2862
2863
Leo Kimdaaf16b2015-10-12 16:55:44 +09002864 strWID.id = (u16)WID_11E_P_ACTION_REQ;
Leo Kim416d8322015-10-12 16:55:43 +09002865 strWID.type = WID_STR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002866 strWID.size = 15;
Leo Kim900bb4a2015-10-12 16:55:46 +09002867 ptr = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002868 *ptr++ = 15;
2869 *ptr++ = 7;
2870 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002871 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002872 ptr += ETH_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002873 *ptr++ = strHostIfBASessionInfo->u8Ted;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002874 *ptr++ = 8;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002875 *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
2876 *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002877 *ptr++ = 3;
Tony Cho03362282015-10-12 16:55:39 +09002878 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002879 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002880
Leo Kim900bb4a2015-10-12 16:55:46 +09002881 if (strWID.val != NULL)
2882 kfree(strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002883
2884 return s32Error;
2885
2886}
2887
Tony Choa4ab1ad2015-10-12 16:56:05 +09002888static s32 Handle_DelAllRxBASessions(struct host_if_drv *hif_drv,
Tony Cho54265472015-09-21 12:16:56 +09002889 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002890{
Leo Kime6e12662015-09-16 18:36:03 +09002891 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09002892 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002893 char *ptr = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002894
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002895 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002896 strHostIfBASessionInfo->au8Bssid[0],
2897 strHostIfBASessionInfo->au8Bssid[1],
2898 strHostIfBASessionInfo->au8Bssid[2],
2899 strHostIfBASessionInfo->u8Ted);
2900
Leo Kimdaaf16b2015-10-12 16:55:44 +09002901 strWID.id = (u16)WID_DEL_ALL_RX_BA;
Leo Kim416d8322015-10-12 16:55:43 +09002902 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09002903 strWID.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
Leo Kim2fd3e442015-10-12 16:55:45 +09002904 strWID.size = BLOCK_ACK_REQ_SIZE;
Leo Kim900bb4a2015-10-12 16:55:46 +09002905 ptr = strWID.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002906 *ptr++ = 0x14;
2907 *ptr++ = 0x3;
2908 *ptr++ = 0x2;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002909 memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002910 ptr += ETH_ALEN;
2911 *ptr++ = strHostIfBASessionInfo->u8Ted;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002912 *ptr++ = 0;
Leo Kimae4dfa52015-10-13 19:49:26 +09002913 *ptr++ = 32;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002914
Tony Cho03362282015-10-12 16:55:39 +09002915 s32Error = send_config_pkt(SET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09002916 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002917 if (s32Error)
2918 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
2919
2920
Leo Kim900bb4a2015-10-12 16:55:46 +09002921 if (strWID.val != NULL)
2922 kfree(strWID.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002923
Arnd Bergmann83383ea2015-06-01 21:06:43 +02002924 up(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002925
2926 return s32Error;
2927
2928}
2929
Arnd Bergmann1999bd52015-05-29 22:52:14 +02002930static int hostIFthread(void *pvArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002931{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002932 u32 u32Ret;
Tony Cho143eb952015-09-21 12:16:32 +09002933 struct host_if_msg msg;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002934 struct host_if_drv *hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002935
Tony Cho143eb952015-09-21 12:16:32 +09002936 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002937
2938 while (1) {
Tony Cho143eb952015-09-21 12:16:32 +09002939 wilc_mq_recv(&gMsgQHostIF, &msg, sizeof(struct host_if_msg), &u32Ret);
Tony Choa4ab1ad2015-10-12 16:56:05 +09002940 hif_drv = (struct host_if_drv *)msg.drv;
Tony Choa9f812a2015-09-21 12:16:33 +09002941 if (msg.id == HOST_IF_MSG_EXIT) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002942 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
2943 break;
2944 }
2945
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002946 if ((!g_wilc_initialized)) {
2947 PRINT_D(GENERIC_DBG, "--WAIT--");
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07002948 usleep_range(200 * 1000, 200 * 1000);
Tony Cho143eb952015-09-21 12:16:32 +09002949 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002950 continue;
2951 }
2952
Tony Choa4ab1ad2015-10-12 16:56:05 +09002953 if (msg.id == HOST_IF_MSG_CONNECT && hif_drv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002954 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
Tony Cho143eb952015-09-21 12:16:32 +09002955 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07002956 usleep_range(2 * 1000, 2 * 1000);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002957 continue;
2958 }
2959
Tony Choa9f812a2015-09-21 12:16:33 +09002960 switch (msg.id) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002961 case HOST_IF_MSG_Q_IDLE:
2962 Handle_wait_msg_q_empty();
2963 break;
2964
2965 case HOST_IF_MSG_SCAN:
Leo Kim2482a792015-10-12 16:55:36 +09002966 Handle_Scan(msg.drv, &msg.body.scan_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002967 break;
2968
2969 case HOST_IF_MSG_CONNECT:
Leo Kim2482a792015-10-12 16:55:36 +09002970 Handle_Connect(msg.drv, &msg.body.con_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002971 break;
2972
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002973 case HOST_IF_MSG_FLUSH_CONNECT:
Leo Kim2482a792015-10-12 16:55:36 +09002974 Handle_FlushConnect(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002975 break;
2976
2977 case HOST_IF_MSG_RCVD_NTWRK_INFO:
Leo Kim2482a792015-10-12 16:55:36 +09002978 Handle_RcvdNtwrkInfo(msg.drv, &msg.body.net_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002979 break;
2980
2981 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
Leo Kim2482a792015-10-12 16:55:36 +09002982 Handle_RcvdGnrlAsyncInfo(msg.drv, &msg.body.async_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002983 break;
2984
2985 case HOST_IF_MSG_KEY:
Leo Kim2482a792015-10-12 16:55:36 +09002986 Handle_Key(msg.drv, &msg.body.key_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002987 break;
2988
2989 case HOST_IF_MSG_CFG_PARAMS:
2990
Leo Kim2482a792015-10-12 16:55:36 +09002991 Handle_CfgParam(msg.drv, &msg.body.cfg_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002992 break;
2993
2994 case HOST_IF_MSG_SET_CHANNEL:
Leo Kim2482a792015-10-12 16:55:36 +09002995 Handle_SetChannel(msg.drv, &msg.body.channel_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002996 break;
2997
2998 case HOST_IF_MSG_DISCONNECT:
Leo Kim2482a792015-10-12 16:55:36 +09002999 Handle_Disconnect(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003000 break;
3001
3002 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
Tony Choa4ab1ad2015-10-12 16:56:05 +09003003 del_timer(&hif_drv->hScanTimer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003004 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
3005
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003006 if (!linux_wlan_get_num_conn_ifcs())
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003007 chip_sleep_manually(INFINITE_SLEEP_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003008
Leo Kim2482a792015-10-12 16:55:36 +09003009 Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003010
Tony Choa4ab1ad2015-10-12 16:56:05 +09003011 if (hif_drv->u8RemainOnChan_pendingreq)
Leo Kim2482a792015-10-12 16:55:36 +09003012 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003013
3014 break;
3015
3016 case HOST_IF_MSG_GET_RSSI:
Leo Kim2482a792015-10-12 16:55:36 +09003017 Handle_GetRssi(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003018 break;
3019
3020 case HOST_IF_MSG_GET_LINKSPEED:
Leo Kim2482a792015-10-12 16:55:36 +09003021 Handle_GetLinkspeed(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003022 break;
3023
3024 case HOST_IF_MSG_GET_STATISTICS:
Leo Kim03e7b9c2015-10-12 16:55:58 +09003025 Handle_GetStatistics(msg.drv, (struct rf_info *)msg.body.data);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003026 break;
3027
3028 case HOST_IF_MSG_GET_CHNL:
Leo Kim2482a792015-10-12 16:55:36 +09003029 Handle_GetChnl(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003030 break;
3031
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003032 case HOST_IF_MSG_ADD_BEACON:
Leo Kim2482a792015-10-12 16:55:36 +09003033 Handle_AddBeacon(msg.drv, &msg.body.beacon_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003034 break;
3035
3036 case HOST_IF_MSG_DEL_BEACON:
Leo Kim2482a792015-10-12 16:55:36 +09003037 Handle_DelBeacon(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003038 break;
3039
3040 case HOST_IF_MSG_ADD_STATION:
Leo Kim2482a792015-10-12 16:55:36 +09003041 Handle_AddStation(msg.drv, &msg.body.add_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003042 break;
3043
3044 case HOST_IF_MSG_DEL_STATION:
Leo Kim2482a792015-10-12 16:55:36 +09003045 Handle_DelStation(msg.drv, &msg.body.del_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003046 break;
3047
3048 case HOST_IF_MSG_EDIT_STATION:
Leo Kim2482a792015-10-12 16:55:36 +09003049 Handle_EditStation(msg.drv, &msg.body.edit_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003050 break;
3051
3052 case HOST_IF_MSG_GET_INACTIVETIME:
Leo Kim2482a792015-10-12 16:55:36 +09003053 Handle_Get_InActiveTime(msg.drv, &msg.body.mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003054 break;
3055
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003056 case HOST_IF_MSG_SCAN_TIMER_FIRED:
3057 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
3058
Leo Kim2482a792015-10-12 16:55:36 +09003059 Handle_ScanDone(msg.drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003060 break;
3061
3062 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003063 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
Leo Kim2482a792015-10-12 16:55:36 +09003064 Handle_ConnectTimeout(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003065 break;
3066
3067 case HOST_IF_MSG_POWER_MGMT:
Leo Kim2482a792015-10-12 16:55:36 +09003068 Handle_PowerManagement(msg.drv, &msg.body.pwr_mgmt_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003069 break;
3070
3071 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
Leo Kim2482a792015-10-12 16:55:36 +09003072 Handle_SetWfiDrvHandler(msg.drv,
Tony Cho5e4377e2015-09-30 18:44:38 +09003073 &msg.body.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003074 break;
3075
3076 case HOST_IF_MSG_SET_OPERATION_MODE:
Leo Kim2482a792015-10-12 16:55:36 +09003077 Handle_SetOperationMode(msg.drv, &msg.body.mode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003078 break;
3079
3080 case HOST_IF_MSG_SET_IPADDRESS:
3081 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Leo Kim78675be2015-10-13 20:02:09 +09003082 Handle_set_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003083 break;
3084
3085 case HOST_IF_MSG_GET_IPADDRESS:
3086 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Leo Kim78675be2015-10-13 20:02:09 +09003087 Handle_get_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003088 break;
3089
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003090 case HOST_IF_MSG_SET_MAC_ADDRESS:
Leo Kim2482a792015-10-12 16:55:36 +09003091 Handle_SetMacAddress(msg.drv, &msg.body.set_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003092 break;
3093
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003094 case HOST_IF_MSG_GET_MAC_ADDRESS:
Leo Kim2482a792015-10-12 16:55:36 +09003095 Handle_GetMacAddress(msg.drv, &msg.body.get_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003096 break;
3097
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003098 case HOST_IF_MSG_REMAIN_ON_CHAN:
3099 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
Leo Kim2482a792015-10-12 16:55:36 +09003100 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003101 break;
3102
3103 case HOST_IF_MSG_REGISTER_FRAME:
3104 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
Leo Kim2482a792015-10-12 16:55:36 +09003105 Handle_RegisterFrame(msg.drv, &msg.body.reg_frame);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003106 break;
3107
3108 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
Leo Kim2482a792015-10-12 16:55:36 +09003109 Handle_ListenStateExpired(msg.drv, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003110 break;
3111
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003112 case HOST_IF_MSG_SET_MULTICAST_FILTER:
3113 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
Leo Kim2482a792015-10-12 16:55:36 +09003114 Handle_SetMulticastFilter(msg.drv, &msg.body.multicast_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003115 break;
3116
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003117 case HOST_IF_MSG_ADD_BA_SESSION:
Leo Kim2482a792015-10-12 16:55:36 +09003118 Handle_AddBASession(msg.drv, &msg.body.session_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003119 break;
3120
3121 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
Leo Kim2482a792015-10-12 16:55:36 +09003122 Handle_DelAllRxBASessions(msg.drv, &msg.body.session_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003123 break;
3124
3125 case HOST_IF_MSG_DEL_ALL_STA:
Leo Kim2482a792015-10-12 16:55:36 +09003126 Handle_DelAllSta(msg.drv, &msg.body.del_all_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003127 break;
3128
3129 default:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003130 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003131 break;
3132 }
3133 }
3134
3135 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003136 up(&hSemHostIFthrdEnd);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02003137 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003138}
3139
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003140static void TimerCB_Scan(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003141{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003142 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09003143 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003144
Tony Cho143eb952015-09-21 12:16:32 +09003145 memset(&msg, 0, sizeof(struct host_if_msg));
Leo Kim2482a792015-10-12 16:55:36 +09003146 msg.drv = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09003147 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003148
Tony Cho143eb952015-09-21 12:16:32 +09003149 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003150}
3151
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003152static void TimerCB_Connect(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003153{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003154 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09003155 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003156
Tony Cho143eb952015-09-21 12:16:32 +09003157 memset(&msg, 0, sizeof(struct host_if_msg));
Leo Kim2482a792015-10-12 16:55:36 +09003158 msg.drv = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09003159 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003160
Tony Cho143eb952015-09-21 12:16:32 +09003161 wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003162}
3163
Tony Choa4ab1ad2015-10-12 16:56:05 +09003164s32 host_int_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003165{
Leo Kime9e0c262015-10-12 16:55:41 +09003166 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003167
Leo Kimdaaf16b2015-10-12 16:55:44 +09003168 strWID.id = (u16)WID_REMOVE_KEY;
Leo Kim416d8322015-10-12 16:55:43 +09003169 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09003170 strWID.val = (s8 *)pu8StaAddress;
Leo Kim2fd3e442015-10-12 16:55:45 +09003171 strWID.size = 6;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003172
Leo Kimb68d820b2015-10-12 16:55:37 +09003173 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003174}
3175
Tony Choa4ab1ad2015-10-12 16:56:05 +09003176int host_int_remove_wep_key(struct host_if_drv *hif_drv, u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003177{
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003178 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003179 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003180
Tony Choa4ab1ad2015-10-12 16:56:05 +09003181 if (!hif_drv) {
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003182 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003183 PRINT_ER("Failed to send setup multicast config packet\n");
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003184 return result;
Leo Kim24db7132015-09-16 18:36:01 +09003185 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003186
Tony Cho143eb952015-09-21 12:16:32 +09003187 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003188
Tony Choa9f812a2015-09-21 12:16:33 +09003189 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003190 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003191 msg.body.key_info.action = REMOVEKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003192 msg.drv = hif_drv;
Leo Kim73b2e382015-10-13 19:49:29 +09003193 msg.body.key_info.attr.wep.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003194
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003195 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3196 if (result)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003197 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09003198 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003199
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003200 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003201}
3202
Tony Choa4ab1ad2015-10-12 16:56:05 +09003203s32 host_int_set_WEPDefaultKeyID(struct host_if_drv *hif_drv, u8 u8Index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003204{
Leo Kime6e12662015-09-16 18:36:03 +09003205 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003206 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003207
3208
Tony Choa4ab1ad2015-10-12 16:56:05 +09003209 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003210 s32Error = -EFAULT;
3211 PRINT_ER("driver is null\n");
3212 return s32Error;
3213 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003214
Tony Cho143eb952015-09-21 12:16:32 +09003215 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003216
3217
Tony Choa9f812a2015-09-21 12:16:33 +09003218 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003219 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003220 msg.body.key_info.action = DEFAULTKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003221 msg.drv = hif_drv;
Leo Kim73b2e382015-10-13 19:49:29 +09003222 msg.body.key_info.attr.wep.index = u8Index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003223
Tony Cho143eb952015-09-21 12:16:32 +09003224 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003225 if (s32Error)
3226 PRINT_ER("Error in sending message queue : Default key index\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09003227 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003228
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003229 return s32Error;
3230}
3231
Tony Choa4ab1ad2015-10-12 16:56:05 +09003232s32 host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
3233 const u8 *pu8WepKey,
3234 u8 u8WepKeylen,
3235 u8 u8Keyidx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003236{
3237
Leo Kime6e12662015-09-16 18:36:03 +09003238 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003239 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003240
Tony Choa4ab1ad2015-10-12 16:56:05 +09003241 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003242 s32Error = -EFAULT;
3243 PRINT_ER("driver is null\n");
3244 return s32Error;
3245 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003246
Tony Cho143eb952015-09-21 12:16:32 +09003247 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003248
3249
Tony Choa9f812a2015-09-21 12:16:33 +09003250 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003251 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003252 msg.body.key_info.action = ADDKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003253 msg.drv = hif_drv;
Leo Kim73b2e382015-10-13 19:49:29 +09003254 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3255 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, u8WepKeylen);
3256 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3257 msg.body.key_info.attr.wep.index = u8Keyidx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003258
Tony Cho143eb952015-09-21 12:16:32 +09003259 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003260 if (s32Error)
3261 PRINT_ER("Error in sending message queue :WEP Key\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09003262 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003263
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003264 return s32Error;
3265
3266}
3267
Tony Choa4ab1ad2015-10-12 16:56:05 +09003268s32 host_int_add_wep_key_bss_ap(struct host_if_drv *hif_drv,
3269 const u8 *pu8WepKey,
3270 u8 u8WepKeylen,
3271 u8 u8Keyidx,
3272 u8 u8mode,
3273 enum AUTHTYPE tenuAuth_type)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003274{
3275
Leo Kime6e12662015-09-16 18:36:03 +09003276 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003277 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003278 u8 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003279
Tony Choa4ab1ad2015-10-12 16:56:05 +09003280 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003281 s32Error = -EFAULT;
3282 PRINT_ER("driver is null\n");
3283 return s32Error;
3284 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003285
Tony Cho143eb952015-09-21 12:16:32 +09003286 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003287
3288 if (INFO) {
3289 for (i = 0; i < u8WepKeylen; i++)
3290 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
3291 }
Tony Choa9f812a2015-09-21 12:16:33 +09003292 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003293 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003294 msg.body.key_info.action = ADDKEY_AP;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003295 msg.drv = hif_drv;
Leo Kim73b2e382015-10-13 19:49:29 +09003296 msg.body.key_info.attr.wep.key = kmalloc(u8WepKeylen, GFP_KERNEL);
3297 memcpy(msg.body.key_info.attr.wep.key, pu8WepKey, (u8WepKeylen));
3298 msg.body.key_info.attr.wep.key_len = (u8WepKeylen);
3299 msg.body.key_info.attr.wep.index = u8Keyidx;
3300 msg.body.key_info.attr.wep.mode = u8mode;
3301 msg.body.key_info.attr.wep.auth_type = tenuAuth_type;
Leo Kimae4dfa52015-10-13 19:49:26 +09003302
Tony Cho143eb952015-09-21 12:16:32 +09003303 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003304
3305 if (s32Error)
3306 PRINT_ER("Error in sending message queue :WEP Key\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09003307 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003308
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003309 return s32Error;
3310
3311}
Glen Lee108b3432015-09-16 18:53:20 +09003312
Tony Choa4ab1ad2015-10-12 16:56:05 +09003313s32 host_int_add_ptk(struct host_if_drv *hif_drv, const u8 *pu8Ptk,
3314 u8 u8PtkKeylen, const u8 *mac_addr,
3315 const u8 *pu8RxMic, const u8 *pu8TxMic,
3316 u8 mode, u8 u8Ciphermode, u8 u8Idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003317{
Leo Kime6e12662015-09-16 18:36:03 +09003318 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003319 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003320 u8 u8KeyLen = u8PtkKeylen;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003321 u32 i;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003322
Tony Choa4ab1ad2015-10-12 16:56:05 +09003323 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003324 s32Error = -EFAULT;
3325 PRINT_ER("driver is null\n");
3326 return s32Error;
3327 }
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003328 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003329 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003330 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003331 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003332
Tony Cho143eb952015-09-21 12:16:32 +09003333 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003334
3335
Tony Choa9f812a2015-09-21 12:16:33 +09003336 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003337 msg.body.key_info.type = WPAPtk;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003338 if (mode == AP_MODE) {
Leo Kim0d17e382015-10-13 19:49:28 +09003339 msg.body.key_info.action = ADDKEY_AP;
Leo Kime2dfbac2015-10-13 19:49:34 +09003340 msg.body.key_info.attr.wpa.index = u8Idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003341 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003342 if (mode == STATION_MODE)
Leo Kim0d17e382015-10-13 19:49:28 +09003343 msg.body.key_info.action = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003344
Leo Kim124968fc2015-10-13 19:49:30 +09003345 msg.body.key_info.attr.wpa.key = kmalloc(u8PtkKeylen, GFP_KERNEL);
3346 memcpy(msg.body.key_info.attr.wpa.key, pu8Ptk, u8PtkKeylen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003347
3348 if (pu8RxMic != NULL) {
Leo Kim124968fc2015-10-13 19:49:30 +09003349 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003350 if (INFO) {
3351 for (i = 0; i < RX_MIC_KEY_LEN; i++)
3352 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
3353 }
3354 }
3355 if (pu8TxMic != NULL) {
Leo Kim124968fc2015-10-13 19:49:30 +09003356 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003357 if (INFO) {
3358 for (i = 0; i < TX_MIC_KEY_LEN; i++)
3359 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
3360 }
3361 }
3362
Leo Kim6acf2912015-10-13 19:49:35 +09003363 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
Leo Kim248080a2015-10-13 19:49:31 +09003364 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
Leo Kim7b2ebb22015-10-13 19:49:36 +09003365 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003366 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003367
Tony Cho143eb952015-09-21 12:16:32 +09003368 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003369
3370 if (s32Error)
3371 PRINT_ER("Error in sending message queue: PTK Key\n");
3372
Tony Choa4ab1ad2015-10-12 16:56:05 +09003373 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003374
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003375 return s32Error;
3376}
3377
Tony Choa4ab1ad2015-10-12 16:56:05 +09003378s32 host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *pu8RxGtk,
3379 u8 u8GtkKeylen, u8 u8KeyIdx,
3380 u32 u32KeyRSClen, const u8 *KeyRSC,
3381 const u8 *pu8RxMic, const u8 *pu8TxMic,
3382 u8 mode, u8 u8Ciphermode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003383{
Leo Kime6e12662015-09-16 18:36:03 +09003384 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003385 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003386 u8 u8KeyLen = u8GtkKeylen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003387
Tony Choa4ab1ad2015-10-12 16:56:05 +09003388 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003389 s32Error = -EFAULT;
3390 PRINT_ER("driver is null\n");
3391 return s32Error;
3392 }
Tony Cho143eb952015-09-21 12:16:32 +09003393 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003394
3395
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003396 if (pu8RxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003397 u8KeyLen += RX_MIC_KEY_LEN;
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02003398 if (pu8TxMic != NULL)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003399 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003400 if (KeyRSC != NULL) {
Leo Kim0e74c002015-10-13 19:49:32 +09003401 msg.body.key_info.attr.wpa.seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
3402 memcpy(msg.body.key_info.attr.wpa.seq, KeyRSC, u32KeyRSClen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003403 }
3404
3405
Tony Choa9f812a2015-09-21 12:16:33 +09003406 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003407 msg.body.key_info.type = WPARxGtk;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003408 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003409
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003410 if (mode == AP_MODE) {
Leo Kim0d17e382015-10-13 19:49:28 +09003411 msg.body.key_info.action = ADDKEY_AP;
Leo Kim7b2ebb22015-10-13 19:49:36 +09003412 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003413 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003414 if (mode == STATION_MODE)
Leo Kim0d17e382015-10-13 19:49:28 +09003415 msg.body.key_info.action = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003416
Leo Kim124968fc2015-10-13 19:49:30 +09003417 msg.body.key_info.attr.wpa.key = kmalloc(u8KeyLen, GFP_KERNEL);
3418 memcpy(msg.body.key_info.attr.wpa.key, pu8RxGtk, u8GtkKeylen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003419
3420 if (pu8RxMic != NULL) {
Leo Kim124968fc2015-10-13 19:49:30 +09003421 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003422 }
3423 if (pu8TxMic != NULL) {
Leo Kim124968fc2015-10-13 19:49:30 +09003424 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003425 }
3426
Leo Kime2dfbac2015-10-13 19:49:34 +09003427 msg.body.key_info.attr.wpa.index = u8KeyIdx;
Leo Kim6acf2912015-10-13 19:49:35 +09003428 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
Leo Kimdacc5942015-10-13 19:49:33 +09003429 msg.body.key_info.attr.wpa.seq_len = u32KeyRSClen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003430
Tony Cho143eb952015-09-21 12:16:32 +09003431 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003432 if (s32Error)
3433 PRINT_ER("Error in sending message queue: RX GTK\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09003434
Tony Choa4ab1ad2015-10-12 16:56:05 +09003435 down(&hif_drv->hSemTestKeyBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003436
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003437 return s32Error;
3438}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003439
Tony Choa4ab1ad2015-10-12 16:56:05 +09003440s32 host_int_set_pmkid_info(struct host_if_drv *hif_drv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003441{
Leo Kime6e12662015-09-16 18:36:03 +09003442 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003443 struct host_if_msg msg;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003444 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003445
3446
Tony Choa4ab1ad2015-10-12 16:56:05 +09003447 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003448 s32Error = -EFAULT;
3449 PRINT_ER("driver is null\n");
3450 return s32Error;
3451 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003452
Tony Cho143eb952015-09-21 12:16:32 +09003453 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003454
Tony Choa9f812a2015-09-21 12:16:33 +09003455 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003456 msg.body.key_info.type = PMKSA;
Leo Kim0d17e382015-10-13 19:49:28 +09003457 msg.body.key_info.action = ADDKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003458 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003459
3460 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
Leo Kim73b2e382015-10-13 19:49:29 +09003461 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003462 ETH_ALEN);
Leo Kim73b2e382015-10-13 19:49:29 +09003463 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003464 PMKID_LEN);
3465 }
3466
Tony Cho143eb952015-09-21 12:16:32 +09003467 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003468 if (s32Error)
3469 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3470
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003471 return s32Error;
3472}
3473
Tony Choa4ab1ad2015-10-12 16:56:05 +09003474s32 host_int_get_pmkid_info(struct host_if_drv *hif_drv,
3475 u8 *pu8PmkidInfoArray,
3476 u32 u32PmkidInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003477{
Leo Kime9e0c262015-10-12 16:55:41 +09003478 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003479
Leo Kimdaaf16b2015-10-12 16:55:44 +09003480 strWID.id = (u16)WID_PMKID_INFO;
Leo Kim416d8322015-10-12 16:55:43 +09003481 strWID.type = WID_STR;
Leo Kim2fd3e442015-10-12 16:55:45 +09003482 strWID.size = u32PmkidInfoLen;
Leo Kim900bb4a2015-10-12 16:55:46 +09003483 strWID.val = pu8PmkidInfoArray;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003484
Leo Kimb68d820b2015-10-12 16:55:37 +09003485 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003486}
3487
Tony Choa4ab1ad2015-10-12 16:56:05 +09003488s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3489 u8 *pu8PassPhrase,
3490 u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003491{
Leo Kime9e0c262015-10-12 16:55:41 +09003492 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003493
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003494 if ((u8Psklength > 7) && (u8Psklength < 65)) {
Leo Kimdaaf16b2015-10-12 16:55:44 +09003495 strWID.id = (u16)WID_11I_PSK;
Leo Kim416d8322015-10-12 16:55:43 +09003496 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09003497 strWID.val = pu8PassPhrase;
Leo Kim2fd3e442015-10-12 16:55:45 +09003498 strWID.size = u8Psklength;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003499 }
3500
Leo Kimb68d820b2015-10-12 16:55:37 +09003501 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003502}
Leo Kimae4dfa52015-10-13 19:49:26 +09003503
Tony Choa4ab1ad2015-10-12 16:56:05 +09003504s32 host_int_get_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003505{
Leo Kime6e12662015-09-16 18:36:03 +09003506 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003507 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003508
Tony Cho143eb952015-09-21 12:16:32 +09003509 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003510
Tony Choa9f812a2015-09-21 12:16:33 +09003511 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
Tony Choa5848692015-09-30 18:55:08 +09003512 msg.body.get_mac_info.u8MacAddress = pu8MacAddress;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003513 msg.drv = hif_drv;
Leo Kimae4dfa52015-10-13 19:49:26 +09003514
Tony Cho143eb952015-09-21 12:16:32 +09003515 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003516 if (s32Error) {
3517 PRINT_ER("Failed to send get mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +09003518 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003519 }
3520
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003521 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003522 return s32Error;
3523}
3524
Tony Choa4ab1ad2015-10-12 16:56:05 +09003525s32 host_int_set_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003526{
Leo Kime6e12662015-09-16 18:36:03 +09003527 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003528 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003529
3530 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
3531
Tony Cho143eb952015-09-21 12:16:32 +09003532 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003533 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
Tony Cho15326e22015-09-30 18:55:07 +09003534 memcpy(msg.body.set_mac_info.u8MacAddress, pu8MacAddress, ETH_ALEN);
Tony Choa4ab1ad2015-10-12 16:56:05 +09003535 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003536
Tony Cho143eb952015-09-21 12:16:32 +09003537 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim24db7132015-09-16 18:36:01 +09003538 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003539 PRINT_ER("Failed to send message queue: Set mac address\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003540
3541 return s32Error;
3542
3543}
3544
Tony Choa4ab1ad2015-10-12 16:56:05 +09003545s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3546 u8 *pu8PassPhrase, u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003547{
Leo Kime9e0c262015-10-12 16:55:41 +09003548 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003549
Leo Kimdaaf16b2015-10-12 16:55:44 +09003550 strWID.id = (u16)WID_11I_PSK;
Leo Kim416d8322015-10-12 16:55:43 +09003551 strWID.type = WID_STR;
Leo Kim2fd3e442015-10-12 16:55:45 +09003552 strWID.size = u8Psklength;
Leo Kim900bb4a2015-10-12 16:55:46 +09003553 strWID.val = pu8PassPhrase;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003554
Leo Kimb68d820b2015-10-12 16:55:37 +09003555 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003556}
3557
Tony Choa4ab1ad2015-10-12 16:56:05 +09003558s32 host_int_set_start_scan_req(struct host_if_drv *hif_drv, u8 scanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003559{
Leo Kime9e0c262015-10-12 16:55:41 +09003560 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003561
Leo Kimdaaf16b2015-10-12 16:55:44 +09003562 strWID.id = (u16)WID_START_SCAN_REQ;
Leo Kim416d8322015-10-12 16:55:43 +09003563 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09003564 strWID.val = (s8 *)&scanSource;
Leo Kim2fd3e442015-10-12 16:55:45 +09003565 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003566
Leo Kimb68d820b2015-10-12 16:55:37 +09003567 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003568}
3569
Tony Choa4ab1ad2015-10-12 16:56:05 +09003570s32 host_int_get_start_scan_req(struct host_if_drv *hif_drv, u8 *pu8ScanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003571{
Leo Kime9e0c262015-10-12 16:55:41 +09003572 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003573
Leo Kimdaaf16b2015-10-12 16:55:44 +09003574 strWID.id = (u16)WID_START_SCAN_REQ;
Leo Kim416d8322015-10-12 16:55:43 +09003575 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09003576 strWID.val = (s8 *)pu8ScanSource;
Leo Kim2fd3e442015-10-12 16:55:45 +09003577 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003578
Leo Kimb68d820b2015-10-12 16:55:37 +09003579 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003580}
3581
Tony Choa4ab1ad2015-10-12 16:56:05 +09003582s32 host_int_set_join_req(struct host_if_drv *hif_drv, u8 *pu8bssid,
3583 const u8 *pu8ssid, size_t ssidLen,
3584 const u8 *pu8IEs, size_t IEsLen,
3585 wilc_connect_result pfConnectResult, void *pvUserArg,
3586 u8 u8security, enum AUTHTYPE tenuAuth_type,
3587 u8 u8channel, void *pJoinParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003588{
Leo Kime6e12662015-09-16 18:36:03 +09003589 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003590 struct host_if_msg msg;
Leo Kim7696edf2015-10-12 16:56:02 +09003591 enum scan_conn_timer enuScanConnTimer;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003592
Tony Choa4ab1ad2015-10-12 16:56:05 +09003593 if (!hif_drv || pfConnectResult == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09003594 s32Error = -EFAULT;
3595 PRINT_ER("Driver is null\n");
3596 return s32Error;
3597 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003598
Tony Choa4ab1ad2015-10-12 16:56:05 +09003599 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003600 PRINT_ER("Driver is null\n");
3601 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003602 }
3603
3604 if (pJoinParams == NULL) {
3605 PRINT_ER("Unable to Join - JoinParams is NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003606 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003607 }
Leo Kim24db7132015-09-16 18:36:01 +09003608
Tony Cho143eb952015-09-21 12:16:32 +09003609 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003610
Tony Choa9f812a2015-09-21 12:16:33 +09003611 msg.id = HOST_IF_MSG_CONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003612
Leo Kima64fd672015-10-13 19:49:54 +09003613 msg.body.con_info.security = u8security;
Leo Kim61b4fd02015-10-13 19:49:57 +09003614 msg.body.con_info.auth_type = tenuAuth_type;
Leo Kim0d1527e2015-10-13 19:49:58 +09003615 msg.body.con_info.ch = u8channel;
Leo Kim6abcc112015-10-13 19:49:55 +09003616 msg.body.con_info.result = pfConnectResult;
Leo Kim8f38db82015-10-13 19:49:56 +09003617 msg.body.con_info.arg = pvUserArg;
Leo Kimf2bed2c2015-10-13 19:49:59 +09003618 msg.body.con_info.params = pJoinParams;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003619 msg.drv = hif_drv ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003620
3621 if (pu8bssid != NULL) {
Leo Kim9254db02015-10-13 19:49:49 +09003622 msg.body.con_info.bssid = kmalloc(6, GFP_KERNEL);
3623 memcpy(msg.body.con_info.bssid, pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003624 }
3625
3626 if (pu8ssid != NULL) {
Leo Kim8b3c9fa2015-10-13 19:49:51 +09003627 msg.body.con_info.ssid_len = ssidLen;
Leo Kimf7bbd9c2015-10-13 19:49:50 +09003628 msg.body.con_info.ssid = kmalloc(ssidLen, GFP_KERNEL);
3629 memcpy(msg.body.con_info.ssid, pu8ssid, ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003630 }
3631
3632 if (pu8IEs != NULL) {
Leo Kimb59d5c52015-10-13 19:49:53 +09003633 msg.body.con_info.ies_len = IEsLen;
Leo Kim2ea158c2015-10-13 19:49:52 +09003634 msg.body.con_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3635 memcpy(msg.body.con_info.ies, pu8IEs, IEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003636 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09003637 if (hif_drv->enuHostIFstate < HOST_IF_CONNECTING)
3638 hif_drv->enuHostIFstate = HOST_IF_CONNECTING;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05303639 else
Tony Choa4ab1ad2015-10-12 16:56:05 +09003640 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", hif_drv->enuHostIFstate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003641
Tony Cho143eb952015-09-21 12:16:32 +09003642 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003643 if (s32Error) {
3644 PRINT_ER("Failed to send message queue: Set join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09003645 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003646 }
3647
3648 enuScanConnTimer = CONNECT_TIMER;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003649 hif_drv->hConnectTimer.data = (unsigned long)hif_drv;
3650 mod_timer(&hif_drv->hConnectTimer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003651 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003652
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003653 return s32Error;
3654}
3655
Tony Choa4ab1ad2015-10-12 16:56:05 +09003656s32 host_int_flush_join_req(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003657{
Leo Kime6e12662015-09-16 18:36:03 +09003658 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003659 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003660
3661 if (!gu8FlushedJoinReq) {
Leo Kime6e12662015-09-16 18:36:03 +09003662 s32Error = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003663 return s32Error;
3664 }
3665
3666
Tony Choa4ab1ad2015-10-12 16:56:05 +09003667 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003668 s32Error = -EFAULT;
3669 PRINT_ER("Driver is null\n");
3670 return s32Error;
3671 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003672
Tony Choa9f812a2015-09-21 12:16:33 +09003673 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003674 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003675
Tony Cho143eb952015-09-21 12:16:32 +09003676 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003677 if (s32Error) {
3678 PRINT_ER("Failed to send message queue: Flush join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09003679 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003680 }
3681
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003682 return s32Error;
3683}
3684
Tony Choa4ab1ad2015-10-12 16:56:05 +09003685s32 host_int_disconnect(struct host_if_drv *hif_drv, u16 u16ReasonCode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003686{
Leo Kime6e12662015-09-16 18:36:03 +09003687 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003688 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003689
Tony Choa4ab1ad2015-10-12 16:56:05 +09003690 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003691 PRINT_ER("Driver is null\n");
3692 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003693 }
3694
Tony Cho143eb952015-09-21 12:16:32 +09003695 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003696
Tony Choa9f812a2015-09-21 12:16:33 +09003697 msg.id = HOST_IF_MSG_DISCONNECT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003698 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003699
Tony Cho143eb952015-09-21 12:16:32 +09003700 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003701 if (s32Error)
3702 PRINT_ER("Failed to send message queue: disconnect\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09003703
Tony Choa4ab1ad2015-10-12 16:56:05 +09003704 down(&hif_drv->hSemTestDisconnectBlock);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003705
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003706 return s32Error;
3707}
3708
Tony Choa4ab1ad2015-10-12 16:56:05 +09003709s32 host_int_disconnect_station(struct host_if_drv *hif_drv, u8 assoc_id)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003710{
Leo Kime9e0c262015-10-12 16:55:41 +09003711 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003712
Leo Kimdaaf16b2015-10-12 16:55:44 +09003713 strWID.id = (u16)WID_DISCONNECT;
Leo Kim416d8322015-10-12 16:55:43 +09003714 strWID.type = WID_CHAR;
Leo Kim900bb4a2015-10-12 16:55:46 +09003715 strWID.val = (s8 *)&assoc_id;
Leo Kim2fd3e442015-10-12 16:55:45 +09003716 strWID.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003717
Leo Kimb68d820b2015-10-12 16:55:37 +09003718 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003719}
3720
Tony Choa4ab1ad2015-10-12 16:56:05 +09003721s32 host_int_get_assoc_req_info(struct host_if_drv *hif_drv, u8 *pu8AssocReqInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003722 u32 u32AssocReqInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003723{
Leo Kime9e0c262015-10-12 16:55:41 +09003724 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003725
Leo Kimdaaf16b2015-10-12 16:55:44 +09003726 strWID.id = (u16)WID_ASSOC_REQ_INFO;
Leo Kim416d8322015-10-12 16:55:43 +09003727 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09003728 strWID.val = pu8AssocReqInfo;
Leo Kim2fd3e442015-10-12 16:55:45 +09003729 strWID.size = u32AssocReqInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003730
Leo Kimb68d820b2015-10-12 16:55:37 +09003731 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003732}
3733
Tony Choa4ab1ad2015-10-12 16:56:05 +09003734s32 host_int_get_assoc_res_info(struct host_if_drv *hif_drv, u8 *pu8AssocRespInfo,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003735 u32 u32MaxAssocRespInfoLen, u32 *pu32RcvdAssocRespInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003736{
Leo Kime6e12662015-09-16 18:36:03 +09003737 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09003738 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003739
Tony Choa4ab1ad2015-10-12 16:56:05 +09003740 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003741 PRINT_ER("Driver is null\n");
3742 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003743 }
3744
Leo Kimdaaf16b2015-10-12 16:55:44 +09003745 strWID.id = (u16)WID_ASSOC_RES_INFO;
Leo Kim416d8322015-10-12 16:55:43 +09003746 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09003747 strWID.val = pu8AssocRespInfo;
Leo Kim2fd3e442015-10-12 16:55:45 +09003748 strWID.size = u32MaxAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003749
Tony Cho03362282015-10-12 16:55:39 +09003750 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09003751 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003752 if (s32Error) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003753 *pu32RcvdAssocRespInfoLen = 0;
Leo Kim24db7132015-09-16 18:36:01 +09003754 PRINT_ER("Failed to send association response config packet\n");
3755 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003756 } else {
Leo Kim2fd3e442015-10-12 16:55:45 +09003757 *pu32RcvdAssocRespInfoLen = strWID.size;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003758 }
3759
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003760 return s32Error;
3761}
3762
Tony Choa4ab1ad2015-10-12 16:56:05 +09003763s32 host_int_get_rx_power_level(struct host_if_drv *hif_drv, u8 *pu8RxPowerLevel,
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003764 u32 u32RxPowerLevelLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003765{
Leo Kime9e0c262015-10-12 16:55:41 +09003766 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003767
Leo Kimdaaf16b2015-10-12 16:55:44 +09003768 strWID.id = (u16)WID_RX_POWER_LEVEL;
Leo Kim416d8322015-10-12 16:55:43 +09003769 strWID.type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09003770 strWID.val = pu8RxPowerLevel;
Leo Kim2fd3e442015-10-12 16:55:45 +09003771 strWID.size = u32RxPowerLevelLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003772
Leo Kimb68d820b2015-10-12 16:55:37 +09003773 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003774}
3775
Tony Choa4ab1ad2015-10-12 16:56:05 +09003776int host_int_set_mac_chnl_num(struct host_if_drv *hif_drv, u8 channel)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003777{
Chaehyun Lim792fb252015-10-05 11:07:22 +09003778 int result;
Tony Cho143eb952015-09-21 12:16:32 +09003779 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003780
Tony Choa4ab1ad2015-10-12 16:56:05 +09003781 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003782 PRINT_ER("driver is null\n");
3783 return -EFAULT;
3784 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003785
Tony Cho143eb952015-09-21 12:16:32 +09003786 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003787 msg.id = HOST_IF_MSG_SET_CHANNEL;
Leo Kim730ee052015-10-13 19:50:02 +09003788 msg.body.channel_info.set_ch = channel;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003789 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003790
Chaehyun Lim1ef58e42015-10-02 21:44:49 +09003791 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3792 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003793 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim792fb252015-10-05 11:07:22 +09003794 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003795 }
3796
Chaehyun Lim792fb252015-10-05 11:07:22 +09003797 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003798}
3799
Chaehyun Lim244efb12015-10-02 21:44:53 +09003800int host_int_wait_msg_queue_idle(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003801{
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003802 int result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003803
Tony Cho143eb952015-09-21 12:16:32 +09003804 struct host_if_msg msg;
Tony Cho143eb952015-09-21 12:16:32 +09003805 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003806 msg.id = HOST_IF_MSG_Q_IDLE;
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003807 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3808 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003809 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003810 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003811 }
3812
Arnd Bergmann83383ea2015-06-01 21:06:43 +02003813 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003814
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003815 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003816}
3817
Tony Choa4ab1ad2015-10-12 16:56:05 +09003818int host_int_set_wfi_drv_handler(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003819{
Chaehyun Lima0941012015-10-05 19:34:47 +09003820 int result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003821
Tony Cho143eb952015-09-21 12:16:32 +09003822 struct host_if_msg msg;
Tony Cho143eb952015-09-21 12:16:32 +09003823 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003824 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003825 msg.body.drv.u32Address = get_id_from_handler(hif_drv);
3826 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003827
Chaehyun Lima0941012015-10-05 19:34:47 +09003828 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3829 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003830 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0941012015-10-05 19:34:47 +09003831 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003832 }
3833
Chaehyun Lima0941012015-10-05 19:34:47 +09003834 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003835}
3836
Tony Choa4ab1ad2015-10-12 16:56:05 +09003837int host_int_set_operation_mode(struct host_if_drv *hif_drv, u32 mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003838{
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003839 int result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003840
Tony Cho143eb952015-09-21 12:16:32 +09003841 struct host_if_msg msg;
Tony Cho143eb952015-09-21 12:16:32 +09003842 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003843 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
Chaehyun Lim49fb6f72015-10-05 19:34:52 +09003844 msg.body.mode.u32Mode = mode;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003845 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003846
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003847 result = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
3848 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003849 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003850 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003851 }
3852
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003853 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003854}
3855
Tony Choa4ab1ad2015-10-12 16:56:05 +09003856s32 host_int_get_host_chnl_num(struct host_if_drv *hif_drv, u8 *pu8ChNo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003857{
Leo Kime6e12662015-09-16 18:36:03 +09003858 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003859 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003860
Tony Choa4ab1ad2015-10-12 16:56:05 +09003861 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003862 PRINT_ER("driver is null\n");
3863 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003864 }
3865
Tony Cho143eb952015-09-21 12:16:32 +09003866 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003867
Tony Choa9f812a2015-09-21 12:16:33 +09003868 msg.id = HOST_IF_MSG_GET_CHNL;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003869 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003870
Tony Cho143eb952015-09-21 12:16:32 +09003871 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003872 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09003873 PRINT_ER("wilc mq send fail\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09003874 down(&hif_drv->hSemGetCHNL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003875
3876 *pu8ChNo = gu8Chnl;
3877
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003878 return s32Error;
3879
3880
3881}
3882
Tony Choa4ab1ad2015-10-12 16:56:05 +09003883s32 host_int_get_inactive_time(struct host_if_drv *hif_drv,
3884 const u8 *mac, u32 *pu32InactiveTime)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003885{
Leo Kime6e12662015-09-16 18:36:03 +09003886 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003887 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003888
Tony Choa4ab1ad2015-10-12 16:56:05 +09003889 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003890 PRINT_ER("driver is null\n");
3891 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003892 }
3893
Tony Cho143eb952015-09-21 12:16:32 +09003894 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003895
3896
Tony Cho66bac7f2015-09-30 18:44:37 +09003897 memcpy(msg.body.mac_info.mac,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003898 mac, ETH_ALEN);
3899
Tony Choa9f812a2015-09-21 12:16:33 +09003900 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003901 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003902
Tony Cho143eb952015-09-21 12:16:32 +09003903 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003904 if (s32Error)
3905 PRINT_ER("Failed to send get host channel param's message queue ");
3906
Tony Choa4ab1ad2015-10-12 16:56:05 +09003907 down(&hif_drv->hSemInactiveTime);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003908
3909 *pu32InactiveTime = gu32InactiveTime;
3910
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003911 return s32Error;
3912}
Glen Lee108b3432015-09-16 18:53:20 +09003913
Tony Choa4ab1ad2015-10-12 16:56:05 +09003914s32 host_int_test_get_int_wid(struct host_if_drv *hif_drv, u32 *pu32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003915{
3916
Leo Kime6e12662015-09-16 18:36:03 +09003917 s32 s32Error = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09003918 struct wid strWID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003919
Tony Choa4ab1ad2015-10-12 16:56:05 +09003920 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003921 PRINT_ER("driver is null\n");
3922 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003923 }
3924
Leo Kimdaaf16b2015-10-12 16:55:44 +09003925 strWID.id = (u16)WID_MEMORY_ADDRESS;
Leo Kim416d8322015-10-12 16:55:43 +09003926 strWID.type = WID_INT;
Leo Kim900bb4a2015-10-12 16:55:46 +09003927 strWID.val = (s8 *)pu32TestMemAddr;
Leo Kim2fd3e442015-10-12 16:55:45 +09003928 strWID.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003929
Tony Cho03362282015-10-12 16:55:39 +09003930 s32Error = send_config_pkt(GET_CFG, &strWID, 1,
Tony Choa4ab1ad2015-10-12 16:56:05 +09003931 get_id_from_handler(hif_drv));
Leo Kimae4dfa52015-10-13 19:49:26 +09003932
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003933 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09003934 PRINT_ER("Failed to get wid value\n");
3935 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003936 } else {
3937 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
3938
3939 }
3940
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003941 return s32Error;
3942}
3943
Tony Choa4ab1ad2015-10-12 16:56:05 +09003944s32 host_int_get_rssi(struct host_if_drv *hif_drv, s8 *ps8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003945{
Leo Kime6e12662015-09-16 18:36:03 +09003946 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003947 struct host_if_msg msg;
Tony Cho143eb952015-09-21 12:16:32 +09003948 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003949
Tony Choa9f812a2015-09-21 12:16:33 +09003950 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003951 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003952
Tony Cho143eb952015-09-21 12:16:32 +09003953 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003954 if (s32Error) {
3955 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003956 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003957 }
3958
Tony Choa4ab1ad2015-10-12 16:56:05 +09003959 down(&hif_drv->hSemGetRSSI);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003960
3961
3962 if (ps8Rssi == NULL) {
3963 PRINT_ER("RSS pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09003964 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003965 }
3966
3967
3968 *ps8Rssi = gs8Rssi;
3969
3970
3971 return s32Error;
3972}
3973
Tony Choa4ab1ad2015-10-12 16:56:05 +09003974s32 host_int_get_link_speed(struct host_if_drv *hif_drv, s8 *ps8lnkspd)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003975{
Tony Cho143eb952015-09-21 12:16:32 +09003976 struct host_if_msg msg;
Leo Kime6e12662015-09-16 18:36:03 +09003977 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003978 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003979
Tony Choa9f812a2015-09-21 12:16:33 +09003980 msg.id = HOST_IF_MSG_GET_LINKSPEED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003981 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003982
Tony Cho143eb952015-09-21 12:16:32 +09003983 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003984 if (s32Error) {
3985 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003986 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003987 }
3988
Tony Choa4ab1ad2015-10-12 16:56:05 +09003989 down(&hif_drv->hSemGetLINKSPEED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003990
3991
3992 if (ps8lnkspd == NULL) {
3993 PRINT_ER("LINKSPEED pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09003994 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003995 }
3996
3997
3998 *ps8lnkspd = gs8lnkspd;
3999
4000
4001 return s32Error;
4002}
4003
Tony Choa4ab1ad2015-10-12 16:56:05 +09004004s32 host_int_get_statistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004005{
Leo Kime6e12662015-09-16 18:36:03 +09004006 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004007 struct host_if_msg msg;
Tony Cho143eb952015-09-21 12:16:32 +09004008 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004009
Tony Choa9f812a2015-09-21 12:16:33 +09004010 msg.id = HOST_IF_MSG_GET_STATISTICS;
Tony Choe60831e2015-10-05 13:50:45 +09004011 msg.body.data = (char *)pstrStatistics;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004012 msg.drv = hif_drv;
Leo Kimae4dfa52015-10-13 19:49:26 +09004013
Tony Cho143eb952015-09-21 12:16:32 +09004014 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004015 if (s32Error) {
4016 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09004017 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004018 }
4019
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004020 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004021 return s32Error;
4022}
4023
Tony Choa4ab1ad2015-10-12 16:56:05 +09004024s32 host_int_scan(struct host_if_drv *hif_drv, u8 u8ScanSource,
4025 u8 u8ScanType, u8 *pu8ChnlFreqList,
4026 u8 u8ChnlListLen, const u8 *pu8IEs,
4027 size_t IEsLen, wilc_scan_result ScanResult,
4028 void *pvUserArg, struct hidden_network *pstrHiddenNetwork)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004029{
Leo Kime6e12662015-09-16 18:36:03 +09004030 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004031 struct host_if_msg msg;
Leo Kim7696edf2015-10-12 16:56:02 +09004032 enum scan_conn_timer enuScanConnTimer;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004033
Tony Choa4ab1ad2015-10-12 16:56:05 +09004034 if (!hif_drv || ScanResult == NULL) {
4035 PRINT_ER("hif_drv or ScanResult = NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09004036 return -EFAULT;
4037 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004038
Tony Cho143eb952015-09-21 12:16:32 +09004039 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004040
Tony Choa9f812a2015-09-21 12:16:33 +09004041 msg.id = HOST_IF_MSG_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004042
4043 if (pstrHiddenNetwork != NULL) {
Leo Kim629b9ca2015-10-13 19:49:46 +09004044 msg.body.scan_info.hidden_network.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
4045 msg.body.scan_info.hidden_network.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004046
4047 } else
4048 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
4049
Tony Choa4ab1ad2015-10-12 16:56:05 +09004050 msg.drv = hif_drv;
Leo Kim42568892015-10-13 19:49:37 +09004051 msg.body.scan_info.src = u8ScanSource;
Leo Kim1e276c82015-10-13 19:49:38 +09004052 msg.body.scan_info.type = u8ScanType;
Leo Kimc17c6da2015-10-13 19:49:44 +09004053 msg.body.scan_info.result = ScanResult;
Leo Kim5f2b50c2015-10-13 19:49:45 +09004054 msg.body.scan_info.arg = pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004055
Leo Kimf97bd9c2015-10-13 19:49:41 +09004056 msg.body.scan_info.ch_list_len = u8ChnlListLen;
Leo Kim82eeb0a2015-10-13 19:49:40 +09004057 msg.body.scan_info.ch_freq_list = kmalloc(u8ChnlListLen, GFP_KERNEL);
4058 memcpy(msg.body.scan_info.ch_freq_list, pu8ChnlFreqList, u8ChnlListLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004059
Leo Kim7b1f76c2015-10-13 19:49:43 +09004060 msg.body.scan_info.ies_len = IEsLen;
Leo Kimd6f19aa2015-10-13 19:49:42 +09004061 msg.body.scan_info.ies = kmalloc(IEsLen, GFP_KERNEL);
4062 memcpy(msg.body.scan_info.ies, pu8IEs, IEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004063
Tony Cho143eb952015-09-21 12:16:32 +09004064 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004065 if (s32Error) {
Leo Kim24db7132015-09-16 18:36:01 +09004066 PRINT_ER("Error in sending message queue\n");
4067 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004068 }
4069
4070 enuScanConnTimer = SCAN_TIMER;
4071 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09004072 hif_drv->hScanTimer.data = (unsigned long)hif_drv;
4073 mod_timer(&hif_drv->hScanTimer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07004074 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004075
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004076 return s32Error;
4077
4078}
Leo Kimae4dfa52015-10-13 19:49:26 +09004079
Tony Choa4ab1ad2015-10-12 16:56:05 +09004080s32 hif_set_cfg(struct host_if_drv *hif_drv,
4081 struct cfg_param_val *pstrCfgParamVal)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004082{
4083
Leo Kime6e12662015-09-16 18:36:03 +09004084 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004085 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004086
4087
Tony Choa4ab1ad2015-10-12 16:56:05 +09004088 if (!hif_drv) {
4089 PRINT_ER("hif_drv NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09004090 return -EFAULT;
4091 }
Leo Kimae4dfa52015-10-13 19:49:26 +09004092
Tony Cho143eb952015-09-21 12:16:32 +09004093 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09004094 msg.id = HOST_IF_MSG_CFG_PARAMS;
Tony Cho221371e2015-10-12 16:56:06 +09004095 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004096 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004097
Tony Cho143eb952015-09-21 12:16:32 +09004098 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004099
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004100 return s32Error;
4101
4102}
4103
Tony Choa4ab1ad2015-10-12 16:56:05 +09004104s32 hif_get_cfg(struct host_if_drv *hif_drv, u16 u16WID, u16 *pu16WID_Value)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004105{
Leo Kime6e12662015-09-16 18:36:03 +09004106 s32 s32Error = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004107
Tony Choa4ab1ad2015-10-12 16:56:05 +09004108 down(&hif_drv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004109
Tony Choa4ab1ad2015-10-12 16:56:05 +09004110 if (!hif_drv) {
4111 PRINT_ER("hif_drv NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09004112 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004113 }
4114 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
4115 switch (u16WID) {
4116
4117 case WID_BSS_TYPE:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004118 *pu16WID_Value = (u16)hif_drv->strCfgValues.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004119 break;
4120
4121 case WID_AUTH_TYPE:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004122 *pu16WID_Value = (u16)hif_drv->strCfgValues.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004123 break;
4124
4125 case WID_AUTH_TIMEOUT:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004126 *pu16WID_Value = hif_drv->strCfgValues.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004127 break;
4128
4129 case WID_POWER_MANAGEMENT:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004130 *pu16WID_Value = (u16)hif_drv->strCfgValues.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004131 break;
4132
4133 case WID_SHORT_RETRY_LIMIT:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004134 *pu16WID_Value = hif_drv->strCfgValues.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004135 break;
4136
4137 case WID_LONG_RETRY_LIMIT:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004138 *pu16WID_Value = hif_drv->strCfgValues.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004139 break;
4140
4141 case WID_FRAG_THRESHOLD:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004142 *pu16WID_Value = hif_drv->strCfgValues.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004143 break;
4144
4145 case WID_RTS_THRESHOLD:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004146 *pu16WID_Value = hif_drv->strCfgValues.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004147 break;
4148
4149 case WID_PREAMBLE:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004150 *pu16WID_Value = (u16)hif_drv->strCfgValues.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004151 break;
4152
4153 case WID_SHORT_SLOT_ALLOWED:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004154 *pu16WID_Value = (u16) hif_drv->strCfgValues.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004155 break;
4156
4157 case WID_11N_TXOP_PROT_DISABLE:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004158 *pu16WID_Value = (u16)hif_drv->strCfgValues.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004159 break;
4160
4161 case WID_BEACON_INTERVAL:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004162 *pu16WID_Value = hif_drv->strCfgValues.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004163 break;
4164
4165 case WID_DTIM_PERIOD:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004166 *pu16WID_Value = (u16)hif_drv->strCfgValues.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004167 break;
4168
4169 case WID_SITE_SURVEY:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004170 *pu16WID_Value = (u16)hif_drv->strCfgValues.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004171 break;
4172
4173 case WID_SITE_SURVEY_SCAN_TIME:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004174 *pu16WID_Value = hif_drv->strCfgValues.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004175 break;
4176
4177 case WID_ACTIVE_SCAN_TIME:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004178 *pu16WID_Value = hif_drv->strCfgValues.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004179 break;
4180
4181 case WID_PASSIVE_SCAN_TIME:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004182 *pu16WID_Value = hif_drv->strCfgValues.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004183 break;
4184
4185 case WID_CURRENT_TX_RATE:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004186 *pu16WID_Value = hif_drv->strCfgValues.curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004187 break;
4188
4189 default:
4190 break;
4191 }
4192
Tony Choa4ab1ad2015-10-12 16:56:05 +09004193 up(&hif_drv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004194
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004195 return s32Error;
4196
4197}
4198
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004199void host_int_send_join_leave_info_to_host
Dean Lee72ed4dc2015-06-12 14:11:44 +09004200 (u16 assocId, u8 *stationAddr, bool joining)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004201{
4202}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004203
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004204static void GetPeriodicRSSI(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004205{
Tony Choa4ab1ad2015-10-12 16:56:05 +09004206 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004207
Tony Choa4ab1ad2015-10-12 16:56:05 +09004208 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004209 PRINT_ER("Driver handler is NULL\n");
4210 return;
4211 }
4212
Tony Choa4ab1ad2015-10-12 16:56:05 +09004213 if (hif_drv->enuHostIFstate == HOST_IF_CONNECTED) {
Leo Kime6e12662015-09-16 18:36:03 +09004214 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004215 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004216
Tony Cho143eb952015-09-21 12:16:32 +09004217 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004218
Tony Choa9f812a2015-09-21 12:16:33 +09004219 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004220 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004221
Tony Cho143eb952015-09-21 12:16:32 +09004222 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004223 if (s32Error) {
4224 PRINT_ER("Failed to send get host channel param's message queue ");
4225 return;
4226 }
4227 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09004228 g_hPeriodicRSSI.data = (unsigned long)hif_drv;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07004229 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004230}
4231
4232
4233void host_int_send_network_info_to_host
Chaehyun Limca356ad2015-06-11 14:35:57 +09004234 (u8 *macStartAddress, u16 u16RxFrameLen, s8 s8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004235{
4236}
Leo Kimae4dfa52015-10-13 19:49:26 +09004237
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004238static u32 clients_count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004239
Tony Choa4ab1ad2015-10-12 16:56:05 +09004240s32 host_int_init(struct host_if_drv **hif_drv_handler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004241{
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004242 s32 result = 0;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004243 struct host_if_drv *hif_drv;
Johnny Kimd42ab082015-08-20 16:32:52 +09004244 int err;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004245
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004246 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
4247
Dean Lee72ed4dc2015-06-12 14:11:44 +09004248 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004249
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004250 sema_init(&hWaitResponse, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004251
Tony Choa4ab1ad2015-10-12 16:56:05 +09004252 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
4253 if (!hif_drv) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004254 result = -ENOMEM;
Vincent Stehlé17db84e2015-10-07 07:08:25 +02004255 goto _fail_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004256 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09004257 *hif_drv_handler = hif_drv;
4258 err = add_handler_in_list(hif_drv);
Johnny Kimd42ab082015-08-20 16:32:52 +09004259 if (err) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004260 result = -EFAULT;
Johnny Kimd42ab082015-08-20 16:32:52 +09004261 goto _fail_timer_2;
4262 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004263
Dean Lee72ed4dc2015-06-12 14:11:44 +09004264 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004265
Tony Choa4ab1ad2015-10-12 16:56:05 +09004266 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004267 if (clients_count == 0) {
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004268 sema_init(&hSemHostIFthrdEnd, 0);
4269 sema_init(&hSemDeinitDrvHandle, 0);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004270 sema_init(&hSemHostIntDeinit, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004271 }
4272
Tony Choa4ab1ad2015-10-12 16:56:05 +09004273 sema_init(&hif_drv->hSemTestKeyBlock, 0);
4274 sema_init(&hif_drv->hSemTestDisconnectBlock, 0);
4275 sema_init(&hif_drv->hSemGetRSSI, 0);
4276 sema_init(&hif_drv->hSemGetLINKSPEED, 0);
4277 sema_init(&hif_drv->hSemGetCHNL, 0);
4278 sema_init(&hif_drv->hSemInactiveTime, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004279
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004280 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
4281
4282 if (clients_count == 0) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004283 result = wilc_mq_create(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004284
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004285 if (result < 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004286 PRINT_ER("Failed to creat MQ\n");
4287 goto _fail_;
4288 }
Arnd Bergmann1999bd52015-05-29 22:52:14 +02004289 HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
4290 if (IS_ERR(HostIFthreadHandler)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004291 PRINT_ER("Failed to creat Thread\n");
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004292 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004293 goto _fail_mq_;
4294 }
Greg Kroah-Hartman507d7fc2015-08-17 12:59:42 -07004295 setup_timer(&g_hPeriodicRSSI, GetPeriodicRSSI,
Tony Choa4ab1ad2015-10-12 16:56:05 +09004296 (unsigned long)hif_drv);
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07004297 mod_timer(&g_hPeriodicRSSI, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004298 }
4299
Tony Choa4ab1ad2015-10-12 16:56:05 +09004300 setup_timer(&hif_drv->hScanTimer, TimerCB_Scan, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004301
Tony Choa4ab1ad2015-10-12 16:56:05 +09004302 setup_timer(&hif_drv->hConnectTimer, TimerCB_Connect, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004303
Tony Choa4ab1ad2015-10-12 16:56:05 +09004304 setup_timer(&hif_drv->hRemainOnChannel, ListenTimerCB, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004305
Tony Choa4ab1ad2015-10-12 16:56:05 +09004306 sema_init(&(hif_drv->gtOsCfgValuesSem), 1);
4307 down(&hif_drv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004308
Tony Choa4ab1ad2015-10-12 16:56:05 +09004309 hif_drv->enuHostIFstate = HOST_IF_IDLE;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004310 hif_drv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
4311 hif_drv->strCfgValues.scan_source = DEFAULT_SCAN;
4312 hif_drv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
4313 hif_drv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
4314 hif_drv->strCfgValues.curr_tx_rate = AUTORATE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004315
Tony Choa4ab1ad2015-10-12 16:56:05 +09004316 hif_drv->u64P2p_MgmtTimeout = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004317
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004318 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",
4319
Tony Choa4ab1ad2015-10-12 16:56:05 +09004320 hif_drv->strCfgValues.site_survey_enabled, hif_drv->strCfgValues.scan_source,
4321 hif_drv->strCfgValues.active_scan_time, hif_drv->strCfgValues.passive_scan_time,
4322 hif_drv->strCfgValues.curr_tx_rate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004323
Tony Choa4ab1ad2015-10-12 16:56:05 +09004324 up(&hif_drv->gtOsCfgValuesSem);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004325
Leo Kimae4dfa52015-10-13 19:49:26 +09004326 clients_count++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004327
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004328 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004329
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004330_fail_timer_2:
Tony Choa4ab1ad2015-10-12 16:56:05 +09004331 up(&hif_drv->gtOsCfgValuesSem);
4332 del_timer_sync(&hif_drv->hConnectTimer);
4333 del_timer_sync(&hif_drv->hScanTimer);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02004334 kthread_stop(HostIFthreadHandler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004335_fail_mq_:
Chaehyun Lim1b128f62015-08-19 15:59:08 +09004336 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004337_fail_:
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004338 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004339}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004340
Tony Choa4ab1ad2015-10-12 16:56:05 +09004341s32 host_int_deinit(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004342{
Leo Kime6e12662015-09-16 18:36:03 +09004343 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004344 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004345 int ret;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004346
Tony Choa4ab1ad2015-10-12 16:56:05 +09004347 if (!hif_drv) {
4348 PRINT_ER("hif_drv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004349 return 0;
4350 }
4351
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004352 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004353
Tony Choa4ab1ad2015-10-12 16:56:05 +09004354 terminated_handle = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004355 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
4356
Tony Choa4ab1ad2015-10-12 16:56:05 +09004357 if (del_timer_sync(&hif_drv->hScanTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004358 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004359 }
4360
Tony Choa4ab1ad2015-10-12 16:56:05 +09004361 if (del_timer_sync(&hif_drv->hConnectTimer)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004362 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004363 }
4364
4365
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07004366 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004367 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004368 }
4369
Tony Choa4ab1ad2015-10-12 16:56:05 +09004370 del_timer_sync(&hif_drv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004371
Johnny Kim218dc402015-08-13 13:41:19 +09004372 host_int_set_wfi_drv_handler(NULL);
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004373 down(&hSemDeinitDrvHandle);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004374
Tony Choa4ab1ad2015-10-12 16:56:05 +09004375 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
4376 hif_drv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
4377 hif_drv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004378
Tony Choa4ab1ad2015-10-12 16:56:05 +09004379 hif_drv->strWILC_UsrScanReq.pfUserScanResult = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004380 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004381
Tony Choa4ab1ad2015-10-12 16:56:05 +09004382 hif_drv->enuHostIFstate = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004383
Dean Lee72ed4dc2015-06-12 14:11:44 +09004384 gbScanWhileConnected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004385
Tony Cho143eb952015-09-21 12:16:32 +09004386 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004387
4388 if (clients_count == 1) {
Greg Kroah-Hartman4183e972015-08-14 20:11:16 -07004389 if (del_timer_sync(&g_hPeriodicRSSI)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004390 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004391 }
Tony Choa9f812a2015-09-21 12:16:33 +09004392 msg.id = HOST_IF_MSG_EXIT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004393 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004394
4395
Tony Cho143eb952015-09-21 12:16:32 +09004396 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kime6e12662015-09-16 18:36:03 +09004397 if (s32Error != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004398 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004399
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004400 down(&hSemHostIFthrdEnd);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004401
Chaehyun Lim1b128f62015-08-19 15:59:08 +09004402 wilc_mq_destroy(&gMsgQHostIF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004403 }
4404
Tony Choa4ab1ad2015-10-12 16:56:05 +09004405 down(&(hif_drv->gtOsCfgValuesSem));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004406
Tony Choa4ab1ad2015-10-12 16:56:05 +09004407 ret = remove_handler_in_list(hif_drv);
Johnny Kimd42ab082015-08-20 16:32:52 +09004408 if (ret)
Leo Kime6e12662015-09-16 18:36:03 +09004409 s32Error = -ENOENT;
Johnny Kimd42ab082015-08-20 16:32:52 +09004410
Tony Choa4ab1ad2015-10-12 16:56:05 +09004411 kfree(hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004412
Leo Kimae4dfa52015-10-13 19:49:26 +09004413 clients_count--;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09004414 terminated_handle = NULL;
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004415 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004416 return s32Error;
4417}
4418
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004419void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004420{
Leo Kime6e12662015-09-16 18:36:03 +09004421 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004422 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004423 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004424 struct host_if_drv *hif_drv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004425
Johnny Kimd42ab082015-08-20 16:32:52 +09004426 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09004427 hif_drv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004428
4429
4430
4431
Tony Choa4ab1ad2015-10-12 16:56:05 +09004432 if (!hif_drv || hif_drv == terminated_handle) {
4433 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004434 return;
4435 }
4436
Tony Cho143eb952015-09-21 12:16:32 +09004437 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004438
Tony Choa9f812a2015-09-21 12:16:33 +09004439 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004440 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004441
Tony Cho02d19462015-09-30 18:44:22 +09004442 msg.body.net_info.u32Length = u32Length;
Leo Kimb021b802015-10-13 20:02:10 +09004443 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4444 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004445
Tony Cho143eb952015-09-21 12:16:32 +09004446 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004447 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004448 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004449}
4450
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004451void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004452{
Leo Kime6e12662015-09-16 18:36:03 +09004453 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004454 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004455 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004456 struct host_if_drv *hif_drv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004457
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004458 down(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004459
Johnny Kimd42ab082015-08-20 16:32:52 +09004460 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09004461 hif_drv = get_handler_from_id(id);
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004462 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004463
4464
Tony Choa4ab1ad2015-10-12 16:56:05 +09004465 if (!hif_drv || hif_drv == terminated_handle) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004466 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004467 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004468 return;
4469 }
4470
Tony Choa4ab1ad2015-10-12 16:56:05 +09004471 if (!hif_drv->strWILC_UsrConnReq.pfUserConnectResult) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004472 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004473 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004474 return;
4475 }
4476
Tony Cho143eb952015-09-21 12:16:32 +09004477 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004478
4479
Tony Choa9f812a2015-09-21 12:16:33 +09004480 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004481 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004482
Leo Kimf94f4882015-10-13 19:50:01 +09004483 msg.body.async_info.len = u32Length;
Leo Kim33722ac72015-10-13 19:50:00 +09004484 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4485 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004486
Tony Cho143eb952015-09-21 12:16:32 +09004487 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004488 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004489 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004490
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004491 up(&hSemHostIntDeinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004492}
4493
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004494void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004495{
Leo Kime6e12662015-09-16 18:36:03 +09004496 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004497 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004498 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004499 struct host_if_drv *hif_drv = NULL;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004500
Johnny Kimd42ab082015-08-20 16:32:52 +09004501 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09004502 hif_drv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004503
4504
Tony Choa4ab1ad2015-10-12 16:56:05 +09004505 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004506
Tony Choa4ab1ad2015-10-12 16:56:05 +09004507 if (!hif_drv || hif_drv == terminated_handle)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004508 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004509
Tony Choa4ab1ad2015-10-12 16:56:05 +09004510 if (hif_drv->strWILC_UsrScanReq.pfUserScanResult) {
Tony Cho143eb952015-09-21 12:16:32 +09004511 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004512
Tony Choa9f812a2015-09-21 12:16:33 +09004513 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004514 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004515
Tony Cho143eb952015-09-21 12:16:32 +09004516 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004517 if (s32Error)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004518 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004519 }
4520
4521
4522 return;
4523
4524}
4525
Tony Choa4ab1ad2015-10-12 16:56:05 +09004526s32 host_int_remain_on_channel(struct host_if_drv *hif_drv, u32 u32SessionID,
4527 u32 u32duration, u16 chan,
4528 wilc_remain_on_chan_expired RemainOnChanExpired,
4529 wilc_remain_on_chan_ready RemainOnChanReady,
4530 void *pvUserArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004531{
Leo Kime6e12662015-09-16 18:36:03 +09004532 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004533 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004534
Tony Choa4ab1ad2015-10-12 16:56:05 +09004535 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004536 PRINT_ER("driver is null\n");
4537 return -EFAULT;
4538 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004539
Tony Cho143eb952015-09-21 12:16:32 +09004540 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004541
Tony Choa9f812a2015-09-21 12:16:33 +09004542 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
Tony Cho070d3652015-09-30 18:55:10 +09004543 msg.body.remain_on_ch.u16Channel = chan;
4544 msg.body.remain_on_ch.pRemainOnChanExpired = RemainOnChanExpired;
4545 msg.body.remain_on_ch.pRemainOnChanReady = RemainOnChanReady;
4546 msg.body.remain_on_ch.pVoid = pvUserArg;
4547 msg.body.remain_on_ch.u32duration = u32duration;
4548 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004549 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004550
Tony Cho143eb952015-09-21 12:16:32 +09004551 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004552 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09004553 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004554
4555 return s32Error;
4556}
4557
Tony Choa4ab1ad2015-10-12 16:56:05 +09004558s32 host_int_ListenStateExpired(struct host_if_drv *hif_drv, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004559{
Leo Kime6e12662015-09-16 18:36:03 +09004560 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004561 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004562
Tony Choa4ab1ad2015-10-12 16:56:05 +09004563 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004564 PRINT_ER("driver is null\n");
4565 return -EFAULT;
4566 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004567
Tony Choa4ab1ad2015-10-12 16:56:05 +09004568 del_timer(&hif_drv->hRemainOnChannel);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004569
Tony Cho143eb952015-09-21 12:16:32 +09004570 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09004571 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004572 msg.drv = hif_drv;
Tony Cho070d3652015-09-30 18:55:10 +09004573 msg.body.remain_on_ch.u32ListenSessionID = u32SessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004574
Tony Cho143eb952015-09-21 12:16:32 +09004575 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004576 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09004577 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004578
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004579 return s32Error;
4580}
4581
Tony Choa4ab1ad2015-10-12 16:56:05 +09004582s32 host_int_frame_register(struct host_if_drv *hif_drv, u16 u16FrameType, bool bReg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004583{
Leo Kime6e12662015-09-16 18:36:03 +09004584 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004585 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004586
Tony Choa4ab1ad2015-10-12 16:56:05 +09004587 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004588 PRINT_ER("driver is null\n");
4589 return -EFAULT;
4590 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004591
Tony Cho143eb952015-09-21 12:16:32 +09004592 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004593
Tony Choa9f812a2015-09-21 12:16:33 +09004594 msg.id = HOST_IF_MSG_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004595 switch (u16FrameType) {
4596 case ACTION:
4597 PRINT_D(HOSTINF_DBG, "ACTION\n");
Tony Cho5c4008d2015-10-05 13:50:44 +09004598 msg.body.reg_frame.u8Regid = ACTION_FRM_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004599 break;
4600
4601 case PROBE_REQ:
4602 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
Tony Cho5c4008d2015-10-05 13:50:44 +09004603 msg.body.reg_frame.u8Regid = PROBE_REQ_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004604 break;
4605
4606 default:
4607 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
4608 break;
4609 }
Tony Cho5c4008d2015-10-05 13:50:44 +09004610 msg.body.reg_frame.u16FrameType = u16FrameType;
4611 msg.body.reg_frame.bReg = bReg;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004612 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004613
Tony Cho143eb952015-09-21 12:16:32 +09004614 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004615 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09004616 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004617
4618 return s32Error;
4619
4620
4621}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004622
Tony Choa4ab1ad2015-10-12 16:56:05 +09004623s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
4624 u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head,
4625 u32 u32TailLen, u8 *pu8Tail)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004626{
Leo Kime6e12662015-09-16 18:36:03 +09004627 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004628 struct host_if_msg msg;
Tony Choa98491e2015-09-30 18:44:31 +09004629 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004630
Tony Choa4ab1ad2015-10-12 16:56:05 +09004631 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004632 PRINT_ER("driver is null\n");
4633 return -EFAULT;
4634 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004635
Tony Cho143eb952015-09-21 12:16:32 +09004636 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004637
4638 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
4639
Tony Choa9f812a2015-09-21 12:16:33 +09004640 msg.id = HOST_IF_MSG_ADD_BEACON;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004641 msg.drv = hif_drv;
Leo Kim12262dd2015-10-13 19:50:03 +09004642 pstrSetBeaconParam->interval = u32Interval;
Leo Kime76ab772015-10-13 19:50:04 +09004643 pstrSetBeaconParam->dtim_period = u32DTIMPeriod;
Leo Kim51c66182015-10-13 19:50:05 +09004644 pstrSetBeaconParam->head_len = u32HeadLen;
Leo Kim8ce528b2015-10-13 19:50:06 +09004645 pstrSetBeaconParam->head = kmalloc(u32HeadLen, GFP_KERNEL);
4646 if (pstrSetBeaconParam->head == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09004647 s32Error = -ENOMEM;
4648 goto ERRORHANDLER;
4649 }
Leo Kim8ce528b2015-10-13 19:50:06 +09004650 memcpy(pstrSetBeaconParam->head, pu8Head, u32HeadLen);
Leo Kim030c57e2015-10-13 19:50:07 +09004651 pstrSetBeaconParam->tail_len = u32TailLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004652
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004653 if (u32TailLen > 0) {
Leo Kim7dbcb6d32015-10-13 19:50:08 +09004654 pstrSetBeaconParam->tail = kmalloc(u32TailLen, GFP_KERNEL);
4655 if (pstrSetBeaconParam->tail == NULL) {
Leo Kim24db7132015-09-16 18:36:01 +09004656 s32Error = -ENOMEM;
4657 goto ERRORHANDLER;
4658 }
Leo Kim7dbcb6d32015-10-13 19:50:08 +09004659 memcpy(pstrSetBeaconParam->tail, pu8Tail, u32TailLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004660 } else {
Leo Kim7dbcb6d32015-10-13 19:50:08 +09004661 pstrSetBeaconParam->tail = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004662 }
4663
Tony Cho143eb952015-09-21 12:16:32 +09004664 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004665 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09004666 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004667
Leo Kim24db7132015-09-16 18:36:01 +09004668ERRORHANDLER:
4669 if (s32Error) {
Leo Kim8ce528b2015-10-13 19:50:06 +09004670 if (pstrSetBeaconParam->head != NULL)
4671 kfree(pstrSetBeaconParam->head);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004672
Leo Kim7dbcb6d32015-10-13 19:50:08 +09004673 if (pstrSetBeaconParam->tail != NULL)
4674 kfree(pstrSetBeaconParam->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004675 }
4676
4677 return s32Error;
4678
4679}
4680
Tony Choa4ab1ad2015-10-12 16:56:05 +09004681s32 host_int_del_beacon(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004682{
Leo Kime6e12662015-09-16 18:36:03 +09004683 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004684 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004685
Tony Choa4ab1ad2015-10-12 16:56:05 +09004686 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004687 PRINT_ER("driver is null\n");
4688 return -EFAULT;
4689 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004690
Tony Choa9f812a2015-09-21 12:16:33 +09004691 msg.id = HOST_IF_MSG_DEL_BEACON;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004692 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004693 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
4694
Tony Cho143eb952015-09-21 12:16:32 +09004695 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Leo Kim7dc1d0c2015-09-16 18:36:00 +09004696 if (s32Error)
4697 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004698
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004699 return s32Error;
4700}
4701
Tony Choa4ab1ad2015-10-12 16:56:05 +09004702s32 host_int_add_station(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09004703 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004704{
Leo Kime6e12662015-09-16 18:36:03 +09004705 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004706 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09004707 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004708
4709
Tony Choa4ab1ad2015-10-12 16:56:05 +09004710 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004711 PRINT_ER("driver is null\n");
4712 return -EFAULT;
4713 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004714
Tony Cho143eb952015-09-21 12:16:32 +09004715 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004716
4717 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
4718
Tony Choa9f812a2015-09-21 12:16:33 +09004719 msg.id = HOST_IF_MSG_ADD_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004720 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004721
Tony Cho6a89ba92015-09-21 12:16:46 +09004722 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004723 if (pstrAddStationMsg->u8NumRates > 0) {
Glen Leef3052582015-09-10 12:03:04 +09004724 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004725
Leo Kim7ae43362015-09-16 18:35:59 +09004726 if (!rates)
4727 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004728
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004729 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02004730 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004731 }
4732
4733
Tony Cho143eb952015-09-21 12:16:32 +09004734 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004735 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09004736 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004737 return s32Error;
4738}
4739
Tony Choa4ab1ad2015-10-12 16:56:05 +09004740s32 host_int_del_station(struct host_if_drv *hif_drv, const u8 *pu8MacAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004741{
Leo Kime6e12662015-09-16 18:36:03 +09004742 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004743 struct host_if_msg msg;
Tony Cho889c25b2015-09-30 18:44:33 +09004744 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004745
Tony Choa4ab1ad2015-10-12 16:56:05 +09004746 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004747 PRINT_ER("driver is null\n");
4748 return -EFAULT;
4749 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004750
Tony Cho143eb952015-09-21 12:16:32 +09004751 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004752
4753 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
4754
Tony Choa9f812a2015-09-21 12:16:33 +09004755 msg.id = HOST_IF_MSG_DEL_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004756 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004757
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09004758 if (pu8MacAddr == NULL)
Leo Kime4839d32015-10-13 20:02:06 +09004759 memset(pstrDelStationMsg->mac_addr, 255, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004760 else
Leo Kime4839d32015-10-13 20:02:06 +09004761 memcpy(pstrDelStationMsg->mac_addr, pu8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004762
Tony Cho143eb952015-09-21 12:16:32 +09004763 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004764 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09004765 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004766 return s32Error;
4767}
Leo Kimae4dfa52015-10-13 19:49:26 +09004768
Tony Choa4ab1ad2015-10-12 16:56:05 +09004769s32 host_int_del_allstation(struct host_if_drv *hif_drv,
Leo Kim441dc602015-10-12 16:55:35 +09004770 u8 pu8MacAddr[][ETH_ALEN])
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004771{
Leo Kime6e12662015-09-16 18:36:03 +09004772 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004773 struct host_if_msg msg;
Tony Chob0c1e802015-10-05 13:50:46 +09004774 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004775 u8 au8Zero_Buff[ETH_ALEN] = {0};
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004776 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004777 u8 u8AssocNumb = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004778
4779
Tony Choa4ab1ad2015-10-12 16:56:05 +09004780 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004781 PRINT_ER("driver is null\n");
4782 return -EFAULT;
4783 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004784
Tony Cho143eb952015-09-21 12:16:32 +09004785 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004786
4787 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
4788
Tony Choa9f812a2015-09-21 12:16:33 +09004789 msg.id = HOST_IF_MSG_DEL_ALL_STA;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004790 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004791
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004792 for (i = 0; i < MAX_NUM_STA; i++) {
4793 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
Leo Kime51b9212015-10-13 19:50:09 +09004794 memcpy(pstrDelAllStationMsg->del_all_sta[i], pu8MacAddr[i], ETH_ALEN);
4795 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
4796 pstrDelAllStationMsg->del_all_sta[i][0],
4797 pstrDelAllStationMsg->del_all_sta[i][1],
4798 pstrDelAllStationMsg->del_all_sta[i][2],
4799 pstrDelAllStationMsg->del_all_sta[i][3],
4800 pstrDelAllStationMsg->del_all_sta[i][4],
4801 pstrDelAllStationMsg->del_all_sta[i][5]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004802 u8AssocNumb++;
4803 }
4804 }
4805 if (!u8AssocNumb) {
4806 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
4807 return s32Error;
4808 }
4809
Leo Kim8ba18032015-10-13 19:50:10 +09004810 pstrDelAllStationMsg->assoc_sta = u8AssocNumb;
Tony Cho143eb952015-09-21 12:16:32 +09004811 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004812
4813
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004814 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09004815 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004816
Arnd Bergmann83383ea2015-06-01 21:06:43 +02004817 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004818
4819 return s32Error;
4820
4821}
4822
Tony Choa4ab1ad2015-10-12 16:56:05 +09004823s32 host_int_edit_station(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09004824 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004825{
Leo Kime6e12662015-09-16 18:36:03 +09004826 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004827 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09004828 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004829
Tony Choa4ab1ad2015-10-12 16:56:05 +09004830 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004831 PRINT_ER("driver is null\n");
4832 return -EFAULT;
4833 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004834
4835 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
4836
Tony Cho143eb952015-09-21 12:16:32 +09004837 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004838
Tony Choa9f812a2015-09-21 12:16:33 +09004839 msg.id = HOST_IF_MSG_EDIT_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004840 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004841
Tony Cho6a89ba92015-09-21 12:16:46 +09004842 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004843 if (pstrAddStationMsg->u8NumRates > 0) {
Glen Leef3052582015-09-10 12:03:04 +09004844 u8 *rates = kmalloc(pstrAddStationMsg->u8NumRates, GFP_KERNEL);
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004845
Leo Kim7ae43362015-09-16 18:35:59 +09004846 if (!rates)
4847 return -ENOMEM;
4848
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004849 memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
Arnd Bergmann057d1e92015-06-01 21:06:44 +02004850 pstrAddStationMsg->pu8Rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004851 }
4852
Tony Cho143eb952015-09-21 12:16:32 +09004853 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004854 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09004855 PRINT_ER("wilc_mq_send fail\n");
4856
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004857 return s32Error;
4858}
Glen Lee108b3432015-09-16 18:53:20 +09004859
Tony Choa4ab1ad2015-10-12 16:56:05 +09004860s32 host_int_set_power_mgmt(struct host_if_drv *hif_drv,
4861 bool bIsEnabled,
4862 u32 u32Timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004863{
Leo Kime6e12662015-09-16 18:36:03 +09004864 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004865 struct host_if_msg msg;
Tony Cho49e1f812015-09-30 18:44:36 +09004866 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004867
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004868 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004869
Tony Choa4ab1ad2015-10-12 16:56:05 +09004870 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004871 PRINT_ER("driver is null\n");
4872 return -EFAULT;
4873 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004874
4875 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
4876
Tony Cho143eb952015-09-21 12:16:32 +09004877 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004878
Tony Choa9f812a2015-09-21 12:16:33 +09004879 msg.id = HOST_IF_MSG_POWER_MGMT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004880 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004881
Leo Kim33c70c12015-10-13 20:02:07 +09004882 pstrPowerMgmtParam->enabled = bIsEnabled;
Leo Kim937918f2015-10-13 20:02:08 +09004883 pstrPowerMgmtParam->timeout = u32Timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004884
Tony Cho143eb952015-09-21 12:16:32 +09004885 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004886 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09004887 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004888 return s32Error;
4889}
4890
Tony Choa4ab1ad2015-10-12 16:56:05 +09004891s32 host_int_setup_multicast_filter(struct host_if_drv *hif_drv,
4892 bool bIsEnabled,
4893 u32 u32count)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004894{
Leo Kime6e12662015-09-16 18:36:03 +09004895 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004896 struct host_if_msg msg;
Tony Choa079cf4d2015-09-30 18:55:05 +09004897 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004898
4899
Tony Choa4ab1ad2015-10-12 16:56:05 +09004900 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004901 PRINT_ER("driver is null\n");
4902 return -EFAULT;
4903 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004904
4905 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
4906
Tony Cho143eb952015-09-21 12:16:32 +09004907 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004908
Tony Choa9f812a2015-09-21 12:16:33 +09004909 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004910 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004911
Leo Kimbae636eb2015-10-13 20:02:04 +09004912 pstrMulticastFilterParam->enabled = bIsEnabled;
Leo Kimadab2f72015-10-13 20:02:05 +09004913 pstrMulticastFilterParam->cnt = u32count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004914
Tony Cho143eb952015-09-21 12:16:32 +09004915 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02004916 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09004917 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004918 return s32Error;
4919}
4920
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004921static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
4922{
Leo Kime0a12212015-10-12 16:55:49 +09004923 struct join_bss_param *pNewJoinBssParam = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004924 u8 *pu8IEs;
Chaehyun Limd85f5322015-06-11 14:35:54 +09004925 u16 u16IEsLen;
4926 u16 index = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004927 u8 suppRatesNo = 0;
4928 u8 extSuppRatesNo;
Chaehyun Limd85f5322015-06-11 14:35:54 +09004929 u16 jumpOffset;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004930 u8 pcipherCount;
4931 u8 authCount;
4932 u8 pcipherTotalCount = 0;
4933 u8 authTotalCount = 0;
4934 u8 i, j;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004935
4936 pu8IEs = ptstrNetworkInfo->pu8IEs;
4937 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4938
Leo Kime0a12212015-10-12 16:55:49 +09004939 pNewJoinBssParam = kmalloc(sizeof(struct join_bss_param), GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004940 if (pNewJoinBssParam != NULL) {
Leo Kime0a12212015-10-12 16:55:49 +09004941 memset(pNewJoinBssParam, 0, sizeof(struct join_bss_param));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004942 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4943 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
4944 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004945 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004946 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004947 pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004948 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4949 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004950
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004951 while (index < u16IEsLen) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004952 if (pu8IEs[index] == SUPP_RATES_IE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004953 suppRatesNo = pu8IEs[index + 1];
4954 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
Leo Kimae4dfa52015-10-13 19:49:26 +09004955 index += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004956
4957 for (i = 0; i < suppRatesNo; i++) {
4958 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004959 }
4960 index += suppRatesNo;
4961 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004962 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004963 extSuppRatesNo = pu8IEs[index + 1];
4964 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4965 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4966 else
4967 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4968 index += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004969 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
4970 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004971 }
4972 index += extSuppRatesNo;
4973 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004974 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004975 pNewJoinBssParam->ht_capable = true;
Leo Kimae4dfa52015-10-13 19:49:26 +09004976 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004977 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004978 } else if ((pu8IEs[index] == WMM_IE) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004979 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
Leo Kimae4dfa52015-10-13 19:49:26 +09004980 (pu8IEs[index + 4] == 0xF2) &&
4981 (pu8IEs[index + 5] == 0x02) &&
4982 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004983 (pu8IEs[index + 7] == 0x01)) {
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004984 pNewJoinBssParam->wmm_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004985
Anish Bhattffda2032015-09-29 12:15:49 -07004986 if (pu8IEs[index + 8] & BIT(7))
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004987 pNewJoinBssParam->uapsd_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004988 index += pu8IEs[index + 1] + 2;
4989 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004990 } else if ((pu8IEs[index] == P2P_IE) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004991 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
Leo Kimae4dfa52015-10-13 19:49:26 +09004992 (pu8IEs[index + 4] == 0x9a) &&
4993 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09004994 u16 u16P2P_count;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004995
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004996 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
4997 pNewJoinBssParam->u8NoaEnbaled = 1;
4998 pNewJoinBssParam->u8Index = pu8IEs[index + 9];
4999
Anish Bhattffda2032015-09-29 12:15:49 -07005000 if (pu8IEs[index + 10] & BIT(7)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005001 pNewJoinBssParam->u8OppEnable = 1;
5002 pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
5003 } else
5004 pNewJoinBssParam->u8OppEnable = 0;
Leo Kimae4dfa52015-10-13 19:49:26 +09005005
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005006 PRINT_D(GENERIC_DBG, "P2P Dump\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005007 for (i = 0; i < pu8IEs[index + 7]; i++)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02005008 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005009
5010 pNewJoinBssParam->u8Count = pu8IEs[index + 11];
5011 u16P2P_count = index + 12;
5012
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005013 memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005014 u16P2P_count += 4;
5015
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005016 memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005017 u16P2P_count += 4;
5018
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09005019 memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005020
5021 index += pu8IEs[index + 1] + 2;
5022 continue;
5023
Leo Kimae4dfa52015-10-13 19:49:26 +09005024 } else if ((pu8IEs[index] == RSN_IE) ||
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005025 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
5026 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
5027 (pu8IEs[index + 5] == 0x01))) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09005028 u16 rsnIndex = index;
Leo Kimae4dfa52015-10-13 19:49:26 +09005029
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005030 if (pu8IEs[rsnIndex] == RSN_IE) {
5031 pNewJoinBssParam->mode_802_11i = 2;
Leo Kimae4dfa52015-10-13 19:49:26 +09005032 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005033 if (pNewJoinBssParam->mode_802_11i == 0)
5034 pNewJoinBssParam->mode_802_11i = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005035 rsnIndex += 4;
5036 }
Leo Kimae4dfa52015-10-13 19:49:26 +09005037
5038 rsnIndex += 7;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005039 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
5040 rsnIndex++;
Leo Kimae4dfa52015-10-13 19:49:26 +09005041 jumpOffset = pu8IEs[rsnIndex] * 4;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005042 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
Leo Kimae4dfa52015-10-13 19:49:26 +09005043 rsnIndex += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005044
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005045 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005046 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005047 }
5048 pcipherTotalCount += pcipherCount;
5049 rsnIndex += jumpOffset;
5050
5051 jumpOffset = pu8IEs[rsnIndex] * 4;
5052
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005053 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
Leo Kimae4dfa52015-10-13 19:49:26 +09005054 rsnIndex += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005055
5056 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005057 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
5058 }
5059 authTotalCount += authCount;
5060 rsnIndex += jumpOffset;
Leo Kimae4dfa52015-10-13 19:49:26 +09005061
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005062 if (pu8IEs[index] == RSN_IE) {
5063 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
5064 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
5065 rsnIndex += 2;
5066 }
Abdul Hussainf717c0eb2015-06-16 09:49:49 +00005067 pNewJoinBssParam->rsn_found = true;
Leo Kimae4dfa52015-10-13 19:49:26 +09005068 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005069 continue;
5070 } else
Leo Kimae4dfa52015-10-13 19:49:26 +09005071 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005072
5073 }
5074
5075
5076 }
5077
5078 return (void *)pNewJoinBssParam;
5079
5080}
5081
5082void host_int_freeJoinParams(void *pJoinParams)
5083{
Leo Kime0a12212015-10-12 16:55:49 +09005084 if ((struct bss_param *)pJoinParams != NULL)
5085 kfree((struct bss_param *)pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005086 else
5087 PRINT_ER("Unable to FREE null pointer\n");
5088}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005089
Tony Choa4ab1ad2015-10-12 16:56:05 +09005090s32 host_int_delBASession(struct host_if_drv *hif_drv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005091{
Leo Kime6e12662015-09-16 18:36:03 +09005092 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005093 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09005094 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005095
Tony Choa4ab1ad2015-10-12 16:56:05 +09005096 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005097 PRINT_ER("driver is null\n");
5098 return -EFAULT;
5099 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005100
Tony Cho143eb952015-09-21 12:16:32 +09005101 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005102
Tony Choa9f812a2015-09-21 12:16:33 +09005103 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005104
5105 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
5106 pBASessionInfo->u8Ted = TID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005107 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005108
Tony Cho143eb952015-09-21 12:16:32 +09005109 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005110 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09005111 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005112
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005113 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005114
5115 return s32Error;
5116}
5117
Tony Choa4ab1ad2015-10-12 16:56:05 +09005118s32 host_int_del_All_Rx_BASession(struct host_if_drv *hif_drv,
5119 char *pBSSID,
5120 char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005121{
Leo Kime6e12662015-09-16 18:36:03 +09005122 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005123 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09005124 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005125
Tony Choa4ab1ad2015-10-12 16:56:05 +09005126 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005127 PRINT_ER("driver is null\n");
5128 return -EFAULT;
5129 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005130
Tony Cho143eb952015-09-21 12:16:32 +09005131 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005132
Tony Choa9f812a2015-09-21 12:16:33 +09005133 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005134
5135 memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
5136 pBASessionInfo->u8Ted = TID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005137 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005138
Tony Cho143eb952015-09-21 12:16:32 +09005139 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005140 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09005141 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005142
Arnd Bergmann83383ea2015-06-01 21:06:43 +02005143 down(&hWaitResponse);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005144
5145 return s32Error;
5146}
5147
Tony Choa4ab1ad2015-10-12 16:56:05 +09005148s32 host_int_setup_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005149{
Leo Kime6e12662015-09-16 18:36:03 +09005150 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005151 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005152
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005153 return 0;
5154
Tony Choa4ab1ad2015-10-12 16:56:05 +09005155 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005156 PRINT_ER("driver is null\n");
5157 return -EFAULT;
5158 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005159
Tony Cho143eb952015-09-21 12:16:32 +09005160 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005161
Tony Choa9f812a2015-09-21 12:16:33 +09005162 msg.id = HOST_IF_MSG_SET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005163
Leo Kim78675be2015-10-13 20:02:09 +09005164 msg.body.ip_info.ip_addr = u16ipadd;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005165 msg.drv = hif_drv;
Tony Chofb2d65e2015-09-30 18:44:39 +09005166 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005167
Tony Cho143eb952015-09-21 12:16:32 +09005168 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005169 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09005170 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005171
5172 return s32Error;
5173
5174
5175}
5176
Tony Choa4ab1ad2015-10-12 16:56:05 +09005177s32 host_int_get_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005178{
Leo Kime6e12662015-09-16 18:36:03 +09005179 s32 s32Error = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005180 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005181
Tony Choa4ab1ad2015-10-12 16:56:05 +09005182 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005183 PRINT_ER("driver is null\n");
5184 return -EFAULT;
5185 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005186
Tony Cho143eb952015-09-21 12:16:32 +09005187 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005188
Tony Choa9f812a2015-09-21 12:16:33 +09005189 msg.id = HOST_IF_MSG_GET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005190
Leo Kim78675be2015-10-13 20:02:09 +09005191 msg.body.ip_info.ip_addr = u16ipadd;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005192 msg.drv = hif_drv;
Tony Chofb2d65e2015-09-30 18:44:39 +09005193 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005194
Tony Cho143eb952015-09-21 12:16:32 +09005195 s32Error = wilc_mq_send(&gMsgQHostIF, &msg, sizeof(struct host_if_msg));
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02005196 if (s32Error)
Leo Kim24db7132015-09-16 18:36:01 +09005197 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005198
5199 return s32Error;
5200
5201
5202}