blob: ac00b17c6d3b209f279a433c3db38489353e1c02 [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"
Arnd Bergmann491880e2015-11-16 15:04:55 +01007#include "wilc_wlan.h"
Chaehyun Lim53660122015-09-17 16:48:49 +09008#include "wilc_wlan_if.h"
Chaehyun Limf23eb982015-09-23 18:03:47 +09009#include "wilc_msgqueue.h"
Shraddha Barke281dd5a2015-10-05 17:00:33 +053010#include <linux/etherdevice.h>
Glen Leed53822192015-10-27 18:27:49 +090011#include "wilc_wfi_netdevice.h"
Johnny Kimc5c77ba2015-05-11 14:30:56 +090012
Chaehyun Lim9eac3a12015-06-18 22:08:51 +090013#define HOST_IF_MSG_SCAN 0
14#define HOST_IF_MSG_CONNECT 1
15#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
16#define HOST_IF_MSG_KEY 3
17#define HOST_IF_MSG_RCVD_NTWRK_INFO 4
18#define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
19#define HOST_IF_MSG_CFG_PARAMS 6
20#define HOST_IF_MSG_SET_CHANNEL 7
21#define HOST_IF_MSG_DISCONNECT 8
22#define HOST_IF_MSG_GET_RSSI 9
23#define HOST_IF_MSG_GET_CHNL 10
24#define HOST_IF_MSG_ADD_BEACON 11
25#define HOST_IF_MSG_DEL_BEACON 12
26#define HOST_IF_MSG_ADD_STATION 13
27#define HOST_IF_MSG_DEL_STATION 14
28#define HOST_IF_MSG_EDIT_STATION 15
29#define HOST_IF_MSG_SCAN_TIMER_FIRED 16
30#define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
31#define HOST_IF_MSG_POWER_MGMT 18
32#define HOST_IF_MSG_GET_INACTIVETIME 19
33#define HOST_IF_MSG_REMAIN_ON_CHAN 20
34#define HOST_IF_MSG_REGISTER_FRAME 21
35#define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
36#define HOST_IF_MSG_GET_LINKSPEED 23
37#define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
38#define HOST_IF_MSG_SET_MAC_ADDRESS 25
39#define HOST_IF_MSG_GET_MAC_ADDRESS 26
40#define HOST_IF_MSG_SET_OPERATION_MODE 27
41#define HOST_IF_MSG_SET_IPADDRESS 28
42#define HOST_IF_MSG_GET_IPADDRESS 29
43#define HOST_IF_MSG_FLUSH_CONNECT 30
44#define HOST_IF_MSG_GET_STATISTICS 31
45#define HOST_IF_MSG_SET_MULTICAST_FILTER 32
Chaehyun Lim9eac3a12015-06-18 22:08:51 +090046#define HOST_IF_MSG_DEL_BA_SESSION 34
47#define HOST_IF_MSG_Q_IDLE 35
48#define HOST_IF_MSG_DEL_ALL_STA 36
49#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
50#define HOST_IF_MSG_EXIT 100
Johnny Kimc5c77ba2015-05-11 14:30:56 +090051
Chaehyun Lime54d5b72015-06-18 22:08:50 +090052#define HOST_IF_SCAN_TIMEOUT 4000
53#define HOST_IF_CONNECT_TIMEOUT 9500
Johnny Kimc5c77ba2015-05-11 14:30:56 +090054
Chaehyun Lime54d5b72015-06-18 22:08:50 +090055#define BA_SESSION_DEFAULT_BUFFER_SIZE 16
56#define BA_SESSION_DEFAULT_TIMEOUT 1000
57#define BLOCK_ACK_REQ_SIZE 0x14
Leo Kim9f3295a2015-10-19 18:26:10 +090058#define FALSE_FRMWR_CHANNEL 100
Johnny Kimc5c77ba2015-05-11 14:30:56 +090059
Tony Cho361ff842015-09-21 12:16:41 +090060struct cfg_param_attr {
Tony Cho221371e2015-10-12 16:56:06 +090061 struct cfg_param_val cfg_attr_info;
Tony Cho361ff842015-09-21 12:16:41 +090062};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090063
Leo Kim4372d3d2015-10-05 15:25:43 +090064struct host_if_wpa_attr {
Leo Kim124968fc2015-10-13 19:49:30 +090065 u8 *key;
Leo Kim248080a2015-10-13 19:49:31 +090066 const u8 *mac_addr;
Leo Kim0e74c002015-10-13 19:49:32 +090067 u8 *seq;
Leo Kimdacc5942015-10-13 19:49:33 +090068 u8 seq_len;
Leo Kime2dfbac2015-10-13 19:49:34 +090069 u8 index;
Leo Kim6acf2912015-10-13 19:49:35 +090070 u8 key_len;
Leo Kim7b2ebb22015-10-13 19:49:36 +090071 u8 mode;
Leo Kim4372d3d2015-10-05 15:25:43 +090072};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090073
Leo Kimc276c442015-10-05 15:25:42 +090074struct host_if_wep_attr {
Tony Choe5538d32015-10-12 16:56:11 +090075 u8 *key;
Tony Chod520e352015-10-12 16:56:12 +090076 u8 key_len;
Tony Cho259b3aa2015-10-12 16:56:13 +090077 u8 index;
Tony Chob5eaff12015-10-12 16:56:14 +090078 u8 mode;
Tony Cho7fa252e2015-10-12 16:56:15 +090079 enum AUTHTYPE auth_type;
Leo Kimc276c442015-10-05 15:25:42 +090080};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090081
Leo Kim40cc2c92015-10-05 15:25:41 +090082union host_if_key_attr {
Tony Cho2ed7a2f2015-10-12 16:56:08 +090083 struct host_if_wep_attr wep;
Tony Choe3501a42015-10-12 16:56:09 +090084 struct host_if_wpa_attr wpa;
Tony Cho610e3862015-10-12 16:56:10 +090085 struct host_if_pmkid_attr pmkid;
Leo Kim40cc2c92015-10-05 15:25:41 +090086};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090087
Tony Choc98387a2015-09-21 12:16:40 +090088struct key_attr {
Leo Kim8e9f4272015-10-13 19:49:27 +090089 enum KEY_TYPE type;
Leo Kim0d17e382015-10-13 19:49:28 +090090 u8 action;
Leo Kim73b2e382015-10-13 19:49:29 +090091 union host_if_key_attr attr;
Tony Choc98387a2015-09-21 12:16:40 +090092};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090093
Tony Choc476feb2015-09-21 12:16:36 +090094struct scan_attr {
Leo Kim42568892015-10-13 19:49:37 +090095 u8 src;
Leo Kim1e276c82015-10-13 19:49:38 +090096 u8 type;
Leo Kim82eeb0a2015-10-13 19:49:40 +090097 u8 *ch_freq_list;
Leo Kimf97bd9c2015-10-13 19:49:41 +090098 u8 ch_list_len;
Leo Kimd6f19aa2015-10-13 19:49:42 +090099 u8 *ies;
Leo Kim7b1f76c2015-10-13 19:49:43 +0900100 size_t ies_len;
Leo Kimc17c6da2015-10-13 19:49:44 +0900101 wilc_scan_result result;
Leo Kim5f2b50c2015-10-13 19:49:45 +0900102 void *arg;
Leo Kim629b9ca2015-10-13 19:49:46 +0900103 struct hidden_network hidden_network;
Tony Choc476feb2015-09-21 12:16:36 +0900104};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900105
Tony Cho120ae592015-09-21 12:16:37 +0900106struct connect_attr {
Leo Kim9254db02015-10-13 19:49:49 +0900107 u8 *bssid;
Leo Kimf7bbd9c2015-10-13 19:49:50 +0900108 u8 *ssid;
Leo Kim8b3c9fa2015-10-13 19:49:51 +0900109 size_t ssid_len;
Leo Kim2ea158c2015-10-13 19:49:52 +0900110 u8 *ies;
Leo Kimb59d5c52015-10-13 19:49:53 +0900111 size_t ies_len;
Leo Kima64fd672015-10-13 19:49:54 +0900112 u8 security;
Leo Kim6abcc112015-10-13 19:49:55 +0900113 wilc_connect_result result;
Leo Kim8f38db82015-10-13 19:49:56 +0900114 void *arg;
Leo Kim61b4fd02015-10-13 19:49:57 +0900115 enum AUTHTYPE auth_type;
Leo Kim0d1527e2015-10-13 19:49:58 +0900116 u8 ch;
Leo Kimf2bed2c2015-10-13 19:49:59 +0900117 void *params;
Tony Cho120ae592015-09-21 12:16:37 +0900118};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900119
Tony Chof23a9ea2015-09-21 12:16:39 +0900120struct rcvd_async_info {
Leo Kim33722ac72015-10-13 19:50:00 +0900121 u8 *buffer;
Leo Kimf94f4882015-10-13 19:50:01 +0900122 u32 len;
Tony Chof23a9ea2015-09-21 12:16:39 +0900123};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900124
Tony Cho94bdfe42015-09-30 18:44:27 +0900125struct channel_attr {
Leo Kim730ee052015-10-13 19:50:02 +0900126 u8 set_ch;
Tony Cho326b3232015-09-21 12:16:42 +0900127};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900128
Tony Cho7f33fec2015-09-30 18:44:30 +0900129struct beacon_attr {
Leo Kim12262dd2015-10-13 19:50:03 +0900130 u32 interval;
Leo Kime76ab772015-10-13 19:50:04 +0900131 u32 dtim_period;
Leo Kim51c66182015-10-13 19:50:05 +0900132 u32 head_len;
Leo Kim8ce528b2015-10-13 19:50:06 +0900133 u8 *head;
Leo Kim030c57e2015-10-13 19:50:07 +0900134 u32 tail_len;
Leo Kim7dbcb6d32015-10-13 19:50:08 +0900135 u8 *tail;
Tony Cho902362b2015-09-21 12:16:44 +0900136};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900137
Tony Cho641210a2015-09-21 12:16:52 +0900138struct set_multicast {
Leo Kimbae636eb2015-10-13 20:02:04 +0900139 bool enabled;
Leo Kimadab2f72015-10-13 20:02:05 +0900140 u32 cnt;
Tony Cho641210a2015-09-21 12:16:52 +0900141};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900142
Tony Chob4e644e2015-09-21 12:17:00 +0900143struct del_all_sta {
Leo Kime51b9212015-10-13 19:50:09 +0900144 u8 del_all_sta[MAX_NUM_STA][ETH_ALEN];
Leo Kim8ba18032015-10-13 19:50:10 +0900145 u8 assoc_sta;
Tony Chob4e644e2015-09-21 12:17:00 +0900146};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900147
Tony Chofb93a1e2015-09-21 12:16:57 +0900148struct del_sta {
Leo Kime4839d32015-10-13 20:02:06 +0900149 u8 mac_addr[ETH_ALEN];
Tony Chofb93a1e2015-09-21 12:16:57 +0900150};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900151
Tony Cho5a008f12015-09-21 12:16:48 +0900152struct power_mgmt_param {
Leo Kim33c70c12015-10-13 20:02:07 +0900153 bool enabled;
Leo Kim937918f2015-10-13 20:02:08 +0900154 u32 timeout;
Tony Cho5a008f12015-09-21 12:16:48 +0900155};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900156
Tony Cho15191ea2015-09-21 12:16:50 +0900157struct set_ip_addr {
Leo Kim78675be2015-10-13 20:02:09 +0900158 u8 *ip_addr;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900159 u8 idx;
Tony Cho15191ea2015-09-21 12:16:50 +0900160};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900161
Tony Cho3d1eac02015-09-21 12:16:49 +0900162struct sta_inactive_t {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900163 u8 mac[6];
Tony Cho3d1eac02015-09-21 12:16:49 +0900164};
Leo Kimae4dfa52015-10-13 19:49:26 +0900165
Tony Chodfc76632015-09-21 12:16:34 +0900166union message_body {
Tony Cho4528bdb2015-09-30 18:44:20 +0900167 struct scan_attr scan_info;
Tony Cho3f501972015-09-30 18:44:21 +0900168 struct connect_attr con_info;
Tony Cho02d19462015-09-30 18:44:22 +0900169 struct rcvd_net_info net_info;
Tony Cho66add622015-09-30 18:44:23 +0900170 struct rcvd_async_info async_info;
Tony Cho18990bf2015-09-30 18:44:24 +0900171 struct key_attr key_info;
Tony Choa2340c32015-09-30 18:44:25 +0900172 struct cfg_param_attr cfg_info;
Tony Choffd6dbc2015-09-30 18:44:28 +0900173 struct channel_attr channel_info;
Tony Choa98491e2015-09-30 18:44:31 +0900174 struct beacon_attr beacon_info;
Tony Choca8f47f2015-09-30 18:44:32 +0900175 struct add_sta_param add_sta_info;
Tony Cho889c25b2015-09-30 18:44:33 +0900176 struct del_sta del_sta_info;
Tony Cho4a930962015-09-30 18:44:34 +0900177 struct add_sta_param edit_sta_info;
Tony Cho49e1f812015-09-30 18:44:36 +0900178 struct power_mgmt_param pwr_mgmt_info;
Tony Cho66bac7f2015-09-30 18:44:37 +0900179 struct sta_inactive_t mac_info;
Tony Chofb2d65e2015-09-30 18:44:39 +0900180 struct set_ip_addr ip_info;
Tony Cho5e4377e2015-09-30 18:44:38 +0900181 struct drv_handler drv;
Tony Choa079cf4d2015-09-30 18:55:05 +0900182 struct set_multicast multicast_info;
Tony Cho00c46302015-09-30 18:55:06 +0900183 struct op_mode mode;
Tony Cho15326e22015-09-30 18:55:07 +0900184 struct set_mac_addr set_mac_info;
Tony Choa5848692015-09-30 18:55:08 +0900185 struct get_mac_addr get_mac_info;
Tony Choc833b472015-09-30 18:55:09 +0900186 struct ba_session_info session_info;
Tony Cho070d3652015-09-30 18:55:10 +0900187 struct remain_ch remain_on_ch;
Tony Cho5c4008d2015-10-05 13:50:44 +0900188 struct reg_frame reg_frame;
Tony Choe60831e2015-10-05 13:50:45 +0900189 char *data;
Tony Chob0c1e802015-10-05 13:50:46 +0900190 struct del_all_sta del_all_sta_info;
Tony Chodfc76632015-09-21 12:16:34 +0900191};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900192
Tony Cho3a8c41b2015-09-18 18:11:04 +0900193struct host_if_msg {
Leo Kimae4dfa52015-10-13 19:49:26 +0900194 u16 id;
195 union message_body body;
Glen Leecf601062015-12-21 14:18:39 +0900196 struct wilc_vif *vif;
Tony Cho3a8c41b2015-09-18 18:11:04 +0900197};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900198
Leo Kime0a12212015-10-12 16:55:49 +0900199struct join_bss_param {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900200 BSSTYPE_T bss_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900201 u8 dtim_period;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900202 u16 beacon_period;
203 u16 cap_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900204 u8 au8bssid[6];
Dean Lee576917a2015-06-15 11:58:57 +0900205 char ssid[MAX_SSID_LEN];
Leo Kim619d27b2015-10-15 13:24:42 +0900206 u8 ssid_len;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900207 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
208 u8 ht_capable;
209 u8 wmm_cap;
210 u8 uapsd_cap;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900211 bool rsn_found;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900212 u8 rsn_grp_policy;
213 u8 mode_802_11i;
214 u8 rsn_pcip_policy[3];
215 u8 rsn_auth_policy[3];
216 u8 rsn_cap[2];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900217 u32 tsf;
Leo Kim7a8d51d2015-10-15 13:24:43 +0900218 u8 noa_enabled;
Leo Kimd72b33c2015-10-15 13:24:44 +0900219 u8 opp_enabled;
Leo Kim99b66942015-10-15 13:24:45 +0900220 u8 ct_window;
Leo Kimc21047e2015-10-15 13:24:46 +0900221 u8 cnt;
Leo Kimcc179002015-10-15 13:24:47 +0900222 u8 idx;
Leo Kim109e6ca2015-10-15 13:24:48 +0900223 u8 duration[4];
Leo Kim1d8b76b2015-10-15 13:24:49 +0900224 u8 interval[4];
Leo Kim4be55e22015-10-28 15:59:27 +0900225 u8 start_time[4];
Leo Kime0a12212015-10-12 16:55:49 +0900226};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900227
Hugo Camboulived27afda2016-01-04 22:02:23 +0000228static struct host_if_drv *terminated_handle;
Arnd Bergmann0e1af732015-11-16 15:04:54 +0100229bool wilc_optaining_ip;
Arnd Bergmann1608c402015-11-16 15:04:53 +0100230static u8 P2P_LISTEN_STATE;
Leo Kimc2115d82015-10-15 13:24:52 +0900231static struct task_struct *hif_thread_handler;
Leo Kimcb067dc2015-10-15 13:24:53 +0900232static WILC_MsgQueueHandle hif_msg_q;
Leo Kim834e0cb2015-10-15 13:24:54 +0900233static struct semaphore hif_sema_thread;
kbuild test robot413f9302015-10-15 14:07:41 +0800234static struct semaphore hif_sema_driver;
Leo Kim2d25af82015-10-15 13:24:56 +0900235static struct semaphore hif_sema_wait_response;
kbuild test robot17225002015-10-15 14:21:32 +0800236static struct semaphore hif_sema_deinit;
kbuild test robot24aadb82015-10-15 14:32:40 +0800237static struct timer_list periodic_rssi;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900238
Arnd Bergmann0e1af732015-11-16 15:04:54 +0100239u8 wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900240
Leo Kima633c0b2015-10-15 13:24:59 +0900241static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900242
kbuild test robotf64321c2015-10-15 14:46:26 +0800243static bool scan_while_connected;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900244
Leo Kim144b7b22015-10-15 13:25:01 +0900245static s8 rssi;
Leo Kim75327a02015-10-15 13:25:02 +0900246static s8 link_speed;
Leo Kim95ebb0f2015-10-15 13:25:03 +0900247static u8 ch_no;
Leo Kim078b1e92015-10-15 13:25:04 +0900248static u8 set_ip[2][4];
Leo Kim1e75d012015-10-15 13:25:05 +0900249static u8 get_ip[2][4];
Leo Kimad269062015-10-15 13:25:06 +0900250static u32 inactive_time;
Leo Kima74c7bf2015-10-15 13:25:07 +0900251static u8 del_beacon;
Leo Kim7178aed2015-10-19 18:26:09 +0900252static u32 clients_count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900253
kbuild test robotef599192015-10-15 15:04:15 +0800254static u8 *join_req;
Arnd Bergmann1608c402015-11-16 15:04:53 +0100255static u8 *info_element;
kbuild test robot23047d52015-10-15 15:18:34 +0800256static u8 mode_11i;
Arnd Bergmann1608c402015-11-16 15:04:53 +0100257static u8 auth_type;
258static u32 join_req_size;
kbuild test robot5e0e7c22015-10-15 15:47:44 +0800259static u32 info_element_size;
Glen Lee7036c622015-12-21 14:18:45 +0900260static struct wilc_vif *join_req_vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900261#define REAL_JOIN_REQ 0
262#define FLUSHED_JOIN_REQ 1
Leo Kimae4dfa52015-10-13 19:49:26 +0900263#define FLUSHED_BYTE_POS 79
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900264
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900265static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
Chaehyun Lim4ad878b2015-12-30 21:15:44 +0900266static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900267
Glen Leeeb9939b2015-12-21 14:18:43 +0900268/* The u8IfIdx starts from 0 to NUM_CONCURRENT_IFC -1, but 0 index used as
269 * special purpose in wilc device, so we add 1 to the index to starts from 1.
270 * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC.
271 */
Glen Lee31f0f692015-12-21 14:18:44 +0900272int wilc_get_vif_idx(struct wilc_vif *vif)
Johnny Kimd42ab082015-08-20 16:32:52 +0900273{
Glen Leeeb9939b2015-12-21 14:18:43 +0900274 return vif->u8IfIdx + 1;
275}
276
277/* We need to minus 1 from idx which is from wilc device to get real index
278 * of wilc->vif[], because we add 1 when pass to wilc device in the function
279 * wilc_get_vif_idx.
280 * As a result, the index should be between 0 and NUM_CONCURRENT_IFC -1.
281 */
282static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx)
283{
284 int index = idx - 1;
285
286 if (index < 0 || index >= NUM_CONCURRENT_IFC)
Johnny Kimd42ab082015-08-20 16:32:52 +0900287 return NULL;
Glen Leeeb9939b2015-12-21 14:18:43 +0900288
289 return wilc->vif[index];
Johnny Kimd42ab082015-08-20 16:32:52 +0900290}
291
Glen Lee71130e82015-12-21 14:18:41 +0900292static s32 handle_set_channel(struct wilc_vif *vif,
Leo Kim9cf78782015-10-29 12:05:54 +0900293 struct channel_attr *hif_set_ch)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900294{
Leo Kim31390ee2015-10-19 18:26:08 +0900295 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900296 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900297
Leo Kim45102f82015-10-28 15:59:28 +0900298 wid.id = (u16)WID_CURRENT_CHANNEL;
299 wid.type = WID_CHAR;
Leo Kim9cf78782015-10-29 12:05:54 +0900300 wid.val = (char *)&hif_set_ch->set_ch;
Leo Kim45102f82015-10-28 15:59:28 +0900301 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900302
303 PRINT_D(HOSTINF_DBG, "Setting channel\n");
Leo Kimae4dfa52015-10-13 19:49:26 +0900304
Glen Leecd2920a2015-12-21 14:18:48 +0900305 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +0900306 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +0900307
308 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900309 PRINT_ER("Failed to set channel\n");
Leo Kim24db7132015-09-16 18:36:01 +0900310 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900311 }
312
Leo Kim31390ee2015-10-19 18:26:08 +0900313 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900314}
Leo Kimae4dfa52015-10-13 19:49:26 +0900315
Glen Lee71130e82015-12-21 14:18:41 +0900316static s32 handle_set_wfi_drv_handler(struct wilc_vif *vif,
Leo Kim23f2bad2015-11-06 11:20:04 +0900317 struct drv_handler *hif_drv_handler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900318{
Leo Kim31390ee2015-10-19 18:26:08 +0900319 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900320 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900321
Leo Kim45102f82015-10-28 15:59:28 +0900322 wid.id = (u16)WID_SET_DRV_HANDLER;
323 wid.type = WID_INT;
Leo Kim6b73c742015-10-29 12:05:55 +0900324 wid.val = (s8 *)&hif_drv_handler->handler;
Leo Kim45102f82015-10-28 15:59:28 +0900325 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900326
Glen Lee31f0f692015-12-21 14:18:44 +0900327 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeec62e6d2015-11-18 15:11:33 +0900328 hif_drv_handler->handler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900329
Glen Lee31f0f692015-12-21 14:18:44 +0900330 if (!hif_drv_handler->handler)
Leo Kim27ff2162015-10-15 13:24:55 +0900331 up(&hif_sema_driver);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900332
Leo Kim31390ee2015-10-19 18:26:08 +0900333 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900334 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900335 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900336 }
337
Leo Kim31390ee2015-10-19 18:26:08 +0900338 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900339}
340
Glen Lee71130e82015-12-21 14:18:41 +0900341static s32 handle_set_operation_mode(struct wilc_vif *vif,
Leo Kim97b5c592015-11-06 11:20:05 +0900342 struct op_mode *hif_op_mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900343{
Leo Kim31390ee2015-10-19 18:26:08 +0900344 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900345 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900346
Leo Kim45102f82015-10-28 15:59:28 +0900347 wid.id = (u16)WID_SET_OPERATION_MODE;
348 wid.type = WID_INT;
Leo Kimacff1d72015-10-29 12:05:56 +0900349 wid.val = (s8 *)&hif_op_mode->mode;
Leo Kim45102f82015-10-28 15:59:28 +0900350 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900351
Glen Leecd2920a2015-12-21 14:18:48 +0900352 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +0900353 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900354
Leo Kimacff1d72015-10-29 12:05:56 +0900355 if ((hif_op_mode->mode) == IDLE_MODE)
Leo Kim27ff2162015-10-15 13:24:55 +0900356 up(&hif_sema_driver);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900357
Leo Kim31390ee2015-10-19 18:26:08 +0900358 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900359 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900360 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900361 }
362
Leo Kim31390ee2015-10-19 18:26:08 +0900363 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900364}
365
Glen Lee71130e82015-12-21 14:18:41 +0900366static s32 handle_set_ip_address(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900367{
Leo Kim31390ee2015-10-19 18:26:08 +0900368 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900369 struct wid wid;
Leo Kimebc57d12015-11-05 14:36:03 +0900370 char firmware_ip_addr[4] = {0};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900371
Leo Kima6527c32015-11-05 14:36:02 +0900372 if (ip_addr[0] < 192)
373 ip_addr[0] = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900374
Leo Kima6527c32015-11-05 14:36:02 +0900375 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n",
376 idx, ip_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900377
Leo Kima6527c32015-11-05 14:36:02 +0900378 memcpy(set_ip[idx], ip_addr, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900379
Leo Kim45102f82015-10-28 15:59:28 +0900380 wid.id = (u16)WID_IP_ADDRESS;
381 wid.type = WID_STR;
Leo Kima6527c32015-11-05 14:36:02 +0900382 wid.val = (u8 *)ip_addr;
Leo Kim45102f82015-10-28 15:59:28 +0900383 wid.size = IP_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900384
Glen Leecd2920a2015-12-21 14:18:48 +0900385 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +0900386 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900387
Chaehyun Limf8813d32015-12-30 21:15:42 +0900388 host_int_get_ipaddress(vif, firmware_ip_addr, idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900389
Leo Kim31390ee2015-10-19 18:26:08 +0900390 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +0900391 PRINT_ER("Failed to set IP address\n");
392 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900393 }
394
Leo Kim24db7132015-09-16 18:36:01 +0900395 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900396
Leo Kim31390ee2015-10-19 18:26:08 +0900397 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900398}
399
Glen Lee71130e82015-12-21 14:18:41 +0900400static s32 handle_get_ip_address(struct wilc_vif *vif, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900401{
Leo Kim31390ee2015-10-19 18:26:08 +0900402 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900403 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900404
Leo Kim45102f82015-10-28 15:59:28 +0900405 wid.id = (u16)WID_IP_ADDRESS;
406 wid.type = WID_STR;
407 wid.val = kmalloc(IP_ALEN, GFP_KERNEL);
408 wid.size = IP_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900409
Glen Leecd2920a2015-12-21 14:18:48 +0900410 result = wilc_send_config_pkt(vif->wilc, GET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +0900411 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900412
Leo Kim45102f82015-10-28 15:59:28 +0900413 PRINT_INFO(HOSTINF_DBG, "%pI4\n", wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900414
Leo Kim45102f82015-10-28 15:59:28 +0900415 memcpy(get_ip[idx], wid.val, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900416
Leo Kim45102f82015-10-28 15:59:28 +0900417 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900418
Leo Kim1e75d012015-10-15 13:25:05 +0900419 if (memcmp(get_ip[idx], set_ip[idx], IP_ALEN) != 0)
Glen Leefbf53792015-12-21 14:18:40 +0900420 wilc_setup_ipaddress(vif, set_ip[idx], idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900421
Leo Kim31390ee2015-10-19 18:26:08 +0900422 if (result != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900423 PRINT_ER("Failed to get IP address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900424 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900425 }
426
Leo Kim24db7132015-09-16 18:36:01 +0900427 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
Leo Kim1e75d012015-10-15 13:25:05 +0900428 PRINT_INFO(HOSTINF_DBG, "%pI4\n", get_ip[idx]);
Leo Kim24db7132015-09-16 18:36:01 +0900429 PRINT_INFO(HOSTINF_DBG, "\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900430
Leo Kim31390ee2015-10-19 18:26:08 +0900431 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900432}
433
Glen Lee71130e82015-12-21 14:18:41 +0900434static s32 handle_set_mac_address(struct wilc_vif *vif,
Leo Kima8267422015-11-06 11:20:08 +0900435 struct set_mac_addr *set_mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900436{
Leo Kim31390ee2015-10-19 18:26:08 +0900437 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900438 struct wid wid;
Glen Leef3052582015-09-10 12:03:04 +0900439 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
Leo Kimc09389a2015-10-28 15:59:24 +0900440
Leo Kim91109e12015-10-19 18:26:13 +0900441 if (!mac_buf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900442 PRINT_ER("No buffer to send mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +0900443 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900444 }
Leo Kim090dbb12015-11-05 14:36:05 +0900445 memcpy(mac_buf, set_mac_addr->mac_addr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900446
Leo Kim45102f82015-10-28 15:59:28 +0900447 wid.id = (u16)WID_MAC_ADDR;
448 wid.type = WID_STR;
449 wid.val = mac_buf;
450 wid.size = ETH_ALEN;
451 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", wid.val);
Leo Kimae4dfa52015-10-13 19:49:26 +0900452
Glen Leecd2920a2015-12-21 14:18:48 +0900453 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +0900454 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +0900455 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900456 PRINT_ER("Failed to set mac address\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900457 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900458 }
459
Chaehyun Lim49188af2015-08-11 10:32:41 +0900460 kfree(mac_buf);
Leo Kim31390ee2015-10-19 18:26:08 +0900461 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900462}
463
Glen Lee71130e82015-12-21 14:18:41 +0900464static s32 handle_get_mac_address(struct wilc_vif *vif,
Leo Kimb3bf8fd2015-11-06 11:20:09 +0900465 struct get_mac_addr *get_mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900466{
Leo Kim31390ee2015-10-19 18:26:08 +0900467 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900468 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900469
Leo Kim45102f82015-10-28 15:59:28 +0900470 wid.id = (u16)WID_MAC_ADDR;
471 wid.type = WID_STR;
Leo Kim7f0ee9a2015-11-05 14:36:06 +0900472 wid.val = get_mac_addr->mac_addr;
Leo Kim45102f82015-10-28 15:59:28 +0900473 wid.size = ETH_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900474
Glen Leecd2920a2015-12-21 14:18:48 +0900475 result = wilc_send_config_pkt(vif->wilc, GET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +0900476 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +0900477
478 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900479 PRINT_ER("Failed to get mac address\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900480 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900481 }
Leo Kim2d25af82015-10-15 13:24:56 +0900482 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900483
Leo Kim31390ee2015-10-19 18:26:08 +0900484 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900485}
486
Glen Lee71130e82015-12-21 14:18:41 +0900487static s32 handle_cfg_param(struct wilc_vif *vif,
Leo Kimdc276662015-11-06 11:20:10 +0900488 struct cfg_param_attr *cfg_param_attr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900489{
Leo Kim31390ee2015-10-19 18:26:08 +0900490 s32 result = 0;
Leo Kim13ca52a2015-11-06 11:20:11 +0900491 struct wid wid_list[32];
Glen Lee71130e82015-12-21 14:18:41 +0900492 struct host_if_drv *hif_drv = vif->hif_drv;
Leo Kim540c3e82015-11-06 11:20:12 +0900493 u8 wid_cnt = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900494
Leo Kim33110ad2015-10-29 11:58:27 +0900495 down(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900496
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900497 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
498
Leo Kim02ae2bd2015-11-05 14:36:07 +0900499 if (cfg_param_attr->cfg_attr_info.flag & BSS_TYPE) {
500 if (cfg_param_attr->cfg_attr_info.bss_type < 6) {
Leo Kim540c3e82015-11-06 11:20:12 +0900501 wid_list[wid_cnt].id = WID_BSS_TYPE;
502 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.bss_type;
503 wid_list[wid_cnt].type = WID_CHAR;
504 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900505 hif_drv->cfg_values.bss_type = (u8)cfg_param_attr->cfg_attr_info.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900506 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900507 PRINT_ER("check value 6 over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900508 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900509 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900510 }
Leo Kim540c3e82015-11-06 11:20:12 +0900511 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900512 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900513 if (cfg_param_attr->cfg_attr_info.flag & AUTH_TYPE) {
514 if (cfg_param_attr->cfg_attr_info.auth_type == 1 ||
515 cfg_param_attr->cfg_attr_info.auth_type == 2 ||
516 cfg_param_attr->cfg_attr_info.auth_type == 5) {
Leo Kim540c3e82015-11-06 11:20:12 +0900517 wid_list[wid_cnt].id = WID_AUTH_TYPE;
518 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.auth_type;
519 wid_list[wid_cnt].type = WID_CHAR;
520 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900521 hif_drv->cfg_values.auth_type = (u8)cfg_param_attr->cfg_attr_info.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900522 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900523 PRINT_ER("Impossible value \n");
Leo Kim31390ee2015-10-19 18:26:08 +0900524 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900525 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900526 }
Leo Kim540c3e82015-11-06 11:20:12 +0900527 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900528 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900529 if (cfg_param_attr->cfg_attr_info.flag & AUTHEN_TIMEOUT) {
530 if (cfg_param_attr->cfg_attr_info.auth_timeout > 0 &&
531 cfg_param_attr->cfg_attr_info.auth_timeout < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900532 wid_list[wid_cnt].id = WID_AUTH_TIMEOUT;
533 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.auth_timeout;
534 wid_list[wid_cnt].type = WID_SHORT;
535 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900536 hif_drv->cfg_values.auth_timeout = cfg_param_attr->cfg_attr_info.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900537 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900538 PRINT_ER("Range(1 ~ 65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900539 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900540 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900541 }
Leo Kim540c3e82015-11-06 11:20:12 +0900542 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900543 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900544 if (cfg_param_attr->cfg_attr_info.flag & POWER_MANAGEMENT) {
545 if (cfg_param_attr->cfg_attr_info.power_mgmt_mode < 5) {
Leo Kim540c3e82015-11-06 11:20:12 +0900546 wid_list[wid_cnt].id = WID_POWER_MANAGEMENT;
547 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.power_mgmt_mode;
548 wid_list[wid_cnt].type = WID_CHAR;
549 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900550 hif_drv->cfg_values.power_mgmt_mode = (u8)cfg_param_attr->cfg_attr_info.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900551 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900552 PRINT_ER("Invalide power mode\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900553 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900554 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900555 }
Leo Kim540c3e82015-11-06 11:20:12 +0900556 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900557 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900558 if (cfg_param_attr->cfg_attr_info.flag & RETRY_SHORT) {
559 if (cfg_param_attr->cfg_attr_info.short_retry_limit > 0 &&
560 cfg_param_attr->cfg_attr_info.short_retry_limit < 256) {
Leo Kim540c3e82015-11-06 11:20:12 +0900561 wid_list[wid_cnt].id = WID_SHORT_RETRY_LIMIT;
562 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.short_retry_limit;
563 wid_list[wid_cnt].type = WID_SHORT;
564 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900565 hif_drv->cfg_values.short_retry_limit = cfg_param_attr->cfg_attr_info.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900566 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900567 PRINT_ER("Range(1~256) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900568 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900569 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900570 }
Leo Kim540c3e82015-11-06 11:20:12 +0900571 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900572 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900573 if (cfg_param_attr->cfg_attr_info.flag & RETRY_LONG) {
574 if (cfg_param_attr->cfg_attr_info.long_retry_limit > 0 &&
575 cfg_param_attr->cfg_attr_info.long_retry_limit < 256) {
Leo Kim540c3e82015-11-06 11:20:12 +0900576 wid_list[wid_cnt].id = WID_LONG_RETRY_LIMIT;
577 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.long_retry_limit;
578 wid_list[wid_cnt].type = WID_SHORT;
579 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900580 hif_drv->cfg_values.long_retry_limit = cfg_param_attr->cfg_attr_info.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900581 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900582 PRINT_ER("Range(1~256) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900583 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900584 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900585 }
Leo Kim540c3e82015-11-06 11:20:12 +0900586 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900587 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900588 if (cfg_param_attr->cfg_attr_info.flag & FRAG_THRESHOLD) {
589 if (cfg_param_attr->cfg_attr_info.frag_threshold > 255 &&
590 cfg_param_attr->cfg_attr_info.frag_threshold < 7937) {
Leo Kim540c3e82015-11-06 11:20:12 +0900591 wid_list[wid_cnt].id = WID_FRAG_THRESHOLD;
592 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.frag_threshold;
593 wid_list[wid_cnt].type = WID_SHORT;
594 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900595 hif_drv->cfg_values.frag_threshold = cfg_param_attr->cfg_attr_info.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900596 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900597 PRINT_ER("Threshold Range fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900598 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900599 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900600 }
Leo Kim540c3e82015-11-06 11:20:12 +0900601 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900602 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900603 if (cfg_param_attr->cfg_attr_info.flag & RTS_THRESHOLD) {
604 if (cfg_param_attr->cfg_attr_info.rts_threshold > 255 &&
605 cfg_param_attr->cfg_attr_info.rts_threshold < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900606 wid_list[wid_cnt].id = WID_RTS_THRESHOLD;
607 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.rts_threshold;
608 wid_list[wid_cnt].type = WID_SHORT;
609 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900610 hif_drv->cfg_values.rts_threshold = cfg_param_attr->cfg_attr_info.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900611 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900612 PRINT_ER("Threshold Range fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900613 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900614 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900615 }
Leo Kim540c3e82015-11-06 11:20:12 +0900616 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900617 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900618 if (cfg_param_attr->cfg_attr_info.flag & PREAMBLE) {
619 if (cfg_param_attr->cfg_attr_info.preamble_type < 3) {
Leo Kim540c3e82015-11-06 11:20:12 +0900620 wid_list[wid_cnt].id = WID_PREAMBLE;
621 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.preamble_type;
622 wid_list[wid_cnt].type = WID_CHAR;
623 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900624 hif_drv->cfg_values.preamble_type = cfg_param_attr->cfg_attr_info.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900625 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900626 PRINT_ER("Preamle Range(0~2) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900627 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900628 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900629 }
Leo Kim540c3e82015-11-06 11:20:12 +0900630 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900631 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900632 if (cfg_param_attr->cfg_attr_info.flag & SHORT_SLOT_ALLOWED) {
633 if (cfg_param_attr->cfg_attr_info.short_slot_allowed < 2) {
Leo Kim540c3e82015-11-06 11:20:12 +0900634 wid_list[wid_cnt].id = WID_SHORT_SLOT_ALLOWED;
635 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.short_slot_allowed;
636 wid_list[wid_cnt].type = WID_CHAR;
637 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900638 hif_drv->cfg_values.short_slot_allowed = (u8)cfg_param_attr->cfg_attr_info.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900639 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900640 PRINT_ER("Short slot(2) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900641 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900642 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900643 }
Leo Kim540c3e82015-11-06 11:20:12 +0900644 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900645 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900646 if (cfg_param_attr->cfg_attr_info.flag & TXOP_PROT_DISABLE) {
647 if (cfg_param_attr->cfg_attr_info.txop_prot_disabled < 2) {
Leo Kim540c3e82015-11-06 11:20:12 +0900648 wid_list[wid_cnt].id = WID_11N_TXOP_PROT_DISABLE;
649 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.txop_prot_disabled;
650 wid_list[wid_cnt].type = WID_CHAR;
651 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900652 hif_drv->cfg_values.txop_prot_disabled = (u8)cfg_param_attr->cfg_attr_info.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900653 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900654 PRINT_ER("TXOP prot disable\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900655 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900656 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900657 }
Leo Kim540c3e82015-11-06 11:20:12 +0900658 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900659 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900660 if (cfg_param_attr->cfg_attr_info.flag & BEACON_INTERVAL) {
661 if (cfg_param_attr->cfg_attr_info.beacon_interval > 0 &&
662 cfg_param_attr->cfg_attr_info.beacon_interval < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900663 wid_list[wid_cnt].id = WID_BEACON_INTERVAL;
664 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.beacon_interval;
665 wid_list[wid_cnt].type = WID_SHORT;
666 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900667 hif_drv->cfg_values.beacon_interval = cfg_param_attr->cfg_attr_info.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900668 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900669 PRINT_ER("Beacon interval(1~65535) fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900670 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900671 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900672 }
Leo Kim540c3e82015-11-06 11:20:12 +0900673 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900674 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900675 if (cfg_param_attr->cfg_attr_info.flag & DTIM_PERIOD) {
676 if (cfg_param_attr->cfg_attr_info.dtim_period > 0 &&
677 cfg_param_attr->cfg_attr_info.dtim_period < 256) {
Leo Kim540c3e82015-11-06 11:20:12 +0900678 wid_list[wid_cnt].id = WID_DTIM_PERIOD;
679 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.dtim_period;
680 wid_list[wid_cnt].type = WID_CHAR;
681 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900682 hif_drv->cfg_values.dtim_period = cfg_param_attr->cfg_attr_info.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900683 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900684 PRINT_ER("DTIM range(1~255) fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900685 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900686 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900687 }
Leo Kim540c3e82015-11-06 11:20:12 +0900688 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900689 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900690 if (cfg_param_attr->cfg_attr_info.flag & SITE_SURVEY) {
691 if (cfg_param_attr->cfg_attr_info.site_survey_enabled < 3) {
Leo Kim540c3e82015-11-06 11:20:12 +0900692 wid_list[wid_cnt].id = WID_SITE_SURVEY;
693 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.site_survey_enabled;
694 wid_list[wid_cnt].type = WID_CHAR;
695 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900696 hif_drv->cfg_values.site_survey_enabled = (u8)cfg_param_attr->cfg_attr_info.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900697 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900698 PRINT_ER("Site survey disable\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900699 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900700 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900701 }
Leo Kim540c3e82015-11-06 11:20:12 +0900702 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900703 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900704 if (cfg_param_attr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) {
705 if (cfg_param_attr->cfg_attr_info.site_survey_scan_time > 0 &&
706 cfg_param_attr->cfg_attr_info.site_survey_scan_time < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900707 wid_list[wid_cnt].id = WID_SITE_SURVEY_SCAN_TIME;
708 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.site_survey_scan_time;
709 wid_list[wid_cnt].type = WID_SHORT;
710 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900711 hif_drv->cfg_values.site_survey_scan_time = cfg_param_attr->cfg_attr_info.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900712 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900713 PRINT_ER("Site survey scan time(1~65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900714 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900715 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900716 }
Leo Kim540c3e82015-11-06 11:20:12 +0900717 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900718 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900719 if (cfg_param_attr->cfg_attr_info.flag & ACTIVE_SCANTIME) {
720 if (cfg_param_attr->cfg_attr_info.active_scan_time > 0 &&
721 cfg_param_attr->cfg_attr_info.active_scan_time < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900722 wid_list[wid_cnt].id = WID_ACTIVE_SCAN_TIME;
723 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.active_scan_time;
724 wid_list[wid_cnt].type = WID_SHORT;
725 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900726 hif_drv->cfg_values.active_scan_time = cfg_param_attr->cfg_attr_info.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900727 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900728 PRINT_ER("Active scan time(1~65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900729 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900730 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900731 }
Leo Kim540c3e82015-11-06 11:20:12 +0900732 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900733 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900734 if (cfg_param_attr->cfg_attr_info.flag & PASSIVE_SCANTIME) {
735 if (cfg_param_attr->cfg_attr_info.passive_scan_time > 0 &&
736 cfg_param_attr->cfg_attr_info.passive_scan_time < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900737 wid_list[wid_cnt].id = WID_PASSIVE_SCAN_TIME;
738 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.passive_scan_time;
739 wid_list[wid_cnt].type = WID_SHORT;
740 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900741 hif_drv->cfg_values.passive_scan_time = cfg_param_attr->cfg_attr_info.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900742 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900743 PRINT_ER("Passive scan time(1~65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900744 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900745 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900746 }
Leo Kim540c3e82015-11-06 11:20:12 +0900747 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900748 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900749 if (cfg_param_attr->cfg_attr_info.flag & CURRENT_TX_RATE) {
750 enum CURRENT_TXRATE curr_tx_rate = cfg_param_attr->cfg_attr_info.curr_tx_rate;
Leo Kimc09389a2015-10-28 15:59:24 +0900751
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900752 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
753 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
754 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
755 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
756 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
757 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
Leo Kim540c3e82015-11-06 11:20:12 +0900758 wid_list[wid_cnt].id = WID_CURRENT_TX_RATE;
759 wid_list[wid_cnt].val = (s8 *)&curr_tx_rate;
760 wid_list[wid_cnt].type = WID_SHORT;
761 wid_list[wid_cnt].size = sizeof(u16);
Leo Kimace303f2015-10-29 11:58:26 +0900762 hif_drv->cfg_values.curr_tx_rate = (u8)curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900763 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900764 PRINT_ER("out of TX rate\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900765 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900766 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900767 }
Leo Kim540c3e82015-11-06 11:20:12 +0900768 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900769 }
Leo Kim31390ee2015-10-19 18:26:08 +0900770
Glen Leecd2920a2015-12-21 14:18:48 +0900771 result = wilc_send_config_pkt(vif->wilc, SET_CFG, wid_list,
Glen Leeeb9939b2015-12-21 14:18:43 +0900772 wid_cnt, wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900773
Leo Kim31390ee2015-10-19 18:26:08 +0900774 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900775 PRINT_ER("Error in setting CFG params\n");
776
Leo Kim24db7132015-09-16 18:36:01 +0900777ERRORHANDLER:
Leo Kim33110ad2015-10-29 11:58:27 +0900778 up(&hif_drv->sem_cfg_values);
Leo Kim31390ee2015-10-19 18:26:08 +0900779 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900780}
781
Leo Kim3b840e42015-11-05 14:36:08 +0900782static void Handle_wait_msg_q_empty(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900783{
Arnd Bergmann0e1af732015-11-16 15:04:54 +0100784 wilc_initialized = 0;
Leo Kim2d25af82015-10-15 13:24:56 +0900785 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900786}
787
Glen Lee71130e82015-12-21 14:18:41 +0900788static s32 Handle_ScanDone(struct wilc_vif *vif,
Arnd Bergmann1608c402015-11-16 15:04:53 +0100789 enum scan_event enuEvent);
790
Glen Lee71130e82015-12-21 14:18:41 +0900791static s32 Handle_Scan(struct wilc_vif *vif,
Tony Choc476feb2015-09-21 12:16:36 +0900792 struct scan_attr *pstrHostIFscanAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900793{
Leo Kim31390ee2015-10-19 18:26:08 +0900794 s32 result = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900795 struct wid strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900796 u32 u32WidsCount = 0;
797 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900798 u8 *pu8Buffer;
799 u8 valuesize = 0;
800 u8 *pu8HdnNtwrksWidVal = NULL;
Glen Lee71130e82015-12-21 14:18:41 +0900801 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900802
803 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
Leo Kimb60005a2015-10-29 11:58:24 +0900804 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", hif_drv->hif_state);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900805
Leo Kimbc801852015-10-29 11:58:50 +0900806 hif_drv->usr_scan_req.scan_result = pstrHostIFscanAttr->result;
Leo Kim66eaea32015-10-29 11:58:51 +0900807 hif_drv->usr_scan_req.arg = pstrHostIFscanAttr->arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900808
Leo Kimb60005a2015-10-29 11:58:24 +0900809 if ((hif_drv->hif_state >= HOST_IF_SCANNING) &&
810 (hif_drv->hif_state < HOST_IF_CONNECTED)) {
811 PRINT_D(GENERIC_DBG, "Don't scan already in [%d] state\n",
812 hif_drv->hif_state);
Leo Kim24db7132015-09-16 18:36:01 +0900813 PRINT_ER("Already scan\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900814 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +0900815 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900816 }
817
Arnd Bergmann0e1af732015-11-16 15:04:54 +0100818 if (wilc_optaining_ip || wilc_connecting) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900819 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +0900820 PRINT_ER("Don't do obss scan\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900821 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +0900822 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900823 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900824
825 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
826
Leo Kimf79756e2015-10-29 12:05:36 +0900827 hif_drv->usr_scan_req.rcvd_ch_cnt = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900828
Leo Kimdaaf16b2015-10-12 16:55:44 +0900829 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
Leo Kim416d8322015-10-12 16:55:43 +0900830 strWIDList[u32WidsCount].type = WID_STR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900831
Chaehyun Lim40e05e82016-01-05 13:26:33 +0900832 for (i = 0; i < pstrHostIFscanAttr->hidden_network.n_ssids; i++)
Chaehyun Lim245a1862016-01-05 13:26:32 +0900833 valuesize += ((pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len) + 1);
Glen Leef3052582015-09-10 12:03:04 +0900834 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
Leo Kim900bb4a2015-10-12 16:55:46 +0900835 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
Leo Kim91109e12015-10-19 18:26:13 +0900836 if (strWIDList[u32WidsCount].val) {
Leo Kim900bb4a2015-10-12 16:55:46 +0900837 pu8Buffer = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900838
Chaehyun Lim40e05e82016-01-05 13:26:33 +0900839 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.n_ssids;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900840
Chaehyun Lim40e05e82016-01-05 13:26:33 +0900841 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->hidden_network.n_ssids);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900842
Chaehyun Lim40e05e82016-01-05 13:26:33 +0900843 for (i = 0; i < pstrHostIFscanAttr->hidden_network.n_ssids; i++) {
Chaehyun Lim245a1862016-01-05 13:26:32 +0900844 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len;
845 memcpy(pu8Buffer, pstrHostIFscanAttr->hidden_network.net_info[i].ssid, pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len);
846 pu8Buffer += pstrHostIFscanAttr->hidden_network.net_info[i].ssid_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900847 }
848
Leo Kim2fd3e442015-10-12 16:55:45 +0900849 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900850 u32WidsCount++;
851 }
852
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900853 {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900854 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
Leo Kim416d8322015-10-12 16:55:43 +0900855 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kimd6f19aa2015-10-13 19:49:42 +0900856 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ies;
Leo Kim7b1f76c2015-10-13 19:49:43 +0900857 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ies_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900858 u32WidsCount++;
859 }
860
Leo Kimdaaf16b2015-10-12 16:55:44 +0900861 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +0900862 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900863 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +0900864 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900865 u32WidsCount++;
866
Leo Kimdaaf16b2015-10-12 16:55:44 +0900867 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
Leo Kim416d8322015-10-12 16:55:43 +0900868 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900869
Leo Kim91109e12015-10-19 18:26:13 +0900870 if (pstrHostIFscanAttr->ch_freq_list &&
871 pstrHostIFscanAttr->ch_list_len > 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900872 int i;
873
Leo Kimf97bd9c2015-10-13 19:49:41 +0900874 for (i = 0; i < pstrHostIFscanAttr->ch_list_len; i++) {
Leo Kim82eeb0a2015-10-13 19:49:40 +0900875 if (pstrHostIFscanAttr->ch_freq_list[i] > 0)
876 pstrHostIFscanAttr->ch_freq_list[i] = pstrHostIFscanAttr->ch_freq_list[i] - 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900877 }
878 }
879
Leo Kim82eeb0a2015-10-13 19:49:40 +0900880 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
Leo Kimf97bd9c2015-10-13 19:49:41 +0900881 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900882 u32WidsCount++;
883
Leo Kimdaaf16b2015-10-12 16:55:44 +0900884 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
Leo Kim416d8322015-10-12 16:55:43 +0900885 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900886 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +0900887 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->src;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900888 u32WidsCount++;
889
Leo Kimb60005a2015-10-29 11:58:24 +0900890 if (hif_drv->hif_state == HOST_IF_CONNECTED)
Leo Kimca8540e42015-10-15 13:25:00 +0900891 scan_while_connected = true;
Leo Kimb60005a2015-10-29 11:58:24 +0900892 else if (hif_drv->hif_state == HOST_IF_IDLE)
Leo Kimca8540e42015-10-15 13:25:00 +0900893 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900894
Glen Leecd2920a2015-12-21 14:18:48 +0900895 result = wilc_send_config_pkt(vif->wilc, SET_CFG, strWIDList,
Glen Leeec62e6d2015-11-18 15:11:33 +0900896 u32WidsCount,
Glen Leeeb9939b2015-12-21 14:18:43 +0900897 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900898
Leo Kim31390ee2015-10-19 18:26:08 +0900899 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900900 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +0900901 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900902 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900903
Leo Kim24db7132015-09-16 18:36:01 +0900904ERRORHANDLER:
Leo Kim31390ee2015-10-19 18:26:08 +0900905 if (result) {
Leo Kim13b313e2015-10-29 11:58:34 +0900906 del_timer(&hif_drv->scan_timer);
Glen Lee71130e82015-12-21 14:18:41 +0900907 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900908 }
909
Shraddha Barke95f840f2015-10-14 07:29:19 +0530910 kfree(pstrHostIFscanAttr->ch_freq_list);
911 pstrHostIFscanAttr->ch_freq_list = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900912
Shraddha Barke95f840f2015-10-14 07:29:19 +0530913 kfree(pstrHostIFscanAttr->ies);
914 pstrHostIFscanAttr->ies = NULL;
Chaehyun Lim245a1862016-01-05 13:26:32 +0900915 kfree(pstrHostIFscanAttr->hidden_network.net_info);
916 pstrHostIFscanAttr->hidden_network.net_info = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900917
Shraddha Barke95f840f2015-10-14 07:29:19 +0530918 kfree(pu8HdnNtwrksWidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900919
Leo Kim31390ee2015-10-19 18:26:08 +0900920 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900921}
922
Glen Lee71130e82015-12-21 14:18:41 +0900923static s32 Handle_ScanDone(struct wilc_vif *vif,
Tony Choa4ab1ad2015-10-12 16:56:05 +0900924 enum scan_event enuEvent)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900925{
Leo Kim31390ee2015-10-19 18:26:08 +0900926 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900927 u8 u8abort_running_scan;
Leo Kim45102f82015-10-28 15:59:28 +0900928 struct wid wid;
Glen Lee71130e82015-12-21 14:18:41 +0900929 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900930
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900931 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
932
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900933 if (enuEvent == SCAN_EVENT_ABORTED) {
934 PRINT_D(GENERIC_DBG, "Abort running scan\n");
935 u8abort_running_scan = 1;
Leo Kim45102f82015-10-28 15:59:28 +0900936 wid.id = (u16)WID_ABORT_RUNNING_SCAN;
937 wid.type = WID_CHAR;
938 wid.val = (s8 *)&u8abort_running_scan;
939 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900940
Glen Leecd2920a2015-12-21 14:18:48 +0900941 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +0900942 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +0900943
944 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900945 PRINT_ER("Failed to set abort running scan\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900946 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900947 }
948 }
949
Tony Choa4ab1ad2015-10-12 16:56:05 +0900950 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900951 PRINT_ER("Driver handler is NULL\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900952 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900953 }
954
Leo Kimbc801852015-10-29 11:58:50 +0900955 if (hif_drv->usr_scan_req.scan_result) {
956 hif_drv->usr_scan_req.scan_result(enuEvent, NULL,
Leo Kim66eaea32015-10-29 11:58:51 +0900957 hif_drv->usr_scan_req.arg, NULL);
Leo Kimbc801852015-10-29 11:58:50 +0900958 hif_drv->usr_scan_req.scan_result = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900959 }
960
Leo Kim31390ee2015-10-19 18:26:08 +0900961 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900962}
963
Leo Kime554a302015-11-19 15:56:21 +0900964u8 wilc_connected_ssid[6] = {0};
Glen Lee71130e82015-12-21 14:18:41 +0900965static s32 Handle_Connect(struct wilc_vif *vif,
Tony Cho120ae592015-09-21 12:16:37 +0900966 struct connect_attr *pstrHostIFconnectAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900967{
Leo Kim31390ee2015-10-19 18:26:08 +0900968 s32 result = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900969 struct wid strWIDList[8];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900970 u32 u32WidsCount = 0, dummyval = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900971 u8 *pu8CurrByte = NULL;
Leo Kime0a12212015-10-12 16:55:49 +0900972 struct join_bss_param *ptstrJoinBssParam;
Glen Lee71130e82015-12-21 14:18:41 +0900973 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900974
975 PRINT_D(GENERIC_DBG, "Handling connect request\n");
976
Leo Kime554a302015-11-19 15:56:21 +0900977 if (memcmp(pstrHostIFconnectAttr->bssid, wilc_connected_ssid, ETH_ALEN) == 0) {
Leo Kim31390ee2015-10-19 18:26:08 +0900978 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900979 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900980 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900981 }
982
983 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
984
Leo Kimf2bed2c2015-10-13 19:49:59 +0900985 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->params;
Leo Kim91109e12015-10-19 18:26:13 +0900986 if (!ptstrJoinBssParam) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900987 PRINT_ER("Required BSSID not found\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900988 result = -ENOENT;
Leo Kim24db7132015-09-16 18:36:01 +0900989 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900990 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900991
Leo Kim91109e12015-10-19 18:26:13 +0900992 if (pstrHostIFconnectAttr->bssid) {
Leo Kimf8b17132015-10-28 15:59:34 +0900993 hif_drv->usr_conn_req.pu8bssid = kmalloc(6, GFP_KERNEL);
994 memcpy(hif_drv->usr_conn_req.pu8bssid, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900995 }
996
Leo Kim74ab5e42015-10-29 11:58:53 +0900997 hif_drv->usr_conn_req.ssid_len = pstrHostIFconnectAttr->ssid_len;
Leo Kim91109e12015-10-19 18:26:13 +0900998 if (pstrHostIFconnectAttr->ssid) {
Leo Kimf8b17132015-10-28 15:59:34 +0900999 hif_drv->usr_conn_req.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
1000 memcpy(hif_drv->usr_conn_req.pu8ssid,
Leo Kim8c8360b2015-10-19 18:26:12 +09001001 pstrHostIFconnectAttr->ssid,
1002 pstrHostIFconnectAttr->ssid_len);
Leo Kimf8b17132015-10-28 15:59:34 +09001003 hif_drv->usr_conn_req.pu8ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001004 }
1005
Leo Kim331ed082015-10-29 11:58:55 +09001006 hif_drv->usr_conn_req.ies_len = pstrHostIFconnectAttr->ies_len;
Leo Kim91109e12015-10-19 18:26:13 +09001007 if (pstrHostIFconnectAttr->ies) {
Leo Kima3b2f4b2015-10-29 11:58:54 +09001008 hif_drv->usr_conn_req.ies = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1009 memcpy(hif_drv->usr_conn_req.ies,
Leo Kim8c8360b2015-10-19 18:26:12 +09001010 pstrHostIFconnectAttr->ies,
1011 pstrHostIFconnectAttr->ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001012 }
1013
Leo Kimf8b17132015-10-28 15:59:34 +09001014 hif_drv->usr_conn_req.u8security = pstrHostIFconnectAttr->security;
Leo Kim7d069722015-10-29 12:05:37 +09001015 hif_drv->usr_conn_req.auth_type = pstrHostIFconnectAttr->auth_type;
Leo Kim33bfb192015-10-29 11:58:56 +09001016 hif_drv->usr_conn_req.conn_result = pstrHostIFconnectAttr->result;
Leo Kim73abaa42015-10-29 12:05:27 +09001017 hif_drv->usr_conn_req.arg = pstrHostIFconnectAttr->arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001018
Leo Kimdaaf16b2015-10-12 16:55:44 +09001019 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001020 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001021 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001022 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001023 u32WidsCount++;
1024
Leo Kimdaaf16b2015-10-12 16:55:44 +09001025 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001026 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001027 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001028 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001029 u32WidsCount++;
1030
Leo Kimdaaf16b2015-10-12 16:55:44 +09001031 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001032 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001033 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001034 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001035 u32WidsCount++;
1036
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001037 {
Leo Kimdaaf16b2015-10-12 16:55:44 +09001038 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
Leo Kim416d8322015-10-12 16:55:43 +09001039 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001040 strWIDList[u32WidsCount].val = hif_drv->usr_conn_req.ies;
Leo Kim331ed082015-10-29 11:58:55 +09001041 strWIDList[u32WidsCount].size = hif_drv->usr_conn_req.ies_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001042 u32WidsCount++;
1043
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001044 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Leo Kim331ed082015-10-29 11:58:55 +09001045 info_element_size = hif_drv->usr_conn_req.ies_len;
Leo Kimdfef7b82015-10-15 13:25:14 +09001046 info_element = kmalloc(info_element_size, GFP_KERNEL);
Leo Kima3b2f4b2015-10-29 11:58:54 +09001047 memcpy(info_element, hif_drv->usr_conn_req.ies,
Leo Kimdfef7b82015-10-15 13:25:14 +09001048 info_element_size);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001049 }
1050 }
Leo Kimdaaf16b2015-10-12 16:55:44 +09001051 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001052 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001053 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimf8b17132015-10-28 15:59:34 +09001054 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001055 u32WidsCount++;
1056
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001057 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
Leo Kimf8b17132015-10-28 15:59:34 +09001058 mode_11i = hif_drv->usr_conn_req.u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001059
Leo Kimf8b17132015-10-28 15:59:34 +09001060 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", hif_drv->usr_conn_req.u8security);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001061
Leo Kimdaaf16b2015-10-12 16:55:44 +09001062 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001063 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001064 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim7d069722015-10-29 12:05:37 +09001065 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001066 u32WidsCount++;
1067
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001068 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
Leo Kim7d069722015-10-29 12:05:37 +09001069 auth_type = (u8)hif_drv->usr_conn_req.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001070
Leo Kim7d069722015-10-29 12:05:37 +09001071 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n",
1072 hif_drv->usr_conn_req.auth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001073 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
Leo Kimf8b17132015-10-28 15:59:34 +09001074 hif_drv->usr_conn_req.pu8ssid, pstrHostIFconnectAttr->ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001075
Leo Kimdaaf16b2015-10-12 16:55:44 +09001076 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
Leo Kim416d8322015-10-12 16:55:43 +09001077 strWIDList[u32WidsCount].type = WID_STR;
Leo Kimae4dfa52015-10-13 19:49:26 +09001078 strWIDList[u32WidsCount].size = 112;
Leo Kim900bb4a2015-10-12 16:55:46 +09001079 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001080
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001081 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Leo Kim0626baa2015-10-15 13:25:13 +09001082 join_req_size = strWIDList[u32WidsCount].size;
1083 join_req = kmalloc(join_req_size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001084 }
Leo Kim91109e12015-10-19 18:26:13 +09001085 if (!strWIDList[u32WidsCount].val) {
Leo Kim31390ee2015-10-19 18:26:08 +09001086 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09001087 goto ERRORHANDLER;
1088 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001089
Leo Kim900bb4a2015-10-12 16:55:46 +09001090 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001091
Leo Kim91109e12015-10-19 18:26:13 +09001092 if (pstrHostIFconnectAttr->ssid) {
Leo Kim8b3c9fa2015-10-13 19:49:51 +09001093 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1094 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001095 }
1096 pu8CurrByte += MAX_SSID_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001097 *(pu8CurrByte++) = INFRASTRUCTURE;
Leo Kimae4dfa52015-10-13 19:49:26 +09001098
Leo Kim0d1527e2015-10-13 19:49:58 +09001099 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1100 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001101 } else {
1102 PRINT_ER("Channel out of range\n");
1103 *(pu8CurrByte++) = 0xFF;
1104 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001105 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1106 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1107 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1108
Leo Kim91109e12015-10-19 18:26:13 +09001109 if (pstrHostIFconnectAttr->bssid)
Leo Kim9254db02015-10-13 19:49:49 +09001110 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001111 pu8CurrByte += 6;
1112
Tony Choc0f52fb2015-10-20 17:10:46 +09001113 if (pstrHostIFconnectAttr->bssid)
1114 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1115 pu8CurrByte += 6;
1116
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001117 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1118 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1119 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001120 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1121 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
Leo Kimae4dfa52015-10-13 19:49:26 +09001122
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001123 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001124 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1125
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001126 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1127 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001128 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1129
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001130 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
Leo Kimff069822015-10-29 12:05:26 +09001131 hif_drv->usr_conn_req.ht_capable = ptstrJoinBssParam->ht_capable;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001132
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001133 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1134 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001135 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1136 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001137 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1138 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
Leo Kimae4dfa52015-10-13 19:49:26 +09001139
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001140 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001141 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1142
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001143 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001144 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1145
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001146 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001147 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1148
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001149 *(pu8CurrByte++) = REAL_JOIN_REQ;
Leo Kim7a8d51d2015-10-15 13:24:43 +09001150 *(pu8CurrByte++) = ptstrJoinBssParam->noa_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001151
Leo Kim7a8d51d2015-10-15 13:24:43 +09001152 if (ptstrJoinBssParam->noa_enabled) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001153 PRINT_D(HOSTINF_DBG, "NOA present\n");
1154
1155 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1156 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1157 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1158 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1159
Leo Kimd72b33c2015-10-15 13:24:44 +09001160 *(pu8CurrByte++) = ptstrJoinBssParam->opp_enabled;
Leo Kimcc179002015-10-15 13:24:47 +09001161 *(pu8CurrByte++) = ptstrJoinBssParam->idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001162
Leo Kimd72b33c2015-10-15 13:24:44 +09001163 if (ptstrJoinBssParam->opp_enabled)
Leo Kim99b66942015-10-15 13:24:45 +09001164 *(pu8CurrByte++) = ptstrJoinBssParam->ct_window;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001165
Leo Kimc21047e2015-10-15 13:24:46 +09001166 *(pu8CurrByte++) = ptstrJoinBssParam->cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001167
Leo Kim109e6ca2015-10-15 13:24:48 +09001168 memcpy(pu8CurrByte, ptstrJoinBssParam->duration, sizeof(ptstrJoinBssParam->duration));
1169 pu8CurrByte += sizeof(ptstrJoinBssParam->duration);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001170
Leo Kim1d8b76b2015-10-15 13:24:49 +09001171 memcpy(pu8CurrByte, ptstrJoinBssParam->interval, sizeof(ptstrJoinBssParam->interval));
1172 pu8CurrByte += sizeof(ptstrJoinBssParam->interval);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001173
Leo Kim4be55e22015-10-28 15:59:27 +09001174 memcpy(pu8CurrByte, ptstrJoinBssParam->start_time, sizeof(ptstrJoinBssParam->start_time));
1175 pu8CurrByte += sizeof(ptstrJoinBssParam->start_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001176 } else
1177 PRINT_D(HOSTINF_DBG, "NOA not present\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001178
Leo Kim900bb4a2015-10-12 16:55:46 +09001179 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001180 u32WidsCount++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001181
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001182 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Leo Kim0626baa2015-10-15 13:25:13 +09001183 memcpy(join_req, pu8CurrByte, join_req_size);
Glen Lee7036c622015-12-21 14:18:45 +09001184 join_req_vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001185 }
1186
1187 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1188
Leo Kim91109e12015-10-19 18:26:13 +09001189 if (pstrHostIFconnectAttr->bssid) {
Leo Kime554a302015-11-19 15:56:21 +09001190 memcpy(wilc_connected_ssid,
1191 pstrHostIFconnectAttr->bssid, ETH_ALEN);
1192 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n",
1193 pstrHostIFconnectAttr->bssid);
1194 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", wilc_connected_ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001195 }
1196
Glen Leecd2920a2015-12-21 14:18:48 +09001197 result = wilc_send_config_pkt(vif->wilc, SET_CFG, strWIDList,
Glen Leeec62e6d2015-11-18 15:11:33 +09001198 u32WidsCount,
Glen Leeeb9939b2015-12-21 14:18:43 +09001199 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09001200 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09001201 PRINT_ER("failed to send config packet\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001202 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09001203 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001204 } else {
1205 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
Leo Kimb60005a2015-10-29 11:58:24 +09001206 hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001207 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001208
Leo Kim24db7132015-09-16 18:36:01 +09001209ERRORHANDLER:
Leo Kim31390ee2015-10-19 18:26:08 +09001210 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001211 tstrConnectInfo strConnectInfo;
1212
Leo Kim81a59502015-10-29 11:58:35 +09001213 del_timer(&hif_drv->connect_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001214
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001215 PRINT_D(HOSTINF_DBG, "could not start wilc_connecting to the required network\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001216
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001217 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001218
Leo Kim91109e12015-10-19 18:26:13 +09001219 if (pstrHostIFconnectAttr->result) {
1220 if (pstrHostIFconnectAttr->bssid)
Leo Kim9254db02015-10-13 19:49:49 +09001221 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001222
Leo Kim91109e12015-10-19 18:26:13 +09001223 if (pstrHostIFconnectAttr->ies) {
Leo Kimb59d5c52015-10-13 19:49:53 +09001224 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->ies_len;
1225 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001226 memcpy(strConnectInfo.pu8ReqIEs,
Leo Kim8c8360b2015-10-19 18:26:12 +09001227 pstrHostIFconnectAttr->ies,
1228 pstrHostIFconnectAttr->ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001229 }
1230
Leo Kim6abcc112015-10-13 19:49:55 +09001231 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001232 &strConnectInfo,
1233 MAC_DISCONNECTED,
1234 NULL,
Leo Kim8f38db82015-10-13 19:49:56 +09001235 pstrHostIFconnectAttr->arg);
Leo Kimb60005a2015-10-29 11:58:24 +09001236 hif_drv->hif_state = HOST_IF_IDLE;
Shraddha Barke95f840f2015-10-14 07:29:19 +05301237 kfree(strConnectInfo.pu8ReqIEs);
1238 strConnectInfo.pu8ReqIEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001239
1240 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001241 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001242 }
1243 }
1244
1245 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
Shraddha Barke95f840f2015-10-14 07:29:19 +05301246 kfree(pstrHostIFconnectAttr->bssid);
1247 pstrHostIFconnectAttr->bssid = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001248
Shraddha Barke95f840f2015-10-14 07:29:19 +05301249 kfree(pstrHostIFconnectAttr->ssid);
1250 pstrHostIFconnectAttr->ssid = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001251
Shraddha Barke95f840f2015-10-14 07:29:19 +05301252 kfree(pstrHostIFconnectAttr->ies);
1253 pstrHostIFconnectAttr->ies = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001254
Shraddha Barke95f840f2015-10-14 07:29:19 +05301255 kfree(pu8CurrByte);
Leo Kim31390ee2015-10-19 18:26:08 +09001256 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001257}
1258
Glen Lee71130e82015-12-21 14:18:41 +09001259static s32 Handle_FlushConnect(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001260{
Leo Kim31390ee2015-10-19 18:26:08 +09001261 s32 result = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09001262 struct wid strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001263 u32 u32WidsCount = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001264 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001265
Leo Kimdaaf16b2015-10-12 16:55:44 +09001266 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
Leo Kim416d8322015-10-12 16:55:43 +09001267 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kim48ce2462015-10-15 13:25:10 +09001268 strWIDList[u32WidsCount].val = info_element;
Leo Kimdfef7b82015-10-15 13:25:14 +09001269 strWIDList[u32WidsCount].size = info_element_size;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001270 u32WidsCount++;
1271
Leo Kimdaaf16b2015-10-12 16:55:44 +09001272 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001273 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001274 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim1bd9d442015-10-15 13:25:11 +09001275 strWIDList[u32WidsCount].val = (s8 *)(&(mode_11i));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001276 u32WidsCount++;
1277
Leo Kimdaaf16b2015-10-12 16:55:44 +09001278 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001279 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001280 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimfba49892015-10-15 13:25:12 +09001281 strWIDList[u32WidsCount].val = (s8 *)(&auth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001282 u32WidsCount++;
1283
Leo Kimdaaf16b2015-10-12 16:55:44 +09001284 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
Leo Kim416d8322015-10-12 16:55:43 +09001285 strWIDList[u32WidsCount].type = WID_STR;
Leo Kim0626baa2015-10-15 13:25:13 +09001286 strWIDList[u32WidsCount].size = join_req_size;
Leo Kim044a64102015-10-15 13:25:09 +09001287 strWIDList[u32WidsCount].val = (s8 *)join_req;
Leo Kim900bb4a2015-10-12 16:55:46 +09001288 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001289
1290 pu8CurrByte += FLUSHED_BYTE_POS;
1291 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1292
1293 u32WidsCount++;
1294
Glen Leecd2920a2015-12-21 14:18:48 +09001295 result = wilc_send_config_pkt(vif->wilc, SET_CFG, strWIDList,
Glen Leeec62e6d2015-11-18 15:11:33 +09001296 u32WidsCount,
Glen Lee7036c622015-12-21 14:18:45 +09001297 wilc_get_vif_idx(join_req_vif));
Leo Kim31390ee2015-10-19 18:26:08 +09001298 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09001299 PRINT_ER("failed to send config packet\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001300 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001301 }
1302
Leo Kim31390ee2015-10-19 18:26:08 +09001303 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001304}
1305
Glen Lee71130e82015-12-21 14:18:41 +09001306static s32 Handle_ConnectTimeout(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001307{
Leo Kim31390ee2015-10-19 18:26:08 +09001308 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001309 tstrConnectInfo strConnectInfo;
Leo Kim45102f82015-10-28 15:59:28 +09001310 struct wid wid;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001311 u16 u16DummyReasonCode = 0;
Glen Lee71130e82015-12-21 14:18:41 +09001312 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001313
Tony Choa4ab1ad2015-10-12 16:56:05 +09001314 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001315 PRINT_ER("Driver handler is NULL\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001316 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001317 }
1318
Leo Kimb60005a2015-10-29 11:58:24 +09001319 hif_drv->hif_state = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001320
Leo Kimca8540e42015-10-15 13:25:00 +09001321 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001322
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001323 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001324
Leo Kim33bfb192015-10-29 11:58:56 +09001325 if (hif_drv->usr_conn_req.conn_result) {
Leo Kimf8b17132015-10-28 15:59:34 +09001326 if (hif_drv->usr_conn_req.pu8bssid) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001327 memcpy(strConnectInfo.au8bssid,
Leo Kimf8b17132015-10-28 15:59:34 +09001328 hif_drv->usr_conn_req.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001329 }
1330
Leo Kima3b2f4b2015-10-29 11:58:54 +09001331 if (hif_drv->usr_conn_req.ies) {
Leo Kim331ed082015-10-29 11:58:55 +09001332 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len;
1333 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001334 memcpy(strConnectInfo.pu8ReqIEs,
Leo Kima3b2f4b2015-10-29 11:58:54 +09001335 hif_drv->usr_conn_req.ies,
Leo Kim331ed082015-10-29 11:58:55 +09001336 hif_drv->usr_conn_req.ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001337 }
1338
Leo Kim33bfb192015-10-29 11:58:56 +09001339 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1340 &strConnectInfo,
1341 MAC_DISCONNECTED,
1342 NULL,
Leo Kim73abaa42015-10-29 12:05:27 +09001343 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001344
Shraddha Barke95f840f2015-10-14 07:29:19 +05301345 kfree(strConnectInfo.pu8ReqIEs);
1346 strConnectInfo.pu8ReqIEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001347 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001348 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001349 }
1350
Leo Kim45102f82015-10-28 15:59:28 +09001351 wid.id = (u16)WID_DISCONNECT;
1352 wid.type = WID_CHAR;
1353 wid.val = (s8 *)&u16DummyReasonCode;
1354 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001355
1356 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1357
Glen Leecd2920a2015-12-21 14:18:48 +09001358 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09001359 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09001360 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001361 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001362
Leo Kim74ab5e42015-10-29 11:58:53 +09001363 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09001364 kfree(hif_drv->usr_conn_req.pu8ssid);
Glen Leecc28e4b2015-12-18 18:26:02 +09001365 hif_drv->usr_conn_req.pu8ssid = NULL;
Leo Kimf8b17132015-10-28 15:59:34 +09001366 kfree(hif_drv->usr_conn_req.pu8bssid);
Glen Leecc28e4b2015-12-18 18:26:02 +09001367 hif_drv->usr_conn_req.pu8bssid = NULL;
Leo Kim331ed082015-10-29 11:58:55 +09001368 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001369 kfree(hif_drv->usr_conn_req.ies);
Glen Leecc28e4b2015-12-18 18:26:02 +09001370 hif_drv->usr_conn_req.ies = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001371
Leo Kime554a302015-11-19 15:56:21 +09001372 eth_zero_addr(wilc_connected_ssid);
Leo Kimae4dfa52015-10-13 19:49:26 +09001373
Glen Lee7036c622015-12-21 14:18:45 +09001374 if (join_req && join_req_vif == vif) {
Leo Kim044a64102015-10-15 13:25:09 +09001375 kfree(join_req);
1376 join_req = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001377 }
Leo Kim48ce2462015-10-15 13:25:10 +09001378
Glen Lee7036c622015-12-21 14:18:45 +09001379 if (info_element && join_req_vif == vif) {
Leo Kim48ce2462015-10-15 13:25:10 +09001380 kfree(info_element);
1381 info_element = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001382 }
1383
Leo Kim31390ee2015-10-19 18:26:08 +09001384 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001385}
1386
Glen Lee71130e82015-12-21 14:18:41 +09001387static s32 Handle_RcvdNtwrkInfo(struct wilc_vif *vif,
Tony Cho3bbd59f2015-09-21 12:16:38 +09001388 struct rcvd_net_info *pstrRcvdNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001389{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001390 u32 i;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001391 bool bNewNtwrkFound;
Leo Kim31390ee2015-10-19 18:26:08 +09001392 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001393 tstrNetworkInfo *pstrNetworkInfo = NULL;
1394 void *pJoinParams = NULL;
Glen Lee71130e82015-12-21 14:18:41 +09001395 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001396
Dean Lee72ed4dc2015-06-12 14:11:44 +09001397 bNewNtwrkFound = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001398 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1399
Leo Kimbc801852015-10-29 11:58:50 +09001400 if (hif_drv->usr_scan_req.scan_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001401 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001402 wilc_parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo);
Leo Kim91109e12015-10-19 18:26:13 +09001403 if ((!pstrNetworkInfo) ||
Leo Kimbc801852015-10-29 11:58:50 +09001404 (!hif_drv->usr_scan_req.scan_result)) {
Leo Kim24db7132015-09-16 18:36:01 +09001405 PRINT_ER("driver is null\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001406 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +09001407 goto done;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001408 }
1409
Leo Kimf79756e2015-10-29 12:05:36 +09001410 for (i = 0; i < hif_drv->usr_scan_req.rcvd_ch_cnt; i++) {
Leo Kimaf973f32015-10-29 11:58:52 +09001411 if ((hif_drv->usr_scan_req.net_info[i].au8bssid) &&
Leo Kim91109e12015-10-19 18:26:13 +09001412 (pstrNetworkInfo->au8bssid)) {
Leo Kimaf973f32015-10-29 11:58:52 +09001413 if (memcmp(hif_drv->usr_scan_req.net_info[i].au8bssid,
Leo Kim8c8360b2015-10-19 18:26:12 +09001414 pstrNetworkInfo->au8bssid, 6) == 0) {
Leo Kimaf973f32015-10-29 11:58:52 +09001415 if (pstrNetworkInfo->s8rssi <= hif_drv->usr_scan_req.net_info[i].s8rssi) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001416 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
1417 goto done;
1418 } else {
Leo Kimaf973f32015-10-29 11:58:52 +09001419 hif_drv->usr_scan_req.net_info[i].s8rssi = pstrNetworkInfo->s8rssi;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001420 bNewNtwrkFound = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001421 break;
1422 }
1423 }
1424 }
1425 }
1426
Punit Vara047e6642015-10-25 04:01:25 +05301427 if (bNewNtwrkFound) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001428 PRINT_D(HOSTINF_DBG, "New network found\n");
1429
Leo Kimf79756e2015-10-29 12:05:36 +09001430 if (hif_drv->usr_scan_req.rcvd_ch_cnt < MAX_NUM_SCANNED_NETWORKS) {
1431 hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].s8rssi = pstrNetworkInfo->s8rssi;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001432
Leo Kimf79756e2015-10-29 12:05:36 +09001433 if (hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].au8bssid &&
Leo Kim91109e12015-10-19 18:26:13 +09001434 pstrNetworkInfo->au8bssid) {
Leo Kimf79756e2015-10-29 12:05:36 +09001435 memcpy(hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].au8bssid,
Leo Kim8c8360b2015-10-19 18:26:12 +09001436 pstrNetworkInfo->au8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001437
Leo Kimf79756e2015-10-29 12:05:36 +09001438 hif_drv->usr_scan_req.rcvd_ch_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001439
Dean Lee72ed4dc2015-06-12 14:11:44 +09001440 pstrNetworkInfo->bNewNetwork = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001441 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001442
Leo Kimbc801852015-10-29 11:58:50 +09001443 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
Leo Kim66eaea32015-10-29 11:58:51 +09001444 hif_drv->usr_scan_req.arg,
Leo Kimbc801852015-10-29 11:58:50 +09001445 pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001446 }
1447 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001448 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001449 }
1450 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001451 pstrNetworkInfo->bNewNetwork = false;
Leo Kimbc801852015-10-29 11:58:50 +09001452 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
Leo Kim66eaea32015-10-29 11:58:51 +09001453 hif_drv->usr_scan_req.arg, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001454 }
1455 }
1456
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001457done:
Shraddha Barke95f840f2015-10-14 07:29:19 +05301458 kfree(pstrRcvdNetworkInfo->buffer);
1459 pstrRcvdNetworkInfo->buffer = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001460
Leo Kim91109e12015-10-19 18:26:13 +09001461 if (pstrNetworkInfo) {
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001462 wilc_dealloc_network_info(pstrNetworkInfo);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001463 pstrNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001464 }
1465
Leo Kim31390ee2015-10-19 18:26:08 +09001466 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001467}
1468
Glen Lee71130e82015-12-21 14:18:41 +09001469static s32 host_int_get_assoc_res_info(struct wilc_vif *vif,
Arnd Bergmann1608c402015-11-16 15:04:53 +01001470 u8 *pu8AssocRespInfo,
1471 u32 u32MaxAssocRespInfoLen,
1472 u32 *pu32RcvdAssocRespInfoLen);
1473
Glen Leecf601062015-12-21 14:18:39 +09001474static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif,
Tony Chof23a9ea2015-09-21 12:16:39 +09001475 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001476{
Leo Kim31390ee2015-10-19 18:26:08 +09001477 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001478 u8 u8MsgType = 0;
1479 u8 u8MsgID = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001480 u16 u16MsgLen = 0;
1481 u16 u16WidID = (u16)WID_NIL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001482 u8 u8WidLen = 0;
1483 u8 u8MacStatus;
1484 u8 u8MacStatusReasonCode;
1485 u8 u8MacStatusAdditionalInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001486 tstrConnectInfo strConnectInfo;
1487 tstrDisconnectNotifInfo strDisconnectNotifInfo;
Leo Kime6e12662015-09-16 18:36:03 +09001488 s32 s32Err = 0;
Glen Lee71130e82015-12-21 14:18:41 +09001489 struct host_if_drv *hif_drv = vif->hif_drv;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02001490
Tony Choa4ab1ad2015-10-12 16:56:05 +09001491 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001492 PRINT_ER("Driver handler is NULL\n");
Leo Kim234837d2015-09-22 14:34:43 +09001493 return -ENODEV;
1494 }
Leo Kimb60005a2015-10-29 11:58:24 +09001495 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n",
1496 hif_drv->hif_state, pstrRcvdGnrlAsyncInfo->buffer[7]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001497
Leo Kimb60005a2015-10-29 11:58:24 +09001498 if ((hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
1499 (hif_drv->hif_state == HOST_IF_CONNECTED) ||
Leo Kimbc801852015-10-29 11:58:50 +09001500 hif_drv->usr_scan_req.scan_result) {
Leo Kim91109e12015-10-19 18:26:13 +09001501 if (!pstrRcvdGnrlAsyncInfo->buffer ||
Leo Kim33bfb192015-10-29 11:58:56 +09001502 !hif_drv->usr_conn_req.conn_result) {
Leo Kim24db7132015-09-16 18:36:01 +09001503 PRINT_ER("driver is null\n");
1504 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001505 }
1506
Leo Kim33722ac72015-10-13 19:50:00 +09001507 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001508
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001509 if ('I' != u8MsgType) {
1510 PRINT_ER("Received Message format incorrect.\n");
Leo Kim24db7132015-09-16 18:36:01 +09001511 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001512 }
1513
Leo Kim33722ac72015-10-13 19:50:00 +09001514 u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1];
1515 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]);
1516 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]);
1517 u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6];
1518 u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7];
1519 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8];
1520 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001521 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
Leo Kimb60005a2015-10-29 11:58:24 +09001522 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
Glen Lee71130e82015-12-21 14:18:41 +09001523 u32 u32RcvdAssocRespInfoLen = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001524 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
1525
1526 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1527
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001528 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001529
1530 if (u8MacStatus == MAC_CONNECTED) {
Leo Kima633c0b2015-10-15 13:24:59 +09001531 memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001532
Glen Lee71130e82015-12-21 14:18:41 +09001533 host_int_get_assoc_res_info(vif,
Leo Kima633c0b2015-10-15 13:24:59 +09001534 rcv_assoc_resp,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001535 MAX_ASSOC_RESP_FRAME_SIZE,
1536 &u32RcvdAssocRespInfoLen);
1537
1538 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
1539
1540 if (u32RcvdAssocRespInfoLen != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001541 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001542 s32Err = wilc_parse_assoc_resp_info(rcv_assoc_resp, u32RcvdAssocRespInfoLen,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001543 &pstrConnectRespInfo);
1544 if (s32Err) {
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001545 PRINT_ER("wilc_parse_assoc_resp_info() returned error %d\n", s32Err);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001546 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001547 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
1548
1549 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
1550 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
Leo Kim91109e12015-10-19 18:26:13 +09001551 if (pstrConnectRespInfo->pu8RespIEs) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001552 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001553 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001554 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001555 pstrConnectRespInfo->u16RespIEsLen);
1556 }
1557 }
1558
Leo Kim91109e12015-10-19 18:26:13 +09001559 if (pstrConnectRespInfo) {
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001560 wilc_dealloc_assoc_resp_info(pstrConnectRespInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001561 pstrConnectRespInfo = NULL;
1562 }
1563 }
1564 }
1565 }
1566
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001567 if ((u8MacStatus == MAC_CONNECTED) &&
1568 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001569 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
Leo Kime554a302015-11-19 15:56:21 +09001570 eth_zero_addr(wilc_connected_ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001571 } else if (u8MacStatus == MAC_DISCONNECTED) {
1572 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
Leo Kime554a302015-11-19 15:56:21 +09001573 eth_zero_addr(wilc_connected_ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001574 }
1575
Leo Kimf8b17132015-10-28 15:59:34 +09001576 if (hif_drv->usr_conn_req.pu8bssid) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001577 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
Leo Kimf8b17132015-10-28 15:59:34 +09001578 memcpy(strConnectInfo.au8bssid, hif_drv->usr_conn_req.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001579
1580 if ((u8MacStatus == MAC_CONNECTED) &&
1581 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Leo Kim2a4eded2015-10-29 11:58:25 +09001582 memcpy(hif_drv->assoc_bssid,
Leo Kimf8b17132015-10-28 15:59:34 +09001583 hif_drv->usr_conn_req.pu8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001584 }
1585 }
1586
Leo Kima3b2f4b2015-10-29 11:58:54 +09001587 if (hif_drv->usr_conn_req.ies) {
Leo Kim331ed082015-10-29 11:58:55 +09001588 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len;
1589 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001590 memcpy(strConnectInfo.pu8ReqIEs,
Leo Kima3b2f4b2015-10-29 11:58:54 +09001591 hif_drv->usr_conn_req.ies,
Leo Kim331ed082015-10-29 11:58:55 +09001592 hif_drv->usr_conn_req.ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001593 }
1594
Leo Kim81a59502015-10-29 11:58:35 +09001595 del_timer(&hif_drv->connect_timer);
Leo Kim33bfb192015-10-29 11:58:56 +09001596 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1597 &strConnectInfo,
1598 u8MacStatus,
1599 NULL,
Leo Kim73abaa42015-10-29 12:05:27 +09001600 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001601
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001602 if ((u8MacStatus == MAC_CONNECTED) &&
1603 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Glen Leefbf53792015-12-21 14:18:40 +09001604 wilc_set_power_mgmt(vif, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001605
1606 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
Leo Kimb60005a2015-10-29 11:58:24 +09001607 hif_drv->hif_state = HOST_IF_CONNECTED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001608
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001609 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001610 wilc_optaining_ip = true;
1611 mod_timer(&wilc_during_ip_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07001612 jiffies + msecs_to_jiffies(10000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001613 } else {
1614 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
Leo Kimb60005a2015-10-29 11:58:24 +09001615 hif_drv->hif_state = HOST_IF_IDLE;
Leo Kimca8540e42015-10-15 13:25:00 +09001616 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001617 }
1618
Shraddha Barke95f840f2015-10-14 07:29:19 +05301619 kfree(strConnectInfo.pu8RespIEs);
1620 strConnectInfo.pu8RespIEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001621
Shraddha Barke95f840f2015-10-14 07:29:19 +05301622 kfree(strConnectInfo.pu8ReqIEs);
1623 strConnectInfo.pu8ReqIEs = NULL;
Leo Kim74ab5e42015-10-29 11:58:53 +09001624 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09001625 kfree(hif_drv->usr_conn_req.pu8ssid);
Glen Leecc28e4b2015-12-18 18:26:02 +09001626 hif_drv->usr_conn_req.pu8ssid = NULL;
Leo Kimf8b17132015-10-28 15:59:34 +09001627 kfree(hif_drv->usr_conn_req.pu8bssid);
Glen Leecc28e4b2015-12-18 18:26:02 +09001628 hif_drv->usr_conn_req.pu8bssid = NULL;
Leo Kim331ed082015-10-29 11:58:55 +09001629 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001630 kfree(hif_drv->usr_conn_req.ies);
Glen Leecc28e4b2015-12-18 18:26:02 +09001631 hif_drv->usr_conn_req.ies = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001632 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
Leo Kimb60005a2015-10-29 11:58:24 +09001633 (hif_drv->hif_state == HOST_IF_CONNECTED)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001634 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
1635
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001636 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001637
Leo Kimbc801852015-10-29 11:58:50 +09001638 if (hif_drv->usr_scan_req.scan_result) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001639 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
Leo Kim13b313e2015-10-29 11:58:34 +09001640 del_timer(&hif_drv->scan_timer);
Glen Lee71130e82015-12-21 14:18:41 +09001641 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001642 }
1643
1644 strDisconnectNotifInfo.u16reason = 0;
1645 strDisconnectNotifInfo.ie = NULL;
1646 strDisconnectNotifInfo.ie_len = 0;
1647
Leo Kim33bfb192015-10-29 11:58:56 +09001648 if (hif_drv->usr_conn_req.conn_result) {
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001649 wilc_optaining_ip = false;
Glen Leefbf53792015-12-21 14:18:40 +09001650 wilc_set_power_mgmt(vif, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001651
Leo Kim33bfb192015-10-29 11:58:56 +09001652 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1653 NULL,
1654 0,
1655 &strDisconnectNotifInfo,
Leo Kim73abaa42015-10-29 12:05:27 +09001656 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001657 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001658 PRINT_ER("Connect result callback function is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001659 }
1660
Leo Kim2a4eded2015-10-29 11:58:25 +09001661 eth_zero_addr(hif_drv->assoc_bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001662
Leo Kim74ab5e42015-10-29 11:58:53 +09001663 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09001664 kfree(hif_drv->usr_conn_req.pu8ssid);
Glen Leecc28e4b2015-12-18 18:26:02 +09001665 hif_drv->usr_conn_req.pu8ssid = NULL;
Leo Kimf8b17132015-10-28 15:59:34 +09001666 kfree(hif_drv->usr_conn_req.pu8bssid);
Glen Leecc28e4b2015-12-18 18:26:02 +09001667 hif_drv->usr_conn_req.pu8bssid = NULL;
Leo Kim331ed082015-10-29 11:58:55 +09001668 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001669 kfree(hif_drv->usr_conn_req.ies);
Glen Leecc28e4b2015-12-18 18:26:02 +09001670 hif_drv->usr_conn_req.ies = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001671
Glen Lee7036c622015-12-21 14:18:45 +09001672 if (join_req && join_req_vif == vif) {
Leo Kim044a64102015-10-15 13:25:09 +09001673 kfree(join_req);
1674 join_req = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001675 }
Leo Kim48ce2462015-10-15 13:25:10 +09001676
Glen Lee7036c622015-12-21 14:18:45 +09001677 if (info_element && join_req_vif == vif) {
Leo Kim48ce2462015-10-15 13:25:10 +09001678 kfree(info_element);
1679 info_element = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001680 }
1681
Leo Kimb60005a2015-10-29 11:58:24 +09001682 hif_drv->hif_state = HOST_IF_IDLE;
Leo Kimca8540e42015-10-15 13:25:00 +09001683 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001684
1685 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
Leo Kimbc801852015-10-29 11:58:50 +09001686 (hif_drv->usr_scan_req.scan_result)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001687 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001688 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09001689
Leo Kim13b313e2015-10-29 11:58:34 +09001690 del_timer(&hif_drv->scan_timer);
Leo Kimbc801852015-10-29 11:58:50 +09001691 if (hif_drv->usr_scan_req.scan_result)
Glen Lee71130e82015-12-21 14:18:41 +09001692 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001693 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001694 }
1695
Shraddha Barke95f840f2015-10-14 07:29:19 +05301696 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1697 pstrRcvdGnrlAsyncInfo->buffer = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001698
Leo Kim31390ee2015-10-19 18:26:08 +09001699 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001700}
1701
Glen Lee71130e82015-12-21 14:18:41 +09001702static int Handle_Key(struct wilc_vif *vif,
Tony Choc98387a2015-09-21 12:16:40 +09001703 struct key_attr *pstrHostIFkeyAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001704{
Leo Kim31390ee2015-10-19 18:26:08 +09001705 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09001706 struct wid wid;
Leo Kime9e0c262015-10-12 16:55:41 +09001707 struct wid strWIDList[5];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001708 u8 i;
1709 u8 *pu8keybuf;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001710 s8 s8idxarray[1];
1711 s8 ret = 0;
Glen Lee71130e82015-12-21 14:18:41 +09001712 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001713
Leo Kim8e9f4272015-10-13 19:49:27 +09001714 switch (pstrHostIFkeyAttr->type) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001715 case WEP:
1716
Leo Kim0d17e382015-10-13 19:49:28 +09001717 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001718 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Leo Kimbafaa692015-10-28 15:59:21 +09001719 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", pstrHostIFkeyAttr->attr.wep.index);
Leo Kimdaaf16b2015-10-12 16:55:44 +09001720 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001721 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001722 strWIDList[0].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001723 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001724
Leo Kimdaaf16b2015-10-12 16:55:44 +09001725 strWIDList[1].id = WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001726 strWIDList[1].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001727 strWIDList[1].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001728 strWIDList[1].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001729
Leo Kimdaaf16b2015-10-12 16:55:44 +09001730 strWIDList[2].id = (u16)WID_KEY_ID;
Leo Kim416d8322015-10-12 16:55:43 +09001731 strWIDList[2].type = WID_CHAR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001732
Leo Kimbafaa692015-10-28 15:59:21 +09001733 strWIDList[2].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
Leo Kim2fd3e442015-10-12 16:55:45 +09001734 strWIDList[2].size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001735
Shraddha Barke543f5b12015-10-16 10:47:11 +05301736 pu8keybuf = kmemdup(pstrHostIFkeyAttr->attr.wep.key,
1737 pstrHostIFkeyAttr->attr.wep.key_len,
1738 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001739
1740 if (pu8keybuf == NULL) {
1741 PRINT_ER("No buffer to send Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001742 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001743 }
1744
Leo Kim73b2e382015-10-13 19:49:29 +09001745 kfree(pstrHostIFkeyAttr->attr.wep.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001746
Leo Kimdaaf16b2015-10-12 16:55:44 +09001747 strWIDList[3].id = (u16)WID_WEP_KEY_VALUE;
Leo Kim416d8322015-10-12 16:55:43 +09001748 strWIDList[3].type = WID_STR;
Leo Kim73b2e382015-10-13 19:49:29 +09001749 strWIDList[3].size = pstrHostIFkeyAttr->attr.wep.key_len;
Leo Kim900bb4a2015-10-12 16:55:46 +09001750 strWIDList[3].val = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001751
Glen Leecd2920a2015-12-21 14:18:48 +09001752 result = wilc_send_config_pkt(vif->wilc, SET_CFG,
Glen Leeec62e6d2015-11-18 15:11:33 +09001753 strWIDList, 4,
Glen Leeeb9939b2015-12-21 14:18:43 +09001754 wilc_get_vif_idx(vif));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001755 kfree(pu8keybuf);
Leo Kim9edaa5f2015-11-25 11:59:48 +09001756 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001757 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Leo Kim73b2e382015-10-13 19:49:29 +09001758 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001759 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001760 PRINT_ER("No buffer to send Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001761 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001762 }
Leo Kim73b2e382015-10-13 19:49:29 +09001763 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1764 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1765 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001766 pstrHostIFkeyAttr->attr.wep.key_len);
Leo Kim73b2e382015-10-13 19:49:29 +09001767 kfree(pstrHostIFkeyAttr->attr.wep.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001768
Leo Kim45102f82015-10-28 15:59:28 +09001769 wid.id = (u16)WID_ADD_WEP_KEY;
1770 wid.type = WID_STR;
1771 wid.val = (s8 *)pu8keybuf;
1772 wid.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001773
Glen Leecd2920a2015-12-21 14:18:48 +09001774 result = wilc_send_config_pkt(vif->wilc, SET_CFG,
Glen Leeec62e6d2015-11-18 15:11:33 +09001775 &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09001776 wilc_get_vif_idx(vif));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001777 kfree(pu8keybuf);
Leo Kim0d17e382015-10-13 19:49:28 +09001778 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001779 PRINT_D(HOSTINF_DBG, "Removing key\n");
Leo Kim45102f82015-10-28 15:59:28 +09001780 wid.id = (u16)WID_REMOVE_WEP_KEY;
1781 wid.type = WID_STR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001782
Leo Kim73b2e382015-10-13 19:49:29 +09001783 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
Leo Kim45102f82015-10-28 15:59:28 +09001784 wid.val = s8idxarray;
1785 wid.size = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001786
Glen Leecd2920a2015-12-21 14:18:48 +09001787 result = wilc_send_config_pkt(vif->wilc, SET_CFG,
Glen Leeec62e6d2015-11-18 15:11:33 +09001788 &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09001789 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001790 } else {
Leo Kim45102f82015-10-28 15:59:28 +09001791 wid.id = (u16)WID_KEY_ID;
1792 wid.type = WID_CHAR;
1793 wid.val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
1794 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001795
1796 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
1797
Glen Leecd2920a2015-12-21 14:18:48 +09001798 result = wilc_send_config_pkt(vif->wilc, SET_CFG,
Glen Leeec62e6d2015-11-18 15:11:33 +09001799 &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09001800 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001801 }
Leo Kim9ea47132015-10-29 11:58:28 +09001802 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001803 break;
1804
Leo Kim5cd8f7a2015-10-29 12:05:34 +09001805 case WPA_RX_GTK:
Leo Kim0d17e382015-10-13 19:49:28 +09001806 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Shraddha Barkeb156f1e2015-10-13 23:07:00 +05301807 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001808 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001809 PRINT_ER("No buffer to send RxGTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001810 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001811 goto _WPARxGtk_end_case_;
1812 }
1813
Leo Kim91109e12015-10-19 18:26:13 +09001814 if (pstrHostIFkeyAttr->attr.wpa.seq)
Leo Kim0e74c002015-10-13 19:49:32 +09001815 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001816
Leo Kime2dfbac2015-10-13 19:49:34 +09001817 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
Leo Kim6acf2912015-10-13 19:49:35 +09001818 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001819 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001820 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001821
Leo Kimdaaf16b2015-10-12 16:55:44 +09001822 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001823 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001824 strWIDList[0].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001825 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001826
Leo Kimdaaf16b2015-10-12 16:55:44 +09001827 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
Leo Kim416d8322015-10-12 16:55:43 +09001828 strWIDList[1].type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09001829 strWIDList[1].val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09001830 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001831
Glen Leecd2920a2015-12-21 14:18:48 +09001832 result = wilc_send_config_pkt(vif->wilc, SET_CFG,
Glen Leeec62e6d2015-11-18 15:11:33 +09001833 strWIDList, 2,
Glen Leeeb9939b2015-12-21 14:18:43 +09001834 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001835
Chaehyun Lim49188af2015-08-11 10:32:41 +09001836 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001837 up(&hif_drv->sem_test_key_block);
Leo Kim9edaa5f2015-11-25 11:59:48 +09001838 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001839 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
1840
Shraddha Barkeb156f1e2015-10-13 23:07:00 +05301841 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001842 if (pu8keybuf == NULL) {
1843 PRINT_ER("No buffer to send RxGTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001844 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001845 goto _WPARxGtk_end_case_;
1846 }
1847
Leo Kimb60005a2015-10-29 11:58:24 +09001848 if (hif_drv->hif_state == HOST_IF_CONNECTED)
Leo Kim2a4eded2015-10-29 11:58:25 +09001849 memcpy(pu8keybuf, hif_drv->assoc_bssid, ETH_ALEN);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301850 else
Leo Kimb60005a2015-10-29 11:58:24 +09001851 PRINT_ER("Couldn't handle WPARxGtk while state is not HOST_IF_CONNECTED\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001852
Leo Kim0e74c002015-10-13 19:49:32 +09001853 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
Leo Kime2dfbac2015-10-13 19:49:34 +09001854 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
Leo Kim6acf2912015-10-13 19:49:35 +09001855 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001856 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001857 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001858
Leo Kim45102f82015-10-28 15:59:28 +09001859 wid.id = (u16)WID_ADD_RX_GTK;
1860 wid.type = WID_STR;
1861 wid.val = (s8 *)pu8keybuf;
1862 wid.size = RX_MIC_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001863
Glen Leecd2920a2015-12-21 14:18:48 +09001864 result = wilc_send_config_pkt(vif->wilc, SET_CFG,
Glen Leeec62e6d2015-11-18 15:11:33 +09001865 &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09001866 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001867
Chaehyun Lim49188af2015-08-11 10:32:41 +09001868 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001869 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001870 }
1871_WPARxGtk_end_case_:
Leo Kim124968fc2015-10-13 19:49:30 +09001872 kfree(pstrHostIFkeyAttr->attr.wpa.key);
Leo Kim0e74c002015-10-13 19:49:32 +09001873 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
Luis de Bethencourt90819872015-10-26 05:52:50 +00001874 if (ret)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001875 return ret;
1876
1877 break;
1878
Leo Kim2141fe32015-10-29 12:05:35 +09001879 case WPA_PTK:
Leo Kim0d17e382015-10-13 19:49:28 +09001880 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Glen Leef3052582015-09-10 12:03:04 +09001881 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001882 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001883 PRINT_ER("No buffer to send PTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001884 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001885 goto _WPAPtk_end_case_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001886 }
1887
Leo Kim248080a2015-10-13 19:49:31 +09001888 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
Leo Kime2dfbac2015-10-13 19:49:34 +09001889 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
Leo Kim6acf2912015-10-13 19:49:35 +09001890 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001891 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001892 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001893
Leo Kimdaaf16b2015-10-12 16:55:44 +09001894 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001895 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001896 strWIDList[0].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001897 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001898
Leo Kimdaaf16b2015-10-12 16:55:44 +09001899 strWIDList[1].id = (u16)WID_ADD_PTK;
Leo Kim416d8322015-10-12 16:55:43 +09001900 strWIDList[1].type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09001901 strWIDList[1].val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09001902 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001903
Glen Leecd2920a2015-12-21 14:18:48 +09001904 result = wilc_send_config_pkt(vif->wilc, SET_CFG,
Glen Leeec62e6d2015-11-18 15:11:33 +09001905 strWIDList, 2,
Glen Leeeb9939b2015-12-21 14:18:43 +09001906 wilc_get_vif_idx(vif));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001907 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001908 up(&hif_drv->sem_test_key_block);
Leo Kim9edaa5f2015-11-25 11:59:48 +09001909 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
Glen Leef3052582015-09-10 12:03:04 +09001910 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001911 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001912 PRINT_ER("No buffer to send PTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001913 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001914 goto _WPAPtk_end_case_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001915 }
1916
Leo Kim248080a2015-10-13 19:49:31 +09001917 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
Leo Kim6acf2912015-10-13 19:49:35 +09001918 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001919 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001920 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001921
Leo Kim45102f82015-10-28 15:59:28 +09001922 wid.id = (u16)WID_ADD_PTK;
1923 wid.type = WID_STR;
1924 wid.val = (s8 *)pu8keybuf;
1925 wid.size = PTK_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001926
Glen Leecd2920a2015-12-21 14:18:48 +09001927 result = wilc_send_config_pkt(vif->wilc, SET_CFG,
Glen Leeec62e6d2015-11-18 15:11:33 +09001928 &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09001929 wilc_get_vif_idx(vif));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001930 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001931 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001932 }
1933
1934_WPAPtk_end_case_:
Leo Kim124968fc2015-10-13 19:49:30 +09001935 kfree(pstrHostIFkeyAttr->attr.wpa.key);
Luis de Bethencourt90819872015-10-26 05:52:50 +00001936 if (ret)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001937 return ret;
1938
1939 break;
1940
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001941 case PMKSA:
1942
1943 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
1944
Leo Kim73b2e382015-10-13 19:49:29 +09001945 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001946 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001947 PRINT_ER("No buffer to send PMKSA Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001948 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001949 }
1950
Leo Kim73b2e382015-10-13 19:49:29 +09001951 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001952
Leo Kim73b2e382015-10-13 19:49:29 +09001953 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
1954 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
1955 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001956 }
1957
Leo Kim45102f82015-10-28 15:59:28 +09001958 wid.id = (u16)WID_PMKID_INFO;
1959 wid.type = WID_STR;
1960 wid.val = (s8 *)pu8keybuf;
1961 wid.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001962
Glen Leecd2920a2015-12-21 14:18:48 +09001963 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09001964 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001965
Chaehyun Lim49188af2015-08-11 10:32:41 +09001966 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001967 break;
1968 }
1969
Leo Kim31390ee2015-10-19 18:26:08 +09001970 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001971 PRINT_ER("Failed to send key config packet\n");
1972
Leo Kim31390ee2015-10-19 18:26:08 +09001973 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001974}
1975
Glen Lee71130e82015-12-21 14:18:41 +09001976static void Handle_Disconnect(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001977{
Leo Kim45102f82015-10-28 15:59:28 +09001978 struct wid wid;
Glen Lee71130e82015-12-21 14:18:41 +09001979 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001980
Leo Kim31390ee2015-10-19 18:26:08 +09001981 s32 result = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001982 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001983
Leo Kim45102f82015-10-28 15:59:28 +09001984 wid.id = (u16)WID_DISCONNECT;
1985 wid.type = WID_CHAR;
1986 wid.val = (s8 *)&u16DummyReasonCode;
1987 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001988
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001989 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1990
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001991 wilc_optaining_ip = false;
Glen Leefbf53792015-12-21 14:18:40 +09001992 wilc_set_power_mgmt(vif, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001993
Leo Kime554a302015-11-19 15:56:21 +09001994 eth_zero_addr(wilc_connected_ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001995
Glen Leecd2920a2015-12-21 14:18:48 +09001996 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09001997 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001998
Leo Kim31390ee2015-10-19 18:26:08 +09001999 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002000 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002001 } else {
2002 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2003
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002004 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002005
2006 strDisconnectNotifInfo.u16reason = 0;
2007 strDisconnectNotifInfo.ie = NULL;
2008 strDisconnectNotifInfo.ie_len = 0;
2009
Leo Kimbc801852015-10-29 11:58:50 +09002010 if (hif_drv->usr_scan_req.scan_result) {
Leo Kim13b313e2015-10-29 11:58:34 +09002011 del_timer(&hif_drv->scan_timer);
Leo Kim33bfb192015-10-29 11:58:56 +09002012 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED,
2013 NULL,
2014 hif_drv->usr_scan_req.arg,
2015 NULL);
Leo Kimbc801852015-10-29 11:58:50 +09002016 hif_drv->usr_scan_req.scan_result = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002017 }
2018
Leo Kim33bfb192015-10-29 11:58:56 +09002019 if (hif_drv->usr_conn_req.conn_result) {
Leo Kimb60005a2015-10-29 11:58:24 +09002020 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002021 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
Leo Kim81a59502015-10-29 11:58:35 +09002022 del_timer(&hif_drv->connect_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002023 }
2024
Leo Kim33bfb192015-10-29 11:58:56 +09002025 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2026 NULL,
2027 0,
2028 &strDisconnectNotifInfo,
Leo Kim73abaa42015-10-29 12:05:27 +09002029 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002030 } else {
Leo Kim33bfb192015-10-29 11:58:56 +09002031 PRINT_ER("usr_conn_req.conn_result = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002032 }
2033
Leo Kimca8540e42015-10-15 13:25:00 +09002034 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002035
Leo Kimb60005a2015-10-29 11:58:24 +09002036 hif_drv->hif_state = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002037
Leo Kim2a4eded2015-10-29 11:58:25 +09002038 eth_zero_addr(hif_drv->assoc_bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002039
Leo Kim74ab5e42015-10-29 11:58:53 +09002040 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09002041 kfree(hif_drv->usr_conn_req.pu8ssid);
Glen Leecc28e4b2015-12-18 18:26:02 +09002042 hif_drv->usr_conn_req.pu8ssid = NULL;
Leo Kimf8b17132015-10-28 15:59:34 +09002043 kfree(hif_drv->usr_conn_req.pu8bssid);
Glen Leecc28e4b2015-12-18 18:26:02 +09002044 hif_drv->usr_conn_req.pu8bssid = NULL;
Leo Kim331ed082015-10-29 11:58:55 +09002045 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09002046 kfree(hif_drv->usr_conn_req.ies);
Glen Leecc28e4b2015-12-18 18:26:02 +09002047 hif_drv->usr_conn_req.ies = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002048
Glen Lee7036c622015-12-21 14:18:45 +09002049 if (join_req && join_req_vif == vif) {
Leo Kim044a64102015-10-15 13:25:09 +09002050 kfree(join_req);
2051 join_req = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002052 }
Leo Kim48ce2462015-10-15 13:25:10 +09002053
Glen Lee7036c622015-12-21 14:18:45 +09002054 if (info_element && join_req_vif == vif) {
Leo Kim48ce2462015-10-15 13:25:10 +09002055 kfree(info_element);
2056 info_element = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002057 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002058 }
2059
Leo Kime55e4962015-10-29 11:58:29 +09002060 up(&hif_drv->sem_test_disconn_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002061}
2062
Glen Leefbf53792015-12-21 14:18:40 +09002063void wilc_resolve_disconnect_aberration(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002064{
Glen Leefbf53792015-12-21 14:18:40 +09002065 if (!vif->hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002066 return;
Glen Leefbf53792015-12-21 14:18:40 +09002067 if ((vif->hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
2068 (vif->hif_drv->hif_state == HOST_IF_CONNECTING)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002069 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
Glen Leefbf53792015-12-21 14:18:40 +09002070 wilc_disconnect(vif, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002071 }
2072}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002073
Glen Lee71130e82015-12-21 14:18:41 +09002074static s32 Handle_GetChnl(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002075{
Leo Kim31390ee2015-10-19 18:26:08 +09002076 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002077 struct wid wid;
Glen Lee71130e82015-12-21 14:18:41 +09002078 struct host_if_drv *hif_drv = vif->hif_drv;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002079
Leo Kim45102f82015-10-28 15:59:28 +09002080 wid.id = (u16)WID_CURRENT_CHANNEL;
2081 wid.type = WID_CHAR;
2082 wid.val = (s8 *)&ch_no;
2083 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002084
2085 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2086
Glen Leecd2920a2015-12-21 14:18:48 +09002087 result = wilc_send_config_pkt(vif->wilc, GET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002088 wilc_get_vif_idx(vif));
Leo Kimae4dfa52015-10-13 19:49:26 +09002089
Leo Kim31390ee2015-10-19 18:26:08 +09002090 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002091 PRINT_ER("Failed to get channel number\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002092 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002093 }
2094
Leo Kim4ea90002015-10-29 11:58:32 +09002095 up(&hif_drv->sem_get_chnl);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002096
Leo Kim31390ee2015-10-19 18:26:08 +09002097 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002098}
2099
Glen Lee71130e82015-12-21 14:18:41 +09002100static void Handle_GetRssi(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002101{
Leo Kim31390ee2015-10-19 18:26:08 +09002102 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002103 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002104
Leo Kim45102f82015-10-28 15:59:28 +09002105 wid.id = (u16)WID_RSSI;
2106 wid.type = WID_CHAR;
2107 wid.val = &rssi;
2108 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002109
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002110 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2111
Glen Leecd2920a2015-12-21 14:18:48 +09002112 result = wilc_send_config_pkt(vif->wilc, GET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002113 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002114 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002115 PRINT_ER("Failed to get RSSI value\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002116 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002117 }
2118
Glen Lee71130e82015-12-21 14:18:41 +09002119 up(&vif->hif_drv->sem_get_rssi);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002120}
2121
Glen Lee71130e82015-12-21 14:18:41 +09002122static void Handle_GetLinkspeed(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002123{
Leo Kim31390ee2015-10-19 18:26:08 +09002124 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002125 struct wid wid;
Glen Lee71130e82015-12-21 14:18:41 +09002126 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002127
Leo Kim75327a02015-10-15 13:25:02 +09002128 link_speed = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002129
Leo Kim45102f82015-10-28 15:59:28 +09002130 wid.id = (u16)WID_LINKSPEED;
2131 wid.type = WID_CHAR;
2132 wid.val = &link_speed;
2133 wid.size = sizeof(char);
Leo Kimae4dfa52015-10-13 19:49:26 +09002134
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002135 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2136
Glen Leecd2920a2015-12-21 14:18:48 +09002137 result = wilc_send_config_pkt(vif->wilc, GET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002138 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002139 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002140 PRINT_ER("Failed to get LINKSPEED value\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002141 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002142 }
2143
Leo Kimbc34da62015-10-29 11:58:31 +09002144 up(&hif_drv->sem_get_link_speed);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002145}
2146
Glen Lee71130e82015-12-21 14:18:41 +09002147static s32 Handle_GetStatistics(struct wilc_vif *vif,
2148 struct rf_info *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002149{
Leo Kime9e0c262015-10-12 16:55:41 +09002150 struct wid strWIDList[5];
Leo Kim31390ee2015-10-19 18:26:08 +09002151 u32 u32WidsCount = 0, result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002152
Leo Kimdaaf16b2015-10-12 16:55:44 +09002153 strWIDList[u32WidsCount].id = WID_LINKSPEED;
Leo Kim416d8322015-10-12 16:55:43 +09002154 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002155 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim5babeec2015-10-29 12:05:29 +09002156 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->link_speed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002157 u32WidsCount++;
2158
Leo Kimdaaf16b2015-10-12 16:55:44 +09002159 strWIDList[u32WidsCount].id = WID_RSSI;
Leo Kim416d8322015-10-12 16:55:43 +09002160 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002161 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim00c8dfc2015-10-29 12:05:30 +09002162 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rssi;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002163 u32WidsCount++;
2164
Leo Kimdaaf16b2015-10-12 16:55:44 +09002165 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002166 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002167 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim7e84ff42015-10-29 12:05:31 +09002168 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002169 u32WidsCount++;
2170
Leo Kimdaaf16b2015-10-12 16:55:44 +09002171 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002172 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002173 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim9b992742015-10-29 12:05:32 +09002174 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rx_cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002175 u32WidsCount++;
2176
Leo Kimdaaf16b2015-10-12 16:55:44 +09002177 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002178 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002179 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim54160372015-10-29 12:05:33 +09002180 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_fail_cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002181 u32WidsCount++;
2182
Glen Leecd2920a2015-12-21 14:18:48 +09002183 result = wilc_send_config_pkt(vif->wilc, GET_CFG, strWIDList,
Glen Leeec62e6d2015-11-18 15:11:33 +09002184 u32WidsCount,
Glen Leeeb9939b2015-12-21 14:18:43 +09002185 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002186
Leo Kim31390ee2015-10-19 18:26:08 +09002187 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002188 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09002189
Leo Kim2d25af82015-10-15 13:24:56 +09002190 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002191 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002192}
2193
Glen Lee71130e82015-12-21 14:18:41 +09002194static s32 Handle_Get_InActiveTime(struct wilc_vif *vif,
Tony Cho3d1eac02015-09-21 12:16:49 +09002195 struct sta_inactive_t *strHostIfStaInactiveT)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002196{
Leo Kim31390ee2015-10-19 18:26:08 +09002197 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002198 u8 *stamac;
Leo Kim45102f82015-10-28 15:59:28 +09002199 struct wid wid;
Glen Lee71130e82015-12-21 14:18:41 +09002200 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002201
Leo Kim45102f82015-10-28 15:59:28 +09002202 wid.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2203 wid.type = WID_STR;
2204 wid.size = ETH_ALEN;
2205 wid.val = kmalloc(wid.size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002206
Leo Kim45102f82015-10-28 15:59:28 +09002207 stamac = wid.val;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002208 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002209
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002210 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2211
Glen Leecd2920a2015-12-21 14:18:48 +09002212 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002213 wilc_get_vif_idx(vif));
Leo Kimae4dfa52015-10-13 19:49:26 +09002214
Leo Kim31390ee2015-10-19 18:26:08 +09002215 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002216 PRINT_ER("Failed to SET incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09002217 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002218 }
2219
Leo Kim45102f82015-10-28 15:59:28 +09002220 wid.id = (u16)WID_GET_INACTIVE_TIME;
2221 wid.type = WID_INT;
2222 wid.val = (s8 *)&inactive_time;
2223 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002224
Glen Leecd2920a2015-12-21 14:18:48 +09002225 result = wilc_send_config_pkt(vif->wilc, GET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002226 wilc_get_vif_idx(vif));
Leo Kimae4dfa52015-10-13 19:49:26 +09002227
Leo Kim31390ee2015-10-19 18:26:08 +09002228 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002229 PRINT_ER("Failed to get incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09002230 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002231 }
2232
Leo Kimad269062015-10-15 13:25:06 +09002233 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", inactive_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002234
Leo Kim569a3c62015-10-29 11:58:33 +09002235 up(&hif_drv->sem_inactive_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002236
Leo Kim31390ee2015-10-19 18:26:08 +09002237 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002238}
2239
Glen Lee71130e82015-12-21 14:18:41 +09002240static void Handle_AddBeacon(struct wilc_vif *vif,
Tony Cho7f33fec2015-09-30 18:44:30 +09002241 struct beacon_attr *pstrSetBeaconParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002242{
Leo Kim31390ee2015-10-19 18:26:08 +09002243 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002244 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002245 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002246
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002247 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
2248
Leo Kim45102f82015-10-28 15:59:28 +09002249 wid.id = (u16)WID_ADD_BEACON;
2250 wid.type = WID_BIN;
2251 wid.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
2252 wid.val = kmalloc(wid.size, GFP_KERNEL);
2253 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002254 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002255
Leo Kim45102f82015-10-28 15:59:28 +09002256 pu8CurrByte = wid.val;
Leo Kim12262dd2015-10-13 19:50:03 +09002257 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2258 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2259 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2260 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002261
Leo Kime76ab772015-10-13 19:50:04 +09002262 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2263 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2264 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2265 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002266
Leo Kim51c66182015-10-13 19:50:05 +09002267 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2268 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2269 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2270 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002271
Leo Kim8ce528b2015-10-13 19:50:06 +09002272 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
Leo Kim51c66182015-10-13 19:50:05 +09002273 pu8CurrByte += pstrSetBeaconParam->head_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002274
Leo Kim030c57e2015-10-13 19:50:07 +09002275 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2276 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2277 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2278 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002279
Mario J. Rugiero7cf8e592015-12-03 13:24:05 -03002280 if (pstrSetBeaconParam->tail)
Leo Kim7dbcb6d32015-10-13 19:50:08 +09002281 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
Leo Kim030c57e2015-10-13 19:50:07 +09002282 pu8CurrByte += pstrSetBeaconParam->tail_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002283
Glen Leecd2920a2015-12-21 14:18:48 +09002284 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002285 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002286 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002287 PRINT_ER("Failed to send add beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002288
Leo Kim24db7132015-09-16 18:36:01 +09002289ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002290 kfree(wid.val);
Leo Kim8ce528b2015-10-13 19:50:06 +09002291 kfree(pstrSetBeaconParam->head);
Leo Kim7dbcb6d32015-10-13 19:50:08 +09002292 kfree(pstrSetBeaconParam->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002293}
2294
Glen Lee71130e82015-12-21 14:18:41 +09002295static void Handle_DelBeacon(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002296{
Leo Kim31390ee2015-10-19 18:26:08 +09002297 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002298 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002299 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002300
Leo Kim45102f82015-10-28 15:59:28 +09002301 wid.id = (u16)WID_DEL_BEACON;
2302 wid.type = WID_CHAR;
2303 wid.size = sizeof(char);
2304 wid.val = &del_beacon;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002305
Leo Kim45102f82015-10-28 15:59:28 +09002306 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002307 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002308
Leo Kim45102f82015-10-28 15:59:28 +09002309 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002310
2311 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002312
Glen Leecd2920a2015-12-21 14:18:48 +09002313 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002314 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002315 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002316 PRINT_ER("Failed to send delete beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002317}
2318
Tony Cho6a89ba92015-09-21 12:16:46 +09002319static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2320 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002321{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002322 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002323
2324 pu8CurrByte = pu8Buffer;
2325
2326 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
Leo Kim2353c382015-10-29 12:05:41 +09002327 memcpy(pu8CurrByte, pstrStationParam->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002328 pu8CurrByte += ETH_ALEN;
2329
Leo Kim4101eb82015-10-29 12:05:42 +09002330 *pu8CurrByte++ = pstrStationParam->aid & 0xFF;
2331 *pu8CurrByte++ = (pstrStationParam->aid >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002332
Leo Kime7342232015-10-29 12:05:43 +09002333 *pu8CurrByte++ = pstrStationParam->rates_len;
2334 if (pstrStationParam->rates_len > 0)
Leo Kima622e012015-10-29 12:05:44 +09002335 memcpy(pu8CurrByte, pstrStationParam->rates,
Leo Kime7342232015-10-29 12:05:43 +09002336 pstrStationParam->rates_len);
2337 pu8CurrByte += pstrStationParam->rates_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002338
Leo Kim22520122015-10-29 12:05:45 +09002339 *pu8CurrByte++ = pstrStationParam->ht_supported;
Leo Kim0d073f62015-10-29 12:05:46 +09002340 *pu8CurrByte++ = pstrStationParam->ht_capa_info & 0xFF;
2341 *pu8CurrByte++ = (pstrStationParam->ht_capa_info >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002342
Leo Kimfba1f2d2015-10-29 12:05:47 +09002343 *pu8CurrByte++ = pstrStationParam->ht_ampdu_params;
Leo Kim5ebbf4f2015-10-29 12:05:48 +09002344 memcpy(pu8CurrByte, pstrStationParam->ht_supp_mcs_set,
2345 WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002346 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2347
Leo Kim223741d2015-10-29 12:05:49 +09002348 *pu8CurrByte++ = pstrStationParam->ht_ext_params & 0xFF;
2349 *pu8CurrByte++ = (pstrStationParam->ht_ext_params >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002350
Leo Kim74fe73c2015-10-29 12:05:50 +09002351 *pu8CurrByte++ = pstrStationParam->ht_tx_bf_cap & 0xFF;
2352 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 8) & 0xFF;
2353 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 16) & 0xFF;
2354 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 24) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002355
Leo Kima486baf2015-10-29 12:05:51 +09002356 *pu8CurrByte++ = pstrStationParam->ht_ante_sel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002357
Leo Kimf676e172015-10-29 12:05:52 +09002358 *pu8CurrByte++ = pstrStationParam->flags_mask & 0xFF;
2359 *pu8CurrByte++ = (pstrStationParam->flags_mask >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002360
Leo Kim67ab64e2015-10-29 12:05:53 +09002361 *pu8CurrByte++ = pstrStationParam->flags_set & 0xFF;
2362 *pu8CurrByte++ = (pstrStationParam->flags_set >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002363
2364 return pu8CurrByte - pu8Buffer;
2365}
2366
Glen Lee71130e82015-12-21 14:18:41 +09002367static void Handle_AddStation(struct wilc_vif *vif,
Tony Cho6a89ba92015-09-21 12:16:46 +09002368 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002369{
Leo Kim31390ee2015-10-19 18:26:08 +09002370 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002371 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002372 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002373
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002374 PRINT_D(HOSTINF_DBG, "Handling add station\n");
Leo Kim45102f82015-10-28 15:59:28 +09002375 wid.id = (u16)WID_ADD_STA;
2376 wid.type = WID_BIN;
Leo Kime7342232015-10-29 12:05:43 +09002377 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002378
Leo Kim45102f82015-10-28 15:59:28 +09002379 wid.val = kmalloc(wid.size, GFP_KERNEL);
2380 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002381 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002382
Leo Kim45102f82015-10-28 15:59:28 +09002383 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002384 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2385
Glen Leecd2920a2015-12-21 14:18:48 +09002386 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002387 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002388 if (result != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002389 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002390
Leo Kim24db7132015-09-16 18:36:01 +09002391ERRORHANDLER:
Leo Kima622e012015-10-29 12:05:44 +09002392 kfree(pstrStationParam->rates);
Leo Kim45102f82015-10-28 15:59:28 +09002393 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002394}
2395
Glen Lee71130e82015-12-21 14:18:41 +09002396static void Handle_DelAllSta(struct wilc_vif *vif,
Tony Chob4e644e2015-09-21 12:17:00 +09002397 struct del_all_sta *pstrDelAllStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002398{
Leo Kim31390ee2015-10-19 18:26:08 +09002399 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002400 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002401 u8 *pu8CurrByte;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002402 u8 i;
Chaehyun Lim37034802015-06-11 14:34:32 +09002403 u8 au8Zero_Buff[6] = {0};
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002404
Leo Kim45102f82015-10-28 15:59:28 +09002405 wid.id = (u16)WID_DEL_ALL_STA;
2406 wid.type = WID_STR;
2407 wid.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002408
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002409 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002410
Leo Kim45102f82015-10-28 15:59:28 +09002411 wid.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2412 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002413 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002414
Leo Kim45102f82015-10-28 15:59:28 +09002415 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002416
Leo Kim8ba18032015-10-13 19:50:10 +09002417 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002418
2419 for (i = 0; i < MAX_NUM_STA; i++) {
Leo Kime51b9212015-10-13 19:50:09 +09002420 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2421 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002422 else
2423 continue;
2424
2425 pu8CurrByte += ETH_ALEN;
2426 }
2427
Glen Leecd2920a2015-12-21 14:18:48 +09002428 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002429 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002430 if (result)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02002431 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002432
Leo Kim24db7132015-09-16 18:36:01 +09002433ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002434 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002435
Leo Kim2d25af82015-10-15 13:24:56 +09002436 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002437}
2438
Glen Lee71130e82015-12-21 14:18:41 +09002439static void Handle_DelStation(struct wilc_vif *vif,
Tony Chofb93a1e2015-09-21 12:16:57 +09002440 struct del_sta *pstrDelStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002441{
Leo Kim31390ee2015-10-19 18:26:08 +09002442 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002443 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002444 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002445
Leo Kim45102f82015-10-28 15:59:28 +09002446 wid.id = (u16)WID_REMOVE_STA;
2447 wid.type = WID_BIN;
2448 wid.size = ETH_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002449
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002450 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002451
Leo Kim45102f82015-10-28 15:59:28 +09002452 wid.val = kmalloc(wid.size, GFP_KERNEL);
2453 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002454 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002455
Leo Kim45102f82015-10-28 15:59:28 +09002456 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002457
Leo Kime4839d32015-10-13 20:02:06 +09002458 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002459
Glen Leecd2920a2015-12-21 14:18:48 +09002460 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002461 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002462 if (result)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02002463 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002464
Leo Kim24db7132015-09-16 18:36:01 +09002465ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002466 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002467}
2468
Glen Lee71130e82015-12-21 14:18:41 +09002469static void Handle_EditStation(struct wilc_vif *vif,
Tony Cho6a89ba92015-09-21 12:16:46 +09002470 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002471{
Leo Kim31390ee2015-10-19 18:26:08 +09002472 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002473 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002474 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002475
Leo Kim45102f82015-10-28 15:59:28 +09002476 wid.id = (u16)WID_EDIT_STA;
2477 wid.type = WID_BIN;
Leo Kime7342232015-10-29 12:05:43 +09002478 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002479
2480 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
Leo Kim45102f82015-10-28 15:59:28 +09002481 wid.val = kmalloc(wid.size, GFP_KERNEL);
2482 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002483 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002484
Leo Kim45102f82015-10-28 15:59:28 +09002485 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002486 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2487
Glen Leecd2920a2015-12-21 14:18:48 +09002488 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002489 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002490 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002491 PRINT_ER("Failed to send edit station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002492
Leo Kim24db7132015-09-16 18:36:01 +09002493ERRORHANDLER:
Leo Kima622e012015-10-29 12:05:44 +09002494 kfree(pstrStationParam->rates);
Leo Kim45102f82015-10-28 15:59:28 +09002495 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002496}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002497
Glen Lee71130e82015-12-21 14:18:41 +09002498static int Handle_RemainOnChan(struct wilc_vif *vif,
Tony Cho2f9c03f2015-09-21 12:16:58 +09002499 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002500{
Leo Kim31390ee2015-10-19 18:26:08 +09002501 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002502 u8 u8remain_on_chan_flag;
Leo Kim45102f82015-10-28 15:59:28 +09002503 struct wid wid;
Glen Lee71130e82015-12-21 14:18:41 +09002504 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002505
Leo Kim5beef2c2015-10-28 15:59:36 +09002506 if (!hif_drv->remain_on_ch_pending) {
Leo Kimc5cc4b12015-10-29 11:58:44 +09002507 hif_drv->remain_on_ch.arg = pstrHostIfRemainOnChan->arg;
Leo Kimbfb62ab2015-10-29 11:58:42 +09002508 hif_drv->remain_on_ch.expired = pstrHostIfRemainOnChan->expired;
Leo Kim5e5f7912015-10-29 11:58:43 +09002509 hif_drv->remain_on_ch.ready = pstrHostIfRemainOnChan->ready;
Leo Kim839ab702015-10-29 11:58:41 +09002510 hif_drv->remain_on_ch.ch = pstrHostIfRemainOnChan->ch;
Leo Kim9d764e32015-10-29 12:05:38 +09002511 hif_drv->remain_on_ch.id = pstrHostIfRemainOnChan->id;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002512 } else {
Leo Kim839ab702015-10-29 11:58:41 +09002513 pstrHostIfRemainOnChan->ch = hif_drv->remain_on_ch.ch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002514 }
2515
Leo Kimbc801852015-10-29 11:58:50 +09002516 if (hif_drv->usr_scan_req.scan_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002517 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
Leo Kim5beef2c2015-10-28 15:59:36 +09002518 hif_drv->remain_on_ch_pending = 1;
Leo Kim31390ee2015-10-19 18:26:08 +09002519 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +09002520 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002521 }
Leo Kimb60005a2015-10-29 11:58:24 +09002522 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002523 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002524 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +09002525 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002526 }
2527
Arnd Bergmann0e1af732015-11-16 15:04:54 +01002528 if (wilc_optaining_ip || wilc_connecting) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002529 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002530 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +09002531 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002532 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002533
Leo Kim839ab702015-10-29 11:58:41 +09002534 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n",
2535 pstrHostIfRemainOnChan->ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002536
Dean Lee72ed4dc2015-06-12 14:11:44 +09002537 u8remain_on_chan_flag = true;
Leo Kim45102f82015-10-28 15:59:28 +09002538 wid.id = (u16)WID_REMAIN_ON_CHAN;
2539 wid.type = WID_STR;
2540 wid.size = 2;
2541 wid.val = kmalloc(wid.size, GFP_KERNEL);
2542 if (!wid.val) {
Leo Kim31390ee2015-10-19 18:26:08 +09002543 result = -ENOMEM;
Leo Kim24db7132015-09-16 18:36:01 +09002544 goto ERRORHANDLER;
2545 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002546
Leo Kim45102f82015-10-28 15:59:28 +09002547 wid.val[0] = u8remain_on_chan_flag;
Leo Kim839ab702015-10-29 11:58:41 +09002548 wid.val[1] = (s8)pstrHostIfRemainOnChan->ch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002549
Glen Leecd2920a2015-12-21 14:18:48 +09002550 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002551 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002552 if (result != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002553 PRINT_ER("Failed to set remain on channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002554
Leo Kim24db7132015-09-16 18:36:01 +09002555ERRORHANDLER:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002556 {
2557 P2P_LISTEN_STATE = 1;
Glen Lee71130e82015-12-21 14:18:41 +09002558 hif_drv->remain_on_ch_timer.data = (unsigned long)vif;
Leo Kimcc2d7e92015-10-29 11:58:36 +09002559 mod_timer(&hif_drv->remain_on_ch_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002560 jiffies +
Chaehyun Limfb6e0682016-01-03 17:35:33 +09002561 msecs_to_jiffies(pstrHostIfRemainOnChan->duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002562
Leo Kim5e5f7912015-10-29 11:58:43 +09002563 if (hif_drv->remain_on_ch.ready)
Leo Kimc5cc4b12015-10-29 11:58:44 +09002564 hif_drv->remain_on_ch.ready(hif_drv->remain_on_ch.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002565
Leo Kim5beef2c2015-10-28 15:59:36 +09002566 if (hif_drv->remain_on_ch_pending)
2567 hif_drv->remain_on_ch_pending = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002568 }
Leo Kim31390ee2015-10-19 18:26:08 +09002569
2570 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002571}
2572
Glen Lee71130e82015-12-21 14:18:41 +09002573static int Handle_RegisterFrame(struct wilc_vif *vif,
Tony Chobc37c5d2015-09-21 12:16:59 +09002574 struct reg_frame *pstrHostIfRegisterFrame)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002575{
Leo Kim31390ee2015-10-19 18:26:08 +09002576 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002577 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002578 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002579
Leo Kim6abf8682015-10-29 11:58:38 +09002580 PRINT_D(HOSTINF_DBG, "Handling frame register : %d FrameType: %d\n",
2581 pstrHostIfRegisterFrame->reg,
Leo Kimd5f654c2015-10-29 11:58:39 +09002582 pstrHostIfRegisterFrame->frame_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002583
Leo Kim45102f82015-10-28 15:59:28 +09002584 wid.id = (u16)WID_REGISTER_FRAME;
2585 wid.type = WID_STR;
2586 wid.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2587 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002588 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002589
Leo Kim45102f82015-10-28 15:59:28 +09002590 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002591
Leo Kim6abf8682015-10-29 11:58:38 +09002592 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg;
Leo Kimbcb410b2015-10-29 11:58:40 +09002593 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg_id;
Leo Kimd5f654c2015-10-29 11:58:39 +09002594 memcpy(pu8CurrByte, &pstrHostIfRegisterFrame->frame_type, sizeof(u16));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002595
Leo Kim45102f82015-10-28 15:59:28 +09002596 wid.size = sizeof(u16) + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002597
Glen Leecd2920a2015-12-21 14:18:48 +09002598 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002599 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002600 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002601 PRINT_ER("Failed to frame register config packet\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002602 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002603 }
2604
Leo Kim31390ee2015-10-19 18:26:08 +09002605 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002606}
2607
Glen Lee71130e82015-12-21 14:18:41 +09002608static u32 Handle_ListenStateExpired(struct wilc_vif *vif,
Tony Cho2f9c03f2015-09-21 12:16:58 +09002609 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002610{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002611 u8 u8remain_on_chan_flag;
Leo Kim45102f82015-10-28 15:59:28 +09002612 struct wid wid;
Leo Kim31390ee2015-10-19 18:26:08 +09002613 s32 result = 0;
Glen Lee71130e82015-12-21 14:18:41 +09002614 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002615
2616 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
2617
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002618 if (P2P_LISTEN_STATE) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002619 u8remain_on_chan_flag = false;
Leo Kim45102f82015-10-28 15:59:28 +09002620 wid.id = (u16)WID_REMAIN_ON_CHAN;
2621 wid.type = WID_STR;
2622 wid.size = 2;
2623 wid.val = kmalloc(wid.size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002624
Leo Kim653bb462015-12-21 14:18:24 +09002625 if (!wid.val) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002626 PRINT_ER("Failed to allocate memory\n");
Leo Kim653bb462015-12-21 14:18:24 +09002627 return -ENOMEM;
2628 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002629
Leo Kim45102f82015-10-28 15:59:28 +09002630 wid.val[0] = u8remain_on_chan_flag;
2631 wid.val[1] = FALSE_FRMWR_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002632
Glen Leecd2920a2015-12-21 14:18:48 +09002633 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002634 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002635 if (result != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002636 PRINT_ER("Failed to set remain on channel\n");
2637 goto _done_;
2638 }
2639
Leo Kimbfb62ab2015-10-29 11:58:42 +09002640 if (hif_drv->remain_on_ch.expired) {
Leo Kimc5cc4b12015-10-29 11:58:44 +09002641 hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg,
Leo Kim9d764e32015-10-29 12:05:38 +09002642 pstrHostIfRemainOnChan->id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002643 }
2644 P2P_LISTEN_STATE = 0;
2645 } else {
2646 PRINT_D(GENERIC_DBG, "Not in listen state\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002647 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002648 }
2649
2650_done_:
Leo Kim31390ee2015-10-19 18:26:08 +09002651 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002652}
2653
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07002654static void ListenTimerCB(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002655{
Leo Kim31390ee2015-10-19 18:26:08 +09002656 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09002657 struct host_if_msg msg;
Glen Lee71130e82015-12-21 14:18:41 +09002658 struct wilc_vif *vif = (struct wilc_vif *)arg;
Leo Kimae4dfa52015-10-13 19:49:26 +09002659
Glen Lee71130e82015-12-21 14:18:41 +09002660 del_timer(&vif->hif_drv->remain_on_ch_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002661
Tony Cho143eb952015-09-21 12:16:32 +09002662 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09002663 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Glen Lee71130e82015-12-21 14:18:41 +09002664 msg.vif = vif;
2665 msg.body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002666
Leo Kim31390ee2015-10-19 18:26:08 +09002667 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2668 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09002669 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002670}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002671
Glen Lee71130e82015-12-21 14:18:41 +09002672static void Handle_PowerManagement(struct wilc_vif *vif,
Tony Cho5a008f12015-09-21 12:16:48 +09002673 struct power_mgmt_param *strPowerMgmtParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002674{
Leo Kim31390ee2015-10-19 18:26:08 +09002675 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002676 struct wid wid;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002677 s8 s8PowerMode;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002678
Leo Kim45102f82015-10-28 15:59:28 +09002679 wid.id = (u16)WID_POWER_MANAGEMENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002680
Punit Vara047e6642015-10-25 04:01:25 +05302681 if (strPowerMgmtParam->enabled)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002682 s8PowerMode = MIN_FAST_PS;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302683 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002684 s8PowerMode = NO_POWERSAVE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002685 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
Leo Kim45102f82015-10-28 15:59:28 +09002686 wid.val = &s8PowerMode;
2687 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002688
2689 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
2690
Glen Leecd2920a2015-12-21 14:18:48 +09002691 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002692 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002693 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002694 PRINT_ER("Failed to send power management config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002695}
2696
Glen Lee71130e82015-12-21 14:18:41 +09002697static void Handle_SetMulticastFilter(struct wilc_vif *vif,
Tony Cho641210a2015-09-21 12:16:52 +09002698 struct set_multicast *strHostIfSetMulti)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002699{
Leo Kim31390ee2015-10-19 18:26:08 +09002700 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002701 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002702 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002703
2704 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
2705
Leo Kim45102f82015-10-28 15:59:28 +09002706 wid.id = (u16)WID_SETUP_MULTICAST_FILTER;
2707 wid.type = WID_BIN;
2708 wid.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2709 wid.val = kmalloc(wid.size, GFP_KERNEL);
2710 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002711 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002712
Leo Kim45102f82015-10-28 15:59:28 +09002713 pu8CurrByte = wid.val;
Leo Kimbae636eb2015-10-13 20:02:04 +09002714 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
Leo Kimc8751ad2015-11-25 11:59:49 +09002715 *pu8CurrByte++ = 0;
2716 *pu8CurrByte++ = 0;
2717 *pu8CurrByte++ = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002718
Leo Kimadab2f72015-10-13 20:02:05 +09002719 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2720 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2721 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2722 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002723
Leo Kimadab2f72015-10-13 20:02:05 +09002724 if ((strHostIfSetMulti->cnt) > 0)
Arnd Bergmann0e1af732015-11-16 15:04:54 +01002725 memcpy(pu8CurrByte, wilc_multicast_mac_addr_list,
Leo Kimfb70e9f2015-11-05 14:36:09 +09002726 ((strHostIfSetMulti->cnt) * ETH_ALEN));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002727
Glen Leecd2920a2015-12-21 14:18:48 +09002728 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002729 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002730 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002731 PRINT_ER("Failed to send setup multicast config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002732
Leo Kim24db7132015-09-16 18:36:01 +09002733ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002734 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002735}
2736
Glen Lee71130e82015-12-21 14:18:41 +09002737static s32 Handle_DelAllRxBASessions(struct wilc_vif *vif,
Tony Cho54265472015-09-21 12:16:56 +09002738 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002739{
Leo Kim31390ee2015-10-19 18:26:08 +09002740 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002741 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002742 char *ptr = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002743
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002744 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Leo Kim3fc49992015-10-29 11:58:45 +09002745 strHostIfBASessionInfo->bssid[0],
2746 strHostIfBASessionInfo->bssid[1],
2747 strHostIfBASessionInfo->bssid[2],
Leo Kim16c9b392015-10-29 11:58:46 +09002748 strHostIfBASessionInfo->tid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002749
Leo Kim45102f82015-10-28 15:59:28 +09002750 wid.id = (u16)WID_DEL_ALL_RX_BA;
2751 wid.type = WID_STR;
2752 wid.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2753 wid.size = BLOCK_ACK_REQ_SIZE;
2754 ptr = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002755 *ptr++ = 0x14;
2756 *ptr++ = 0x3;
2757 *ptr++ = 0x2;
Leo Kim3fc49992015-10-29 11:58:45 +09002758 memcpy(ptr, strHostIfBASessionInfo->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002759 ptr += ETH_ALEN;
Leo Kim16c9b392015-10-29 11:58:46 +09002760 *ptr++ = strHostIfBASessionInfo->tid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002761 *ptr++ = 0;
Leo Kimae4dfa52015-10-13 19:49:26 +09002762 *ptr++ = 32;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002763
Glen Leecd2920a2015-12-21 14:18:48 +09002764 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002765 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002766 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002767 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
2768
Leo Kim45102f82015-10-28 15:59:28 +09002769 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002770
Leo Kim2d25af82015-10-15 13:24:56 +09002771 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002772
Leo Kim31390ee2015-10-19 18:26:08 +09002773 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002774}
2775
Arnd Bergmann1999bd52015-05-29 22:52:14 +02002776static int hostIFthread(void *pvArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002777{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002778 u32 u32Ret;
Tony Cho143eb952015-09-21 12:16:32 +09002779 struct host_if_msg msg;
Glen Lee00215dd2015-11-18 15:11:25 +09002780 struct wilc *wilc = (struct wilc*)pvArg;
Glen Leecf601062015-12-21 14:18:39 +09002781 struct wilc_vif *vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002782
Tony Cho143eb952015-09-21 12:16:32 +09002783 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002784
2785 while (1) {
Leo Kimcb067dc2015-10-15 13:24:53 +09002786 wilc_mq_recv(&hif_msg_q, &msg, sizeof(struct host_if_msg), &u32Ret);
Glen Leecf601062015-12-21 14:18:39 +09002787 vif = msg.vif;
Tony Choa9f812a2015-09-21 12:16:33 +09002788 if (msg.id == HOST_IF_MSG_EXIT) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002789 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
2790 break;
2791 }
2792
Arnd Bergmann0e1af732015-11-16 15:04:54 +01002793 if ((!wilc_initialized)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002794 PRINT_D(GENERIC_DBG, "--WAIT--");
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07002795 usleep_range(200 * 1000, 200 * 1000);
Leo Kimcb067dc2015-10-15 13:24:53 +09002796 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002797 continue;
2798 }
2799
Leo Kim91109e12015-10-19 18:26:13 +09002800 if (msg.id == HOST_IF_MSG_CONNECT &&
Glen Leeb13584a2015-12-21 14:18:47 +09002801 vif->hif_drv->usr_scan_req.scan_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002802 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
Leo Kimcb067dc2015-10-15 13:24:53 +09002803 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07002804 usleep_range(2 * 1000, 2 * 1000);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002805 continue;
2806 }
2807
Tony Choa9f812a2015-09-21 12:16:33 +09002808 switch (msg.id) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002809 case HOST_IF_MSG_Q_IDLE:
2810 Handle_wait_msg_q_empty();
2811 break;
2812
2813 case HOST_IF_MSG_SCAN:
Glen Lee71130e82015-12-21 14:18:41 +09002814 Handle_Scan(msg.vif, &msg.body.scan_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002815 break;
2816
2817 case HOST_IF_MSG_CONNECT:
Glen Lee71130e82015-12-21 14:18:41 +09002818 Handle_Connect(msg.vif, &msg.body.con_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002819 break;
2820
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002821 case HOST_IF_MSG_FLUSH_CONNECT:
Glen Lee71130e82015-12-21 14:18:41 +09002822 Handle_FlushConnect(msg.vif);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002823 break;
2824
2825 case HOST_IF_MSG_RCVD_NTWRK_INFO:
Glen Lee71130e82015-12-21 14:18:41 +09002826 Handle_RcvdNtwrkInfo(msg.vif, &msg.body.net_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002827 break;
2828
2829 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
Glen Lee71130e82015-12-21 14:18:41 +09002830 Handle_RcvdGnrlAsyncInfo(vif,
Glen Leecf601062015-12-21 14:18:39 +09002831 &msg.body.async_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002832 break;
2833
2834 case HOST_IF_MSG_KEY:
Glen Lee71130e82015-12-21 14:18:41 +09002835 Handle_Key(msg.vif, &msg.body.key_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002836 break;
2837
2838 case HOST_IF_MSG_CFG_PARAMS:
Glen Lee71130e82015-12-21 14:18:41 +09002839 handle_cfg_param(msg.vif, &msg.body.cfg_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002840 break;
2841
2842 case HOST_IF_MSG_SET_CHANNEL:
Glen Lee71130e82015-12-21 14:18:41 +09002843 handle_set_channel(msg.vif, &msg.body.channel_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002844 break;
2845
2846 case HOST_IF_MSG_DISCONNECT:
Glen Lee71130e82015-12-21 14:18:41 +09002847 Handle_Disconnect(msg.vif);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002848 break;
2849
2850 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
Glen Leeb13584a2015-12-21 14:18:47 +09002851 del_timer(&vif->hif_drv->scan_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002852 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
2853
Glen Lee825b9662015-11-18 15:11:37 +09002854 if (!wilc_wlan_get_num_conn_ifcs(wilc))
Glen Lee00215dd2015-11-18 15:11:25 +09002855 wilc_chip_sleep_manually(wilc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002856
Glen Lee71130e82015-12-21 14:18:41 +09002857 Handle_ScanDone(msg.vif, SCAN_EVENT_DONE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002858
Glen Leeb13584a2015-12-21 14:18:47 +09002859 if (vif->hif_drv->remain_on_ch_pending)
Glen Lee71130e82015-12-21 14:18:41 +09002860 Handle_RemainOnChan(msg.vif,
2861 &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002862
2863 break;
2864
2865 case HOST_IF_MSG_GET_RSSI:
Glen Lee71130e82015-12-21 14:18:41 +09002866 Handle_GetRssi(msg.vif);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002867 break;
2868
2869 case HOST_IF_MSG_GET_LINKSPEED:
Glen Lee71130e82015-12-21 14:18:41 +09002870 Handle_GetLinkspeed(msg.vif);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002871 break;
2872
2873 case HOST_IF_MSG_GET_STATISTICS:
Glen Lee71130e82015-12-21 14:18:41 +09002874 Handle_GetStatistics(msg.vif,
2875 (struct rf_info *)msg.body.data);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002876 break;
2877
2878 case HOST_IF_MSG_GET_CHNL:
Glen Lee71130e82015-12-21 14:18:41 +09002879 Handle_GetChnl(msg.vif);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002880 break;
2881
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002882 case HOST_IF_MSG_ADD_BEACON:
Glen Lee71130e82015-12-21 14:18:41 +09002883 Handle_AddBeacon(msg.vif, &msg.body.beacon_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002884 break;
2885
2886 case HOST_IF_MSG_DEL_BEACON:
Glen Lee71130e82015-12-21 14:18:41 +09002887 Handle_DelBeacon(msg.vif);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002888 break;
2889
2890 case HOST_IF_MSG_ADD_STATION:
Glen Lee71130e82015-12-21 14:18:41 +09002891 Handle_AddStation(msg.vif, &msg.body.add_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002892 break;
2893
2894 case HOST_IF_MSG_DEL_STATION:
Glen Lee71130e82015-12-21 14:18:41 +09002895 Handle_DelStation(msg.vif, &msg.body.del_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002896 break;
2897
2898 case HOST_IF_MSG_EDIT_STATION:
Glen Lee71130e82015-12-21 14:18:41 +09002899 Handle_EditStation(msg.vif, &msg.body.edit_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002900 break;
2901
2902 case HOST_IF_MSG_GET_INACTIVETIME:
Glen Lee71130e82015-12-21 14:18:41 +09002903 Handle_Get_InActiveTime(msg.vif, &msg.body.mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002904 break;
2905
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002906 case HOST_IF_MSG_SCAN_TIMER_FIRED:
2907 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
2908
Glen Lee71130e82015-12-21 14:18:41 +09002909 Handle_ScanDone(msg.vif, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002910 break;
2911
2912 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002913 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
Glen Lee71130e82015-12-21 14:18:41 +09002914 Handle_ConnectTimeout(msg.vif);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002915 break;
2916
2917 case HOST_IF_MSG_POWER_MGMT:
Glen Lee71130e82015-12-21 14:18:41 +09002918 Handle_PowerManagement(msg.vif,
2919 &msg.body.pwr_mgmt_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002920 break;
2921
2922 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
Glen Lee71130e82015-12-21 14:18:41 +09002923 handle_set_wfi_drv_handler(msg.vif, &msg.body.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002924 break;
2925
2926 case HOST_IF_MSG_SET_OPERATION_MODE:
Glen Lee71130e82015-12-21 14:18:41 +09002927 handle_set_operation_mode(msg.vif, &msg.body.mode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002928 break;
2929
2930 case HOST_IF_MSG_SET_IPADDRESS:
2931 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Glen Lee71130e82015-12-21 14:18:41 +09002932 handle_set_ip_address(vif,
Leo Kima6e6d482015-11-06 11:20:06 +09002933 msg.body.ip_info.ip_addr,
2934 msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002935 break;
2936
2937 case HOST_IF_MSG_GET_IPADDRESS:
2938 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Glen Lee71130e82015-12-21 14:18:41 +09002939 handle_get_ip_address(vif, msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002940 break;
2941
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002942 case HOST_IF_MSG_SET_MAC_ADDRESS:
Glen Lee71130e82015-12-21 14:18:41 +09002943 handle_set_mac_address(msg.vif,
Leo Kima8267422015-11-06 11:20:08 +09002944 &msg.body.set_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002945 break;
2946
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002947 case HOST_IF_MSG_GET_MAC_ADDRESS:
Glen Lee71130e82015-12-21 14:18:41 +09002948 handle_get_mac_address(msg.vif,
Leo Kimb3bf8fd2015-11-06 11:20:09 +09002949 &msg.body.get_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002950 break;
2951
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002952 case HOST_IF_MSG_REMAIN_ON_CHAN:
2953 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
Glen Lee71130e82015-12-21 14:18:41 +09002954 Handle_RemainOnChan(msg.vif, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002955 break;
2956
2957 case HOST_IF_MSG_REGISTER_FRAME:
2958 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
Glen Lee71130e82015-12-21 14:18:41 +09002959 Handle_RegisterFrame(msg.vif, &msg.body.reg_frame);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002960 break;
2961
2962 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
Glen Lee71130e82015-12-21 14:18:41 +09002963 Handle_ListenStateExpired(msg.vif, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002964 break;
2965
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002966 case HOST_IF_MSG_SET_MULTICAST_FILTER:
2967 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
Glen Lee71130e82015-12-21 14:18:41 +09002968 Handle_SetMulticastFilter(msg.vif, &msg.body.multicast_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002969 break;
2970
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002971 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
Glen Lee71130e82015-12-21 14:18:41 +09002972 Handle_DelAllRxBASessions(msg.vif, &msg.body.session_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002973 break;
2974
2975 case HOST_IF_MSG_DEL_ALL_STA:
Glen Lee71130e82015-12-21 14:18:41 +09002976 Handle_DelAllSta(msg.vif, &msg.body.del_all_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002977 break;
2978
2979 default:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002980 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002981 break;
2982 }
2983 }
2984
2985 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
Leo Kim834e0cb2015-10-15 13:24:54 +09002986 up(&hif_sema_thread);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02002987 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002988}
2989
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07002990static void TimerCB_Scan(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002991{
Glen Lee71130e82015-12-21 14:18:41 +09002992 struct wilc_vif *vif = (struct wilc_vif *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09002993 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002994
Tony Cho143eb952015-09-21 12:16:32 +09002995 memset(&msg, 0, sizeof(struct host_if_msg));
Glen Lee71130e82015-12-21 14:18:41 +09002996 msg.vif = vif;
Tony Choa9f812a2015-09-21 12:16:33 +09002997 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002998
Leo Kimcb067dc2015-10-15 13:24:53 +09002999 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003000}
3001
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003002static void TimerCB_Connect(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003003{
Glen Lee71130e82015-12-21 14:18:41 +09003004 struct wilc_vif *vif = (struct wilc_vif *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09003005 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003006
Tony Cho143eb952015-09-21 12:16:32 +09003007 memset(&msg, 0, sizeof(struct host_if_msg));
Glen Lee71130e82015-12-21 14:18:41 +09003008 msg.vif = vif;
Tony Choa9f812a2015-09-21 12:16:33 +09003009 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003010
Leo Kimcb067dc2015-10-15 13:24:53 +09003011 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003012}
3013
Arnd Bergmann0e1af732015-11-16 15:04:54 +01003014s32 wilc_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003015{
Leo Kim45102f82015-10-28 15:59:28 +09003016 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003017
Leo Kim45102f82015-10-28 15:59:28 +09003018 wid.id = (u16)WID_REMOVE_KEY;
3019 wid.type = WID_STR;
3020 wid.val = (s8 *)pu8StaAddress;
3021 wid.size = 6;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003022
Leo Kimb68d820b2015-10-12 16:55:37 +09003023 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003024}
3025
Glen Leefbf53792015-12-21 14:18:40 +09003026int wilc_remove_wep_key(struct wilc_vif *vif, u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003027{
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003028 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003029 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003030 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003031
Tony Choa4ab1ad2015-10-12 16:56:05 +09003032 if (!hif_drv) {
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003033 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003034 PRINT_ER("Failed to send setup multicast config packet\n");
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003035 return result;
Leo Kim24db7132015-09-16 18:36:01 +09003036 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003037
Tony Cho143eb952015-09-21 12:16:32 +09003038 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003039
Tony Choa9f812a2015-09-21 12:16:33 +09003040 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003041 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003042 msg.body.key_info.action = REMOVEKEY;
Glen Leecf601062015-12-21 14:18:39 +09003043 msg.vif = vif;
Leo Kim73b2e382015-10-13 19:49:29 +09003044 msg.body.key_info.attr.wep.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003045
Leo Kimcb067dc2015-10-15 13:24:53 +09003046 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003047 if (result)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003048 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003049 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003050
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003051 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003052}
3053
Glen Leefbf53792015-12-21 14:18:40 +09003054int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003055{
Chaehyun Lim5b41c7c2015-10-26 09:44:42 +09003056 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003057 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003058 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003059
Tony Choa4ab1ad2015-10-12 16:56:05 +09003060 if (!hif_drv) {
Leo Kim31390ee2015-10-19 18:26:08 +09003061 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003062 PRINT_ER("driver is null\n");
Leo Kim31390ee2015-10-19 18:26:08 +09003063 return result;
Leo Kim24db7132015-09-16 18:36:01 +09003064 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003065
Tony Cho143eb952015-09-21 12:16:32 +09003066 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003067
Tony Choa9f812a2015-09-21 12:16:33 +09003068 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003069 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003070 msg.body.key_info.action = DEFAULTKEY;
Glen Leecf601062015-12-21 14:18:39 +09003071 msg.vif = vif;
Chaehyun Lime91d0342015-10-26 09:44:44 +09003072 msg.body.key_info.attr.wep.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003073
Leo Kim31390ee2015-10-19 18:26:08 +09003074 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3075 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003076 PRINT_ER("Error in sending message queue : Default key index\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003077 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003078
Leo Kim31390ee2015-10-19 18:26:08 +09003079 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003080}
3081
Glen Leefbf53792015-12-21 14:18:40 +09003082int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len,
3083 u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003084{
Chaehyun Lim66b8cb82015-10-27 20:40:32 +09003085 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003086 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003087 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003088
Tony Choa4ab1ad2015-10-12 16:56:05 +09003089 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003090 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003091 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003092 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003093
Tony Cho143eb952015-09-21 12:16:32 +09003094 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003095
Tony Choa9f812a2015-09-21 12:16:33 +09003096 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003097 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003098 msg.body.key_info.action = ADDKEY;
Glen Leecf601062015-12-21 14:18:39 +09003099 msg.vif = vif;
Chaehyun Lim1cc0c322015-10-27 20:40:37 +09003100 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3101 if (!msg.body.key_info.attr.wep.key)
3102 return -ENOMEM;
3103
Chaehyun Limdbc53192015-10-27 20:40:35 +09003104 msg.body.key_info.attr.wep.key_len = len;
Chaehyun Lim0b2cc3e2015-10-27 20:40:36 +09003105 msg.body.key_info.attr.wep.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003106
Leo Kim31390ee2015-10-19 18:26:08 +09003107 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3108 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003109 PRINT_ER("Error in sending message queue :WEP Key\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003110 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003111
Leo Kim31390ee2015-10-19 18:26:08 +09003112 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003113}
3114
Glen Leefbf53792015-12-21 14:18:40 +09003115int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len,
3116 u8 index, u8 mode, enum AUTHTYPE auth_type)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003117{
Chaehyun Lim641c20a2015-10-28 08:19:19 +09003118 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003119 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003120 struct host_if_drv *hif_drv = vif->hif_drv;
Chaehyun Limfd741462015-10-28 08:19:21 +09003121 int i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003122
Tony Choa4ab1ad2015-10-12 16:56:05 +09003123 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003124 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003125 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003126 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003127
Tony Cho143eb952015-09-21 12:16:32 +09003128 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003129
3130 if (INFO) {
Chaehyun Lima5389b02015-10-28 08:19:23 +09003131 for (i = 0; i < len; i++)
Chaehyun Lim81117252015-10-28 08:19:22 +09003132 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", key[i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003133 }
Tony Choa9f812a2015-09-21 12:16:33 +09003134 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003135 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003136 msg.body.key_info.action = ADDKEY_AP;
Glen Leecf601062015-12-21 14:18:39 +09003137 msg.vif = vif;
Chaehyun Lim58eabd62015-10-28 08:19:27 +09003138 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3139 if (!msg.body.key_info.attr.wep.key)
3140 return -ENOMEM;
3141
Chaehyun Lima5389b02015-10-28 08:19:23 +09003142 msg.body.key_info.attr.wep.key_len = len;
Chaehyun Lima76dc952015-10-28 08:19:24 +09003143 msg.body.key_info.attr.wep.index = index;
Chaehyun Lim730a28d2015-10-28 08:19:25 +09003144 msg.body.key_info.attr.wep.mode = mode;
Chaehyun Limff3bce22015-10-28 08:19:26 +09003145 msg.body.key_info.attr.wep.auth_type = auth_type;
Leo Kimae4dfa52015-10-13 19:49:26 +09003146
Leo Kim31390ee2015-10-19 18:26:08 +09003147 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003148
Leo Kim31390ee2015-10-19 18:26:08 +09003149 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003150 PRINT_ER("Error in sending message queue :WEP Key\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003151 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003152
Leo Kim31390ee2015-10-19 18:26:08 +09003153 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003154}
Glen Lee108b3432015-09-16 18:53:20 +09003155
Glen Leefbf53792015-12-21 14:18:40 +09003156int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
3157 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
3158 u8 mode, u8 cipher_mode, u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003159{
Chaehyun Lim706ab422015-11-08 16:48:54 +09003160 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003161 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003162 struct host_if_drv *hif_drv = vif->hif_drv;
Chaehyun Lim53bbbb52015-11-08 16:49:03 +09003163 u8 key_len = ptk_key_len;
Chaehyun Limfa269072015-11-08 16:49:02 +09003164 int i;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003165
Tony Choa4ab1ad2015-10-12 16:56:05 +09003166 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003167 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003168 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003169 }
Leo Kim91109e12015-10-19 18:26:13 +09003170
Chaehyun Lim38f66292015-11-08 16:48:58 +09003171 if (rx_mic)
Chaehyun Lim53bbbb52015-11-08 16:49:03 +09003172 key_len += RX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003173
Chaehyun Limd7c02422015-11-08 16:48:59 +09003174 if (tx_mic)
Chaehyun Lim53bbbb52015-11-08 16:49:03 +09003175 key_len += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003176
Tony Cho143eb952015-09-21 12:16:32 +09003177 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003178
Tony Choa9f812a2015-09-21 12:16:33 +09003179 msg.id = HOST_IF_MSG_KEY;
Leo Kim2141fe32015-10-29 12:05:35 +09003180 msg.body.key_info.type = WPA_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003181 if (mode == AP_MODE) {
Leo Kim0d17e382015-10-13 19:49:28 +09003182 msg.body.key_info.action = ADDKEY_AP;
Chaehyun Lim3e5c4ab2015-11-08 16:49:01 +09003183 msg.body.key_info.attr.wpa.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003184 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003185 if (mode == STATION_MODE)
Leo Kim0d17e382015-10-13 19:49:28 +09003186 msg.body.key_info.action = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003187
Chaehyun Lim8ab8c592015-11-08 16:49:04 +09003188 msg.body.key_info.attr.wpa.key = kmemdup(ptk, ptk_key_len, GFP_KERNEL);
3189 if (!msg.body.key_info.attr.wpa.key)
3190 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003191
Chaehyun Lim38f66292015-11-08 16:48:58 +09003192 if (rx_mic) {
3193 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic, RX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003194 if (INFO) {
3195 for (i = 0; i < RX_MIC_KEY_LEN; i++)
Chaehyun Lim38f66292015-11-08 16:48:58 +09003196 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, rx_mic[i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003197 }
3198 }
Chaehyun Limd7c02422015-11-08 16:48:59 +09003199 if (tx_mic) {
3200 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic, TX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003201 if (INFO) {
3202 for (i = 0; i < TX_MIC_KEY_LEN; i++)
Chaehyun Limd7c02422015-11-08 16:48:59 +09003203 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, tx_mic[i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003204 }
3205 }
3206
Chaehyun Lim53bbbb52015-11-08 16:49:03 +09003207 msg.body.key_info.attr.wpa.key_len = key_len;
Leo Kim248080a2015-10-13 19:49:31 +09003208 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
Chaehyun Limf0c82572015-11-08 16:49:00 +09003209 msg.body.key_info.attr.wpa.mode = cipher_mode;
Glen Leecf601062015-12-21 14:18:39 +09003210 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003211
Leo Kim31390ee2015-10-19 18:26:08 +09003212 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003213
Leo Kim31390ee2015-10-19 18:26:08 +09003214 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003215 PRINT_ER("Error in sending message queue: PTK Key\n");
3216
Leo Kim9ea47132015-10-29 11:58:28 +09003217 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003218
Leo Kim31390ee2015-10-19 18:26:08 +09003219 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003220}
3221
Glen Leefbf53792015-12-21 14:18:40 +09003222int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
3223 u8 index, u32 key_rsc_len, const u8 *key_rsc,
3224 const u8 *rx_mic, const u8 *tx_mic, u8 mode,
3225 u8 cipher_mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003226{
Chaehyun Lim15034572015-11-08 16:49:05 +09003227 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003228 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003229 struct host_if_drv *hif_drv = vif->hif_drv;
Chaehyun Limd002fcc2015-11-08 16:49:15 +09003230 u8 key_len = gtk_key_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003231
Tony Choa4ab1ad2015-10-12 16:56:05 +09003232 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003233 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003234 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003235 }
Tony Cho143eb952015-09-21 12:16:32 +09003236 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003237
Chaehyun Lim6d36c272015-11-08 16:49:12 +09003238 if (rx_mic)
Chaehyun Limd002fcc2015-11-08 16:49:15 +09003239 key_len += RX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003240
Chaehyun Lim2f797582015-11-08 16:49:13 +09003241 if (tx_mic)
Chaehyun Limd002fcc2015-11-08 16:49:15 +09003242 key_len += TX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003243
Chaehyun Lim982859c2015-11-08 16:49:11 +09003244 if (key_rsc) {
Chaehyun Lim9bfda382015-11-08 16:49:16 +09003245 msg.body.key_info.attr.wpa.seq = kmemdup(key_rsc,
3246 key_rsc_len,
3247 GFP_KERNEL);
3248 if (!msg.body.key_info.attr.wpa.seq)
3249 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003250 }
3251
Tony Choa9f812a2015-09-21 12:16:33 +09003252 msg.id = HOST_IF_MSG_KEY;
Leo Kim5cd8f7a2015-10-29 12:05:34 +09003253 msg.body.key_info.type = WPA_RX_GTK;
Glen Leecf601062015-12-21 14:18:39 +09003254 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003255
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003256 if (mode == AP_MODE) {
Leo Kim0d17e382015-10-13 19:49:28 +09003257 msg.body.key_info.action = ADDKEY_AP;
Chaehyun Lim57bfcbc2015-11-08 16:49:14 +09003258 msg.body.key_info.attr.wpa.mode = cipher_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003259 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003260 if (mode == STATION_MODE)
Leo Kim0d17e382015-10-13 19:49:28 +09003261 msg.body.key_info.action = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003262
Chaehyun Lim9bfda382015-11-08 16:49:16 +09003263 msg.body.key_info.attr.wpa.key = kmemdup(rx_gtk,
3264 key_len,
3265 GFP_KERNEL);
3266 if (!msg.body.key_info.attr.wpa.key)
3267 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003268
Chaehyun Lim6d36c272015-11-08 16:49:12 +09003269 if (rx_mic)
3270 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic,
Leo Kimd1666e22015-10-28 15:59:22 +09003271 RX_MIC_KEY_LEN);
Leo Kim91109e12015-10-19 18:26:13 +09003272
Chaehyun Lim2f797582015-11-08 16:49:13 +09003273 if (tx_mic)
3274 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic,
Leo Kimd1666e22015-10-28 15:59:22 +09003275 TX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003276
Chaehyun Lim9a5e57362015-11-08 16:49:09 +09003277 msg.body.key_info.attr.wpa.index = index;
Chaehyun Limd002fcc2015-11-08 16:49:15 +09003278 msg.body.key_info.attr.wpa.key_len = key_len;
Chaehyun Lim18bef992015-11-08 16:49:10 +09003279 msg.body.key_info.attr.wpa.seq_len = key_rsc_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003280
Leo Kim31390ee2015-10-19 18:26:08 +09003281 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3282 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003283 PRINT_ER("Error in sending message queue: RX GTK\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09003284
Leo Kim9ea47132015-10-29 11:58:28 +09003285 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003286
Leo Kim31390ee2015-10-19 18:26:08 +09003287 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003288}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003289
Chaehyun Lim1ab58702015-12-22 09:49:03 +09003290int wilc_set_pmkid_info(struct wilc_vif *vif,
Chaehyun Lim16c0cba2015-12-22 09:49:05 +09003291 struct host_if_pmkid_attr *pmkid)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003292{
Chaehyun Lim1ab58702015-12-22 09:49:03 +09003293 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003294 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003295 struct host_if_drv *hif_drv = vif->hif_drv;
Chaehyun Lim89dec132015-12-22 09:49:04 +09003296 int i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003297
Tony Choa4ab1ad2015-10-12 16:56:05 +09003298 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003299 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003300 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003301 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003302
Tony Cho143eb952015-09-21 12:16:32 +09003303 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003304
Tony Choa9f812a2015-09-21 12:16:33 +09003305 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003306 msg.body.key_info.type = PMKSA;
Leo Kim0d17e382015-10-13 19:49:28 +09003307 msg.body.key_info.action = ADDKEY;
Glen Leecf601062015-12-21 14:18:39 +09003308 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003309
Chaehyun Lim16c0cba2015-12-22 09:49:05 +09003310 for (i = 0; i < pmkid->numpmkid; i++) {
Leo Kim8c8360b2015-10-19 18:26:12 +09003311 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid,
Chaehyun Lim16c0cba2015-12-22 09:49:05 +09003312 &pmkid->pmkidlist[i].bssid, ETH_ALEN);
Leo Kim8c8360b2015-10-19 18:26:12 +09003313 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid,
Chaehyun Lim16c0cba2015-12-22 09:49:05 +09003314 &pmkid->pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003315 }
3316
Leo Kim31390ee2015-10-19 18:26:08 +09003317 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3318 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003319 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3320
Leo Kim31390ee2015-10-19 18:26:08 +09003321 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003322}
3323
Chaehyun Lim1eabfe32015-12-22 09:49:07 +09003324int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003325{
Chaehyun Limdcb15a02015-12-22 09:49:06 +09003326 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003327 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003328
Tony Cho143eb952015-09-21 12:16:32 +09003329 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003330
Tony Choa9f812a2015-09-21 12:16:33 +09003331 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
Chaehyun Lim1eabfe32015-12-22 09:49:07 +09003332 msg.body.get_mac_info.mac_addr = mac_addr;
Glen Leecf601062015-12-21 14:18:39 +09003333 msg.vif = vif;
Leo Kimae4dfa52015-10-13 19:49:26 +09003334
Leo Kim31390ee2015-10-19 18:26:08 +09003335 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3336 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003337 PRINT_ER("Failed to send get mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +09003338 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003339 }
3340
Leo Kim2d25af82015-10-15 13:24:56 +09003341 down(&hif_sema_wait_response);
Leo Kim31390ee2015-10-19 18:26:08 +09003342 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003343}
3344
Chaehyun Limf95f4802015-12-22 09:49:09 +09003345int wilc_set_mac_address(struct wilc_vif *vif, u8 *mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003346{
Chaehyun Lim0b477622015-12-22 09:49:08 +09003347 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003348 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003349
Chaehyun Limf95f4802015-12-22 09:49:09 +09003350 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", mac_addr[0], mac_addr[1], mac_addr[2]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003351
Tony Cho143eb952015-09-21 12:16:32 +09003352 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003353 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
Chaehyun Limf95f4802015-12-22 09:49:09 +09003354 memcpy(msg.body.set_mac_info.mac_addr, mac_addr, ETH_ALEN);
Glen Leecf601062015-12-21 14:18:39 +09003355 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003356
Leo Kim31390ee2015-10-19 18:26:08 +09003357 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3358 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003359 PRINT_ER("Failed to send message queue: Set mac address\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003360
Leo Kim31390ee2015-10-19 18:26:08 +09003361 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003362}
3363
Chaehyun Limf2cb5f32015-12-24 16:52:22 +09003364int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid,
Chaehyun Lim8c38d962015-12-24 16:52:25 +09003365 size_t ssid_len, const u8 *ies, size_t ies_len,
Chaehyun Lim2ef29832015-12-24 16:52:27 +09003366 wilc_connect_result connect_result, void *user_arg,
Chaehyun Lim12a3b8b2015-12-24 16:52:29 +09003367 u8 security, enum AUTHTYPE auth_type,
Chaehyun Limf382b372015-12-24 16:52:31 +09003368 u8 channel, void *join_params)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003369{
Chaehyun Lim0a285b22015-12-24 16:52:20 +09003370 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003371 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003372 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003373
Chaehyun Lim81c23a72015-12-24 16:52:26 +09003374 if (!hif_drv || !connect_result) {
Leo Kim24db7132015-09-16 18:36:01 +09003375 PRINT_ER("Driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003376 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003377 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003378
Chaehyun Limf382b372015-12-24 16:52:31 +09003379 if (!join_params) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003380 PRINT_ER("Unable to Join - JoinParams is NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003381 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003382 }
Leo Kim24db7132015-09-16 18:36:01 +09003383
Tony Cho143eb952015-09-21 12:16:32 +09003384 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003385
Tony Choa9f812a2015-09-21 12:16:33 +09003386 msg.id = HOST_IF_MSG_CONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003387
Chaehyun Lime0c54a82015-12-24 16:52:28 +09003388 msg.body.con_info.security = security;
Chaehyun Lim12a3b8b2015-12-24 16:52:29 +09003389 msg.body.con_info.auth_type = auth_type;
Chaehyun Lim0ea1ece2015-12-24 16:52:30 +09003390 msg.body.con_info.ch = channel;
Chaehyun Lim81c23a72015-12-24 16:52:26 +09003391 msg.body.con_info.result = connect_result;
Chaehyun Lim2ef29832015-12-24 16:52:27 +09003392 msg.body.con_info.arg = user_arg;
Chaehyun Limf382b372015-12-24 16:52:31 +09003393 msg.body.con_info.params = join_params;
Glen Leecf601062015-12-21 14:18:39 +09003394 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003395
Chaehyun Lim16a537c2015-12-24 16:52:21 +09003396 if (bssid) {
Chaehyun Lim11623132015-12-24 16:52:32 +09003397 msg.body.con_info.bssid = kmemdup(bssid, 6, GFP_KERNEL);
3398 if (!msg.body.con_info.bssid)
3399 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003400 }
3401
Chaehyun Limf2cb5f32015-12-24 16:52:22 +09003402 if (ssid) {
Chaehyun Limdee39b12015-12-24 16:52:23 +09003403 msg.body.con_info.ssid_len = ssid_len;
Chaehyun Lim11623132015-12-24 16:52:32 +09003404 msg.body.con_info.ssid = kmemdup(ssid, ssid_len, GFP_KERNEL);
3405 if (!msg.body.con_info.ssid)
3406 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003407 }
3408
Chaehyun Lim88c94212015-12-24 16:52:24 +09003409 if (ies) {
Chaehyun Lim8c38d962015-12-24 16:52:25 +09003410 msg.body.con_info.ies_len = ies_len;
Chaehyun Lim11623132015-12-24 16:52:32 +09003411 msg.body.con_info.ies = kmemdup(ies, ies_len, GFP_KERNEL);
3412 if (!msg.body.con_info.ies)
3413 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003414 }
Leo Kimb60005a2015-10-29 11:58:24 +09003415 if (hif_drv->hif_state < HOST_IF_CONNECTING)
3416 hif_drv->hif_state = HOST_IF_CONNECTING;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05303417 else
Leo Kimb60005a2015-10-29 11:58:24 +09003418 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' : %d\n",
3419 hif_drv->hif_state);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003420
Leo Kim31390ee2015-10-19 18:26:08 +09003421 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3422 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003423 PRINT_ER("Failed to send message queue: Set join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09003424 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003425 }
3426
Glen Lee71130e82015-12-21 14:18:41 +09003427 hif_drv->connect_timer.data = (unsigned long)vif;
Leo Kim81a59502015-10-29 11:58:35 +09003428 mod_timer(&hif_drv->connect_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003429 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003430
Leo Kim31390ee2015-10-19 18:26:08 +09003431 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003432}
3433
Chaehyun Lim30205892015-12-24 16:52:19 +09003434int wilc_flush_join_req(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003435{
Chaehyun Lim30205892015-12-24 16:52:19 +09003436 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003437 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003438 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003439
Leo Kim7717880782015-10-19 18:26:11 +09003440 if (!join_req)
3441 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003442
Tony Choa4ab1ad2015-10-12 16:56:05 +09003443 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003444 PRINT_ER("Driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003445 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003446 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003447
Tony Choa9f812a2015-09-21 12:16:33 +09003448 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
Glen Leecf601062015-12-21 14:18:39 +09003449 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003450
Leo Kim31390ee2015-10-19 18:26:08 +09003451 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3452 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003453 PRINT_ER("Failed to send message queue: Flush join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09003454 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003455 }
3456
Leo Kim31390ee2015-10-19 18:26:08 +09003457 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003458}
3459
Chaehyun Lim9f723fd2015-12-24 16:52:34 +09003460int wilc_disconnect(struct wilc_vif *vif, u16 reason_code)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003461{
Chaehyun Lim53502512015-12-24 16:52:33 +09003462 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003463 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003464 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003465
Tony Choa4ab1ad2015-10-12 16:56:05 +09003466 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003467 PRINT_ER("Driver is null\n");
3468 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003469 }
3470
Tony Cho143eb952015-09-21 12:16:32 +09003471 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003472
Tony Choa9f812a2015-09-21 12:16:33 +09003473 msg.id = HOST_IF_MSG_DISCONNECT;
Glen Leecf601062015-12-21 14:18:39 +09003474 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003475
Leo Kim31390ee2015-10-19 18:26:08 +09003476 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3477 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003478 PRINT_ER("Failed to send message queue: disconnect\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09003479
Leo Kime55e4962015-10-29 11:58:29 +09003480 down(&hif_drv->sem_test_disconn_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003481
Leo Kim31390ee2015-10-19 18:26:08 +09003482 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003483}
3484
Glen Lee71130e82015-12-21 14:18:41 +09003485static s32 host_int_get_assoc_res_info(struct wilc_vif *vif,
Arnd Bergmann1608c402015-11-16 15:04:53 +01003486 u8 *pu8AssocRespInfo,
3487 u32 u32MaxAssocRespInfoLen,
3488 u32 *pu32RcvdAssocRespInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003489{
Leo Kim31390ee2015-10-19 18:26:08 +09003490 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09003491 struct wid wid;
Glen Lee71130e82015-12-21 14:18:41 +09003492 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003493
Tony Choa4ab1ad2015-10-12 16:56:05 +09003494 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003495 PRINT_ER("Driver is null\n");
3496 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003497 }
3498
Leo Kim45102f82015-10-28 15:59:28 +09003499 wid.id = (u16)WID_ASSOC_RES_INFO;
3500 wid.type = WID_STR;
3501 wid.val = pu8AssocRespInfo;
3502 wid.size = u32MaxAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003503
Glen Leecd2920a2015-12-21 14:18:48 +09003504 result = wilc_send_config_pkt(vif->wilc, GET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09003505 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09003506 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003507 *pu32RcvdAssocRespInfoLen = 0;
Leo Kim24db7132015-09-16 18:36:01 +09003508 PRINT_ER("Failed to send association response config packet\n");
3509 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003510 } else {
Leo Kim45102f82015-10-28 15:59:28 +09003511 *pu32RcvdAssocRespInfoLen = wid.size;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003512 }
3513
Leo Kim31390ee2015-10-19 18:26:08 +09003514 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003515}
3516
Glen Leefbf53792015-12-21 14:18:40 +09003517int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003518{
Chaehyun Lim792fb252015-10-05 11:07:22 +09003519 int result;
Tony Cho143eb952015-09-21 12:16:32 +09003520 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003521 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003522
Tony Choa4ab1ad2015-10-12 16:56:05 +09003523 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003524 PRINT_ER("driver is null\n");
3525 return -EFAULT;
3526 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003527
Tony Cho143eb952015-09-21 12:16:32 +09003528 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003529 msg.id = HOST_IF_MSG_SET_CHANNEL;
Leo Kim730ee052015-10-13 19:50:02 +09003530 msg.body.channel_info.set_ch = channel;
Glen Leecf601062015-12-21 14:18:39 +09003531 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003532
Leo Kimcb067dc2015-10-15 13:24:53 +09003533 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lim1ef58e42015-10-02 21:44:49 +09003534 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003535 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim792fb252015-10-05 11:07:22 +09003536 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003537 }
3538
Chaehyun Lim792fb252015-10-05 11:07:22 +09003539 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003540}
3541
Arnd Bergmann0e1af732015-11-16 15:04:54 +01003542int wilc_wait_msg_queue_idle(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003543{
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003544 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003545 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003546
Tony Cho143eb952015-09-21 12:16:32 +09003547 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003548 msg.id = HOST_IF_MSG_Q_IDLE;
Leo Kimcb067dc2015-10-15 13:24:53 +09003549 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003550 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003551 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003552 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003553 }
3554
Leo Kim2d25af82015-10-15 13:24:56 +09003555 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003556
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003557 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003558}
3559
Glen Lee31f0f692015-12-21 14:18:44 +09003560int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003561{
Chaehyun Lima0941012015-10-05 19:34:47 +09003562 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003563 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003564
Tony Cho143eb952015-09-21 12:16:32 +09003565 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003566 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
Glen Lee31f0f692015-12-21 14:18:44 +09003567 msg.body.drv.handler = index;
Glen Leecf601062015-12-21 14:18:39 +09003568 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003569
Leo Kimcb067dc2015-10-15 13:24:53 +09003570 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lima0941012015-10-05 19:34:47 +09003571 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003572 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0941012015-10-05 19:34:47 +09003573 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003574 }
3575
Chaehyun Lima0941012015-10-05 19:34:47 +09003576 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003577}
3578
Glen Leefbf53792015-12-21 14:18:40 +09003579int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003580{
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003581 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003582 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003583
Tony Cho143eb952015-09-21 12:16:32 +09003584 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003585 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
Leo Kimc96debf2015-10-28 15:59:30 +09003586 msg.body.mode.mode = mode;
Glen Leecf601062015-12-21 14:18:39 +09003587 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003588
Leo Kimcb067dc2015-10-15 13:24:53 +09003589 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003590 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003591 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003592 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003593 }
3594
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003595 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003596}
3597
Glen Leefbf53792015-12-21 14:18:40 +09003598s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
3599 u32 *pu32InactiveTime)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003600{
Leo Kim31390ee2015-10-19 18:26:08 +09003601 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003602 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003603 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003604
Tony Choa4ab1ad2015-10-12 16:56:05 +09003605 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003606 PRINT_ER("driver is null\n");
3607 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003608 }
3609
Tony Cho143eb952015-09-21 12:16:32 +09003610 memset(&msg, 0, sizeof(struct host_if_msg));
Leo Kim8c8360b2015-10-19 18:26:12 +09003611 memcpy(msg.body.mac_info.mac, mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003612
Tony Choa9f812a2015-09-21 12:16:33 +09003613 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
Glen Leecf601062015-12-21 14:18:39 +09003614 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003615
Leo Kim31390ee2015-10-19 18:26:08 +09003616 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3617 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003618 PRINT_ER("Failed to send get host channel param's message queue ");
3619
Leo Kim569a3c62015-10-29 11:58:33 +09003620 down(&hif_drv->sem_inactive_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003621
Leo Kimad269062015-10-15 13:25:06 +09003622 *pu32InactiveTime = inactive_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003623
Leo Kim31390ee2015-10-19 18:26:08 +09003624 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003625}
Glen Lee108b3432015-09-16 18:53:20 +09003626
Chaehyun Lim652bb5e2015-12-24 16:52:37 +09003627int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003628{
Chaehyun Lime16aed62015-12-24 16:52:36 +09003629 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003630 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003631 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003632
Leo Kimc09389a2015-10-28 15:59:24 +09003633 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003634 msg.id = HOST_IF_MSG_GET_RSSI;
Glen Leecf601062015-12-21 14:18:39 +09003635 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003636
Leo Kim31390ee2015-10-19 18:26:08 +09003637 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3638 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003639 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003640 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003641 }
3642
Leo Kim7e111f92015-10-29 11:58:30 +09003643 down(&hif_drv->sem_get_rssi);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003644
Chaehyun Lim652bb5e2015-12-24 16:52:37 +09003645 if (!rssi_level) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003646 PRINT_ER("RSS pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09003647 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003648 }
3649
Chaehyun Lim652bb5e2015-12-24 16:52:37 +09003650 *rssi_level = rssi;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003651
Leo Kim31390ee2015-10-19 18:26:08 +09003652 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003653}
3654
Chaehyun Limf70b25f2015-12-24 16:52:39 +09003655int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003656{
Chaehyun Limcd163d32015-12-24 16:52:38 +09003657 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003658 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003659
Leo Kimc09389a2015-10-28 15:59:24 +09003660 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003661 msg.id = HOST_IF_MSG_GET_STATISTICS;
Chaehyun Limf70b25f2015-12-24 16:52:39 +09003662 msg.body.data = (char *)stats;
Glen Leecf601062015-12-21 14:18:39 +09003663 msg.vif = vif;
Leo Kimae4dfa52015-10-13 19:49:26 +09003664
Leo Kim31390ee2015-10-19 18:26:08 +09003665 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3666 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003667 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003668 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003669 }
3670
Leo Kim2d25af82015-10-15 13:24:56 +09003671 down(&hif_sema_wait_response);
Leo Kim31390ee2015-10-19 18:26:08 +09003672 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003673}
3674
Chaehyun Lim3c2be652016-01-05 23:06:46 +09003675int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 u8ScanType,
Glen Leefbf53792015-12-21 14:18:40 +09003676 u8 *pu8ChnlFreqList, u8 u8ChnlListLen, const u8 *pu8IEs,
3677 size_t IEsLen, wilc_scan_result ScanResult, void *pvUserArg,
3678 struct hidden_network *pstrHiddenNetwork)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003679{
Chaehyun Lim03a5d8c2016-01-05 23:06:45 +09003680 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003681 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003682 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003683
Leo Kim91109e12015-10-19 18:26:13 +09003684 if (!hif_drv || !ScanResult) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09003685 PRINT_ER("hif_drv or ScanResult = NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003686 return -EFAULT;
3687 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003688
Tony Cho143eb952015-09-21 12:16:32 +09003689 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003690
Tony Choa9f812a2015-09-21 12:16:33 +09003691 msg.id = HOST_IF_MSG_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003692
Leo Kim91109e12015-10-19 18:26:13 +09003693 if (pstrHiddenNetwork) {
Chaehyun Lim245a1862016-01-05 13:26:32 +09003694 msg.body.scan_info.hidden_network.net_info = pstrHiddenNetwork->net_info;
Chaehyun Lim40e05e82016-01-05 13:26:33 +09003695 msg.body.scan_info.hidden_network.n_ssids = pstrHiddenNetwork->n_ssids;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003696
3697 } else
3698 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
3699
Glen Leecf601062015-12-21 14:18:39 +09003700 msg.vif = vif;
Chaehyun Lim3c2be652016-01-05 23:06:46 +09003701 msg.body.scan_info.src = scan_source;
Leo Kim1e276c82015-10-13 19:49:38 +09003702 msg.body.scan_info.type = u8ScanType;
Leo Kimc17c6da2015-10-13 19:49:44 +09003703 msg.body.scan_info.result = ScanResult;
Leo Kim5f2b50c2015-10-13 19:49:45 +09003704 msg.body.scan_info.arg = pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003705
Leo Kimf97bd9c2015-10-13 19:49:41 +09003706 msg.body.scan_info.ch_list_len = u8ChnlListLen;
Leo Kim82eeb0a2015-10-13 19:49:40 +09003707 msg.body.scan_info.ch_freq_list = kmalloc(u8ChnlListLen, GFP_KERNEL);
3708 memcpy(msg.body.scan_info.ch_freq_list, pu8ChnlFreqList, u8ChnlListLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003709
Leo Kim7b1f76c2015-10-13 19:49:43 +09003710 msg.body.scan_info.ies_len = IEsLen;
Leo Kimd6f19aa2015-10-13 19:49:42 +09003711 msg.body.scan_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3712 memcpy(msg.body.scan_info.ies, pu8IEs, IEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003713
Leo Kim31390ee2015-10-19 18:26:08 +09003714 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3715 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003716 PRINT_ER("Error in sending message queue\n");
3717 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003718 }
3719
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003720 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
Glen Lee71130e82015-12-21 14:18:41 +09003721 hif_drv->scan_timer.data = (unsigned long)vif;
Leo Kim13b313e2015-10-29 11:58:34 +09003722 mod_timer(&hif_drv->scan_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003723 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003724
Leo Kim31390ee2015-10-19 18:26:08 +09003725 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003726}
Leo Kimae4dfa52015-10-13 19:49:26 +09003727
Glen Leefbf53792015-12-21 14:18:40 +09003728s32 wilc_hif_set_cfg(struct wilc_vif *vif,
3729 struct cfg_param_val *pstrCfgParamVal)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003730{
Leo Kim31390ee2015-10-19 18:26:08 +09003731 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003732 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003733 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003734
Tony Choa4ab1ad2015-10-12 16:56:05 +09003735 if (!hif_drv) {
3736 PRINT_ER("hif_drv NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003737 return -EFAULT;
3738 }
Leo Kimae4dfa52015-10-13 19:49:26 +09003739
Tony Cho143eb952015-09-21 12:16:32 +09003740 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003741 msg.id = HOST_IF_MSG_CFG_PARAMS;
Tony Cho221371e2015-10-12 16:56:06 +09003742 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
Glen Leecf601062015-12-21 14:18:39 +09003743 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003744
Leo Kim31390ee2015-10-19 18:26:08 +09003745 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003746
Leo Kim31390ee2015-10-19 18:26:08 +09003747 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003748}
3749
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003750static void GetPeriodicRSSI(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003751{
Glen Lee71130e82015-12-21 14:18:41 +09003752 struct wilc_vif *vif = (struct wilc_vif *)arg;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003753
Glen Lee71130e82015-12-21 14:18:41 +09003754 if (!vif->hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003755 PRINT_ER("Driver handler is NULL\n");
3756 return;
3757 }
3758
Glen Lee71130e82015-12-21 14:18:41 +09003759 if (vif->hif_drv->hif_state == HOST_IF_CONNECTED) {
Leo Kim31390ee2015-10-19 18:26:08 +09003760 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003761 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003762
Tony Cho143eb952015-09-21 12:16:32 +09003763 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003764
Tony Choa9f812a2015-09-21 12:16:33 +09003765 msg.id = HOST_IF_MSG_GET_RSSI;
Glen Lee71130e82015-12-21 14:18:41 +09003766 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003767
Leo Kim31390ee2015-10-19 18:26:08 +09003768 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3769 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003770 PRINT_ER("Failed to send get host channel param's message queue ");
3771 return;
3772 }
3773 }
Glen Lee71130e82015-12-21 14:18:41 +09003774 periodic_rssi.data = (unsigned long)vif;
Leo Kim262f55e2015-10-15 13:24:58 +09003775 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003776}
3777
Arnd Bergmann0e1af732015-11-16 15:04:54 +01003778s32 wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003779{
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09003780 s32 result = 0;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003781 struct host_if_drv *hif_drv;
Glen Leea4cac482015-12-21 14:18:36 +09003782 struct wilc_vif *vif;
Glen Leed53822192015-10-27 18:27:49 +09003783 struct wilc *wilc;
Glen Lee03efae32015-12-21 14:18:49 +09003784 int i;
Glen Leed53822192015-10-27 18:27:49 +09003785
Glen Leea4cac482015-12-21 14:18:36 +09003786 vif = netdev_priv(dev);
3787 wilc = vif->wilc;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003788
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003789 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
3790
Leo Kimca8540e42015-10-15 13:25:00 +09003791 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003792
Leo Kim2d25af82015-10-15 13:24:56 +09003793 sema_init(&hif_sema_wait_response, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003794
Tony Choa4ab1ad2015-10-12 16:56:05 +09003795 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
3796 if (!hif_drv) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09003797 result = -ENOMEM;
Vincent Stehlé17db84e2015-10-07 07:08:25 +02003798 goto _fail_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003799 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09003800 *hif_drv_handler = hif_drv;
Glen Lee03efae32015-12-21 14:18:49 +09003801 for (i = 0; i < wilc->vif_num; i++)
3802 if (dev == wilc->vif[i]->ndev) {
3803 wilc->vif[i]->hif_drv = hif_drv;
3804 break;
3805 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003806
Arnd Bergmann0e1af732015-11-16 15:04:54 +01003807 wilc_optaining_ip = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003808
Tony Choa4ab1ad2015-10-12 16:56:05 +09003809 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003810 if (clients_count == 0) {
Leo Kim834e0cb2015-10-15 13:24:54 +09003811 sema_init(&hif_sema_thread, 0);
Leo Kim27ff2162015-10-15 13:24:55 +09003812 sema_init(&hif_sema_driver, 0);
Leo Kim440e89932015-10-15 13:24:57 +09003813 sema_init(&hif_sema_deinit, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003814 }
3815
Leo Kim9ea47132015-10-29 11:58:28 +09003816 sema_init(&hif_drv->sem_test_key_block, 0);
Leo Kime55e4962015-10-29 11:58:29 +09003817 sema_init(&hif_drv->sem_test_disconn_block, 0);
Leo Kim7e111f92015-10-29 11:58:30 +09003818 sema_init(&hif_drv->sem_get_rssi, 0);
Leo Kimbc34da62015-10-29 11:58:31 +09003819 sema_init(&hif_drv->sem_get_link_speed, 0);
Leo Kim4ea90002015-10-29 11:58:32 +09003820 sema_init(&hif_drv->sem_get_chnl, 0);
Leo Kim569a3c62015-10-29 11:58:33 +09003821 sema_init(&hif_drv->sem_inactive_time, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003822
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003823 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
3824
3825 if (clients_count == 0) {
Leo Kimcb067dc2015-10-15 13:24:53 +09003826 result = wilc_mq_create(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003827
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09003828 if (result < 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003829 PRINT_ER("Failed to creat MQ\n");
3830 goto _fail_;
3831 }
Leo Kimc2115d82015-10-15 13:24:52 +09003832
Glen Leed53822192015-10-27 18:27:49 +09003833 hif_thread_handler = kthread_run(hostIFthread, wilc,
3834 "WILC_kthread");
Leo Kimc2115d82015-10-15 13:24:52 +09003835
3836 if (IS_ERR(hif_thread_handler)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003837 PRINT_ER("Failed to creat Thread\n");
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09003838 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003839 goto _fail_mq_;
3840 }
Leo Kim262f55e2015-10-15 13:24:58 +09003841 setup_timer(&periodic_rssi, GetPeriodicRSSI,
Glen Lee71130e82015-12-21 14:18:41 +09003842 (unsigned long)vif);
Leo Kim262f55e2015-10-15 13:24:58 +09003843 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003844 }
3845
Leo Kim13b313e2015-10-29 11:58:34 +09003846 setup_timer(&hif_drv->scan_timer, TimerCB_Scan, 0);
Leo Kim81a59502015-10-29 11:58:35 +09003847 setup_timer(&hif_drv->connect_timer, TimerCB_Connect, 0);
Leo Kimcc2d7e92015-10-29 11:58:36 +09003848 setup_timer(&hif_drv->remain_on_ch_timer, ListenTimerCB, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003849
Leo Kim33110ad2015-10-29 11:58:27 +09003850 sema_init(&hif_drv->sem_cfg_values, 1);
3851 down(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003852
Leo Kimb60005a2015-10-29 11:58:24 +09003853 hif_drv->hif_state = HOST_IF_IDLE;
Leo Kimace303f2015-10-29 11:58:26 +09003854 hif_drv->cfg_values.site_survey_enabled = SITE_SURVEY_OFF;
3855 hif_drv->cfg_values.scan_source = DEFAULT_SCAN;
3856 hif_drv->cfg_values.active_scan_time = ACTIVE_SCAN_TIME;
3857 hif_drv->cfg_values.passive_scan_time = PASSIVE_SCAN_TIME;
3858 hif_drv->cfg_values.curr_tx_rate = AUTORATE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003859
Leo Kim1229b1a2015-10-29 12:05:39 +09003860 hif_drv->p2p_timeout = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003861
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003862 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",
Leo Kimace303f2015-10-29 11:58:26 +09003863 hif_drv->cfg_values.site_survey_enabled,
3864 hif_drv->cfg_values.scan_source,
3865 hif_drv->cfg_values.active_scan_time,
3866 hif_drv->cfg_values.passive_scan_time,
3867 hif_drv->cfg_values.curr_tx_rate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003868
Leo Kim33110ad2015-10-29 11:58:27 +09003869 up(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003870
Leo Kimae4dfa52015-10-13 19:49:26 +09003871 clients_count++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003872
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09003873 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003874
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003875_fail_mq_:
Leo Kimcb067dc2015-10-15 13:24:53 +09003876 wilc_mq_destroy(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003877_fail_:
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09003878 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003879}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003880
Glen Leefbf53792015-12-21 14:18:40 +09003881s32 wilc_deinit(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003882{
Leo Kim31390ee2015-10-19 18:26:08 +09003883 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003884 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003885 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003886
Tony Choa4ab1ad2015-10-12 16:56:05 +09003887 if (!hif_drv) {
3888 PRINT_ER("hif_drv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003889 return 0;
3890 }
3891
Leo Kim440e89932015-10-15 13:24:57 +09003892 down(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003893
Tony Choa4ab1ad2015-10-12 16:56:05 +09003894 terminated_handle = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003895 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
3896
Leo Kim13b313e2015-10-29 11:58:34 +09003897 if (del_timer_sync(&hif_drv->scan_timer))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003898 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003899
Leo Kim81a59502015-10-29 11:58:35 +09003900 if (del_timer_sync(&hif_drv->connect_timer))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003901 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003902
Leo Kim262f55e2015-10-15 13:24:58 +09003903 if (del_timer_sync(&periodic_rssi))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003904 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003905
Leo Kimcc2d7e92015-10-29 11:58:36 +09003906 del_timer_sync(&hif_drv->remain_on_ch_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003907
Glen Lee31f0f692015-12-21 14:18:44 +09003908 wilc_set_wfi_drv_handler(vif, 0);
Leo Kim27ff2162015-10-15 13:24:55 +09003909 down(&hif_sema_driver);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003910
Leo Kimbc801852015-10-29 11:58:50 +09003911 if (hif_drv->usr_scan_req.scan_result) {
3912 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL,
Leo Kim66eaea32015-10-29 11:58:51 +09003913 hif_drv->usr_scan_req.arg, NULL);
Leo Kimbc801852015-10-29 11:58:50 +09003914 hif_drv->usr_scan_req.scan_result = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003915 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003916
Leo Kimb60005a2015-10-29 11:58:24 +09003917 hif_drv->hif_state = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003918
Leo Kimca8540e42015-10-15 13:25:00 +09003919 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003920
Tony Cho143eb952015-09-21 12:16:32 +09003921 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003922
3923 if (clients_count == 1) {
Leo Kim262f55e2015-10-15 13:24:58 +09003924 if (del_timer_sync(&periodic_rssi))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003925 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Leo Kim262f55e2015-10-15 13:24:58 +09003926
Tony Choa9f812a2015-09-21 12:16:33 +09003927 msg.id = HOST_IF_MSG_EXIT;
Glen Leecf601062015-12-21 14:18:39 +09003928 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003929
Leo Kim31390ee2015-10-19 18:26:08 +09003930 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3931 if (result != 0)
3932 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003933
Leo Kim834e0cb2015-10-15 13:24:54 +09003934 down(&hif_sema_thread);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003935
Leo Kimcb067dc2015-10-15 13:24:53 +09003936 wilc_mq_destroy(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003937 }
3938
Tony Choa4ab1ad2015-10-12 16:56:05 +09003939 kfree(hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003940
Leo Kimae4dfa52015-10-13 19:49:26 +09003941 clients_count--;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003942 terminated_handle = NULL;
Leo Kim440e89932015-10-15 13:24:57 +09003943 up(&hif_sema_deinit);
Leo Kim31390ee2015-10-19 18:26:08 +09003944 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003945}
3946
Glen Leecd04d222015-12-21 14:18:42 +09003947void wilc_network_info_received(struct wilc *wilc, u8 *pu8Buffer,
3948 u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003949{
Leo Kim31390ee2015-10-19 18:26:08 +09003950 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003951 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09003952 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003953 struct host_if_drv *hif_drv = NULL;
Glen Leeeb9939b2015-12-21 14:18:43 +09003954 struct wilc_vif *vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003955
Johnny Kimd42ab082015-08-20 16:32:52 +09003956 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Glen Leeeb9939b2015-12-21 14:18:43 +09003957 vif = wilc_get_vif_from_idx(wilc, id);
3958 if (!vif)
3959 return;
3960 hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003961
Tony Choa4ab1ad2015-10-12 16:56:05 +09003962 if (!hif_drv || hif_drv == terminated_handle) {
3963 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003964 return;
3965 }
3966
Tony Cho143eb952015-09-21 12:16:32 +09003967 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003968
Tony Choa9f812a2015-09-21 12:16:33 +09003969 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
Glen Leeeb9939b2015-12-21 14:18:43 +09003970 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003971
Leo Kim3bffac62015-10-13 20:02:11 +09003972 msg.body.net_info.len = u32Length;
Leo Kimb021b802015-10-13 20:02:10 +09003973 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
3974 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003975
Leo Kim31390ee2015-10-19 18:26:08 +09003976 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3977 if (result)
3978 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003979}
3980
Glen Leecd04d222015-12-21 14:18:42 +09003981void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *pu8Buffer,
3982 u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003983{
Leo Kim31390ee2015-10-19 18:26:08 +09003984 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003985 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09003986 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003987 struct host_if_drv *hif_drv = NULL;
Glen Leeeb9939b2015-12-21 14:18:43 +09003988 struct wilc_vif *vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003989
Leo Kim440e89932015-10-15 13:24:57 +09003990 down(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003991
Johnny Kimd42ab082015-08-20 16:32:52 +09003992 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Glen Leeeb9939b2015-12-21 14:18:43 +09003993 vif = wilc_get_vif_from_idx(wilc, id);
3994 if (!vif) {
3995 up(&hif_sema_deinit);
3996 return;
3997 }
3998
3999 hif_drv = vif->hif_drv;
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004000 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004001
Tony Choa4ab1ad2015-10-12 16:56:05 +09004002 if (!hif_drv || hif_drv == terminated_handle) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004003 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
Leo Kim440e89932015-10-15 13:24:57 +09004004 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004005 return;
4006 }
4007
Leo Kim33bfb192015-10-29 11:58:56 +09004008 if (!hif_drv->usr_conn_req.conn_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004009 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
Leo Kim440e89932015-10-15 13:24:57 +09004010 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004011 return;
4012 }
4013
Tony Cho143eb952015-09-21 12:16:32 +09004014 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004015
Tony Choa9f812a2015-09-21 12:16:33 +09004016 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
Glen Leeeb9939b2015-12-21 14:18:43 +09004017 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004018
Leo Kimf94f4882015-10-13 19:50:01 +09004019 msg.body.async_info.len = u32Length;
Leo Kim33722ac72015-10-13 19:50:00 +09004020 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4021 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004022
Leo Kim31390ee2015-10-19 18:26:08 +09004023 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4024 if (result)
4025 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004026
Leo Kim440e89932015-10-15 13:24:57 +09004027 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004028}
4029
Glen Leecd04d222015-12-21 14:18:42 +09004030void wilc_scan_complete_received(struct wilc *wilc, u8 *pu8Buffer,
4031 u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004032{
Leo Kim31390ee2015-10-19 18:26:08 +09004033 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004034 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004035 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004036 struct host_if_drv *hif_drv = NULL;
Glen Leeeb9939b2015-12-21 14:18:43 +09004037 struct wilc_vif *vif;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004038
Johnny Kimd42ab082015-08-20 16:32:52 +09004039 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Glen Leeeb9939b2015-12-21 14:18:43 +09004040 vif = wilc_get_vif_from_idx(wilc, id);
4041 if (!vif)
4042 return;
4043 hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004044
Tony Choa4ab1ad2015-10-12 16:56:05 +09004045 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004046
Tony Choa4ab1ad2015-10-12 16:56:05 +09004047 if (!hif_drv || hif_drv == terminated_handle)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004048 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004049
Leo Kimbc801852015-10-29 11:58:50 +09004050 if (hif_drv->usr_scan_req.scan_result) {
Tony Cho143eb952015-09-21 12:16:32 +09004051 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004052
Tony Choa9f812a2015-09-21 12:16:33 +09004053 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
Glen Leeeb9939b2015-12-21 14:18:43 +09004054 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004055
Leo Kim31390ee2015-10-19 18:26:08 +09004056 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4057 if (result)
4058 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004059 }
4060
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004061 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004062}
4063
Chaehyun Lim6f7584b2016-01-03 17:35:35 +09004064int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id,
Chaehyun Limd44cd452016-01-03 17:35:36 +09004065 u32 duration, u16 chan,
Chaehyun Lim95bfdd52016-01-03 17:35:37 +09004066 wilc_remain_on_chan_expired expired,
Chaehyun Lim1aae9392016-01-03 17:35:38 +09004067 wilc_remain_on_chan_ready ready,
Chaehyun Lim482c4332016-01-03 17:35:39 +09004068 void *user_arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004069{
Chaehyun Lim6d6bc402016-01-03 17:35:34 +09004070 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004071 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09004072 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004073
Tony Choa4ab1ad2015-10-12 16:56:05 +09004074 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004075 PRINT_ER("driver is null\n");
4076 return -EFAULT;
4077 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004078
Tony Cho143eb952015-09-21 12:16:32 +09004079 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004080
Tony Choa9f812a2015-09-21 12:16:33 +09004081 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
Leo Kim839ab702015-10-29 11:58:41 +09004082 msg.body.remain_on_ch.ch = chan;
Chaehyun Lim95bfdd52016-01-03 17:35:37 +09004083 msg.body.remain_on_ch.expired = expired;
Chaehyun Lim1aae9392016-01-03 17:35:38 +09004084 msg.body.remain_on_ch.ready = ready;
Chaehyun Lim482c4332016-01-03 17:35:39 +09004085 msg.body.remain_on_ch.arg = user_arg;
Chaehyun Limd44cd452016-01-03 17:35:36 +09004086 msg.body.remain_on_ch.duration = duration;
Chaehyun Lim6f7584b2016-01-03 17:35:35 +09004087 msg.body.remain_on_ch.id = session_id;
Glen Leecf601062015-12-21 14:18:39 +09004088 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004089
Leo Kim31390ee2015-10-19 18:26:08 +09004090 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4091 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004092 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004093
Leo Kim31390ee2015-10-19 18:26:08 +09004094 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004095}
4096
Chaehyun Lim6b0f7cd2015-12-30 21:15:29 +09004097int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004098{
Chaehyun Lim5ca581e2015-12-30 21:15:28 +09004099 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004100 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09004101 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004102
Tony Choa4ab1ad2015-10-12 16:56:05 +09004103 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004104 PRINT_ER("driver is null\n");
4105 return -EFAULT;
4106 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004107
Leo Kimcc2d7e92015-10-29 11:58:36 +09004108 del_timer(&hif_drv->remain_on_ch_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004109
Tony Cho143eb952015-09-21 12:16:32 +09004110 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09004111 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Glen Leecf601062015-12-21 14:18:39 +09004112 msg.vif = vif;
Chaehyun Lim6b0f7cd2015-12-30 21:15:29 +09004113 msg.body.remain_on_ch.id = session_id;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004114
Leo Kim31390ee2015-10-19 18:26:08 +09004115 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4116 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004117 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004118
Leo Kim31390ee2015-10-19 18:26:08 +09004119 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004120}
4121
Chaehyun Lim8859fc22015-12-30 21:15:27 +09004122int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004123{
Chaehyun Limde61db92015-12-30 21:15:25 +09004124 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004125 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09004126 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004127
Tony Choa4ab1ad2015-10-12 16:56:05 +09004128 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004129 PRINT_ER("driver is null\n");
4130 return -EFAULT;
4131 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004132
Tony Cho143eb952015-09-21 12:16:32 +09004133 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004134
Tony Choa9f812a2015-09-21 12:16:33 +09004135 msg.id = HOST_IF_MSG_REGISTER_FRAME;
Chaehyun Lim2a8432f2015-12-30 21:15:26 +09004136 switch (frame_type) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004137 case ACTION:
4138 PRINT_D(HOSTINF_DBG, "ACTION\n");
Leo Kimbcb410b2015-10-29 11:58:40 +09004139 msg.body.reg_frame.reg_id = ACTION_FRM_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004140 break;
4141
4142 case PROBE_REQ:
4143 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
Leo Kimbcb410b2015-10-29 11:58:40 +09004144 msg.body.reg_frame.reg_id = PROBE_REQ_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004145 break;
4146
4147 default:
4148 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
4149 break;
4150 }
Chaehyun Lim2a8432f2015-12-30 21:15:26 +09004151 msg.body.reg_frame.frame_type = frame_type;
Chaehyun Lim8859fc22015-12-30 21:15:27 +09004152 msg.body.reg_frame.reg = reg;
Glen Leecf601062015-12-21 14:18:39 +09004153 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004154
Leo Kim31390ee2015-10-19 18:26:08 +09004155 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4156 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004157 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004158
Leo Kim31390ee2015-10-19 18:26:08 +09004159 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004160}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004161
Chaehyun Lim916935f2016-01-03 17:35:57 +09004162int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
Chaehyun Lim733d1032016-01-03 17:36:01 +09004163 u32 head_len, u8 *head, u32 tail_len, u8 *tail)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004164{
Chaehyun Lim4d84dbe2016-01-03 17:35:55 +09004165 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004166 struct host_if_msg msg;
Chaehyun Lim75bf22c2016-01-03 17:36:02 +09004167 struct beacon_attr *beacon_info = &msg.body.beacon_info;
Glen Leefbf53792015-12-21 14:18:40 +09004168 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004169
Tony Choa4ab1ad2015-10-12 16:56:05 +09004170 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004171 PRINT_ER("driver is null\n");
4172 return -EFAULT;
4173 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004174
Tony Cho143eb952015-09-21 12:16:32 +09004175 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004176
4177 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
4178
Tony Choa9f812a2015-09-21 12:16:33 +09004179 msg.id = HOST_IF_MSG_ADD_BEACON;
Glen Leecf601062015-12-21 14:18:39 +09004180 msg.vif = vif;
Chaehyun Lim75bf22c2016-01-03 17:36:02 +09004181 beacon_info->interval = interval;
4182 beacon_info->dtim_period = dtim_period;
4183 beacon_info->head_len = head_len;
4184 beacon_info->head = kmemdup(head, head_len, GFP_KERNEL);
4185 if (!beacon_info->head) {
Leo Kim31390ee2015-10-19 18:26:08 +09004186 result = -ENOMEM;
Leo Kim24db7132015-09-16 18:36:01 +09004187 goto ERRORHANDLER;
4188 }
Chaehyun Lim75bf22c2016-01-03 17:36:02 +09004189 beacon_info->tail_len = tail_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004190
Chaehyun Lim2df35852016-01-03 17:36:00 +09004191 if (tail_len > 0) {
Chaehyun Lim75bf22c2016-01-03 17:36:02 +09004192 beacon_info->tail = kmemdup(tail, tail_len, GFP_KERNEL);
4193 if (!beacon_info->tail) {
Leo Kim31390ee2015-10-19 18:26:08 +09004194 result = -ENOMEM;
Leo Kim24db7132015-09-16 18:36:01 +09004195 goto ERRORHANDLER;
4196 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004197 } else {
Chaehyun Lim75bf22c2016-01-03 17:36:02 +09004198 beacon_info->tail = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004199 }
4200
Leo Kim31390ee2015-10-19 18:26:08 +09004201 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4202 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004203 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004204
Leo Kim24db7132015-09-16 18:36:01 +09004205ERRORHANDLER:
Leo Kim31390ee2015-10-19 18:26:08 +09004206 if (result) {
Chaehyun Lim75bf22c2016-01-03 17:36:02 +09004207 kfree(beacon_info->head);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004208
Chaehyun Lim75bf22c2016-01-03 17:36:02 +09004209 kfree(beacon_info->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004210 }
4211
Leo Kim31390ee2015-10-19 18:26:08 +09004212 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004213}
4214
Glen Leefbf53792015-12-21 14:18:40 +09004215int wilc_del_beacon(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004216{
Chaehyun Lim0a5298c2015-11-06 19:11:10 +09004217 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004218 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09004219 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004220
Tony Choa4ab1ad2015-10-12 16:56:05 +09004221 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004222 PRINT_ER("driver is null\n");
4223 return -EFAULT;
4224 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004225
Tony Choa9f812a2015-09-21 12:16:33 +09004226 msg.id = HOST_IF_MSG_DEL_BEACON;
Glen Leecf601062015-12-21 14:18:39 +09004227 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004228 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
4229
Leo Kim31390ee2015-10-19 18:26:08 +09004230 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4231 if (result)
Leo Kim7dc1d0c2015-09-16 18:36:00 +09004232 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004233
Leo Kim31390ee2015-10-19 18:26:08 +09004234 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004235}
4236
Glen Leefbf53792015-12-21 14:18:40 +09004237int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004238{
Chaehyun Lim18cfbd32015-11-06 19:11:16 +09004239 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004240 struct host_if_msg msg;
Chaehyun Lim773e02e2015-11-06 19:11:19 +09004241 struct add_sta_param *add_sta_info = &msg.body.add_sta_info;
Glen Leefbf53792015-12-21 14:18:40 +09004242 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004243
Tony Choa4ab1ad2015-10-12 16:56:05 +09004244 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004245 PRINT_ER("driver is null\n");
4246 return -EFAULT;
4247 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004248
Tony Cho143eb952015-09-21 12:16:32 +09004249 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004250
4251 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
4252
Tony Choa9f812a2015-09-21 12:16:33 +09004253 msg.id = HOST_IF_MSG_ADD_STATION;
Glen Leecf601062015-12-21 14:18:39 +09004254 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004255
Chaehyun Lim773e02e2015-11-06 19:11:19 +09004256 memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
4257 if (add_sta_info->rates_len > 0) {
Chaehyun Lim90623052015-11-06 19:11:21 +09004258 add_sta_info->rates = kmemdup(sta_param->rates,
4259 add_sta_info->rates_len,
4260 GFP_KERNEL);
4261 if (!add_sta_info->rates)
Leo Kim7ae43362015-09-16 18:35:59 +09004262 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004263 }
4264
Leo Kim31390ee2015-10-19 18:26:08 +09004265 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4266 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004267 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004268 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004269}
4270
Glen Leefbf53792015-12-21 14:18:40 +09004271int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004272{
Chaehyun Lim79a0c0a2015-11-06 19:11:12 +09004273 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004274 struct host_if_msg msg;
Chaehyun Limc87fbed2015-11-06 19:11:15 +09004275 struct del_sta *del_sta_info = &msg.body.del_sta_info;
Glen Leefbf53792015-12-21 14:18:40 +09004276 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004277
Tony Choa4ab1ad2015-10-12 16:56:05 +09004278 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004279 PRINT_ER("driver is null\n");
4280 return -EFAULT;
4281 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004282
Tony Cho143eb952015-09-21 12:16:32 +09004283 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004284
4285 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
4286
Tony Choa9f812a2015-09-21 12:16:33 +09004287 msg.id = HOST_IF_MSG_DEL_STATION;
Glen Leecf601062015-12-21 14:18:39 +09004288 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004289
Chaehyun Limc9c4eb42015-11-06 19:11:14 +09004290 if (!mac_addr)
Chaehyun Limc87fbed2015-11-06 19:11:15 +09004291 eth_broadcast_addr(del_sta_info->mac_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004292 else
Chaehyun Limc87fbed2015-11-06 19:11:15 +09004293 memcpy(del_sta_info->mac_addr, mac_addr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004294
Leo Kim31390ee2015-10-19 18:26:08 +09004295 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4296 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004297 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004298 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004299}
Leo Kimae4dfa52015-10-13 19:49:26 +09004300
Chaehyun Lim2092374d2016-01-03 17:35:50 +09004301int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN])
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004302{
Chaehyun Lim253eb922016-01-03 17:35:49 +09004303 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004304 struct host_if_msg msg;
Chaehyun Lim55d44a62016-01-03 17:35:51 +09004305 struct del_all_sta *del_all_sta_info = &msg.body.del_all_sta_info;
Glen Leefbf53792015-12-21 14:18:40 +09004306 struct host_if_drv *hif_drv = vif->hif_drv;
Chaehyun Lim06e682b2016-01-03 17:35:52 +09004307 u8 zero_addr[ETH_ALEN] = {0};
Chaehyun Limcc971ee2016-01-03 17:35:53 +09004308 int i;
Chaehyun Lim9d6cec92016-01-03 17:35:54 +09004309 u8 assoc_sta = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004310
Tony Choa4ab1ad2015-10-12 16:56:05 +09004311 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004312 PRINT_ER("driver is null\n");
4313 return -EFAULT;
4314 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004315
Tony Cho143eb952015-09-21 12:16:32 +09004316 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004317
4318 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
4319
Tony Choa9f812a2015-09-21 12:16:33 +09004320 msg.id = HOST_IF_MSG_DEL_ALL_STA;
Glen Leecf601062015-12-21 14:18:39 +09004321 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004322
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004323 for (i = 0; i < MAX_NUM_STA; i++) {
Chaehyun Lim06e682b2016-01-03 17:35:52 +09004324 if (memcmp(mac_addr[i], zero_addr, ETH_ALEN)) {
Chaehyun Lim55d44a62016-01-03 17:35:51 +09004325 memcpy(del_all_sta_info->del_all_sta[i], mac_addr[i], ETH_ALEN);
Leo Kime51b9212015-10-13 19:50:09 +09004326 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
Chaehyun Lim55d44a62016-01-03 17:35:51 +09004327 del_all_sta_info->del_all_sta[i][0],
4328 del_all_sta_info->del_all_sta[i][1],
4329 del_all_sta_info->del_all_sta[i][2],
4330 del_all_sta_info->del_all_sta[i][3],
4331 del_all_sta_info->del_all_sta[i][4],
4332 del_all_sta_info->del_all_sta[i][5]);
Chaehyun Lim9d6cec92016-01-03 17:35:54 +09004333 assoc_sta++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004334 }
4335 }
Chaehyun Lim9d6cec92016-01-03 17:35:54 +09004336 if (!assoc_sta) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004337 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004338 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004339 }
4340
Chaehyun Lim9d6cec92016-01-03 17:35:54 +09004341 del_all_sta_info->assoc_sta = assoc_sta;
Leo Kim31390ee2015-10-19 18:26:08 +09004342 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004343
Leo Kim31390ee2015-10-19 18:26:08 +09004344 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004345 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004346
Leo Kim2d25af82015-10-15 13:24:56 +09004347 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004348
Leo Kim31390ee2015-10-19 18:26:08 +09004349 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004350}
4351
Chaehyun Lim4208e662016-01-03 17:35:44 +09004352int wilc_edit_station(struct wilc_vif *vif,
Chaehyun Lim4c7abe12016-01-03 17:35:45 +09004353 struct add_sta_param *sta_param)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004354{
Chaehyun Lim4208e662016-01-03 17:35:44 +09004355 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004356 struct host_if_msg msg;
Chaehyun Lim785c0712016-01-03 17:35:46 +09004357 struct add_sta_param *add_sta_info = &msg.body.add_sta_info;
Glen Leefbf53792015-12-21 14:18:40 +09004358 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004359
Tony Choa4ab1ad2015-10-12 16:56:05 +09004360 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004361 PRINT_ER("driver is null\n");
4362 return -EFAULT;
4363 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004364
4365 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
4366
Tony Cho143eb952015-09-21 12:16:32 +09004367 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004368
Tony Choa9f812a2015-09-21 12:16:33 +09004369 msg.id = HOST_IF_MSG_EDIT_STATION;
Glen Leecf601062015-12-21 14:18:39 +09004370 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004371
Chaehyun Lim785c0712016-01-03 17:35:46 +09004372 memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
4373 if (add_sta_info->rates_len > 0) {
Chaehyun Lime38d8502016-01-03 17:35:48 +09004374 add_sta_info->rates = kmemdup(sta_param->rates,
4375 add_sta_info->rates_len,
4376 GFP_KERNEL);
4377 if (!add_sta_info->rates)
Leo Kim7ae43362015-09-16 18:35:59 +09004378 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004379 }
4380
Leo Kim31390ee2015-10-19 18:26:08 +09004381 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4382 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004383 PRINT_ER("wilc_mq_send fail\n");
4384
Leo Kim31390ee2015-10-19 18:26:08 +09004385 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004386}
Glen Lee108b3432015-09-16 18:53:20 +09004387
Chaehyun Limecd27502015-12-30 21:15:32 +09004388int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004389{
Chaehyun Lim5d48f122015-12-30 21:15:30 +09004390 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004391 struct host_if_msg msg;
Chaehyun Lim568640e2015-12-30 21:15:33 +09004392 struct power_mgmt_param *pwr_mgmt_info = &msg.body.pwr_mgmt_info;
Glen Leefbf53792015-12-21 14:18:40 +09004393 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004394
Chaehyun Limdbaa5242015-12-30 21:15:31 +09004395 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", enabled);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004396
Tony Choa4ab1ad2015-10-12 16:56:05 +09004397 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004398 PRINT_ER("driver is null\n");
4399 return -EFAULT;
4400 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004401
4402 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
4403
Tony Cho143eb952015-09-21 12:16:32 +09004404 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004405
Tony Choa9f812a2015-09-21 12:16:33 +09004406 msg.id = HOST_IF_MSG_POWER_MGMT;
Glen Leecf601062015-12-21 14:18:39 +09004407 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004408
Chaehyun Lim568640e2015-12-30 21:15:33 +09004409 pwr_mgmt_info->enabled = enabled;
4410 pwr_mgmt_info->timeout = timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004411
Leo Kim31390ee2015-10-19 18:26:08 +09004412 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4413 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004414 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004415 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004416}
4417
Chaehyun Limb80c0942015-12-30 21:15:35 +09004418int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled,
Chaehyun Lim2dff2d42015-12-30 21:15:36 +09004419 u32 count)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004420{
Chaehyun Lim14d95262015-12-30 21:15:34 +09004421 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004422 struct host_if_msg msg;
Chaehyun Lim40ecd382015-12-30 21:15:37 +09004423 struct set_multicast *multicast_filter_param = &msg.body.multicast_info;
Glen Leefbf53792015-12-21 14:18:40 +09004424 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004425
Tony Choa4ab1ad2015-10-12 16:56:05 +09004426 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004427 PRINT_ER("driver is null\n");
4428 return -EFAULT;
4429 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004430
4431 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
4432
Tony Cho143eb952015-09-21 12:16:32 +09004433 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004434
Tony Choa9f812a2015-09-21 12:16:33 +09004435 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
Glen Leecf601062015-12-21 14:18:39 +09004436 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004437
Chaehyun Lim40ecd382015-12-30 21:15:37 +09004438 multicast_filter_param->enabled = enabled;
4439 multicast_filter_param->cnt = count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004440
Leo Kim31390ee2015-10-19 18:26:08 +09004441 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4442 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004443 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004444 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004445}
4446
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004447static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
4448{
Leo Kime0a12212015-10-12 16:55:49 +09004449 struct join_bss_param *pNewJoinBssParam = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004450 u8 *pu8IEs;
Chaehyun Limd85f5322015-06-11 14:35:54 +09004451 u16 u16IEsLen;
4452 u16 index = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004453 u8 suppRatesNo = 0;
4454 u8 extSuppRatesNo;
Chaehyun Limd85f5322015-06-11 14:35:54 +09004455 u16 jumpOffset;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004456 u8 pcipherCount;
4457 u8 authCount;
4458 u8 pcipherTotalCount = 0;
4459 u8 authTotalCount = 0;
4460 u8 i, j;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004461
4462 pu8IEs = ptstrNetworkInfo->pu8IEs;
4463 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4464
Shraddha Barkeb156f1e2015-10-13 23:07:00 +05304465 pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09004466 if (pNewJoinBssParam) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004467 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4468 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
4469 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004470 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004471 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
Leo Kim619d27b2015-10-15 13:24:42 +09004472 pNewJoinBssParam->ssid_len = ptstrNetworkInfo->u8SsidLen;
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004473 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4474 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004475
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004476 while (index < u16IEsLen) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004477 if (pu8IEs[index] == SUPP_RATES_IE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004478 suppRatesNo = pu8IEs[index + 1];
4479 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
Leo Kimae4dfa52015-10-13 19:49:26 +09004480 index += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004481
Leo Kimd1666e22015-10-28 15:59:22 +09004482 for (i = 0; i < suppRatesNo; i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004483 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
Leo Kimd1666e22015-10-28 15:59:22 +09004484
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004485 index += suppRatesNo;
4486 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004487 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004488 extSuppRatesNo = pu8IEs[index + 1];
4489 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4490 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4491 else
4492 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4493 index += 2;
Leo Kimd1666e22015-10-28 15:59:22 +09004494 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004495 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
Leo Kimd1666e22015-10-28 15:59:22 +09004496
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004497 index += extSuppRatesNo;
4498 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004499 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004500 pNewJoinBssParam->ht_capable = true;
Leo Kimae4dfa52015-10-13 19:49:26 +09004501 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004502 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004503 } else if ((pu8IEs[index] == WMM_IE) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004504 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
Leo Kimae4dfa52015-10-13 19:49:26 +09004505 (pu8IEs[index + 4] == 0xF2) &&
4506 (pu8IEs[index + 5] == 0x02) &&
4507 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004508 (pu8IEs[index + 7] == 0x01)) {
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004509 pNewJoinBssParam->wmm_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004510
Anish Bhattffda2032015-09-29 12:15:49 -07004511 if (pu8IEs[index + 8] & BIT(7))
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004512 pNewJoinBssParam->uapsd_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004513 index += pu8IEs[index + 1] + 2;
4514 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004515 } else if ((pu8IEs[index] == P2P_IE) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004516 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
Leo Kimae4dfa52015-10-13 19:49:26 +09004517 (pu8IEs[index + 4] == 0x9a) &&
4518 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09004519 u16 u16P2P_count;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004520
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004521 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
Leo Kim7a8d51d2015-10-15 13:24:43 +09004522 pNewJoinBssParam->noa_enabled = 1;
Leo Kimcc179002015-10-15 13:24:47 +09004523 pNewJoinBssParam->idx = pu8IEs[index + 9];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004524
Anish Bhattffda2032015-09-29 12:15:49 -07004525 if (pu8IEs[index + 10] & BIT(7)) {
Leo Kimd72b33c2015-10-15 13:24:44 +09004526 pNewJoinBssParam->opp_enabled = 1;
Leo Kim99b66942015-10-15 13:24:45 +09004527 pNewJoinBssParam->ct_window = pu8IEs[index + 10];
Leo Kimd72b33c2015-10-15 13:24:44 +09004528 } else {
4529 pNewJoinBssParam->opp_enabled = 0;
4530 }
Leo Kimae4dfa52015-10-13 19:49:26 +09004531
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004532 PRINT_D(GENERIC_DBG, "P2P Dump\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004533 for (i = 0; i < pu8IEs[index + 7]; i++)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004534 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004535
Leo Kimc21047e2015-10-15 13:24:46 +09004536 pNewJoinBssParam->cnt = pu8IEs[index + 11];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004537 u16P2P_count = index + 12;
4538
Leo Kim109e6ca2015-10-15 13:24:48 +09004539 memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004540 u16P2P_count += 4;
4541
Leo Kim1d8b76b2015-10-15 13:24:49 +09004542 memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004543 u16P2P_count += 4;
4544
Leo Kim4be55e22015-10-28 15:59:27 +09004545 memcpy(pNewJoinBssParam->start_time, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004546
4547 index += pu8IEs[index + 1] + 2;
4548 continue;
4549
Leo Kimae4dfa52015-10-13 19:49:26 +09004550 } else if ((pu8IEs[index] == RSN_IE) ||
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004551 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
4552 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
4553 (pu8IEs[index + 5] == 0x01))) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09004554 u16 rsnIndex = index;
Leo Kimae4dfa52015-10-13 19:49:26 +09004555
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004556 if (pu8IEs[rsnIndex] == RSN_IE) {
4557 pNewJoinBssParam->mode_802_11i = 2;
Leo Kimae4dfa52015-10-13 19:49:26 +09004558 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004559 if (pNewJoinBssParam->mode_802_11i == 0)
4560 pNewJoinBssParam->mode_802_11i = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004561 rsnIndex += 4;
4562 }
Leo Kimae4dfa52015-10-13 19:49:26 +09004563
4564 rsnIndex += 7;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004565 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
4566 rsnIndex++;
Leo Kimae4dfa52015-10-13 19:49:26 +09004567 jumpOffset = pu8IEs[rsnIndex] * 4;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004568 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
Leo Kimae4dfa52015-10-13 19:49:26 +09004569 rsnIndex += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004570
Leo Kimd1666e22015-10-28 15:59:22 +09004571 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004572 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
Leo Kimd1666e22015-10-28 15:59:22 +09004573
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004574 pcipherTotalCount += pcipherCount;
4575 rsnIndex += jumpOffset;
4576
4577 jumpOffset = pu8IEs[rsnIndex] * 4;
4578
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004579 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
Leo Kimae4dfa52015-10-13 19:49:26 +09004580 rsnIndex += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004581
Leo Kimd1666e22015-10-28 15:59:22 +09004582 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004583 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
Leo Kimd1666e22015-10-28 15:59:22 +09004584
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004585 authTotalCount += authCount;
4586 rsnIndex += jumpOffset;
Leo Kimae4dfa52015-10-13 19:49:26 +09004587
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004588 if (pu8IEs[index] == RSN_IE) {
4589 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
4590 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
4591 rsnIndex += 2;
4592 }
Abdul Hussainf717c0eb2015-06-16 09:49:49 +00004593 pNewJoinBssParam->rsn_found = true;
Leo Kimae4dfa52015-10-13 19:49:26 +09004594 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004595 continue;
4596 } else
Leo Kimae4dfa52015-10-13 19:49:26 +09004597 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004598 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004599 }
4600
4601 return (void *)pNewJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004602}
4603
Chaehyun Limd7954742016-01-03 17:35:42 +09004604int wilc_del_all_rx_ba_session(struct wilc_vif *vif, char *bssid, char tid)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004605{
Chaehyun Lim2c2e4612016-01-03 17:35:40 +09004606 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004607 struct host_if_msg msg;
Chaehyun Limb91e6f32016-01-03 17:35:43 +09004608 struct ba_session_info *ba_session_info = &msg.body.session_info;
Glen Leefbf53792015-12-21 14:18:40 +09004609 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004610
Tony Choa4ab1ad2015-10-12 16:56:05 +09004611 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004612 PRINT_ER("driver is null\n");
4613 return -EFAULT;
4614 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004615
Tony Cho143eb952015-09-21 12:16:32 +09004616 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004617
Tony Choa9f812a2015-09-21 12:16:33 +09004618 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004619
Chaehyun Limb91e6f32016-01-03 17:35:43 +09004620 memcpy(ba_session_info->bssid, bssid, ETH_ALEN);
4621 ba_session_info->tid = tid;
Glen Leecf601062015-12-21 14:18:39 +09004622 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004623
Leo Kim31390ee2015-10-19 18:26:08 +09004624 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4625 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004626 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004627
Leo Kim2d25af82015-10-15 13:24:56 +09004628 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004629
Leo Kim31390ee2015-10-19 18:26:08 +09004630 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004631}
4632
Chaehyun Lim6964f082015-12-30 21:15:39 +09004633int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004634{
Chaehyun Lim3d2a0bf2015-12-30 21:15:38 +09004635 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004636 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09004637 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004638
Tony Choa4ab1ad2015-10-12 16:56:05 +09004639 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004640 PRINT_ER("driver is null\n");
4641 return -EFAULT;
4642 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004643
Tony Cho143eb952015-09-21 12:16:32 +09004644 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004645
Tony Choa9f812a2015-09-21 12:16:33 +09004646 msg.id = HOST_IF_MSG_SET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004647
Chaehyun Lim6964f082015-12-30 21:15:39 +09004648 msg.body.ip_info.ip_addr = ip_addr;
Glen Leecf601062015-12-21 14:18:39 +09004649 msg.vif = vif;
Tony Chofb2d65e2015-09-30 18:44:39 +09004650 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004651
Leo Kim31390ee2015-10-19 18:26:08 +09004652 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4653 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004654 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004655
Leo Kim31390ee2015-10-19 18:26:08 +09004656 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004657}
4658
Chaehyun Lim3b4276d2015-12-30 21:15:43 +09004659static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004660{
Chaehyun Limcb8f4e02015-12-30 21:15:41 +09004661 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004662 struct host_if_msg msg;
Chaehyun Limf8813d32015-12-30 21:15:42 +09004663 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004664
Tony Choa4ab1ad2015-10-12 16:56:05 +09004665 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004666 PRINT_ER("driver is null\n");
4667 return -EFAULT;
4668 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004669
Tony Cho143eb952015-09-21 12:16:32 +09004670 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004671
Tony Choa9f812a2015-09-21 12:16:33 +09004672 msg.id = HOST_IF_MSG_GET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004673
Chaehyun Lim3b4276d2015-12-30 21:15:43 +09004674 msg.body.ip_info.ip_addr = ip_addr;
Glen Leecf601062015-12-21 14:18:39 +09004675 msg.vif = vif;
Tony Chofb2d65e2015-09-30 18:44:39 +09004676 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004677
Leo Kim31390ee2015-10-19 18:26:08 +09004678 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4679 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004680 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004681
Leo Kim31390ee2015-10-19 18:26:08 +09004682 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004683}