blob: 8c7752034032b804e267fb48f4513740e476eb63 [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
Leo Kim441dc602015-10-12 16:55:35 +0900228struct 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);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900266
Glen Leeeb9939b2015-12-21 14:18:43 +0900267/* The u8IfIdx starts from 0 to NUM_CONCURRENT_IFC -1, but 0 index used as
268 * special purpose in wilc device, so we add 1 to the index to starts from 1.
269 * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC.
270 */
Glen Lee31f0f692015-12-21 14:18:44 +0900271int wilc_get_vif_idx(struct wilc_vif *vif)
Johnny Kimd42ab082015-08-20 16:32:52 +0900272{
Glen Leeeb9939b2015-12-21 14:18:43 +0900273 return vif->u8IfIdx + 1;
274}
275
276/* We need to minus 1 from idx which is from wilc device to get real index
277 * of wilc->vif[], because we add 1 when pass to wilc device in the function
278 * wilc_get_vif_idx.
279 * As a result, the index should be between 0 and NUM_CONCURRENT_IFC -1.
280 */
281static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx)
282{
283 int index = idx - 1;
284
285 if (index < 0 || index >= NUM_CONCURRENT_IFC)
Johnny Kimd42ab082015-08-20 16:32:52 +0900286 return NULL;
Glen Leeeb9939b2015-12-21 14:18:43 +0900287
288 return wilc->vif[index];
Johnny Kimd42ab082015-08-20 16:32:52 +0900289}
290
Glen Lee71130e82015-12-21 14:18:41 +0900291static s32 handle_set_channel(struct wilc_vif *vif,
Leo Kim9cf78782015-10-29 12:05:54 +0900292 struct channel_attr *hif_set_ch)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900293{
Leo Kim31390ee2015-10-19 18:26:08 +0900294 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900295 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900296
Leo Kim45102f82015-10-28 15:59:28 +0900297 wid.id = (u16)WID_CURRENT_CHANNEL;
298 wid.type = WID_CHAR;
Leo Kim9cf78782015-10-29 12:05:54 +0900299 wid.val = (char *)&hif_set_ch->set_ch;
Leo Kim45102f82015-10-28 15:59:28 +0900300 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900301
302 PRINT_D(HOSTINF_DBG, "Setting channel\n");
Leo Kimae4dfa52015-10-13 19:49:26 +0900303
Glen Leecd2920a2015-12-21 14:18:48 +0900304 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +0900305 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +0900306
307 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900308 PRINT_ER("Failed to set channel\n");
Leo Kim24db7132015-09-16 18:36:01 +0900309 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900310 }
311
Leo Kim31390ee2015-10-19 18:26:08 +0900312 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900313}
Leo Kimae4dfa52015-10-13 19:49:26 +0900314
Glen Lee71130e82015-12-21 14:18:41 +0900315static s32 handle_set_wfi_drv_handler(struct wilc_vif *vif,
Leo Kim23f2bad2015-11-06 11:20:04 +0900316 struct drv_handler *hif_drv_handler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900317{
Leo Kim31390ee2015-10-19 18:26:08 +0900318 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900319 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900320
Leo Kim45102f82015-10-28 15:59:28 +0900321 wid.id = (u16)WID_SET_DRV_HANDLER;
322 wid.type = WID_INT;
Leo Kim6b73c742015-10-29 12:05:55 +0900323 wid.val = (s8 *)&hif_drv_handler->handler;
Leo Kim45102f82015-10-28 15:59:28 +0900324 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900325
Glen Lee31f0f692015-12-21 14:18:44 +0900326 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeec62e6d2015-11-18 15:11:33 +0900327 hif_drv_handler->handler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900328
Glen Lee31f0f692015-12-21 14:18:44 +0900329 if (!hif_drv_handler->handler)
Leo Kim27ff2162015-10-15 13:24:55 +0900330 up(&hif_sema_driver);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900331
Leo Kim31390ee2015-10-19 18:26:08 +0900332 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900333 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900334 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900335 }
336
Leo Kim31390ee2015-10-19 18:26:08 +0900337 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900338}
339
Glen Lee71130e82015-12-21 14:18:41 +0900340static s32 handle_set_operation_mode(struct wilc_vif *vif,
Leo Kim97b5c592015-11-06 11:20:05 +0900341 struct op_mode *hif_op_mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900342{
Leo Kim31390ee2015-10-19 18:26:08 +0900343 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900344 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900345
Leo Kim45102f82015-10-28 15:59:28 +0900346 wid.id = (u16)WID_SET_OPERATION_MODE;
347 wid.type = WID_INT;
Leo Kimacff1d72015-10-29 12:05:56 +0900348 wid.val = (s8 *)&hif_op_mode->mode;
Leo Kim45102f82015-10-28 15:59:28 +0900349 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900350
Glen Leecd2920a2015-12-21 14:18:48 +0900351 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +0900352 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900353
Leo Kimacff1d72015-10-29 12:05:56 +0900354 if ((hif_op_mode->mode) == IDLE_MODE)
Leo Kim27ff2162015-10-15 13:24:55 +0900355 up(&hif_sema_driver);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900356
Leo Kim31390ee2015-10-19 18:26:08 +0900357 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900358 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900359 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900360 }
361
Leo Kim31390ee2015-10-19 18:26:08 +0900362 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900363}
364
Glen Leecf601062015-12-21 14:18:39 +0900365static s32 host_int_get_ipaddress(struct wilc_vif *vif,
366 struct host_if_drv *hif_drv,
367 u8 *u16ipadd, u8 idx);
Arnd Bergmann1608c402015-11-16 15:04:53 +0100368
Glen Lee71130e82015-12-21 14:18:41 +0900369static s32 handle_set_ip_address(struct wilc_vif *vif, u8 *ip_addr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900370{
Leo Kim31390ee2015-10-19 18:26:08 +0900371 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900372 struct wid wid;
Leo Kimebc57d12015-11-05 14:36:03 +0900373 char firmware_ip_addr[4] = {0};
Glen Lee71130e82015-12-21 14:18:41 +0900374 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900375
Leo Kima6527c32015-11-05 14:36:02 +0900376 if (ip_addr[0] < 192)
377 ip_addr[0] = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900378
Leo Kima6527c32015-11-05 14:36:02 +0900379 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n",
380 idx, ip_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900381
Leo Kima6527c32015-11-05 14:36:02 +0900382 memcpy(set_ip[idx], ip_addr, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900383
Leo Kim45102f82015-10-28 15:59:28 +0900384 wid.id = (u16)WID_IP_ADDRESS;
385 wid.type = WID_STR;
Leo Kima6527c32015-11-05 14:36:02 +0900386 wid.val = (u8 *)ip_addr;
Leo Kim45102f82015-10-28 15:59:28 +0900387 wid.size = IP_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900388
Glen Leecd2920a2015-12-21 14:18:48 +0900389 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +0900390 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900391
Glen Leecf601062015-12-21 14:18:39 +0900392 host_int_get_ipaddress(vif, hif_drv, firmware_ip_addr, idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900393
Leo Kim31390ee2015-10-19 18:26:08 +0900394 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +0900395 PRINT_ER("Failed to set IP address\n");
396 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900397 }
398
Leo Kim24db7132015-09-16 18:36:01 +0900399 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900400
Leo Kim31390ee2015-10-19 18:26:08 +0900401 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900402}
403
Glen Lee71130e82015-12-21 14:18:41 +0900404static s32 handle_get_ip_address(struct wilc_vif *vif, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900405{
Leo Kim31390ee2015-10-19 18:26:08 +0900406 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900407 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900408
Leo Kim45102f82015-10-28 15:59:28 +0900409 wid.id = (u16)WID_IP_ADDRESS;
410 wid.type = WID_STR;
411 wid.val = kmalloc(IP_ALEN, GFP_KERNEL);
412 wid.size = IP_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900413
Glen Leecd2920a2015-12-21 14:18:48 +0900414 result = wilc_send_config_pkt(vif->wilc, GET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +0900415 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900416
Leo Kim45102f82015-10-28 15:59:28 +0900417 PRINT_INFO(HOSTINF_DBG, "%pI4\n", wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900418
Leo Kim45102f82015-10-28 15:59:28 +0900419 memcpy(get_ip[idx], wid.val, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900420
Leo Kim45102f82015-10-28 15:59:28 +0900421 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900422
Leo Kim1e75d012015-10-15 13:25:05 +0900423 if (memcmp(get_ip[idx], set_ip[idx], IP_ALEN) != 0)
Glen Leefbf53792015-12-21 14:18:40 +0900424 wilc_setup_ipaddress(vif, set_ip[idx], idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900425
Leo Kim31390ee2015-10-19 18:26:08 +0900426 if (result != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900427 PRINT_ER("Failed to get IP address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900428 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900429 }
430
Leo Kim24db7132015-09-16 18:36:01 +0900431 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
Leo Kim1e75d012015-10-15 13:25:05 +0900432 PRINT_INFO(HOSTINF_DBG, "%pI4\n", get_ip[idx]);
Leo Kim24db7132015-09-16 18:36:01 +0900433 PRINT_INFO(HOSTINF_DBG, "\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900434
Leo Kim31390ee2015-10-19 18:26:08 +0900435 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900436}
437
Glen Lee71130e82015-12-21 14:18:41 +0900438static s32 handle_set_mac_address(struct wilc_vif *vif,
Leo Kima8267422015-11-06 11:20:08 +0900439 struct set_mac_addr *set_mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900440{
Leo Kim31390ee2015-10-19 18:26:08 +0900441 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900442 struct wid wid;
Glen Leef3052582015-09-10 12:03:04 +0900443 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
Leo Kimc09389a2015-10-28 15:59:24 +0900444
Leo Kim91109e12015-10-19 18:26:13 +0900445 if (!mac_buf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900446 PRINT_ER("No buffer to send mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +0900447 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900448 }
Leo Kim090dbb12015-11-05 14:36:05 +0900449 memcpy(mac_buf, set_mac_addr->mac_addr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900450
Leo Kim45102f82015-10-28 15:59:28 +0900451 wid.id = (u16)WID_MAC_ADDR;
452 wid.type = WID_STR;
453 wid.val = mac_buf;
454 wid.size = ETH_ALEN;
455 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", wid.val);
Leo Kimae4dfa52015-10-13 19:49:26 +0900456
Glen Leecd2920a2015-12-21 14:18:48 +0900457 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +0900458 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +0900459 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900460 PRINT_ER("Failed to set mac address\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900461 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900462 }
463
Chaehyun Lim49188af2015-08-11 10:32:41 +0900464 kfree(mac_buf);
Leo Kim31390ee2015-10-19 18:26:08 +0900465 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900466}
467
Glen Lee71130e82015-12-21 14:18:41 +0900468static s32 handle_get_mac_address(struct wilc_vif *vif,
Leo Kimb3bf8fd2015-11-06 11:20:09 +0900469 struct get_mac_addr *get_mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900470{
Leo Kim31390ee2015-10-19 18:26:08 +0900471 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900472 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900473
Leo Kim45102f82015-10-28 15:59:28 +0900474 wid.id = (u16)WID_MAC_ADDR;
475 wid.type = WID_STR;
Leo Kim7f0ee9a2015-11-05 14:36:06 +0900476 wid.val = get_mac_addr->mac_addr;
Leo Kim45102f82015-10-28 15:59:28 +0900477 wid.size = ETH_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900478
Glen Leecd2920a2015-12-21 14:18:48 +0900479 result = wilc_send_config_pkt(vif->wilc, GET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +0900480 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +0900481
482 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900483 PRINT_ER("Failed to get mac address\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900484 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900485 }
Leo Kim2d25af82015-10-15 13:24:56 +0900486 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900487
Leo Kim31390ee2015-10-19 18:26:08 +0900488 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900489}
490
Glen Lee71130e82015-12-21 14:18:41 +0900491static s32 handle_cfg_param(struct wilc_vif *vif,
Leo Kimdc276662015-11-06 11:20:10 +0900492 struct cfg_param_attr *cfg_param_attr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900493{
Leo Kim31390ee2015-10-19 18:26:08 +0900494 s32 result = 0;
Leo Kim13ca52a2015-11-06 11:20:11 +0900495 struct wid wid_list[32];
Glen Lee71130e82015-12-21 14:18:41 +0900496 struct host_if_drv *hif_drv = vif->hif_drv;
Leo Kim540c3e82015-11-06 11:20:12 +0900497 u8 wid_cnt = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900498
Leo Kim33110ad2015-10-29 11:58:27 +0900499 down(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900500
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900501 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
502
Leo Kim02ae2bd2015-11-05 14:36:07 +0900503 if (cfg_param_attr->cfg_attr_info.flag & BSS_TYPE) {
504 if (cfg_param_attr->cfg_attr_info.bss_type < 6) {
Leo Kim540c3e82015-11-06 11:20:12 +0900505 wid_list[wid_cnt].id = WID_BSS_TYPE;
506 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.bss_type;
507 wid_list[wid_cnt].type = WID_CHAR;
508 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900509 hif_drv->cfg_values.bss_type = (u8)cfg_param_attr->cfg_attr_info.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900510 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900511 PRINT_ER("check value 6 over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900512 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900513 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900514 }
Leo Kim540c3e82015-11-06 11:20:12 +0900515 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900516 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900517 if (cfg_param_attr->cfg_attr_info.flag & AUTH_TYPE) {
518 if (cfg_param_attr->cfg_attr_info.auth_type == 1 ||
519 cfg_param_attr->cfg_attr_info.auth_type == 2 ||
520 cfg_param_attr->cfg_attr_info.auth_type == 5) {
Leo Kim540c3e82015-11-06 11:20:12 +0900521 wid_list[wid_cnt].id = WID_AUTH_TYPE;
522 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.auth_type;
523 wid_list[wid_cnt].type = WID_CHAR;
524 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900525 hif_drv->cfg_values.auth_type = (u8)cfg_param_attr->cfg_attr_info.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900526 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900527 PRINT_ER("Impossible value \n");
Leo Kim31390ee2015-10-19 18:26:08 +0900528 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900529 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900530 }
Leo Kim540c3e82015-11-06 11:20:12 +0900531 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900532 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900533 if (cfg_param_attr->cfg_attr_info.flag & AUTHEN_TIMEOUT) {
534 if (cfg_param_attr->cfg_attr_info.auth_timeout > 0 &&
535 cfg_param_attr->cfg_attr_info.auth_timeout < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900536 wid_list[wid_cnt].id = WID_AUTH_TIMEOUT;
537 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.auth_timeout;
538 wid_list[wid_cnt].type = WID_SHORT;
539 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900540 hif_drv->cfg_values.auth_timeout = cfg_param_attr->cfg_attr_info.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900541 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900542 PRINT_ER("Range(1 ~ 65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900543 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900544 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900545 }
Leo Kim540c3e82015-11-06 11:20:12 +0900546 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900547 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900548 if (cfg_param_attr->cfg_attr_info.flag & POWER_MANAGEMENT) {
549 if (cfg_param_attr->cfg_attr_info.power_mgmt_mode < 5) {
Leo Kim540c3e82015-11-06 11:20:12 +0900550 wid_list[wid_cnt].id = WID_POWER_MANAGEMENT;
551 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.power_mgmt_mode;
552 wid_list[wid_cnt].type = WID_CHAR;
553 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900554 hif_drv->cfg_values.power_mgmt_mode = (u8)cfg_param_attr->cfg_attr_info.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900555 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900556 PRINT_ER("Invalide power mode\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900557 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900558 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900559 }
Leo Kim540c3e82015-11-06 11:20:12 +0900560 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900561 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900562 if (cfg_param_attr->cfg_attr_info.flag & RETRY_SHORT) {
563 if (cfg_param_attr->cfg_attr_info.short_retry_limit > 0 &&
564 cfg_param_attr->cfg_attr_info.short_retry_limit < 256) {
Leo Kim540c3e82015-11-06 11:20:12 +0900565 wid_list[wid_cnt].id = WID_SHORT_RETRY_LIMIT;
566 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.short_retry_limit;
567 wid_list[wid_cnt].type = WID_SHORT;
568 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900569 hif_drv->cfg_values.short_retry_limit = cfg_param_attr->cfg_attr_info.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900570 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900571 PRINT_ER("Range(1~256) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900572 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900573 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900574 }
Leo Kim540c3e82015-11-06 11:20:12 +0900575 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900576 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900577 if (cfg_param_attr->cfg_attr_info.flag & RETRY_LONG) {
578 if (cfg_param_attr->cfg_attr_info.long_retry_limit > 0 &&
579 cfg_param_attr->cfg_attr_info.long_retry_limit < 256) {
Leo Kim540c3e82015-11-06 11:20:12 +0900580 wid_list[wid_cnt].id = WID_LONG_RETRY_LIMIT;
581 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.long_retry_limit;
582 wid_list[wid_cnt].type = WID_SHORT;
583 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900584 hif_drv->cfg_values.long_retry_limit = cfg_param_attr->cfg_attr_info.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900585 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900586 PRINT_ER("Range(1~256) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900587 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900588 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900589 }
Leo Kim540c3e82015-11-06 11:20:12 +0900590 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900591 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900592 if (cfg_param_attr->cfg_attr_info.flag & FRAG_THRESHOLD) {
593 if (cfg_param_attr->cfg_attr_info.frag_threshold > 255 &&
594 cfg_param_attr->cfg_attr_info.frag_threshold < 7937) {
Leo Kim540c3e82015-11-06 11:20:12 +0900595 wid_list[wid_cnt].id = WID_FRAG_THRESHOLD;
596 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.frag_threshold;
597 wid_list[wid_cnt].type = WID_SHORT;
598 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900599 hif_drv->cfg_values.frag_threshold = cfg_param_attr->cfg_attr_info.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900600 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900601 PRINT_ER("Threshold Range fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900602 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900603 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900604 }
Leo Kim540c3e82015-11-06 11:20:12 +0900605 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900606 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900607 if (cfg_param_attr->cfg_attr_info.flag & RTS_THRESHOLD) {
608 if (cfg_param_attr->cfg_attr_info.rts_threshold > 255 &&
609 cfg_param_attr->cfg_attr_info.rts_threshold < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900610 wid_list[wid_cnt].id = WID_RTS_THRESHOLD;
611 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.rts_threshold;
612 wid_list[wid_cnt].type = WID_SHORT;
613 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900614 hif_drv->cfg_values.rts_threshold = cfg_param_attr->cfg_attr_info.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900615 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900616 PRINT_ER("Threshold Range fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900617 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900618 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900619 }
Leo Kim540c3e82015-11-06 11:20:12 +0900620 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900621 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900622 if (cfg_param_attr->cfg_attr_info.flag & PREAMBLE) {
623 if (cfg_param_attr->cfg_attr_info.preamble_type < 3) {
Leo Kim540c3e82015-11-06 11:20:12 +0900624 wid_list[wid_cnt].id = WID_PREAMBLE;
625 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.preamble_type;
626 wid_list[wid_cnt].type = WID_CHAR;
627 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900628 hif_drv->cfg_values.preamble_type = cfg_param_attr->cfg_attr_info.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900629 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900630 PRINT_ER("Preamle Range(0~2) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900631 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900632 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900633 }
Leo Kim540c3e82015-11-06 11:20:12 +0900634 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900635 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900636 if (cfg_param_attr->cfg_attr_info.flag & SHORT_SLOT_ALLOWED) {
637 if (cfg_param_attr->cfg_attr_info.short_slot_allowed < 2) {
Leo Kim540c3e82015-11-06 11:20:12 +0900638 wid_list[wid_cnt].id = WID_SHORT_SLOT_ALLOWED;
639 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.short_slot_allowed;
640 wid_list[wid_cnt].type = WID_CHAR;
641 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900642 hif_drv->cfg_values.short_slot_allowed = (u8)cfg_param_attr->cfg_attr_info.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900643 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900644 PRINT_ER("Short slot(2) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900645 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900646 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900647 }
Leo Kim540c3e82015-11-06 11:20:12 +0900648 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900649 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900650 if (cfg_param_attr->cfg_attr_info.flag & TXOP_PROT_DISABLE) {
651 if (cfg_param_attr->cfg_attr_info.txop_prot_disabled < 2) {
Leo Kim540c3e82015-11-06 11:20:12 +0900652 wid_list[wid_cnt].id = WID_11N_TXOP_PROT_DISABLE;
653 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.txop_prot_disabled;
654 wid_list[wid_cnt].type = WID_CHAR;
655 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900656 hif_drv->cfg_values.txop_prot_disabled = (u8)cfg_param_attr->cfg_attr_info.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900657 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900658 PRINT_ER("TXOP prot disable\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900659 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900660 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900661 }
Leo Kim540c3e82015-11-06 11:20:12 +0900662 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900663 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900664 if (cfg_param_attr->cfg_attr_info.flag & BEACON_INTERVAL) {
665 if (cfg_param_attr->cfg_attr_info.beacon_interval > 0 &&
666 cfg_param_attr->cfg_attr_info.beacon_interval < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900667 wid_list[wid_cnt].id = WID_BEACON_INTERVAL;
668 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.beacon_interval;
669 wid_list[wid_cnt].type = WID_SHORT;
670 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900671 hif_drv->cfg_values.beacon_interval = cfg_param_attr->cfg_attr_info.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900672 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900673 PRINT_ER("Beacon interval(1~65535) fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900674 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900675 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900676 }
Leo Kim540c3e82015-11-06 11:20:12 +0900677 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900678 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900679 if (cfg_param_attr->cfg_attr_info.flag & DTIM_PERIOD) {
680 if (cfg_param_attr->cfg_attr_info.dtim_period > 0 &&
681 cfg_param_attr->cfg_attr_info.dtim_period < 256) {
Leo Kim540c3e82015-11-06 11:20:12 +0900682 wid_list[wid_cnt].id = WID_DTIM_PERIOD;
683 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.dtim_period;
684 wid_list[wid_cnt].type = WID_CHAR;
685 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900686 hif_drv->cfg_values.dtim_period = cfg_param_attr->cfg_attr_info.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900687 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900688 PRINT_ER("DTIM range(1~255) fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900689 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900690 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900691 }
Leo Kim540c3e82015-11-06 11:20:12 +0900692 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900693 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900694 if (cfg_param_attr->cfg_attr_info.flag & SITE_SURVEY) {
695 if (cfg_param_attr->cfg_attr_info.site_survey_enabled < 3) {
Leo Kim540c3e82015-11-06 11:20:12 +0900696 wid_list[wid_cnt].id = WID_SITE_SURVEY;
697 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.site_survey_enabled;
698 wid_list[wid_cnt].type = WID_CHAR;
699 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900700 hif_drv->cfg_values.site_survey_enabled = (u8)cfg_param_attr->cfg_attr_info.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900701 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900702 PRINT_ER("Site survey disable\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900703 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900704 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900705 }
Leo Kim540c3e82015-11-06 11:20:12 +0900706 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900707 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900708 if (cfg_param_attr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) {
709 if (cfg_param_attr->cfg_attr_info.site_survey_scan_time > 0 &&
710 cfg_param_attr->cfg_attr_info.site_survey_scan_time < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900711 wid_list[wid_cnt].id = WID_SITE_SURVEY_SCAN_TIME;
712 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.site_survey_scan_time;
713 wid_list[wid_cnt].type = WID_SHORT;
714 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900715 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 +0900716 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900717 PRINT_ER("Site survey scan time(1~65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900718 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900719 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900720 }
Leo Kim540c3e82015-11-06 11:20:12 +0900721 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900722 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900723 if (cfg_param_attr->cfg_attr_info.flag & ACTIVE_SCANTIME) {
724 if (cfg_param_attr->cfg_attr_info.active_scan_time > 0 &&
725 cfg_param_attr->cfg_attr_info.active_scan_time < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900726 wid_list[wid_cnt].id = WID_ACTIVE_SCAN_TIME;
727 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.active_scan_time;
728 wid_list[wid_cnt].type = WID_SHORT;
729 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900730 hif_drv->cfg_values.active_scan_time = cfg_param_attr->cfg_attr_info.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900731 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900732 PRINT_ER("Active scan time(1~65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900733 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900734 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900735 }
Leo Kim540c3e82015-11-06 11:20:12 +0900736 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900737 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900738 if (cfg_param_attr->cfg_attr_info.flag & PASSIVE_SCANTIME) {
739 if (cfg_param_attr->cfg_attr_info.passive_scan_time > 0 &&
740 cfg_param_attr->cfg_attr_info.passive_scan_time < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900741 wid_list[wid_cnt].id = WID_PASSIVE_SCAN_TIME;
742 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.passive_scan_time;
743 wid_list[wid_cnt].type = WID_SHORT;
744 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900745 hif_drv->cfg_values.passive_scan_time = cfg_param_attr->cfg_attr_info.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900746 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900747 PRINT_ER("Passive scan time(1~65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900748 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900749 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900750 }
Leo Kim540c3e82015-11-06 11:20:12 +0900751 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900752 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900753 if (cfg_param_attr->cfg_attr_info.flag & CURRENT_TX_RATE) {
754 enum CURRENT_TXRATE curr_tx_rate = cfg_param_attr->cfg_attr_info.curr_tx_rate;
Leo Kimc09389a2015-10-28 15:59:24 +0900755
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900756 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
757 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
758 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
759 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
760 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
761 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
Leo Kim540c3e82015-11-06 11:20:12 +0900762 wid_list[wid_cnt].id = WID_CURRENT_TX_RATE;
763 wid_list[wid_cnt].val = (s8 *)&curr_tx_rate;
764 wid_list[wid_cnt].type = WID_SHORT;
765 wid_list[wid_cnt].size = sizeof(u16);
Leo Kimace303f2015-10-29 11:58:26 +0900766 hif_drv->cfg_values.curr_tx_rate = (u8)curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900767 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900768 PRINT_ER("out of TX rate\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900769 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900770 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900771 }
Leo Kim540c3e82015-11-06 11:20:12 +0900772 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900773 }
Leo Kim31390ee2015-10-19 18:26:08 +0900774
Glen Leecd2920a2015-12-21 14:18:48 +0900775 result = wilc_send_config_pkt(vif->wilc, SET_CFG, wid_list,
Glen Leeeb9939b2015-12-21 14:18:43 +0900776 wid_cnt, wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900777
Leo Kim31390ee2015-10-19 18:26:08 +0900778 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900779 PRINT_ER("Error in setting CFG params\n");
780
Leo Kim24db7132015-09-16 18:36:01 +0900781ERRORHANDLER:
Leo Kim33110ad2015-10-29 11:58:27 +0900782 up(&hif_drv->sem_cfg_values);
Leo Kim31390ee2015-10-19 18:26:08 +0900783 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900784}
785
Leo Kim3b840e42015-11-05 14:36:08 +0900786static void Handle_wait_msg_q_empty(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900787{
Arnd Bergmann0e1af732015-11-16 15:04:54 +0100788 wilc_initialized = 0;
Leo Kim2d25af82015-10-15 13:24:56 +0900789 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900790}
791
Glen Lee71130e82015-12-21 14:18:41 +0900792static s32 Handle_ScanDone(struct wilc_vif *vif,
Arnd Bergmann1608c402015-11-16 15:04:53 +0100793 enum scan_event enuEvent);
794
Glen Lee71130e82015-12-21 14:18:41 +0900795static s32 Handle_Scan(struct wilc_vif *vif,
Tony Choc476feb2015-09-21 12:16:36 +0900796 struct scan_attr *pstrHostIFscanAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900797{
Leo Kim31390ee2015-10-19 18:26:08 +0900798 s32 result = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900799 struct wid strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900800 u32 u32WidsCount = 0;
801 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900802 u8 *pu8Buffer;
803 u8 valuesize = 0;
804 u8 *pu8HdnNtwrksWidVal = NULL;
Glen Lee71130e82015-12-21 14:18:41 +0900805 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900806
807 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
Leo Kimb60005a2015-10-29 11:58:24 +0900808 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", hif_drv->hif_state);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900809
Leo Kimbc801852015-10-29 11:58:50 +0900810 hif_drv->usr_scan_req.scan_result = pstrHostIFscanAttr->result;
Leo Kim66eaea32015-10-29 11:58:51 +0900811 hif_drv->usr_scan_req.arg = pstrHostIFscanAttr->arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900812
Leo Kimb60005a2015-10-29 11:58:24 +0900813 if ((hif_drv->hif_state >= HOST_IF_SCANNING) &&
814 (hif_drv->hif_state < HOST_IF_CONNECTED)) {
815 PRINT_D(GENERIC_DBG, "Don't scan already in [%d] state\n",
816 hif_drv->hif_state);
Leo Kim24db7132015-09-16 18:36:01 +0900817 PRINT_ER("Already scan\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900818 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +0900819 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900820 }
821
Arnd Bergmann0e1af732015-11-16 15:04:54 +0100822 if (wilc_optaining_ip || wilc_connecting) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900823 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +0900824 PRINT_ER("Don't do obss scan\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900825 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +0900826 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900827 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900828
829 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
830
Leo Kimf79756e2015-10-29 12:05:36 +0900831 hif_drv->usr_scan_req.rcvd_ch_cnt = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900832
Leo Kimdaaf16b2015-10-12 16:55:44 +0900833 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
Leo Kim416d8322015-10-12 16:55:43 +0900834 strWIDList[u32WidsCount].type = WID_STR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900835
Leo Kim629b9ca2015-10-13 19:49:46 +0900836 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++)
837 valuesize += ((pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
Glen Leef3052582015-09-10 12:03:04 +0900838 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
Leo Kim900bb4a2015-10-12 16:55:46 +0900839 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
Leo Kim91109e12015-10-19 18:26:13 +0900840 if (strWIDList[u32WidsCount].val) {
Leo Kim900bb4a2015-10-12 16:55:46 +0900841 pu8Buffer = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900842
Leo Kim629b9ca2015-10-13 19:49:46 +0900843 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900844
Leo Kim629b9ca2015-10-13 19:49:46 +0900845 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->hidden_network.u8ssidnum);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900846
Leo Kim629b9ca2015-10-13 19:49:46 +0900847 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++) {
848 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
849 memcpy(pu8Buffer, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen);
850 pu8Buffer += pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900851 }
852
Leo Kim2fd3e442015-10-12 16:55:45 +0900853 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900854 u32WidsCount++;
855 }
856
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900857 {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900858 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
Leo Kim416d8322015-10-12 16:55:43 +0900859 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kimd6f19aa2015-10-13 19:49:42 +0900860 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ies;
Leo Kim7b1f76c2015-10-13 19:49:43 +0900861 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ies_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900862 u32WidsCount++;
863 }
864
Leo Kimdaaf16b2015-10-12 16:55:44 +0900865 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +0900866 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900867 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +0900868 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900869 u32WidsCount++;
870
Leo Kimdaaf16b2015-10-12 16:55:44 +0900871 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
Leo Kim416d8322015-10-12 16:55:43 +0900872 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900873
Leo Kim91109e12015-10-19 18:26:13 +0900874 if (pstrHostIFscanAttr->ch_freq_list &&
875 pstrHostIFscanAttr->ch_list_len > 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900876 int i;
877
Leo Kimf97bd9c2015-10-13 19:49:41 +0900878 for (i = 0; i < pstrHostIFscanAttr->ch_list_len; i++) {
Leo Kim82eeb0a2015-10-13 19:49:40 +0900879 if (pstrHostIFscanAttr->ch_freq_list[i] > 0)
880 pstrHostIFscanAttr->ch_freq_list[i] = pstrHostIFscanAttr->ch_freq_list[i] - 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900881 }
882 }
883
Leo Kim82eeb0a2015-10-13 19:49:40 +0900884 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
Leo Kimf97bd9c2015-10-13 19:49:41 +0900885 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900886 u32WidsCount++;
887
Leo Kimdaaf16b2015-10-12 16:55:44 +0900888 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
Leo Kim416d8322015-10-12 16:55:43 +0900889 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900890 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +0900891 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->src;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900892 u32WidsCount++;
893
Leo Kimb60005a2015-10-29 11:58:24 +0900894 if (hif_drv->hif_state == HOST_IF_CONNECTED)
Leo Kimca8540e42015-10-15 13:25:00 +0900895 scan_while_connected = true;
Leo Kimb60005a2015-10-29 11:58:24 +0900896 else if (hif_drv->hif_state == HOST_IF_IDLE)
Leo Kimca8540e42015-10-15 13:25:00 +0900897 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900898
Glen Leecd2920a2015-12-21 14:18:48 +0900899 result = wilc_send_config_pkt(vif->wilc, SET_CFG, strWIDList,
Glen Leeec62e6d2015-11-18 15:11:33 +0900900 u32WidsCount,
Glen Leeeb9939b2015-12-21 14:18:43 +0900901 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900902
Leo Kim31390ee2015-10-19 18:26:08 +0900903 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900904 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +0900905 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900906 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900907
Leo Kim24db7132015-09-16 18:36:01 +0900908ERRORHANDLER:
Leo Kim31390ee2015-10-19 18:26:08 +0900909 if (result) {
Leo Kim13b313e2015-10-29 11:58:34 +0900910 del_timer(&hif_drv->scan_timer);
Glen Lee71130e82015-12-21 14:18:41 +0900911 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900912 }
913
Shraddha Barke95f840f2015-10-14 07:29:19 +0530914 kfree(pstrHostIFscanAttr->ch_freq_list);
915 pstrHostIFscanAttr->ch_freq_list = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900916
Shraddha Barke95f840f2015-10-14 07:29:19 +0530917 kfree(pstrHostIFscanAttr->ies);
918 pstrHostIFscanAttr->ies = NULL;
919 kfree(pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo);
920 pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900921
Shraddha Barke95f840f2015-10-14 07:29:19 +0530922 kfree(pu8HdnNtwrksWidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900923
Leo Kim31390ee2015-10-19 18:26:08 +0900924 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900925}
926
Glen Lee71130e82015-12-21 14:18:41 +0900927static s32 Handle_ScanDone(struct wilc_vif *vif,
Tony Choa4ab1ad2015-10-12 16:56:05 +0900928 enum scan_event enuEvent)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900929{
Leo Kim31390ee2015-10-19 18:26:08 +0900930 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900931 u8 u8abort_running_scan;
Leo Kim45102f82015-10-28 15:59:28 +0900932 struct wid wid;
Glen Lee71130e82015-12-21 14:18:41 +0900933 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900934
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900935 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
936
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900937 if (enuEvent == SCAN_EVENT_ABORTED) {
938 PRINT_D(GENERIC_DBG, "Abort running scan\n");
939 u8abort_running_scan = 1;
Leo Kim45102f82015-10-28 15:59:28 +0900940 wid.id = (u16)WID_ABORT_RUNNING_SCAN;
941 wid.type = WID_CHAR;
942 wid.val = (s8 *)&u8abort_running_scan;
943 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900944
Glen Leecd2920a2015-12-21 14:18:48 +0900945 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +0900946 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +0900947
948 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900949 PRINT_ER("Failed to set abort running scan\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900950 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900951 }
952 }
953
Tony Choa4ab1ad2015-10-12 16:56:05 +0900954 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900955 PRINT_ER("Driver handler is NULL\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900956 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900957 }
958
Leo Kimbc801852015-10-29 11:58:50 +0900959 if (hif_drv->usr_scan_req.scan_result) {
960 hif_drv->usr_scan_req.scan_result(enuEvent, NULL,
Leo Kim66eaea32015-10-29 11:58:51 +0900961 hif_drv->usr_scan_req.arg, NULL);
Leo Kimbc801852015-10-29 11:58:50 +0900962 hif_drv->usr_scan_req.scan_result = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900963 }
964
Leo Kim31390ee2015-10-19 18:26:08 +0900965 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900966}
967
Leo Kime554a302015-11-19 15:56:21 +0900968u8 wilc_connected_ssid[6] = {0};
Glen Lee71130e82015-12-21 14:18:41 +0900969static s32 Handle_Connect(struct wilc_vif *vif,
Tony Cho120ae592015-09-21 12:16:37 +0900970 struct connect_attr *pstrHostIFconnectAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900971{
Leo Kim31390ee2015-10-19 18:26:08 +0900972 s32 result = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900973 struct wid strWIDList[8];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900974 u32 u32WidsCount = 0, dummyval = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900975 u8 *pu8CurrByte = NULL;
Leo Kime0a12212015-10-12 16:55:49 +0900976 struct join_bss_param *ptstrJoinBssParam;
Glen Lee71130e82015-12-21 14:18:41 +0900977 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900978
979 PRINT_D(GENERIC_DBG, "Handling connect request\n");
980
Leo Kime554a302015-11-19 15:56:21 +0900981 if (memcmp(pstrHostIFconnectAttr->bssid, wilc_connected_ssid, ETH_ALEN) == 0) {
Leo Kim31390ee2015-10-19 18:26:08 +0900982 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900983 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900984 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900985 }
986
987 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
988
Leo Kimf2bed2c2015-10-13 19:49:59 +0900989 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->params;
Leo Kim91109e12015-10-19 18:26:13 +0900990 if (!ptstrJoinBssParam) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900991 PRINT_ER("Required BSSID not found\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900992 result = -ENOENT;
Leo Kim24db7132015-09-16 18:36:01 +0900993 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900994 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900995
Leo Kim91109e12015-10-19 18:26:13 +0900996 if (pstrHostIFconnectAttr->bssid) {
Leo Kimf8b17132015-10-28 15:59:34 +0900997 hif_drv->usr_conn_req.pu8bssid = kmalloc(6, GFP_KERNEL);
998 memcpy(hif_drv->usr_conn_req.pu8bssid, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900999 }
1000
Leo Kim74ab5e42015-10-29 11:58:53 +09001001 hif_drv->usr_conn_req.ssid_len = pstrHostIFconnectAttr->ssid_len;
Leo Kim91109e12015-10-19 18:26:13 +09001002 if (pstrHostIFconnectAttr->ssid) {
Leo Kimf8b17132015-10-28 15:59:34 +09001003 hif_drv->usr_conn_req.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
1004 memcpy(hif_drv->usr_conn_req.pu8ssid,
Leo Kim8c8360b2015-10-19 18:26:12 +09001005 pstrHostIFconnectAttr->ssid,
1006 pstrHostIFconnectAttr->ssid_len);
Leo Kimf8b17132015-10-28 15:59:34 +09001007 hif_drv->usr_conn_req.pu8ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001008 }
1009
Leo Kim331ed082015-10-29 11:58:55 +09001010 hif_drv->usr_conn_req.ies_len = pstrHostIFconnectAttr->ies_len;
Leo Kim91109e12015-10-19 18:26:13 +09001011 if (pstrHostIFconnectAttr->ies) {
Leo Kima3b2f4b2015-10-29 11:58:54 +09001012 hif_drv->usr_conn_req.ies = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1013 memcpy(hif_drv->usr_conn_req.ies,
Leo Kim8c8360b2015-10-19 18:26:12 +09001014 pstrHostIFconnectAttr->ies,
1015 pstrHostIFconnectAttr->ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001016 }
1017
Leo Kimf8b17132015-10-28 15:59:34 +09001018 hif_drv->usr_conn_req.u8security = pstrHostIFconnectAttr->security;
Leo Kim7d069722015-10-29 12:05:37 +09001019 hif_drv->usr_conn_req.auth_type = pstrHostIFconnectAttr->auth_type;
Leo Kim33bfb192015-10-29 11:58:56 +09001020 hif_drv->usr_conn_req.conn_result = pstrHostIFconnectAttr->result;
Leo Kim73abaa42015-10-29 12:05:27 +09001021 hif_drv->usr_conn_req.arg = pstrHostIFconnectAttr->arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001022
Leo Kimdaaf16b2015-10-12 16:55:44 +09001023 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001024 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001025 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001026 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001027 u32WidsCount++;
1028
Leo Kimdaaf16b2015-10-12 16:55:44 +09001029 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001030 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001031 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001032 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001033 u32WidsCount++;
1034
Leo Kimdaaf16b2015-10-12 16:55:44 +09001035 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001036 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001037 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001038 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001039 u32WidsCount++;
1040
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001041 {
Leo Kimdaaf16b2015-10-12 16:55:44 +09001042 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
Leo Kim416d8322015-10-12 16:55:43 +09001043 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001044 strWIDList[u32WidsCount].val = hif_drv->usr_conn_req.ies;
Leo Kim331ed082015-10-29 11:58:55 +09001045 strWIDList[u32WidsCount].size = hif_drv->usr_conn_req.ies_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001046 u32WidsCount++;
1047
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001048 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Leo Kim331ed082015-10-29 11:58:55 +09001049 info_element_size = hif_drv->usr_conn_req.ies_len;
Leo Kimdfef7b82015-10-15 13:25:14 +09001050 info_element = kmalloc(info_element_size, GFP_KERNEL);
Leo Kima3b2f4b2015-10-29 11:58:54 +09001051 memcpy(info_element, hif_drv->usr_conn_req.ies,
Leo Kimdfef7b82015-10-15 13:25:14 +09001052 info_element_size);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001053 }
1054 }
Leo Kimdaaf16b2015-10-12 16:55:44 +09001055 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001056 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001057 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimf8b17132015-10-28 15:59:34 +09001058 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001059 u32WidsCount++;
1060
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001061 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
Leo Kimf8b17132015-10-28 15:59:34 +09001062 mode_11i = hif_drv->usr_conn_req.u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001063
Leo Kimf8b17132015-10-28 15:59:34 +09001064 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", hif_drv->usr_conn_req.u8security);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001065
Leo Kimdaaf16b2015-10-12 16:55:44 +09001066 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001067 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001068 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim7d069722015-10-29 12:05:37 +09001069 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001070 u32WidsCount++;
1071
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001072 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
Leo Kim7d069722015-10-29 12:05:37 +09001073 auth_type = (u8)hif_drv->usr_conn_req.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001074
Leo Kim7d069722015-10-29 12:05:37 +09001075 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n",
1076 hif_drv->usr_conn_req.auth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001077 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
Leo Kimf8b17132015-10-28 15:59:34 +09001078 hif_drv->usr_conn_req.pu8ssid, pstrHostIFconnectAttr->ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001079
Leo Kimdaaf16b2015-10-12 16:55:44 +09001080 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
Leo Kim416d8322015-10-12 16:55:43 +09001081 strWIDList[u32WidsCount].type = WID_STR;
Leo Kimae4dfa52015-10-13 19:49:26 +09001082 strWIDList[u32WidsCount].size = 112;
Leo Kim900bb4a2015-10-12 16:55:46 +09001083 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001084
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001085 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Leo Kim0626baa2015-10-15 13:25:13 +09001086 join_req_size = strWIDList[u32WidsCount].size;
1087 join_req = kmalloc(join_req_size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001088 }
Leo Kim91109e12015-10-19 18:26:13 +09001089 if (!strWIDList[u32WidsCount].val) {
Leo Kim31390ee2015-10-19 18:26:08 +09001090 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09001091 goto ERRORHANDLER;
1092 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001093
Leo Kim900bb4a2015-10-12 16:55:46 +09001094 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001095
Leo Kim91109e12015-10-19 18:26:13 +09001096 if (pstrHostIFconnectAttr->ssid) {
Leo Kim8b3c9fa2015-10-13 19:49:51 +09001097 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1098 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001099 }
1100 pu8CurrByte += MAX_SSID_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001101 *(pu8CurrByte++) = INFRASTRUCTURE;
Leo Kimae4dfa52015-10-13 19:49:26 +09001102
Leo Kim0d1527e2015-10-13 19:49:58 +09001103 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1104 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001105 } else {
1106 PRINT_ER("Channel out of range\n");
1107 *(pu8CurrByte++) = 0xFF;
1108 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001109 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1110 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1111 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1112
Leo Kim91109e12015-10-19 18:26:13 +09001113 if (pstrHostIFconnectAttr->bssid)
Leo Kim9254db02015-10-13 19:49:49 +09001114 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001115 pu8CurrByte += 6;
1116
Tony Choc0f52fb2015-10-20 17:10:46 +09001117 if (pstrHostIFconnectAttr->bssid)
1118 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1119 pu8CurrByte += 6;
1120
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001121 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1122 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1123 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001124 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1125 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
Leo Kimae4dfa52015-10-13 19:49:26 +09001126
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001127 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001128 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1129
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001130 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1131 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001132 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1133
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001134 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
Leo Kimff069822015-10-29 12:05:26 +09001135 hif_drv->usr_conn_req.ht_capable = ptstrJoinBssParam->ht_capable;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001136
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001137 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1138 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001139 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1140 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001141 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1142 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
Leo Kimae4dfa52015-10-13 19:49:26 +09001143
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001144 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001145 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1146
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001147 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001148 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1149
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001150 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001151 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1152
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001153 *(pu8CurrByte++) = REAL_JOIN_REQ;
Leo Kim7a8d51d2015-10-15 13:24:43 +09001154 *(pu8CurrByte++) = ptstrJoinBssParam->noa_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001155
Leo Kim7a8d51d2015-10-15 13:24:43 +09001156 if (ptstrJoinBssParam->noa_enabled) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001157 PRINT_D(HOSTINF_DBG, "NOA present\n");
1158
1159 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1160 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1161 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1162 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1163
Leo Kimd72b33c2015-10-15 13:24:44 +09001164 *(pu8CurrByte++) = ptstrJoinBssParam->opp_enabled;
Leo Kimcc179002015-10-15 13:24:47 +09001165 *(pu8CurrByte++) = ptstrJoinBssParam->idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001166
Leo Kimd72b33c2015-10-15 13:24:44 +09001167 if (ptstrJoinBssParam->opp_enabled)
Leo Kim99b66942015-10-15 13:24:45 +09001168 *(pu8CurrByte++) = ptstrJoinBssParam->ct_window;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001169
Leo Kimc21047e2015-10-15 13:24:46 +09001170 *(pu8CurrByte++) = ptstrJoinBssParam->cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001171
Leo Kim109e6ca2015-10-15 13:24:48 +09001172 memcpy(pu8CurrByte, ptstrJoinBssParam->duration, sizeof(ptstrJoinBssParam->duration));
1173 pu8CurrByte += sizeof(ptstrJoinBssParam->duration);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001174
Leo Kim1d8b76b2015-10-15 13:24:49 +09001175 memcpy(pu8CurrByte, ptstrJoinBssParam->interval, sizeof(ptstrJoinBssParam->interval));
1176 pu8CurrByte += sizeof(ptstrJoinBssParam->interval);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001177
Leo Kim4be55e22015-10-28 15:59:27 +09001178 memcpy(pu8CurrByte, ptstrJoinBssParam->start_time, sizeof(ptstrJoinBssParam->start_time));
1179 pu8CurrByte += sizeof(ptstrJoinBssParam->start_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001180 } else
1181 PRINT_D(HOSTINF_DBG, "NOA not present\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001182
Leo Kim900bb4a2015-10-12 16:55:46 +09001183 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001184 u32WidsCount++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001185
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001186 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Leo Kim0626baa2015-10-15 13:25:13 +09001187 memcpy(join_req, pu8CurrByte, join_req_size);
Glen Lee7036c622015-12-21 14:18:45 +09001188 join_req_vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001189 }
1190
1191 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1192
Leo Kim91109e12015-10-19 18:26:13 +09001193 if (pstrHostIFconnectAttr->bssid) {
Leo Kime554a302015-11-19 15:56:21 +09001194 memcpy(wilc_connected_ssid,
1195 pstrHostIFconnectAttr->bssid, ETH_ALEN);
1196 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n",
1197 pstrHostIFconnectAttr->bssid);
1198 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", wilc_connected_ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001199 }
1200
Glen Leecd2920a2015-12-21 14:18:48 +09001201 result = wilc_send_config_pkt(vif->wilc, SET_CFG, strWIDList,
Glen Leeec62e6d2015-11-18 15:11:33 +09001202 u32WidsCount,
Glen Leeeb9939b2015-12-21 14:18:43 +09001203 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09001204 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09001205 PRINT_ER("failed to send config packet\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001206 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09001207 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001208 } else {
1209 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
Leo Kimb60005a2015-10-29 11:58:24 +09001210 hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001211 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001212
Leo Kim24db7132015-09-16 18:36:01 +09001213ERRORHANDLER:
Leo Kim31390ee2015-10-19 18:26:08 +09001214 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001215 tstrConnectInfo strConnectInfo;
1216
Leo Kim81a59502015-10-29 11:58:35 +09001217 del_timer(&hif_drv->connect_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001218
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001219 PRINT_D(HOSTINF_DBG, "could not start wilc_connecting to the required network\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001220
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001221 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001222
Leo Kim91109e12015-10-19 18:26:13 +09001223 if (pstrHostIFconnectAttr->result) {
1224 if (pstrHostIFconnectAttr->bssid)
Leo Kim9254db02015-10-13 19:49:49 +09001225 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001226
Leo Kim91109e12015-10-19 18:26:13 +09001227 if (pstrHostIFconnectAttr->ies) {
Leo Kimb59d5c52015-10-13 19:49:53 +09001228 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->ies_len;
1229 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001230 memcpy(strConnectInfo.pu8ReqIEs,
Leo Kim8c8360b2015-10-19 18:26:12 +09001231 pstrHostIFconnectAttr->ies,
1232 pstrHostIFconnectAttr->ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001233 }
1234
Leo Kim6abcc112015-10-13 19:49:55 +09001235 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001236 &strConnectInfo,
1237 MAC_DISCONNECTED,
1238 NULL,
Leo Kim8f38db82015-10-13 19:49:56 +09001239 pstrHostIFconnectAttr->arg);
Leo Kimb60005a2015-10-29 11:58:24 +09001240 hif_drv->hif_state = HOST_IF_IDLE;
Shraddha Barke95f840f2015-10-14 07:29:19 +05301241 kfree(strConnectInfo.pu8ReqIEs);
1242 strConnectInfo.pu8ReqIEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001243
1244 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001245 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001246 }
1247 }
1248
1249 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
Shraddha Barke95f840f2015-10-14 07:29:19 +05301250 kfree(pstrHostIFconnectAttr->bssid);
1251 pstrHostIFconnectAttr->bssid = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001252
Shraddha Barke95f840f2015-10-14 07:29:19 +05301253 kfree(pstrHostIFconnectAttr->ssid);
1254 pstrHostIFconnectAttr->ssid = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001255
Shraddha Barke95f840f2015-10-14 07:29:19 +05301256 kfree(pstrHostIFconnectAttr->ies);
1257 pstrHostIFconnectAttr->ies = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001258
Shraddha Barke95f840f2015-10-14 07:29:19 +05301259 kfree(pu8CurrByte);
Leo Kim31390ee2015-10-19 18:26:08 +09001260 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001261}
1262
Glen Lee71130e82015-12-21 14:18:41 +09001263static s32 Handle_FlushConnect(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001264{
Leo Kim31390ee2015-10-19 18:26:08 +09001265 s32 result = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09001266 struct wid strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001267 u32 u32WidsCount = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001268 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001269
Leo Kimdaaf16b2015-10-12 16:55:44 +09001270 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
Leo Kim416d8322015-10-12 16:55:43 +09001271 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kim48ce2462015-10-15 13:25:10 +09001272 strWIDList[u32WidsCount].val = info_element;
Leo Kimdfef7b82015-10-15 13:25:14 +09001273 strWIDList[u32WidsCount].size = info_element_size;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001274 u32WidsCount++;
1275
Leo Kimdaaf16b2015-10-12 16:55:44 +09001276 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001277 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001278 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim1bd9d442015-10-15 13:25:11 +09001279 strWIDList[u32WidsCount].val = (s8 *)(&(mode_11i));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001280 u32WidsCount++;
1281
Leo Kimdaaf16b2015-10-12 16:55:44 +09001282 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001283 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001284 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimfba49892015-10-15 13:25:12 +09001285 strWIDList[u32WidsCount].val = (s8 *)(&auth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001286 u32WidsCount++;
1287
Leo Kimdaaf16b2015-10-12 16:55:44 +09001288 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
Leo Kim416d8322015-10-12 16:55:43 +09001289 strWIDList[u32WidsCount].type = WID_STR;
Leo Kim0626baa2015-10-15 13:25:13 +09001290 strWIDList[u32WidsCount].size = join_req_size;
Leo Kim044a64102015-10-15 13:25:09 +09001291 strWIDList[u32WidsCount].val = (s8 *)join_req;
Leo Kim900bb4a2015-10-12 16:55:46 +09001292 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001293
1294 pu8CurrByte += FLUSHED_BYTE_POS;
1295 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1296
1297 u32WidsCount++;
1298
Glen Leecd2920a2015-12-21 14:18:48 +09001299 result = wilc_send_config_pkt(vif->wilc, SET_CFG, strWIDList,
Glen Leeec62e6d2015-11-18 15:11:33 +09001300 u32WidsCount,
Glen Lee7036c622015-12-21 14:18:45 +09001301 wilc_get_vif_idx(join_req_vif));
Leo Kim31390ee2015-10-19 18:26:08 +09001302 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09001303 PRINT_ER("failed to send config packet\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001304 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001305 }
1306
Leo Kim31390ee2015-10-19 18:26:08 +09001307 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001308}
1309
Glen Lee71130e82015-12-21 14:18:41 +09001310static s32 Handle_ConnectTimeout(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001311{
Leo Kim31390ee2015-10-19 18:26:08 +09001312 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001313 tstrConnectInfo strConnectInfo;
Leo Kim45102f82015-10-28 15:59:28 +09001314 struct wid wid;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001315 u16 u16DummyReasonCode = 0;
Glen Lee71130e82015-12-21 14:18:41 +09001316 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001317
Tony Choa4ab1ad2015-10-12 16:56:05 +09001318 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001319 PRINT_ER("Driver handler is NULL\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001320 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001321 }
1322
Leo Kimb60005a2015-10-29 11:58:24 +09001323 hif_drv->hif_state = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001324
Leo Kimca8540e42015-10-15 13:25:00 +09001325 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001326
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001327 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001328
Leo Kim33bfb192015-10-29 11:58:56 +09001329 if (hif_drv->usr_conn_req.conn_result) {
Leo Kimf8b17132015-10-28 15:59:34 +09001330 if (hif_drv->usr_conn_req.pu8bssid) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001331 memcpy(strConnectInfo.au8bssid,
Leo Kimf8b17132015-10-28 15:59:34 +09001332 hif_drv->usr_conn_req.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001333 }
1334
Leo Kima3b2f4b2015-10-29 11:58:54 +09001335 if (hif_drv->usr_conn_req.ies) {
Leo Kim331ed082015-10-29 11:58:55 +09001336 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len;
1337 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001338 memcpy(strConnectInfo.pu8ReqIEs,
Leo Kima3b2f4b2015-10-29 11:58:54 +09001339 hif_drv->usr_conn_req.ies,
Leo Kim331ed082015-10-29 11:58:55 +09001340 hif_drv->usr_conn_req.ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001341 }
1342
Leo Kim33bfb192015-10-29 11:58:56 +09001343 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1344 &strConnectInfo,
1345 MAC_DISCONNECTED,
1346 NULL,
Leo Kim73abaa42015-10-29 12:05:27 +09001347 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001348
Shraddha Barke95f840f2015-10-14 07:29:19 +05301349 kfree(strConnectInfo.pu8ReqIEs);
1350 strConnectInfo.pu8ReqIEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001351 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001352 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001353 }
1354
Leo Kim45102f82015-10-28 15:59:28 +09001355 wid.id = (u16)WID_DISCONNECT;
1356 wid.type = WID_CHAR;
1357 wid.val = (s8 *)&u16DummyReasonCode;
1358 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001359
1360 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1361
Glen Leecd2920a2015-12-21 14:18:48 +09001362 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09001363 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09001364 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001365 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001366
Leo Kim74ab5e42015-10-29 11:58:53 +09001367 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09001368 kfree(hif_drv->usr_conn_req.pu8ssid);
Glen Leecc28e4b2015-12-18 18:26:02 +09001369 hif_drv->usr_conn_req.pu8ssid = NULL;
Leo Kimf8b17132015-10-28 15:59:34 +09001370 kfree(hif_drv->usr_conn_req.pu8bssid);
Glen Leecc28e4b2015-12-18 18:26:02 +09001371 hif_drv->usr_conn_req.pu8bssid = NULL;
Leo Kim331ed082015-10-29 11:58:55 +09001372 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001373 kfree(hif_drv->usr_conn_req.ies);
Glen Leecc28e4b2015-12-18 18:26:02 +09001374 hif_drv->usr_conn_req.ies = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001375
Leo Kime554a302015-11-19 15:56:21 +09001376 eth_zero_addr(wilc_connected_ssid);
Leo Kimae4dfa52015-10-13 19:49:26 +09001377
Glen Lee7036c622015-12-21 14:18:45 +09001378 if (join_req && join_req_vif == vif) {
Leo Kim044a64102015-10-15 13:25:09 +09001379 kfree(join_req);
1380 join_req = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001381 }
Leo Kim48ce2462015-10-15 13:25:10 +09001382
Glen Lee7036c622015-12-21 14:18:45 +09001383 if (info_element && join_req_vif == vif) {
Leo Kim48ce2462015-10-15 13:25:10 +09001384 kfree(info_element);
1385 info_element = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001386 }
1387
Leo Kim31390ee2015-10-19 18:26:08 +09001388 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001389}
1390
Glen Lee71130e82015-12-21 14:18:41 +09001391static s32 Handle_RcvdNtwrkInfo(struct wilc_vif *vif,
Tony Cho3bbd59f2015-09-21 12:16:38 +09001392 struct rcvd_net_info *pstrRcvdNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001393{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001394 u32 i;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001395 bool bNewNtwrkFound;
Leo Kim31390ee2015-10-19 18:26:08 +09001396 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001397 tstrNetworkInfo *pstrNetworkInfo = NULL;
1398 void *pJoinParams = NULL;
Glen Lee71130e82015-12-21 14:18:41 +09001399 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001400
Dean Lee72ed4dc2015-06-12 14:11:44 +09001401 bNewNtwrkFound = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001402 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1403
Leo Kimbc801852015-10-29 11:58:50 +09001404 if (hif_drv->usr_scan_req.scan_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001405 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001406 wilc_parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo);
Leo Kim91109e12015-10-19 18:26:13 +09001407 if ((!pstrNetworkInfo) ||
Leo Kimbc801852015-10-29 11:58:50 +09001408 (!hif_drv->usr_scan_req.scan_result)) {
Leo Kim24db7132015-09-16 18:36:01 +09001409 PRINT_ER("driver is null\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001410 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +09001411 goto done;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001412 }
1413
Leo Kimf79756e2015-10-29 12:05:36 +09001414 for (i = 0; i < hif_drv->usr_scan_req.rcvd_ch_cnt; i++) {
Leo Kimaf973f32015-10-29 11:58:52 +09001415 if ((hif_drv->usr_scan_req.net_info[i].au8bssid) &&
Leo Kim91109e12015-10-19 18:26:13 +09001416 (pstrNetworkInfo->au8bssid)) {
Leo Kimaf973f32015-10-29 11:58:52 +09001417 if (memcmp(hif_drv->usr_scan_req.net_info[i].au8bssid,
Leo Kim8c8360b2015-10-19 18:26:12 +09001418 pstrNetworkInfo->au8bssid, 6) == 0) {
Leo Kimaf973f32015-10-29 11:58:52 +09001419 if (pstrNetworkInfo->s8rssi <= hif_drv->usr_scan_req.net_info[i].s8rssi) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001420 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
1421 goto done;
1422 } else {
Leo Kimaf973f32015-10-29 11:58:52 +09001423 hif_drv->usr_scan_req.net_info[i].s8rssi = pstrNetworkInfo->s8rssi;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001424 bNewNtwrkFound = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001425 break;
1426 }
1427 }
1428 }
1429 }
1430
Punit Vara047e6642015-10-25 04:01:25 +05301431 if (bNewNtwrkFound) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001432 PRINT_D(HOSTINF_DBG, "New network found\n");
1433
Leo Kimf79756e2015-10-29 12:05:36 +09001434 if (hif_drv->usr_scan_req.rcvd_ch_cnt < MAX_NUM_SCANNED_NETWORKS) {
1435 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 +09001436
Leo Kimf79756e2015-10-29 12:05:36 +09001437 if (hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].au8bssid &&
Leo Kim91109e12015-10-19 18:26:13 +09001438 pstrNetworkInfo->au8bssid) {
Leo Kimf79756e2015-10-29 12:05:36 +09001439 memcpy(hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].au8bssid,
Leo Kim8c8360b2015-10-19 18:26:12 +09001440 pstrNetworkInfo->au8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001441
Leo Kimf79756e2015-10-29 12:05:36 +09001442 hif_drv->usr_scan_req.rcvd_ch_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001443
Dean Lee72ed4dc2015-06-12 14:11:44 +09001444 pstrNetworkInfo->bNewNetwork = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001445 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001446
Leo Kimbc801852015-10-29 11:58:50 +09001447 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
Leo Kim66eaea32015-10-29 11:58:51 +09001448 hif_drv->usr_scan_req.arg,
Leo Kimbc801852015-10-29 11:58:50 +09001449 pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001450 }
1451 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001452 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001453 }
1454 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001455 pstrNetworkInfo->bNewNetwork = false;
Leo Kimbc801852015-10-29 11:58:50 +09001456 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
Leo Kim66eaea32015-10-29 11:58:51 +09001457 hif_drv->usr_scan_req.arg, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001458 }
1459 }
1460
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001461done:
Shraddha Barke95f840f2015-10-14 07:29:19 +05301462 kfree(pstrRcvdNetworkInfo->buffer);
1463 pstrRcvdNetworkInfo->buffer = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001464
Leo Kim91109e12015-10-19 18:26:13 +09001465 if (pstrNetworkInfo) {
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001466 wilc_dealloc_network_info(pstrNetworkInfo);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001467 pstrNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001468 }
1469
Leo Kim31390ee2015-10-19 18:26:08 +09001470 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001471}
1472
Glen Lee71130e82015-12-21 14:18:41 +09001473static s32 host_int_get_assoc_res_info(struct wilc_vif *vif,
Arnd Bergmann1608c402015-11-16 15:04:53 +01001474 u8 *pu8AssocRespInfo,
1475 u32 u32MaxAssocRespInfoLen,
1476 u32 *pu32RcvdAssocRespInfoLen);
1477
Glen Leecf601062015-12-21 14:18:39 +09001478static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif,
Tony Chof23a9ea2015-09-21 12:16:39 +09001479 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001480{
Leo Kim31390ee2015-10-19 18:26:08 +09001481 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001482 u8 u8MsgType = 0;
1483 u8 u8MsgID = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001484 u16 u16MsgLen = 0;
1485 u16 u16WidID = (u16)WID_NIL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001486 u8 u8WidLen = 0;
1487 u8 u8MacStatus;
1488 u8 u8MacStatusReasonCode;
1489 u8 u8MacStatusAdditionalInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001490 tstrConnectInfo strConnectInfo;
1491 tstrDisconnectNotifInfo strDisconnectNotifInfo;
Leo Kime6e12662015-09-16 18:36:03 +09001492 s32 s32Err = 0;
Glen Lee71130e82015-12-21 14:18:41 +09001493 struct host_if_drv *hif_drv = vif->hif_drv;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02001494
Tony Choa4ab1ad2015-10-12 16:56:05 +09001495 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001496 PRINT_ER("Driver handler is NULL\n");
Leo Kim234837d2015-09-22 14:34:43 +09001497 return -ENODEV;
1498 }
Leo Kimb60005a2015-10-29 11:58:24 +09001499 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n",
1500 hif_drv->hif_state, pstrRcvdGnrlAsyncInfo->buffer[7]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001501
Leo Kimb60005a2015-10-29 11:58:24 +09001502 if ((hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
1503 (hif_drv->hif_state == HOST_IF_CONNECTED) ||
Leo Kimbc801852015-10-29 11:58:50 +09001504 hif_drv->usr_scan_req.scan_result) {
Leo Kim91109e12015-10-19 18:26:13 +09001505 if (!pstrRcvdGnrlAsyncInfo->buffer ||
Leo Kim33bfb192015-10-29 11:58:56 +09001506 !hif_drv->usr_conn_req.conn_result) {
Leo Kim24db7132015-09-16 18:36:01 +09001507 PRINT_ER("driver is null\n");
1508 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001509 }
1510
Leo Kim33722ac72015-10-13 19:50:00 +09001511 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001512
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001513 if ('I' != u8MsgType) {
1514 PRINT_ER("Received Message format incorrect.\n");
Leo Kim24db7132015-09-16 18:36:01 +09001515 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001516 }
1517
Leo Kim33722ac72015-10-13 19:50:00 +09001518 u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1];
1519 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]);
1520 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]);
1521 u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6];
1522 u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7];
1523 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8];
1524 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001525 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
Leo Kimb60005a2015-10-29 11:58:24 +09001526 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
Glen Lee71130e82015-12-21 14:18:41 +09001527 u32 u32RcvdAssocRespInfoLen = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001528 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
1529
1530 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1531
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001532 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001533
1534 if (u8MacStatus == MAC_CONNECTED) {
Leo Kima633c0b2015-10-15 13:24:59 +09001535 memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001536
Glen Lee71130e82015-12-21 14:18:41 +09001537 host_int_get_assoc_res_info(vif,
Leo Kima633c0b2015-10-15 13:24:59 +09001538 rcv_assoc_resp,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001539 MAX_ASSOC_RESP_FRAME_SIZE,
1540 &u32RcvdAssocRespInfoLen);
1541
1542 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
1543
1544 if (u32RcvdAssocRespInfoLen != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001545 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001546 s32Err = wilc_parse_assoc_resp_info(rcv_assoc_resp, u32RcvdAssocRespInfoLen,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001547 &pstrConnectRespInfo);
1548 if (s32Err) {
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001549 PRINT_ER("wilc_parse_assoc_resp_info() returned error %d\n", s32Err);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001550 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001551 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
1552
1553 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
1554 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
Leo Kim91109e12015-10-19 18:26:13 +09001555 if (pstrConnectRespInfo->pu8RespIEs) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001556 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001557 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001558 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001559 pstrConnectRespInfo->u16RespIEsLen);
1560 }
1561 }
1562
Leo Kim91109e12015-10-19 18:26:13 +09001563 if (pstrConnectRespInfo) {
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001564 wilc_dealloc_assoc_resp_info(pstrConnectRespInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001565 pstrConnectRespInfo = NULL;
1566 }
1567 }
1568 }
1569 }
1570
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001571 if ((u8MacStatus == MAC_CONNECTED) &&
1572 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001573 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 +09001574 eth_zero_addr(wilc_connected_ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001575 } else if (u8MacStatus == MAC_DISCONNECTED) {
1576 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
Leo Kime554a302015-11-19 15:56:21 +09001577 eth_zero_addr(wilc_connected_ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001578 }
1579
Leo Kimf8b17132015-10-28 15:59:34 +09001580 if (hif_drv->usr_conn_req.pu8bssid) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001581 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
Leo Kimf8b17132015-10-28 15:59:34 +09001582 memcpy(strConnectInfo.au8bssid, hif_drv->usr_conn_req.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001583
1584 if ((u8MacStatus == MAC_CONNECTED) &&
1585 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Leo Kim2a4eded2015-10-29 11:58:25 +09001586 memcpy(hif_drv->assoc_bssid,
Leo Kimf8b17132015-10-28 15:59:34 +09001587 hif_drv->usr_conn_req.pu8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001588 }
1589 }
1590
Leo Kima3b2f4b2015-10-29 11:58:54 +09001591 if (hif_drv->usr_conn_req.ies) {
Leo Kim331ed082015-10-29 11:58:55 +09001592 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len;
1593 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001594 memcpy(strConnectInfo.pu8ReqIEs,
Leo Kima3b2f4b2015-10-29 11:58:54 +09001595 hif_drv->usr_conn_req.ies,
Leo Kim331ed082015-10-29 11:58:55 +09001596 hif_drv->usr_conn_req.ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001597 }
1598
Leo Kim81a59502015-10-29 11:58:35 +09001599 del_timer(&hif_drv->connect_timer);
Leo Kim33bfb192015-10-29 11:58:56 +09001600 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1601 &strConnectInfo,
1602 u8MacStatus,
1603 NULL,
Leo Kim73abaa42015-10-29 12:05:27 +09001604 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001605
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001606 if ((u8MacStatus == MAC_CONNECTED) &&
1607 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Glen Leefbf53792015-12-21 14:18:40 +09001608 wilc_set_power_mgmt(vif, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001609
1610 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
Leo Kimb60005a2015-10-29 11:58:24 +09001611 hif_drv->hif_state = HOST_IF_CONNECTED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001612
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001613 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001614 wilc_optaining_ip = true;
1615 mod_timer(&wilc_during_ip_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07001616 jiffies + msecs_to_jiffies(10000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001617 } else {
1618 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
Leo Kimb60005a2015-10-29 11:58:24 +09001619 hif_drv->hif_state = HOST_IF_IDLE;
Leo Kimca8540e42015-10-15 13:25:00 +09001620 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001621 }
1622
Shraddha Barke95f840f2015-10-14 07:29:19 +05301623 kfree(strConnectInfo.pu8RespIEs);
1624 strConnectInfo.pu8RespIEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001625
Shraddha Barke95f840f2015-10-14 07:29:19 +05301626 kfree(strConnectInfo.pu8ReqIEs);
1627 strConnectInfo.pu8ReqIEs = NULL;
Leo Kim74ab5e42015-10-29 11:58:53 +09001628 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09001629 kfree(hif_drv->usr_conn_req.pu8ssid);
Glen Leecc28e4b2015-12-18 18:26:02 +09001630 hif_drv->usr_conn_req.pu8ssid = NULL;
Leo Kimf8b17132015-10-28 15:59:34 +09001631 kfree(hif_drv->usr_conn_req.pu8bssid);
Glen Leecc28e4b2015-12-18 18:26:02 +09001632 hif_drv->usr_conn_req.pu8bssid = NULL;
Leo Kim331ed082015-10-29 11:58:55 +09001633 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001634 kfree(hif_drv->usr_conn_req.ies);
Glen Leecc28e4b2015-12-18 18:26:02 +09001635 hif_drv->usr_conn_req.ies = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001636 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
Leo Kimb60005a2015-10-29 11:58:24 +09001637 (hif_drv->hif_state == HOST_IF_CONNECTED)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001638 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
1639
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001640 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001641
Leo Kimbc801852015-10-29 11:58:50 +09001642 if (hif_drv->usr_scan_req.scan_result) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001643 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
Leo Kim13b313e2015-10-29 11:58:34 +09001644 del_timer(&hif_drv->scan_timer);
Glen Lee71130e82015-12-21 14:18:41 +09001645 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001646 }
1647
1648 strDisconnectNotifInfo.u16reason = 0;
1649 strDisconnectNotifInfo.ie = NULL;
1650 strDisconnectNotifInfo.ie_len = 0;
1651
Leo Kim33bfb192015-10-29 11:58:56 +09001652 if (hif_drv->usr_conn_req.conn_result) {
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001653 wilc_optaining_ip = false;
Glen Leefbf53792015-12-21 14:18:40 +09001654 wilc_set_power_mgmt(vif, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001655
Leo Kim33bfb192015-10-29 11:58:56 +09001656 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1657 NULL,
1658 0,
1659 &strDisconnectNotifInfo,
Leo Kim73abaa42015-10-29 12:05:27 +09001660 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001661 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001662 PRINT_ER("Connect result callback function is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001663 }
1664
Leo Kim2a4eded2015-10-29 11:58:25 +09001665 eth_zero_addr(hif_drv->assoc_bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001666
Leo Kim74ab5e42015-10-29 11:58:53 +09001667 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09001668 kfree(hif_drv->usr_conn_req.pu8ssid);
Glen Leecc28e4b2015-12-18 18:26:02 +09001669 hif_drv->usr_conn_req.pu8ssid = NULL;
Leo Kimf8b17132015-10-28 15:59:34 +09001670 kfree(hif_drv->usr_conn_req.pu8bssid);
Glen Leecc28e4b2015-12-18 18:26:02 +09001671 hif_drv->usr_conn_req.pu8bssid = NULL;
Leo Kim331ed082015-10-29 11:58:55 +09001672 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001673 kfree(hif_drv->usr_conn_req.ies);
Glen Leecc28e4b2015-12-18 18:26:02 +09001674 hif_drv->usr_conn_req.ies = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001675
Glen Lee7036c622015-12-21 14:18:45 +09001676 if (join_req && join_req_vif == vif) {
Leo Kim044a64102015-10-15 13:25:09 +09001677 kfree(join_req);
1678 join_req = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001679 }
Leo Kim48ce2462015-10-15 13:25:10 +09001680
Glen Lee7036c622015-12-21 14:18:45 +09001681 if (info_element && join_req_vif == vif) {
Leo Kim48ce2462015-10-15 13:25:10 +09001682 kfree(info_element);
1683 info_element = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001684 }
1685
Leo Kimb60005a2015-10-29 11:58:24 +09001686 hif_drv->hif_state = HOST_IF_IDLE;
Leo Kimca8540e42015-10-15 13:25:00 +09001687 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001688
1689 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
Leo Kimbc801852015-10-29 11:58:50 +09001690 (hif_drv->usr_scan_req.scan_result)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001691 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001692 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09001693
Leo Kim13b313e2015-10-29 11:58:34 +09001694 del_timer(&hif_drv->scan_timer);
Leo Kimbc801852015-10-29 11:58:50 +09001695 if (hif_drv->usr_scan_req.scan_result)
Glen Lee71130e82015-12-21 14:18:41 +09001696 Handle_ScanDone(vif, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001697 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001698 }
1699
Shraddha Barke95f840f2015-10-14 07:29:19 +05301700 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1701 pstrRcvdGnrlAsyncInfo->buffer = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001702
Leo Kim31390ee2015-10-19 18:26:08 +09001703 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001704}
1705
Glen Lee71130e82015-12-21 14:18:41 +09001706static int Handle_Key(struct wilc_vif *vif,
Tony Choc98387a2015-09-21 12:16:40 +09001707 struct key_attr *pstrHostIFkeyAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001708{
Leo Kim31390ee2015-10-19 18:26:08 +09001709 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09001710 struct wid wid;
Leo Kime9e0c262015-10-12 16:55:41 +09001711 struct wid strWIDList[5];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001712 u8 i;
1713 u8 *pu8keybuf;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001714 s8 s8idxarray[1];
1715 s8 ret = 0;
Glen Lee71130e82015-12-21 14:18:41 +09001716 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001717
Leo Kim8e9f4272015-10-13 19:49:27 +09001718 switch (pstrHostIFkeyAttr->type) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001719 case WEP:
1720
Leo Kim0d17e382015-10-13 19:49:28 +09001721 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001722 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Leo Kimbafaa692015-10-28 15:59:21 +09001723 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", pstrHostIFkeyAttr->attr.wep.index);
Leo Kimdaaf16b2015-10-12 16:55:44 +09001724 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001725 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001726 strWIDList[0].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001727 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001728
Leo Kimdaaf16b2015-10-12 16:55:44 +09001729 strWIDList[1].id = WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001730 strWIDList[1].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001731 strWIDList[1].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001732 strWIDList[1].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001733
Leo Kimdaaf16b2015-10-12 16:55:44 +09001734 strWIDList[2].id = (u16)WID_KEY_ID;
Leo Kim416d8322015-10-12 16:55:43 +09001735 strWIDList[2].type = WID_CHAR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001736
Leo Kimbafaa692015-10-28 15:59:21 +09001737 strWIDList[2].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
Leo Kim2fd3e442015-10-12 16:55:45 +09001738 strWIDList[2].size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001739
Shraddha Barke543f5b12015-10-16 10:47:11 +05301740 pu8keybuf = kmemdup(pstrHostIFkeyAttr->attr.wep.key,
1741 pstrHostIFkeyAttr->attr.wep.key_len,
1742 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001743
1744 if (pu8keybuf == NULL) {
1745 PRINT_ER("No buffer to send Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001746 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001747 }
1748
Leo Kim73b2e382015-10-13 19:49:29 +09001749 kfree(pstrHostIFkeyAttr->attr.wep.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001750
Leo Kimdaaf16b2015-10-12 16:55:44 +09001751 strWIDList[3].id = (u16)WID_WEP_KEY_VALUE;
Leo Kim416d8322015-10-12 16:55:43 +09001752 strWIDList[3].type = WID_STR;
Leo Kim73b2e382015-10-13 19:49:29 +09001753 strWIDList[3].size = pstrHostIFkeyAttr->attr.wep.key_len;
Leo Kim900bb4a2015-10-12 16:55:46 +09001754 strWIDList[3].val = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001755
Glen Leecd2920a2015-12-21 14:18:48 +09001756 result = wilc_send_config_pkt(vif->wilc, SET_CFG,
Glen Leeec62e6d2015-11-18 15:11:33 +09001757 strWIDList, 4,
Glen Leeeb9939b2015-12-21 14:18:43 +09001758 wilc_get_vif_idx(vif));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001759 kfree(pu8keybuf);
Leo Kim9edaa5f2015-11-25 11:59:48 +09001760 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001761 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Leo Kim73b2e382015-10-13 19:49:29 +09001762 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001763 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001764 PRINT_ER("No buffer to send Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001765 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001766 }
Leo Kim73b2e382015-10-13 19:49:29 +09001767 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1768 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1769 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001770 pstrHostIFkeyAttr->attr.wep.key_len);
Leo Kim73b2e382015-10-13 19:49:29 +09001771 kfree(pstrHostIFkeyAttr->attr.wep.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001772
Leo Kim45102f82015-10-28 15:59:28 +09001773 wid.id = (u16)WID_ADD_WEP_KEY;
1774 wid.type = WID_STR;
1775 wid.val = (s8 *)pu8keybuf;
1776 wid.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001777
Glen Leecd2920a2015-12-21 14:18:48 +09001778 result = wilc_send_config_pkt(vif->wilc, SET_CFG,
Glen Leeec62e6d2015-11-18 15:11:33 +09001779 &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09001780 wilc_get_vif_idx(vif));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001781 kfree(pu8keybuf);
Leo Kim0d17e382015-10-13 19:49:28 +09001782 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001783 PRINT_D(HOSTINF_DBG, "Removing key\n");
Leo Kim45102f82015-10-28 15:59:28 +09001784 wid.id = (u16)WID_REMOVE_WEP_KEY;
1785 wid.type = WID_STR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001786
Leo Kim73b2e382015-10-13 19:49:29 +09001787 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
Leo Kim45102f82015-10-28 15:59:28 +09001788 wid.val = s8idxarray;
1789 wid.size = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001790
Glen Leecd2920a2015-12-21 14:18:48 +09001791 result = wilc_send_config_pkt(vif->wilc, SET_CFG,
Glen Leeec62e6d2015-11-18 15:11:33 +09001792 &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09001793 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001794 } else {
Leo Kim45102f82015-10-28 15:59:28 +09001795 wid.id = (u16)WID_KEY_ID;
1796 wid.type = WID_CHAR;
1797 wid.val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
1798 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001799
1800 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
1801
Glen Leecd2920a2015-12-21 14:18:48 +09001802 result = wilc_send_config_pkt(vif->wilc, SET_CFG,
Glen Leeec62e6d2015-11-18 15:11:33 +09001803 &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09001804 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001805 }
Leo Kim9ea47132015-10-29 11:58:28 +09001806 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001807 break;
1808
Leo Kim5cd8f7a2015-10-29 12:05:34 +09001809 case WPA_RX_GTK:
Leo Kim0d17e382015-10-13 19:49:28 +09001810 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Shraddha Barkeb156f1e2015-10-13 23:07:00 +05301811 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001812 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001813 PRINT_ER("No buffer to send RxGTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001814 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001815 goto _WPARxGtk_end_case_;
1816 }
1817
Leo Kim91109e12015-10-19 18:26:13 +09001818 if (pstrHostIFkeyAttr->attr.wpa.seq)
Leo Kim0e74c002015-10-13 19:49:32 +09001819 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001820
Leo Kime2dfbac2015-10-13 19:49:34 +09001821 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
Leo Kim6acf2912015-10-13 19:49:35 +09001822 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001823 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001824 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001825
Leo Kimdaaf16b2015-10-12 16:55:44 +09001826 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001827 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001828 strWIDList[0].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001829 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001830
Leo Kimdaaf16b2015-10-12 16:55:44 +09001831 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
Leo Kim416d8322015-10-12 16:55:43 +09001832 strWIDList[1].type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09001833 strWIDList[1].val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09001834 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001835
Glen Leecd2920a2015-12-21 14:18:48 +09001836 result = wilc_send_config_pkt(vif->wilc, SET_CFG,
Glen Leeec62e6d2015-11-18 15:11:33 +09001837 strWIDList, 2,
Glen Leeeb9939b2015-12-21 14:18:43 +09001838 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001839
Chaehyun Lim49188af2015-08-11 10:32:41 +09001840 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001841 up(&hif_drv->sem_test_key_block);
Leo Kim9edaa5f2015-11-25 11:59:48 +09001842 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001843 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
1844
Shraddha Barkeb156f1e2015-10-13 23:07:00 +05301845 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001846 if (pu8keybuf == NULL) {
1847 PRINT_ER("No buffer to send RxGTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001848 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001849 goto _WPARxGtk_end_case_;
1850 }
1851
Leo Kimb60005a2015-10-29 11:58:24 +09001852 if (hif_drv->hif_state == HOST_IF_CONNECTED)
Leo Kim2a4eded2015-10-29 11:58:25 +09001853 memcpy(pu8keybuf, hif_drv->assoc_bssid, ETH_ALEN);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301854 else
Leo Kimb60005a2015-10-29 11:58:24 +09001855 PRINT_ER("Couldn't handle WPARxGtk while state is not HOST_IF_CONNECTED\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001856
Leo Kim0e74c002015-10-13 19:49:32 +09001857 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
Leo Kime2dfbac2015-10-13 19:49:34 +09001858 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
Leo Kim6acf2912015-10-13 19:49:35 +09001859 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001860 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001861 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001862
Leo Kim45102f82015-10-28 15:59:28 +09001863 wid.id = (u16)WID_ADD_RX_GTK;
1864 wid.type = WID_STR;
1865 wid.val = (s8 *)pu8keybuf;
1866 wid.size = RX_MIC_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001867
Glen Leecd2920a2015-12-21 14:18:48 +09001868 result = wilc_send_config_pkt(vif->wilc, SET_CFG,
Glen Leeec62e6d2015-11-18 15:11:33 +09001869 &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09001870 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001871
Chaehyun Lim49188af2015-08-11 10:32:41 +09001872 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001873 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001874 }
1875_WPARxGtk_end_case_:
Leo Kim124968fc2015-10-13 19:49:30 +09001876 kfree(pstrHostIFkeyAttr->attr.wpa.key);
Leo Kim0e74c002015-10-13 19:49:32 +09001877 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
Luis de Bethencourt90819872015-10-26 05:52:50 +00001878 if (ret)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001879 return ret;
1880
1881 break;
1882
Leo Kim2141fe32015-10-29 12:05:35 +09001883 case WPA_PTK:
Leo Kim0d17e382015-10-13 19:49:28 +09001884 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Glen Leef3052582015-09-10 12:03:04 +09001885 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001886 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001887 PRINT_ER("No buffer to send PTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001888 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001889 goto _WPAPtk_end_case_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001890 }
1891
Leo Kim248080a2015-10-13 19:49:31 +09001892 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
Leo Kime2dfbac2015-10-13 19:49:34 +09001893 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
Leo Kim6acf2912015-10-13 19:49:35 +09001894 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001895 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001896 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001897
Leo Kimdaaf16b2015-10-12 16:55:44 +09001898 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001899 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001900 strWIDList[0].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001901 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001902
Leo Kimdaaf16b2015-10-12 16:55:44 +09001903 strWIDList[1].id = (u16)WID_ADD_PTK;
Leo Kim416d8322015-10-12 16:55:43 +09001904 strWIDList[1].type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09001905 strWIDList[1].val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09001906 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001907
Glen Leecd2920a2015-12-21 14:18:48 +09001908 result = wilc_send_config_pkt(vif->wilc, SET_CFG,
Glen Leeec62e6d2015-11-18 15:11:33 +09001909 strWIDList, 2,
Glen Leeeb9939b2015-12-21 14:18:43 +09001910 wilc_get_vif_idx(vif));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001911 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001912 up(&hif_drv->sem_test_key_block);
Leo Kim9edaa5f2015-11-25 11:59:48 +09001913 } else if (pstrHostIFkeyAttr->action & ADDKEY) {
Glen Leef3052582015-09-10 12:03:04 +09001914 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001915 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001916 PRINT_ER("No buffer to send PTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001917 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001918 goto _WPAPtk_end_case_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001919 }
1920
Leo Kim248080a2015-10-13 19:49:31 +09001921 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
Leo Kim6acf2912015-10-13 19:49:35 +09001922 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001923 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001924 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001925
Leo Kim45102f82015-10-28 15:59:28 +09001926 wid.id = (u16)WID_ADD_PTK;
1927 wid.type = WID_STR;
1928 wid.val = (s8 *)pu8keybuf;
1929 wid.size = PTK_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001930
Glen Leecd2920a2015-12-21 14:18:48 +09001931 result = wilc_send_config_pkt(vif->wilc, SET_CFG,
Glen Leeec62e6d2015-11-18 15:11:33 +09001932 &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09001933 wilc_get_vif_idx(vif));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001934 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001935 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001936 }
1937
1938_WPAPtk_end_case_:
Leo Kim124968fc2015-10-13 19:49:30 +09001939 kfree(pstrHostIFkeyAttr->attr.wpa.key);
Luis de Bethencourt90819872015-10-26 05:52:50 +00001940 if (ret)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001941 return ret;
1942
1943 break;
1944
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001945 case PMKSA:
1946
1947 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
1948
Leo Kim73b2e382015-10-13 19:49:29 +09001949 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001950 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001951 PRINT_ER("No buffer to send PMKSA Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001952 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001953 }
1954
Leo Kim73b2e382015-10-13 19:49:29 +09001955 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001956
Leo Kim73b2e382015-10-13 19:49:29 +09001957 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
1958 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
1959 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001960 }
1961
Leo Kim45102f82015-10-28 15:59:28 +09001962 wid.id = (u16)WID_PMKID_INFO;
1963 wid.type = WID_STR;
1964 wid.val = (s8 *)pu8keybuf;
1965 wid.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001966
Glen Leecd2920a2015-12-21 14:18:48 +09001967 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09001968 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001969
Chaehyun Lim49188af2015-08-11 10:32:41 +09001970 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001971 break;
1972 }
1973
Leo Kim31390ee2015-10-19 18:26:08 +09001974 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001975 PRINT_ER("Failed to send key config packet\n");
1976
Leo Kim31390ee2015-10-19 18:26:08 +09001977 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001978}
1979
Glen Lee71130e82015-12-21 14:18:41 +09001980static void Handle_Disconnect(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001981{
Leo Kim45102f82015-10-28 15:59:28 +09001982 struct wid wid;
Glen Lee71130e82015-12-21 14:18:41 +09001983 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001984
Leo Kim31390ee2015-10-19 18:26:08 +09001985 s32 result = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001986 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001987
Leo Kim45102f82015-10-28 15:59:28 +09001988 wid.id = (u16)WID_DISCONNECT;
1989 wid.type = WID_CHAR;
1990 wid.val = (s8 *)&u16DummyReasonCode;
1991 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001992
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001993 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1994
Arnd Bergmann0e1af732015-11-16 15:04:54 +01001995 wilc_optaining_ip = false;
Glen Leefbf53792015-12-21 14:18:40 +09001996 wilc_set_power_mgmt(vif, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001997
Leo Kime554a302015-11-19 15:56:21 +09001998 eth_zero_addr(wilc_connected_ssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001999
Glen Leecd2920a2015-12-21 14:18:48 +09002000 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002001 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002002
Leo Kim31390ee2015-10-19 18:26:08 +09002003 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002004 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002005 } else {
2006 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2007
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002008 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002009
2010 strDisconnectNotifInfo.u16reason = 0;
2011 strDisconnectNotifInfo.ie = NULL;
2012 strDisconnectNotifInfo.ie_len = 0;
2013
Leo Kimbc801852015-10-29 11:58:50 +09002014 if (hif_drv->usr_scan_req.scan_result) {
Leo Kim13b313e2015-10-29 11:58:34 +09002015 del_timer(&hif_drv->scan_timer);
Leo Kim33bfb192015-10-29 11:58:56 +09002016 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED,
2017 NULL,
2018 hif_drv->usr_scan_req.arg,
2019 NULL);
Leo Kimbc801852015-10-29 11:58:50 +09002020 hif_drv->usr_scan_req.scan_result = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002021 }
2022
Leo Kim33bfb192015-10-29 11:58:56 +09002023 if (hif_drv->usr_conn_req.conn_result) {
Leo Kimb60005a2015-10-29 11:58:24 +09002024 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002025 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
Leo Kim81a59502015-10-29 11:58:35 +09002026 del_timer(&hif_drv->connect_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002027 }
2028
Leo Kim33bfb192015-10-29 11:58:56 +09002029 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2030 NULL,
2031 0,
2032 &strDisconnectNotifInfo,
Leo Kim73abaa42015-10-29 12:05:27 +09002033 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002034 } else {
Leo Kim33bfb192015-10-29 11:58:56 +09002035 PRINT_ER("usr_conn_req.conn_result = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002036 }
2037
Leo Kimca8540e42015-10-15 13:25:00 +09002038 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002039
Leo Kimb60005a2015-10-29 11:58:24 +09002040 hif_drv->hif_state = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002041
Leo Kim2a4eded2015-10-29 11:58:25 +09002042 eth_zero_addr(hif_drv->assoc_bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002043
Leo Kim74ab5e42015-10-29 11:58:53 +09002044 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09002045 kfree(hif_drv->usr_conn_req.pu8ssid);
Glen Leecc28e4b2015-12-18 18:26:02 +09002046 hif_drv->usr_conn_req.pu8ssid = NULL;
Leo Kimf8b17132015-10-28 15:59:34 +09002047 kfree(hif_drv->usr_conn_req.pu8bssid);
Glen Leecc28e4b2015-12-18 18:26:02 +09002048 hif_drv->usr_conn_req.pu8bssid = NULL;
Leo Kim331ed082015-10-29 11:58:55 +09002049 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09002050 kfree(hif_drv->usr_conn_req.ies);
Glen Leecc28e4b2015-12-18 18:26:02 +09002051 hif_drv->usr_conn_req.ies = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002052
Glen Lee7036c622015-12-21 14:18:45 +09002053 if (join_req && join_req_vif == vif) {
Leo Kim044a64102015-10-15 13:25:09 +09002054 kfree(join_req);
2055 join_req = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002056 }
Leo Kim48ce2462015-10-15 13:25:10 +09002057
Glen Lee7036c622015-12-21 14:18:45 +09002058 if (info_element && join_req_vif == vif) {
Leo Kim48ce2462015-10-15 13:25:10 +09002059 kfree(info_element);
2060 info_element = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002061 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002062 }
2063
Leo Kime55e4962015-10-29 11:58:29 +09002064 up(&hif_drv->sem_test_disconn_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002065}
2066
Glen Leefbf53792015-12-21 14:18:40 +09002067void wilc_resolve_disconnect_aberration(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002068{
Glen Leefbf53792015-12-21 14:18:40 +09002069 if (!vif->hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002070 return;
Glen Leefbf53792015-12-21 14:18:40 +09002071 if ((vif->hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
2072 (vif->hif_drv->hif_state == HOST_IF_CONNECTING)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002073 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
Glen Leefbf53792015-12-21 14:18:40 +09002074 wilc_disconnect(vif, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002075 }
2076}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002077
Glen Lee71130e82015-12-21 14:18:41 +09002078static s32 Handle_GetChnl(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002079{
Leo Kim31390ee2015-10-19 18:26:08 +09002080 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002081 struct wid wid;
Glen Lee71130e82015-12-21 14:18:41 +09002082 struct host_if_drv *hif_drv = vif->hif_drv;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002083
Leo Kim45102f82015-10-28 15:59:28 +09002084 wid.id = (u16)WID_CURRENT_CHANNEL;
2085 wid.type = WID_CHAR;
2086 wid.val = (s8 *)&ch_no;
2087 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002088
2089 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2090
Glen Leecd2920a2015-12-21 14:18:48 +09002091 result = wilc_send_config_pkt(vif->wilc, GET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002092 wilc_get_vif_idx(vif));
Leo Kimae4dfa52015-10-13 19:49:26 +09002093
Leo Kim31390ee2015-10-19 18:26:08 +09002094 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002095 PRINT_ER("Failed to get channel number\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002096 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002097 }
2098
Leo Kim4ea90002015-10-29 11:58:32 +09002099 up(&hif_drv->sem_get_chnl);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002100
Leo Kim31390ee2015-10-19 18:26:08 +09002101 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002102}
2103
Glen Lee71130e82015-12-21 14:18:41 +09002104static void Handle_GetRssi(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002105{
Leo Kim31390ee2015-10-19 18:26:08 +09002106 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002107 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002108
Leo Kim45102f82015-10-28 15:59:28 +09002109 wid.id = (u16)WID_RSSI;
2110 wid.type = WID_CHAR;
2111 wid.val = &rssi;
2112 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002113
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002114 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2115
Glen Leecd2920a2015-12-21 14:18:48 +09002116 result = wilc_send_config_pkt(vif->wilc, GET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002117 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002118 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002119 PRINT_ER("Failed to get RSSI value\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002120 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002121 }
2122
Glen Lee71130e82015-12-21 14:18:41 +09002123 up(&vif->hif_drv->sem_get_rssi);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002124}
2125
Glen Lee71130e82015-12-21 14:18:41 +09002126static void Handle_GetLinkspeed(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002127{
Leo Kim31390ee2015-10-19 18:26:08 +09002128 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002129 struct wid wid;
Glen Lee71130e82015-12-21 14:18:41 +09002130 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002131
Leo Kim75327a02015-10-15 13:25:02 +09002132 link_speed = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002133
Leo Kim45102f82015-10-28 15:59:28 +09002134 wid.id = (u16)WID_LINKSPEED;
2135 wid.type = WID_CHAR;
2136 wid.val = &link_speed;
2137 wid.size = sizeof(char);
Leo Kimae4dfa52015-10-13 19:49:26 +09002138
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002139 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2140
Glen Leecd2920a2015-12-21 14:18:48 +09002141 result = wilc_send_config_pkt(vif->wilc, GET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002142 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002143 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002144 PRINT_ER("Failed to get LINKSPEED value\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002145 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002146 }
2147
Leo Kimbc34da62015-10-29 11:58:31 +09002148 up(&hif_drv->sem_get_link_speed);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002149}
2150
Glen Lee71130e82015-12-21 14:18:41 +09002151static s32 Handle_GetStatistics(struct wilc_vif *vif,
2152 struct rf_info *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002153{
Leo Kime9e0c262015-10-12 16:55:41 +09002154 struct wid strWIDList[5];
Leo Kim31390ee2015-10-19 18:26:08 +09002155 u32 u32WidsCount = 0, result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002156
Leo Kimdaaf16b2015-10-12 16:55:44 +09002157 strWIDList[u32WidsCount].id = WID_LINKSPEED;
Leo Kim416d8322015-10-12 16:55:43 +09002158 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002159 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim5babeec2015-10-29 12:05:29 +09002160 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->link_speed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002161 u32WidsCount++;
2162
Leo Kimdaaf16b2015-10-12 16:55:44 +09002163 strWIDList[u32WidsCount].id = WID_RSSI;
Leo Kim416d8322015-10-12 16:55:43 +09002164 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002165 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim00c8dfc2015-10-29 12:05:30 +09002166 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rssi;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002167 u32WidsCount++;
2168
Leo Kimdaaf16b2015-10-12 16:55:44 +09002169 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002170 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002171 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim7e84ff42015-10-29 12:05:31 +09002172 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002173 u32WidsCount++;
2174
Leo Kimdaaf16b2015-10-12 16:55:44 +09002175 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002176 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002177 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim9b992742015-10-29 12:05:32 +09002178 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rx_cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002179 u32WidsCount++;
2180
Leo Kimdaaf16b2015-10-12 16:55:44 +09002181 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002182 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002183 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim54160372015-10-29 12:05:33 +09002184 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_fail_cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002185 u32WidsCount++;
2186
Glen Leecd2920a2015-12-21 14:18:48 +09002187 result = wilc_send_config_pkt(vif->wilc, GET_CFG, strWIDList,
Glen Leeec62e6d2015-11-18 15:11:33 +09002188 u32WidsCount,
Glen Leeeb9939b2015-12-21 14:18:43 +09002189 wilc_get_vif_idx(vif));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002190
Leo Kim31390ee2015-10-19 18:26:08 +09002191 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002192 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09002193
Leo Kim2d25af82015-10-15 13:24:56 +09002194 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002195 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002196}
2197
Glen Lee71130e82015-12-21 14:18:41 +09002198static s32 Handle_Get_InActiveTime(struct wilc_vif *vif,
Tony Cho3d1eac02015-09-21 12:16:49 +09002199 struct sta_inactive_t *strHostIfStaInactiveT)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002200{
Leo Kim31390ee2015-10-19 18:26:08 +09002201 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002202 u8 *stamac;
Leo Kim45102f82015-10-28 15:59:28 +09002203 struct wid wid;
Glen Lee71130e82015-12-21 14:18:41 +09002204 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002205
Leo Kim45102f82015-10-28 15:59:28 +09002206 wid.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2207 wid.type = WID_STR;
2208 wid.size = ETH_ALEN;
2209 wid.val = kmalloc(wid.size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002210
Leo Kim45102f82015-10-28 15:59:28 +09002211 stamac = wid.val;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002212 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002213
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002214 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2215
Glen Leecd2920a2015-12-21 14:18:48 +09002216 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002217 wilc_get_vif_idx(vif));
Leo Kimae4dfa52015-10-13 19:49:26 +09002218
Leo Kim31390ee2015-10-19 18:26:08 +09002219 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002220 PRINT_ER("Failed to SET incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09002221 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002222 }
2223
Leo Kim45102f82015-10-28 15:59:28 +09002224 wid.id = (u16)WID_GET_INACTIVE_TIME;
2225 wid.type = WID_INT;
2226 wid.val = (s8 *)&inactive_time;
2227 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002228
Glen Leecd2920a2015-12-21 14:18:48 +09002229 result = wilc_send_config_pkt(vif->wilc, GET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002230 wilc_get_vif_idx(vif));
Leo Kimae4dfa52015-10-13 19:49:26 +09002231
Leo Kim31390ee2015-10-19 18:26:08 +09002232 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002233 PRINT_ER("Failed to get incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09002234 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002235 }
2236
Leo Kimad269062015-10-15 13:25:06 +09002237 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", inactive_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002238
Leo Kim569a3c62015-10-29 11:58:33 +09002239 up(&hif_drv->sem_inactive_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002240
Leo Kim31390ee2015-10-19 18:26:08 +09002241 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002242}
2243
Glen Lee71130e82015-12-21 14:18:41 +09002244static void Handle_AddBeacon(struct wilc_vif *vif,
Tony Cho7f33fec2015-09-30 18:44:30 +09002245 struct beacon_attr *pstrSetBeaconParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002246{
Leo Kim31390ee2015-10-19 18:26:08 +09002247 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002248 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002249 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002250
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002251 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
2252
Leo Kim45102f82015-10-28 15:59:28 +09002253 wid.id = (u16)WID_ADD_BEACON;
2254 wid.type = WID_BIN;
2255 wid.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
2256 wid.val = kmalloc(wid.size, GFP_KERNEL);
2257 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002258 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002259
Leo Kim45102f82015-10-28 15:59:28 +09002260 pu8CurrByte = wid.val;
Leo Kim12262dd2015-10-13 19:50:03 +09002261 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2262 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2263 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2264 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002265
Leo Kime76ab772015-10-13 19:50:04 +09002266 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2267 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2268 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2269 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002270
Leo Kim51c66182015-10-13 19:50:05 +09002271 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2272 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2273 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2274 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002275
Leo Kim8ce528b2015-10-13 19:50:06 +09002276 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
Leo Kim51c66182015-10-13 19:50:05 +09002277 pu8CurrByte += pstrSetBeaconParam->head_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002278
Leo Kim030c57e2015-10-13 19:50:07 +09002279 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2280 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2281 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2282 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002283
Mario J. Rugiero7cf8e592015-12-03 13:24:05 -03002284 if (pstrSetBeaconParam->tail)
Leo Kim7dbcb6d32015-10-13 19:50:08 +09002285 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
Leo Kim030c57e2015-10-13 19:50:07 +09002286 pu8CurrByte += pstrSetBeaconParam->tail_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002287
Glen Leecd2920a2015-12-21 14:18:48 +09002288 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002289 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002290 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002291 PRINT_ER("Failed to send add beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002292
Leo Kim24db7132015-09-16 18:36:01 +09002293ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002294 kfree(wid.val);
Leo Kim8ce528b2015-10-13 19:50:06 +09002295 kfree(pstrSetBeaconParam->head);
Leo Kim7dbcb6d32015-10-13 19:50:08 +09002296 kfree(pstrSetBeaconParam->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002297}
2298
Glen Lee71130e82015-12-21 14:18:41 +09002299static void Handle_DelBeacon(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002300{
Leo Kim31390ee2015-10-19 18:26:08 +09002301 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002302 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002303 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002304
Leo Kim45102f82015-10-28 15:59:28 +09002305 wid.id = (u16)WID_DEL_BEACON;
2306 wid.type = WID_CHAR;
2307 wid.size = sizeof(char);
2308 wid.val = &del_beacon;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002309
Leo Kim45102f82015-10-28 15:59:28 +09002310 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002311 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002312
Leo Kim45102f82015-10-28 15:59:28 +09002313 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002314
2315 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002316
Glen Leecd2920a2015-12-21 14:18:48 +09002317 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002318 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002319 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002320 PRINT_ER("Failed to send delete beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002321}
2322
Tony Cho6a89ba92015-09-21 12:16:46 +09002323static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2324 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002325{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002326 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002327
2328 pu8CurrByte = pu8Buffer;
2329
2330 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
Leo Kim2353c382015-10-29 12:05:41 +09002331 memcpy(pu8CurrByte, pstrStationParam->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002332 pu8CurrByte += ETH_ALEN;
2333
Leo Kim4101eb82015-10-29 12:05:42 +09002334 *pu8CurrByte++ = pstrStationParam->aid & 0xFF;
2335 *pu8CurrByte++ = (pstrStationParam->aid >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002336
Leo Kime7342232015-10-29 12:05:43 +09002337 *pu8CurrByte++ = pstrStationParam->rates_len;
2338 if (pstrStationParam->rates_len > 0)
Leo Kima622e012015-10-29 12:05:44 +09002339 memcpy(pu8CurrByte, pstrStationParam->rates,
Leo Kime7342232015-10-29 12:05:43 +09002340 pstrStationParam->rates_len);
2341 pu8CurrByte += pstrStationParam->rates_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002342
Leo Kim22520122015-10-29 12:05:45 +09002343 *pu8CurrByte++ = pstrStationParam->ht_supported;
Leo Kim0d073f62015-10-29 12:05:46 +09002344 *pu8CurrByte++ = pstrStationParam->ht_capa_info & 0xFF;
2345 *pu8CurrByte++ = (pstrStationParam->ht_capa_info >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002346
Leo Kimfba1f2d2015-10-29 12:05:47 +09002347 *pu8CurrByte++ = pstrStationParam->ht_ampdu_params;
Leo Kim5ebbf4f2015-10-29 12:05:48 +09002348 memcpy(pu8CurrByte, pstrStationParam->ht_supp_mcs_set,
2349 WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002350 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2351
Leo Kim223741d2015-10-29 12:05:49 +09002352 *pu8CurrByte++ = pstrStationParam->ht_ext_params & 0xFF;
2353 *pu8CurrByte++ = (pstrStationParam->ht_ext_params >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002354
Leo Kim74fe73c2015-10-29 12:05:50 +09002355 *pu8CurrByte++ = pstrStationParam->ht_tx_bf_cap & 0xFF;
2356 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 8) & 0xFF;
2357 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 16) & 0xFF;
2358 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 24) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002359
Leo Kima486baf2015-10-29 12:05:51 +09002360 *pu8CurrByte++ = pstrStationParam->ht_ante_sel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002361
Leo Kimf676e172015-10-29 12:05:52 +09002362 *pu8CurrByte++ = pstrStationParam->flags_mask & 0xFF;
2363 *pu8CurrByte++ = (pstrStationParam->flags_mask >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002364
Leo Kim67ab64e2015-10-29 12:05:53 +09002365 *pu8CurrByte++ = pstrStationParam->flags_set & 0xFF;
2366 *pu8CurrByte++ = (pstrStationParam->flags_set >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002367
2368 return pu8CurrByte - pu8Buffer;
2369}
2370
Glen Lee71130e82015-12-21 14:18:41 +09002371static void Handle_AddStation(struct wilc_vif *vif,
Tony Cho6a89ba92015-09-21 12:16:46 +09002372 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002373{
Leo Kim31390ee2015-10-19 18:26:08 +09002374 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002375 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002376 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002377
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002378 PRINT_D(HOSTINF_DBG, "Handling add station\n");
Leo Kim45102f82015-10-28 15:59:28 +09002379 wid.id = (u16)WID_ADD_STA;
2380 wid.type = WID_BIN;
Leo Kime7342232015-10-29 12:05:43 +09002381 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002382
Leo Kim45102f82015-10-28 15:59:28 +09002383 wid.val = kmalloc(wid.size, GFP_KERNEL);
2384 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002385 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002386
Leo Kim45102f82015-10-28 15:59:28 +09002387 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002388 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2389
Glen Leecd2920a2015-12-21 14:18:48 +09002390 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002391 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002392 if (result != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002393 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002394
Leo Kim24db7132015-09-16 18:36:01 +09002395ERRORHANDLER:
Leo Kima622e012015-10-29 12:05:44 +09002396 kfree(pstrStationParam->rates);
Leo Kim45102f82015-10-28 15:59:28 +09002397 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002398}
2399
Glen Lee71130e82015-12-21 14:18:41 +09002400static void Handle_DelAllSta(struct wilc_vif *vif,
Tony Chob4e644e2015-09-21 12:17:00 +09002401 struct del_all_sta *pstrDelAllStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002402{
Leo Kim31390ee2015-10-19 18:26:08 +09002403 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002404 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002405 u8 *pu8CurrByte;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002406 u8 i;
Chaehyun Lim37034802015-06-11 14:34:32 +09002407 u8 au8Zero_Buff[6] = {0};
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002408
Leo Kim45102f82015-10-28 15:59:28 +09002409 wid.id = (u16)WID_DEL_ALL_STA;
2410 wid.type = WID_STR;
2411 wid.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002412
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002413 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002414
Leo Kim45102f82015-10-28 15:59:28 +09002415 wid.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2416 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002417 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002418
Leo Kim45102f82015-10-28 15:59:28 +09002419 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002420
Leo Kim8ba18032015-10-13 19:50:10 +09002421 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002422
2423 for (i = 0; i < MAX_NUM_STA; i++) {
Leo Kime51b9212015-10-13 19:50:09 +09002424 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2425 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002426 else
2427 continue;
2428
2429 pu8CurrByte += ETH_ALEN;
2430 }
2431
Glen Leecd2920a2015-12-21 14:18:48 +09002432 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002433 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002434 if (result)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02002435 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002436
Leo Kim24db7132015-09-16 18:36:01 +09002437ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002438 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002439
Leo Kim2d25af82015-10-15 13:24:56 +09002440 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002441}
2442
Glen Lee71130e82015-12-21 14:18:41 +09002443static void Handle_DelStation(struct wilc_vif *vif,
Tony Chofb93a1e2015-09-21 12:16:57 +09002444 struct del_sta *pstrDelStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002445{
Leo Kim31390ee2015-10-19 18:26:08 +09002446 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002447 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002448 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002449
Leo Kim45102f82015-10-28 15:59:28 +09002450 wid.id = (u16)WID_REMOVE_STA;
2451 wid.type = WID_BIN;
2452 wid.size = ETH_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002453
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002454 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002455
Leo Kim45102f82015-10-28 15:59:28 +09002456 wid.val = kmalloc(wid.size, GFP_KERNEL);
2457 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002458 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002459
Leo Kim45102f82015-10-28 15:59:28 +09002460 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002461
Leo Kime4839d32015-10-13 20:02:06 +09002462 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002463
Glen Leecd2920a2015-12-21 14:18:48 +09002464 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002465 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002466 if (result)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02002467 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002468
Leo Kim24db7132015-09-16 18:36:01 +09002469ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002470 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002471}
2472
Glen Lee71130e82015-12-21 14:18:41 +09002473static void Handle_EditStation(struct wilc_vif *vif,
Tony Cho6a89ba92015-09-21 12:16:46 +09002474 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002475{
Leo Kim31390ee2015-10-19 18:26:08 +09002476 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002477 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002478 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002479
Leo Kim45102f82015-10-28 15:59:28 +09002480 wid.id = (u16)WID_EDIT_STA;
2481 wid.type = WID_BIN;
Leo Kime7342232015-10-29 12:05:43 +09002482 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002483
2484 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
Leo Kim45102f82015-10-28 15:59:28 +09002485 wid.val = kmalloc(wid.size, GFP_KERNEL);
2486 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002487 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002488
Leo Kim45102f82015-10-28 15:59:28 +09002489 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002490 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2491
Glen Leecd2920a2015-12-21 14:18:48 +09002492 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002493 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002494 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002495 PRINT_ER("Failed to send edit station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002496
Leo Kim24db7132015-09-16 18:36:01 +09002497ERRORHANDLER:
Leo Kima622e012015-10-29 12:05:44 +09002498 kfree(pstrStationParam->rates);
Leo Kim45102f82015-10-28 15:59:28 +09002499 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002500}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002501
Glen Lee71130e82015-12-21 14:18:41 +09002502static int Handle_RemainOnChan(struct wilc_vif *vif,
Tony Cho2f9c03f2015-09-21 12:16:58 +09002503 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002504{
Leo Kim31390ee2015-10-19 18:26:08 +09002505 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002506 u8 u8remain_on_chan_flag;
Leo Kim45102f82015-10-28 15:59:28 +09002507 struct wid wid;
Glen Lee71130e82015-12-21 14:18:41 +09002508 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002509
Leo Kim5beef2c2015-10-28 15:59:36 +09002510 if (!hif_drv->remain_on_ch_pending) {
Leo Kimc5cc4b12015-10-29 11:58:44 +09002511 hif_drv->remain_on_ch.arg = pstrHostIfRemainOnChan->arg;
Leo Kimbfb62ab2015-10-29 11:58:42 +09002512 hif_drv->remain_on_ch.expired = pstrHostIfRemainOnChan->expired;
Leo Kim5e5f7912015-10-29 11:58:43 +09002513 hif_drv->remain_on_ch.ready = pstrHostIfRemainOnChan->ready;
Leo Kim839ab702015-10-29 11:58:41 +09002514 hif_drv->remain_on_ch.ch = pstrHostIfRemainOnChan->ch;
Leo Kim9d764e32015-10-29 12:05:38 +09002515 hif_drv->remain_on_ch.id = pstrHostIfRemainOnChan->id;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002516 } else {
Leo Kim839ab702015-10-29 11:58:41 +09002517 pstrHostIfRemainOnChan->ch = hif_drv->remain_on_ch.ch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002518 }
2519
Leo Kimbc801852015-10-29 11:58:50 +09002520 if (hif_drv->usr_scan_req.scan_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002521 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
Leo Kim5beef2c2015-10-28 15:59:36 +09002522 hif_drv->remain_on_ch_pending = 1;
Leo Kim31390ee2015-10-19 18:26:08 +09002523 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +09002524 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002525 }
Leo Kimb60005a2015-10-29 11:58:24 +09002526 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002527 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002528 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +09002529 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002530 }
2531
Arnd Bergmann0e1af732015-11-16 15:04:54 +01002532 if (wilc_optaining_ip || wilc_connecting) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002533 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002534 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +09002535 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002536 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002537
Leo Kim839ab702015-10-29 11:58:41 +09002538 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n",
2539 pstrHostIfRemainOnChan->ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002540
Dean Lee72ed4dc2015-06-12 14:11:44 +09002541 u8remain_on_chan_flag = true;
Leo Kim45102f82015-10-28 15:59:28 +09002542 wid.id = (u16)WID_REMAIN_ON_CHAN;
2543 wid.type = WID_STR;
2544 wid.size = 2;
2545 wid.val = kmalloc(wid.size, GFP_KERNEL);
2546 if (!wid.val) {
Leo Kim31390ee2015-10-19 18:26:08 +09002547 result = -ENOMEM;
Leo Kim24db7132015-09-16 18:36:01 +09002548 goto ERRORHANDLER;
2549 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002550
Leo Kim45102f82015-10-28 15:59:28 +09002551 wid.val[0] = u8remain_on_chan_flag;
Leo Kim839ab702015-10-29 11:58:41 +09002552 wid.val[1] = (s8)pstrHostIfRemainOnChan->ch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002553
Glen Leecd2920a2015-12-21 14:18:48 +09002554 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002555 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002556 if (result != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002557 PRINT_ER("Failed to set remain on channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002558
Leo Kim24db7132015-09-16 18:36:01 +09002559ERRORHANDLER:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002560 {
2561 P2P_LISTEN_STATE = 1;
Glen Lee71130e82015-12-21 14:18:41 +09002562 hif_drv->remain_on_ch_timer.data = (unsigned long)vif;
Leo Kimcc2d7e92015-10-29 11:58:36 +09002563 mod_timer(&hif_drv->remain_on_ch_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002564 jiffies +
2565 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002566
Leo Kim5e5f7912015-10-29 11:58:43 +09002567 if (hif_drv->remain_on_ch.ready)
Leo Kimc5cc4b12015-10-29 11:58:44 +09002568 hif_drv->remain_on_ch.ready(hif_drv->remain_on_ch.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002569
Leo Kim5beef2c2015-10-28 15:59:36 +09002570 if (hif_drv->remain_on_ch_pending)
2571 hif_drv->remain_on_ch_pending = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002572 }
Leo Kim31390ee2015-10-19 18:26:08 +09002573
2574 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002575}
2576
Glen Lee71130e82015-12-21 14:18:41 +09002577static int Handle_RegisterFrame(struct wilc_vif *vif,
Tony Chobc37c5d2015-09-21 12:16:59 +09002578 struct reg_frame *pstrHostIfRegisterFrame)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002579{
Leo Kim31390ee2015-10-19 18:26:08 +09002580 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002581 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002582 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002583
Leo Kim6abf8682015-10-29 11:58:38 +09002584 PRINT_D(HOSTINF_DBG, "Handling frame register : %d FrameType: %d\n",
2585 pstrHostIfRegisterFrame->reg,
Leo Kimd5f654c2015-10-29 11:58:39 +09002586 pstrHostIfRegisterFrame->frame_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002587
Leo Kim45102f82015-10-28 15:59:28 +09002588 wid.id = (u16)WID_REGISTER_FRAME;
2589 wid.type = WID_STR;
2590 wid.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2591 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002592 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002593
Leo Kim45102f82015-10-28 15:59:28 +09002594 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002595
Leo Kim6abf8682015-10-29 11:58:38 +09002596 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg;
Leo Kimbcb410b2015-10-29 11:58:40 +09002597 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg_id;
Leo Kimd5f654c2015-10-29 11:58:39 +09002598 memcpy(pu8CurrByte, &pstrHostIfRegisterFrame->frame_type, sizeof(u16));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002599
Leo Kim45102f82015-10-28 15:59:28 +09002600 wid.size = sizeof(u16) + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002601
Glen Leecd2920a2015-12-21 14:18:48 +09002602 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002603 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002604 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002605 PRINT_ER("Failed to frame register config packet\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002606 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002607 }
2608
Leo Kim31390ee2015-10-19 18:26:08 +09002609 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002610}
2611
Glen Lee71130e82015-12-21 14:18:41 +09002612static u32 Handle_ListenStateExpired(struct wilc_vif *vif,
Tony Cho2f9c03f2015-09-21 12:16:58 +09002613 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002614{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002615 u8 u8remain_on_chan_flag;
Leo Kim45102f82015-10-28 15:59:28 +09002616 struct wid wid;
Leo Kim31390ee2015-10-19 18:26:08 +09002617 s32 result = 0;
Glen Lee71130e82015-12-21 14:18:41 +09002618 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002619
2620 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
2621
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002622 if (P2P_LISTEN_STATE) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002623 u8remain_on_chan_flag = false;
Leo Kim45102f82015-10-28 15:59:28 +09002624 wid.id = (u16)WID_REMAIN_ON_CHAN;
2625 wid.type = WID_STR;
2626 wid.size = 2;
2627 wid.val = kmalloc(wid.size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002628
Leo Kim653bb462015-12-21 14:18:24 +09002629 if (!wid.val) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002630 PRINT_ER("Failed to allocate memory\n");
Leo Kim653bb462015-12-21 14:18:24 +09002631 return -ENOMEM;
2632 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002633
Leo Kim45102f82015-10-28 15:59:28 +09002634 wid.val[0] = u8remain_on_chan_flag;
2635 wid.val[1] = FALSE_FRMWR_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002636
Glen Leecd2920a2015-12-21 14:18:48 +09002637 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002638 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002639 if (result != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002640 PRINT_ER("Failed to set remain on channel\n");
2641 goto _done_;
2642 }
2643
Leo Kimbfb62ab2015-10-29 11:58:42 +09002644 if (hif_drv->remain_on_ch.expired) {
Leo Kimc5cc4b12015-10-29 11:58:44 +09002645 hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg,
Leo Kim9d764e32015-10-29 12:05:38 +09002646 pstrHostIfRemainOnChan->id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002647 }
2648 P2P_LISTEN_STATE = 0;
2649 } else {
2650 PRINT_D(GENERIC_DBG, "Not in listen state\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002651 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002652 }
2653
2654_done_:
Leo Kim31390ee2015-10-19 18:26:08 +09002655 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002656}
2657
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07002658static void ListenTimerCB(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002659{
Leo Kim31390ee2015-10-19 18:26:08 +09002660 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09002661 struct host_if_msg msg;
Glen Lee71130e82015-12-21 14:18:41 +09002662 struct wilc_vif *vif = (struct wilc_vif *)arg;
Leo Kimae4dfa52015-10-13 19:49:26 +09002663
Glen Lee71130e82015-12-21 14:18:41 +09002664 del_timer(&vif->hif_drv->remain_on_ch_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002665
Tony Cho143eb952015-09-21 12:16:32 +09002666 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09002667 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Glen Lee71130e82015-12-21 14:18:41 +09002668 msg.vif = vif;
2669 msg.body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002670
Leo Kim31390ee2015-10-19 18:26:08 +09002671 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2672 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09002673 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002674}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002675
Glen Lee71130e82015-12-21 14:18:41 +09002676static void Handle_PowerManagement(struct wilc_vif *vif,
Tony Cho5a008f12015-09-21 12:16:48 +09002677 struct power_mgmt_param *strPowerMgmtParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002678{
Leo Kim31390ee2015-10-19 18:26:08 +09002679 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002680 struct wid wid;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002681 s8 s8PowerMode;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002682
Leo Kim45102f82015-10-28 15:59:28 +09002683 wid.id = (u16)WID_POWER_MANAGEMENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002684
Punit Vara047e6642015-10-25 04:01:25 +05302685 if (strPowerMgmtParam->enabled)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002686 s8PowerMode = MIN_FAST_PS;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302687 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002688 s8PowerMode = NO_POWERSAVE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002689 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
Leo Kim45102f82015-10-28 15:59:28 +09002690 wid.val = &s8PowerMode;
2691 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002692
2693 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
2694
Glen Leecd2920a2015-12-21 14:18:48 +09002695 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002696 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002697 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002698 PRINT_ER("Failed to send power management config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002699}
2700
Glen Lee71130e82015-12-21 14:18:41 +09002701static void Handle_SetMulticastFilter(struct wilc_vif *vif,
Tony Cho641210a2015-09-21 12:16:52 +09002702 struct set_multicast *strHostIfSetMulti)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002703{
Leo Kim31390ee2015-10-19 18:26:08 +09002704 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002705 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002706 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002707
2708 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
2709
Leo Kim45102f82015-10-28 15:59:28 +09002710 wid.id = (u16)WID_SETUP_MULTICAST_FILTER;
2711 wid.type = WID_BIN;
2712 wid.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2713 wid.val = kmalloc(wid.size, GFP_KERNEL);
2714 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002715 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002716
Leo Kim45102f82015-10-28 15:59:28 +09002717 pu8CurrByte = wid.val;
Leo Kimbae636eb2015-10-13 20:02:04 +09002718 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
Leo Kimc8751ad2015-11-25 11:59:49 +09002719 *pu8CurrByte++ = 0;
2720 *pu8CurrByte++ = 0;
2721 *pu8CurrByte++ = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002722
Leo Kimadab2f72015-10-13 20:02:05 +09002723 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2724 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2725 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2726 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002727
Leo Kimadab2f72015-10-13 20:02:05 +09002728 if ((strHostIfSetMulti->cnt) > 0)
Arnd Bergmann0e1af732015-11-16 15:04:54 +01002729 memcpy(pu8CurrByte, wilc_multicast_mac_addr_list,
Leo Kimfb70e9f2015-11-05 14:36:09 +09002730 ((strHostIfSetMulti->cnt) * ETH_ALEN));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002731
Glen Leecd2920a2015-12-21 14:18:48 +09002732 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002733 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002734 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002735 PRINT_ER("Failed to send setup multicast config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002736
Leo Kim24db7132015-09-16 18:36:01 +09002737ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002738 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002739}
2740
Glen Lee71130e82015-12-21 14:18:41 +09002741static s32 Handle_DelAllRxBASessions(struct wilc_vif *vif,
Tony Cho54265472015-09-21 12:16:56 +09002742 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002743{
Leo Kim31390ee2015-10-19 18:26:08 +09002744 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002745 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002746 char *ptr = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002747
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002748 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Leo Kim3fc49992015-10-29 11:58:45 +09002749 strHostIfBASessionInfo->bssid[0],
2750 strHostIfBASessionInfo->bssid[1],
2751 strHostIfBASessionInfo->bssid[2],
Leo Kim16c9b392015-10-29 11:58:46 +09002752 strHostIfBASessionInfo->tid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002753
Leo Kim45102f82015-10-28 15:59:28 +09002754 wid.id = (u16)WID_DEL_ALL_RX_BA;
2755 wid.type = WID_STR;
2756 wid.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2757 wid.size = BLOCK_ACK_REQ_SIZE;
2758 ptr = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002759 *ptr++ = 0x14;
2760 *ptr++ = 0x3;
2761 *ptr++ = 0x2;
Leo Kim3fc49992015-10-29 11:58:45 +09002762 memcpy(ptr, strHostIfBASessionInfo->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002763 ptr += ETH_ALEN;
Leo Kim16c9b392015-10-29 11:58:46 +09002764 *ptr++ = strHostIfBASessionInfo->tid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002765 *ptr++ = 0;
Leo Kimae4dfa52015-10-13 19:49:26 +09002766 *ptr++ = 32;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002767
Glen Leecd2920a2015-12-21 14:18:48 +09002768 result = wilc_send_config_pkt(vif->wilc, SET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09002769 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09002770 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002771 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
2772
Leo Kim45102f82015-10-28 15:59:28 +09002773 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002774
Leo Kim2d25af82015-10-15 13:24:56 +09002775 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002776
Leo Kim31390ee2015-10-19 18:26:08 +09002777 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002778}
2779
Arnd Bergmann1999bd52015-05-29 22:52:14 +02002780static int hostIFthread(void *pvArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002781{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002782 u32 u32Ret;
Tony Cho143eb952015-09-21 12:16:32 +09002783 struct host_if_msg msg;
Glen Lee00215dd2015-11-18 15:11:25 +09002784 struct wilc *wilc = (struct wilc*)pvArg;
Glen Leecf601062015-12-21 14:18:39 +09002785 struct wilc_vif *vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002786
Tony Cho143eb952015-09-21 12:16:32 +09002787 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002788
2789 while (1) {
Leo Kimcb067dc2015-10-15 13:24:53 +09002790 wilc_mq_recv(&hif_msg_q, &msg, sizeof(struct host_if_msg), &u32Ret);
Glen Leecf601062015-12-21 14:18:39 +09002791 vif = msg.vif;
Tony Choa9f812a2015-09-21 12:16:33 +09002792 if (msg.id == HOST_IF_MSG_EXIT) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002793 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
2794 break;
2795 }
2796
Arnd Bergmann0e1af732015-11-16 15:04:54 +01002797 if ((!wilc_initialized)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002798 PRINT_D(GENERIC_DBG, "--WAIT--");
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07002799 usleep_range(200 * 1000, 200 * 1000);
Leo Kimcb067dc2015-10-15 13:24:53 +09002800 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002801 continue;
2802 }
2803
Leo Kim91109e12015-10-19 18:26:13 +09002804 if (msg.id == HOST_IF_MSG_CONNECT &&
Glen Leeb13584a2015-12-21 14:18:47 +09002805 vif->hif_drv->usr_scan_req.scan_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002806 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
Leo Kimcb067dc2015-10-15 13:24:53 +09002807 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07002808 usleep_range(2 * 1000, 2 * 1000);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002809 continue;
2810 }
2811
Tony Choa9f812a2015-09-21 12:16:33 +09002812 switch (msg.id) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002813 case HOST_IF_MSG_Q_IDLE:
2814 Handle_wait_msg_q_empty();
2815 break;
2816
2817 case HOST_IF_MSG_SCAN:
Glen Lee71130e82015-12-21 14:18:41 +09002818 Handle_Scan(msg.vif, &msg.body.scan_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002819 break;
2820
2821 case HOST_IF_MSG_CONNECT:
Glen Lee71130e82015-12-21 14:18:41 +09002822 Handle_Connect(msg.vif, &msg.body.con_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002823 break;
2824
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002825 case HOST_IF_MSG_FLUSH_CONNECT:
Glen Lee71130e82015-12-21 14:18:41 +09002826 Handle_FlushConnect(msg.vif);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002827 break;
2828
2829 case HOST_IF_MSG_RCVD_NTWRK_INFO:
Glen Lee71130e82015-12-21 14:18:41 +09002830 Handle_RcvdNtwrkInfo(msg.vif, &msg.body.net_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002831 break;
2832
2833 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
Glen Lee71130e82015-12-21 14:18:41 +09002834 Handle_RcvdGnrlAsyncInfo(vif,
Glen Leecf601062015-12-21 14:18:39 +09002835 &msg.body.async_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002836 break;
2837
2838 case HOST_IF_MSG_KEY:
Glen Lee71130e82015-12-21 14:18:41 +09002839 Handle_Key(msg.vif, &msg.body.key_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002840 break;
2841
2842 case HOST_IF_MSG_CFG_PARAMS:
Glen Lee71130e82015-12-21 14:18:41 +09002843 handle_cfg_param(msg.vif, &msg.body.cfg_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002844 break;
2845
2846 case HOST_IF_MSG_SET_CHANNEL:
Glen Lee71130e82015-12-21 14:18:41 +09002847 handle_set_channel(msg.vif, &msg.body.channel_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002848 break;
2849
2850 case HOST_IF_MSG_DISCONNECT:
Glen Lee71130e82015-12-21 14:18:41 +09002851 Handle_Disconnect(msg.vif);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002852 break;
2853
2854 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
Glen Leeb13584a2015-12-21 14:18:47 +09002855 del_timer(&vif->hif_drv->scan_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002856 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
2857
Glen Lee825b9662015-11-18 15:11:37 +09002858 if (!wilc_wlan_get_num_conn_ifcs(wilc))
Glen Lee00215dd2015-11-18 15:11:25 +09002859 wilc_chip_sleep_manually(wilc);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002860
Glen Lee71130e82015-12-21 14:18:41 +09002861 Handle_ScanDone(msg.vif, SCAN_EVENT_DONE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002862
Glen Leeb13584a2015-12-21 14:18:47 +09002863 if (vif->hif_drv->remain_on_ch_pending)
Glen Lee71130e82015-12-21 14:18:41 +09002864 Handle_RemainOnChan(msg.vif,
2865 &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002866
2867 break;
2868
2869 case HOST_IF_MSG_GET_RSSI:
Glen Lee71130e82015-12-21 14:18:41 +09002870 Handle_GetRssi(msg.vif);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002871 break;
2872
2873 case HOST_IF_MSG_GET_LINKSPEED:
Glen Lee71130e82015-12-21 14:18:41 +09002874 Handle_GetLinkspeed(msg.vif);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002875 break;
2876
2877 case HOST_IF_MSG_GET_STATISTICS:
Glen Lee71130e82015-12-21 14:18:41 +09002878 Handle_GetStatistics(msg.vif,
2879 (struct rf_info *)msg.body.data);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002880 break;
2881
2882 case HOST_IF_MSG_GET_CHNL:
Glen Lee71130e82015-12-21 14:18:41 +09002883 Handle_GetChnl(msg.vif);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002884 break;
2885
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002886 case HOST_IF_MSG_ADD_BEACON:
Glen Lee71130e82015-12-21 14:18:41 +09002887 Handle_AddBeacon(msg.vif, &msg.body.beacon_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002888 break;
2889
2890 case HOST_IF_MSG_DEL_BEACON:
Glen Lee71130e82015-12-21 14:18:41 +09002891 Handle_DelBeacon(msg.vif);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002892 break;
2893
2894 case HOST_IF_MSG_ADD_STATION:
Glen Lee71130e82015-12-21 14:18:41 +09002895 Handle_AddStation(msg.vif, &msg.body.add_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002896 break;
2897
2898 case HOST_IF_MSG_DEL_STATION:
Glen Lee71130e82015-12-21 14:18:41 +09002899 Handle_DelStation(msg.vif, &msg.body.del_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002900 break;
2901
2902 case HOST_IF_MSG_EDIT_STATION:
Glen Lee71130e82015-12-21 14:18:41 +09002903 Handle_EditStation(msg.vif, &msg.body.edit_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002904 break;
2905
2906 case HOST_IF_MSG_GET_INACTIVETIME:
Glen Lee71130e82015-12-21 14:18:41 +09002907 Handle_Get_InActiveTime(msg.vif, &msg.body.mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002908 break;
2909
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002910 case HOST_IF_MSG_SCAN_TIMER_FIRED:
2911 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
2912
Glen Lee71130e82015-12-21 14:18:41 +09002913 Handle_ScanDone(msg.vif, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002914 break;
2915
2916 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002917 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
Glen Lee71130e82015-12-21 14:18:41 +09002918 Handle_ConnectTimeout(msg.vif);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002919 break;
2920
2921 case HOST_IF_MSG_POWER_MGMT:
Glen Lee71130e82015-12-21 14:18:41 +09002922 Handle_PowerManagement(msg.vif,
2923 &msg.body.pwr_mgmt_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002924 break;
2925
2926 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
Glen Lee71130e82015-12-21 14:18:41 +09002927 handle_set_wfi_drv_handler(msg.vif, &msg.body.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002928 break;
2929
2930 case HOST_IF_MSG_SET_OPERATION_MODE:
Glen Lee71130e82015-12-21 14:18:41 +09002931 handle_set_operation_mode(msg.vif, &msg.body.mode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002932 break;
2933
2934 case HOST_IF_MSG_SET_IPADDRESS:
2935 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Glen Lee71130e82015-12-21 14:18:41 +09002936 handle_set_ip_address(vif,
Leo Kima6e6d482015-11-06 11:20:06 +09002937 msg.body.ip_info.ip_addr,
2938 msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002939 break;
2940
2941 case HOST_IF_MSG_GET_IPADDRESS:
2942 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Glen Lee71130e82015-12-21 14:18:41 +09002943 handle_get_ip_address(vif, msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002944 break;
2945
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002946 case HOST_IF_MSG_SET_MAC_ADDRESS:
Glen Lee71130e82015-12-21 14:18:41 +09002947 handle_set_mac_address(msg.vif,
Leo Kima8267422015-11-06 11:20:08 +09002948 &msg.body.set_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002949 break;
2950
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002951 case HOST_IF_MSG_GET_MAC_ADDRESS:
Glen Lee71130e82015-12-21 14:18:41 +09002952 handle_get_mac_address(msg.vif,
Leo Kimb3bf8fd2015-11-06 11:20:09 +09002953 &msg.body.get_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002954 break;
2955
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002956 case HOST_IF_MSG_REMAIN_ON_CHAN:
2957 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
Glen Lee71130e82015-12-21 14:18:41 +09002958 Handle_RemainOnChan(msg.vif, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002959 break;
2960
2961 case HOST_IF_MSG_REGISTER_FRAME:
2962 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
Glen Lee71130e82015-12-21 14:18:41 +09002963 Handle_RegisterFrame(msg.vif, &msg.body.reg_frame);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002964 break;
2965
2966 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
Glen Lee71130e82015-12-21 14:18:41 +09002967 Handle_ListenStateExpired(msg.vif, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002968 break;
2969
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002970 case HOST_IF_MSG_SET_MULTICAST_FILTER:
2971 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
Glen Lee71130e82015-12-21 14:18:41 +09002972 Handle_SetMulticastFilter(msg.vif, &msg.body.multicast_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002973 break;
2974
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002975 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
Glen Lee71130e82015-12-21 14:18:41 +09002976 Handle_DelAllRxBASessions(msg.vif, &msg.body.session_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002977 break;
2978
2979 case HOST_IF_MSG_DEL_ALL_STA:
Glen Lee71130e82015-12-21 14:18:41 +09002980 Handle_DelAllSta(msg.vif, &msg.body.del_all_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002981 break;
2982
2983 default:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002984 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002985 break;
2986 }
2987 }
2988
2989 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
Leo Kim834e0cb2015-10-15 13:24:54 +09002990 up(&hif_sema_thread);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02002991 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002992}
2993
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07002994static void TimerCB_Scan(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002995{
Glen Lee71130e82015-12-21 14:18:41 +09002996 struct wilc_vif *vif = (struct wilc_vif *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09002997 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002998
Tony Cho143eb952015-09-21 12:16:32 +09002999 memset(&msg, 0, sizeof(struct host_if_msg));
Glen Lee71130e82015-12-21 14:18:41 +09003000 msg.vif = vif;
Tony Choa9f812a2015-09-21 12:16:33 +09003001 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003002
Leo Kimcb067dc2015-10-15 13:24:53 +09003003 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003004}
3005
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003006static void TimerCB_Connect(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003007{
Glen Lee71130e82015-12-21 14:18:41 +09003008 struct wilc_vif *vif = (struct wilc_vif *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09003009 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003010
Tony Cho143eb952015-09-21 12:16:32 +09003011 memset(&msg, 0, sizeof(struct host_if_msg));
Glen Lee71130e82015-12-21 14:18:41 +09003012 msg.vif = vif;
Tony Choa9f812a2015-09-21 12:16:33 +09003013 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003014
Leo Kimcb067dc2015-10-15 13:24:53 +09003015 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003016}
3017
Arnd Bergmann0e1af732015-11-16 15:04:54 +01003018s32 wilc_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003019{
Leo Kim45102f82015-10-28 15:59:28 +09003020 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003021
Leo Kim45102f82015-10-28 15:59:28 +09003022 wid.id = (u16)WID_REMOVE_KEY;
3023 wid.type = WID_STR;
3024 wid.val = (s8 *)pu8StaAddress;
3025 wid.size = 6;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003026
Leo Kimb68d820b2015-10-12 16:55:37 +09003027 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003028}
3029
Glen Leefbf53792015-12-21 14:18:40 +09003030int wilc_remove_wep_key(struct wilc_vif *vif, u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003031{
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003032 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003033 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003034 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003035
Tony Choa4ab1ad2015-10-12 16:56:05 +09003036 if (!hif_drv) {
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003037 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003038 PRINT_ER("Failed to send setup multicast config packet\n");
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003039 return result;
Leo Kim24db7132015-09-16 18:36:01 +09003040 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003041
Tony Cho143eb952015-09-21 12:16:32 +09003042 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003043
Tony Choa9f812a2015-09-21 12:16:33 +09003044 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003045 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003046 msg.body.key_info.action = REMOVEKEY;
Glen Leecf601062015-12-21 14:18:39 +09003047 msg.vif = vif;
Leo Kim73b2e382015-10-13 19:49:29 +09003048 msg.body.key_info.attr.wep.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003049
Leo Kimcb067dc2015-10-15 13:24:53 +09003050 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003051 if (result)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003052 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003053 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003054
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003055 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003056}
3057
Glen Leefbf53792015-12-21 14:18:40 +09003058int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003059{
Chaehyun Lim5b41c7c2015-10-26 09:44:42 +09003060 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003061 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003062 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003063
Tony Choa4ab1ad2015-10-12 16:56:05 +09003064 if (!hif_drv) {
Leo Kim31390ee2015-10-19 18:26:08 +09003065 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003066 PRINT_ER("driver is null\n");
Leo Kim31390ee2015-10-19 18:26:08 +09003067 return result;
Leo Kim24db7132015-09-16 18:36:01 +09003068 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003069
Tony Cho143eb952015-09-21 12:16:32 +09003070 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003071
Tony Choa9f812a2015-09-21 12:16:33 +09003072 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003073 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003074 msg.body.key_info.action = DEFAULTKEY;
Glen Leecf601062015-12-21 14:18:39 +09003075 msg.vif = vif;
Chaehyun Lime91d0342015-10-26 09:44:44 +09003076 msg.body.key_info.attr.wep.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003077
Leo Kim31390ee2015-10-19 18:26:08 +09003078 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3079 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003080 PRINT_ER("Error in sending message queue : Default key index\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003081 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003082
Leo Kim31390ee2015-10-19 18:26:08 +09003083 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003084}
3085
Glen Leefbf53792015-12-21 14:18:40 +09003086int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len,
3087 u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003088{
Chaehyun Lim66b8cb82015-10-27 20:40:32 +09003089 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003090 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003091 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003092
Tony Choa4ab1ad2015-10-12 16:56:05 +09003093 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003094 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003095 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003096 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003097
Tony Cho143eb952015-09-21 12:16:32 +09003098 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003099
Tony Choa9f812a2015-09-21 12:16:33 +09003100 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003101 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003102 msg.body.key_info.action = ADDKEY;
Glen Leecf601062015-12-21 14:18:39 +09003103 msg.vif = vif;
Chaehyun Lim1cc0c322015-10-27 20:40:37 +09003104 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3105 if (!msg.body.key_info.attr.wep.key)
3106 return -ENOMEM;
3107
Chaehyun Limdbc53192015-10-27 20:40:35 +09003108 msg.body.key_info.attr.wep.key_len = len;
Chaehyun Lim0b2cc3e2015-10-27 20:40:36 +09003109 msg.body.key_info.attr.wep.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003110
Leo Kim31390ee2015-10-19 18:26:08 +09003111 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3112 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003113 PRINT_ER("Error in sending message queue :WEP Key\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003114 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003115
Leo Kim31390ee2015-10-19 18:26:08 +09003116 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003117}
3118
Glen Leefbf53792015-12-21 14:18:40 +09003119int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len,
3120 u8 index, u8 mode, enum AUTHTYPE auth_type)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003121{
Chaehyun Lim641c20a2015-10-28 08:19:19 +09003122 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003123 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003124 struct host_if_drv *hif_drv = vif->hif_drv;
Chaehyun Limfd741462015-10-28 08:19:21 +09003125 int i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003126
Tony Choa4ab1ad2015-10-12 16:56:05 +09003127 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003128 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003129 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003130 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003131
Tony Cho143eb952015-09-21 12:16:32 +09003132 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003133
3134 if (INFO) {
Chaehyun Lima5389b02015-10-28 08:19:23 +09003135 for (i = 0; i < len; i++)
Chaehyun Lim81117252015-10-28 08:19:22 +09003136 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", key[i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003137 }
Tony Choa9f812a2015-09-21 12:16:33 +09003138 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003139 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003140 msg.body.key_info.action = ADDKEY_AP;
Glen Leecf601062015-12-21 14:18:39 +09003141 msg.vif = vif;
Chaehyun Lim58eabd62015-10-28 08:19:27 +09003142 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3143 if (!msg.body.key_info.attr.wep.key)
3144 return -ENOMEM;
3145
Chaehyun Lima5389b02015-10-28 08:19:23 +09003146 msg.body.key_info.attr.wep.key_len = len;
Chaehyun Lima76dc952015-10-28 08:19:24 +09003147 msg.body.key_info.attr.wep.index = index;
Chaehyun Lim730a28d2015-10-28 08:19:25 +09003148 msg.body.key_info.attr.wep.mode = mode;
Chaehyun Limff3bce22015-10-28 08:19:26 +09003149 msg.body.key_info.attr.wep.auth_type = auth_type;
Leo Kimae4dfa52015-10-13 19:49:26 +09003150
Leo Kim31390ee2015-10-19 18:26:08 +09003151 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003152
Leo Kim31390ee2015-10-19 18:26:08 +09003153 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003154 PRINT_ER("Error in sending message queue :WEP Key\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003155 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003156
Leo Kim31390ee2015-10-19 18:26:08 +09003157 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003158}
Glen Lee108b3432015-09-16 18:53:20 +09003159
Glen Leefbf53792015-12-21 14:18:40 +09003160int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
3161 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
3162 u8 mode, u8 cipher_mode, u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003163{
Chaehyun Lim706ab422015-11-08 16:48:54 +09003164 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003165 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003166 struct host_if_drv *hif_drv = vif->hif_drv;
Chaehyun Lim53bbbb52015-11-08 16:49:03 +09003167 u8 key_len = ptk_key_len;
Chaehyun Limfa269072015-11-08 16:49:02 +09003168 int i;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003169
Tony Choa4ab1ad2015-10-12 16:56:05 +09003170 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003171 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003172 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003173 }
Leo Kim91109e12015-10-19 18:26:13 +09003174
Chaehyun Lim38f66292015-11-08 16:48:58 +09003175 if (rx_mic)
Chaehyun Lim53bbbb52015-11-08 16:49:03 +09003176 key_len += RX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003177
Chaehyun Limd7c02422015-11-08 16:48:59 +09003178 if (tx_mic)
Chaehyun Lim53bbbb52015-11-08 16:49:03 +09003179 key_len += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003180
Tony Cho143eb952015-09-21 12:16:32 +09003181 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003182
Tony Choa9f812a2015-09-21 12:16:33 +09003183 msg.id = HOST_IF_MSG_KEY;
Leo Kim2141fe32015-10-29 12:05:35 +09003184 msg.body.key_info.type = WPA_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003185 if (mode == AP_MODE) {
Leo Kim0d17e382015-10-13 19:49:28 +09003186 msg.body.key_info.action = ADDKEY_AP;
Chaehyun Lim3e5c4ab2015-11-08 16:49:01 +09003187 msg.body.key_info.attr.wpa.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003188 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003189 if (mode == STATION_MODE)
Leo Kim0d17e382015-10-13 19:49:28 +09003190 msg.body.key_info.action = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003191
Chaehyun Lim8ab8c592015-11-08 16:49:04 +09003192 msg.body.key_info.attr.wpa.key = kmemdup(ptk, ptk_key_len, GFP_KERNEL);
3193 if (!msg.body.key_info.attr.wpa.key)
3194 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003195
Chaehyun Lim38f66292015-11-08 16:48:58 +09003196 if (rx_mic) {
3197 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic, RX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003198 if (INFO) {
3199 for (i = 0; i < RX_MIC_KEY_LEN; i++)
Chaehyun Lim38f66292015-11-08 16:48:58 +09003200 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, rx_mic[i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003201 }
3202 }
Chaehyun Limd7c02422015-11-08 16:48:59 +09003203 if (tx_mic) {
3204 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic, TX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003205 if (INFO) {
3206 for (i = 0; i < TX_MIC_KEY_LEN; i++)
Chaehyun Limd7c02422015-11-08 16:48:59 +09003207 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, tx_mic[i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003208 }
3209 }
3210
Chaehyun Lim53bbbb52015-11-08 16:49:03 +09003211 msg.body.key_info.attr.wpa.key_len = key_len;
Leo Kim248080a2015-10-13 19:49:31 +09003212 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
Chaehyun Limf0c82572015-11-08 16:49:00 +09003213 msg.body.key_info.attr.wpa.mode = cipher_mode;
Glen Leecf601062015-12-21 14:18:39 +09003214 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003215
Leo Kim31390ee2015-10-19 18:26:08 +09003216 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003217
Leo Kim31390ee2015-10-19 18:26:08 +09003218 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003219 PRINT_ER("Error in sending message queue: PTK Key\n");
3220
Leo Kim9ea47132015-10-29 11:58:28 +09003221 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003222
Leo Kim31390ee2015-10-19 18:26:08 +09003223 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003224}
3225
Glen Leefbf53792015-12-21 14:18:40 +09003226int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
3227 u8 index, u32 key_rsc_len, const u8 *key_rsc,
3228 const u8 *rx_mic, const u8 *tx_mic, u8 mode,
3229 u8 cipher_mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003230{
Chaehyun Lim15034572015-11-08 16:49:05 +09003231 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003232 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003233 struct host_if_drv *hif_drv = vif->hif_drv;
Chaehyun Limd002fcc2015-11-08 16:49:15 +09003234 u8 key_len = gtk_key_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003235
Tony Choa4ab1ad2015-10-12 16:56:05 +09003236 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003237 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003238 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003239 }
Tony Cho143eb952015-09-21 12:16:32 +09003240 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003241
Chaehyun Lim6d36c272015-11-08 16:49:12 +09003242 if (rx_mic)
Chaehyun Limd002fcc2015-11-08 16:49:15 +09003243 key_len += RX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003244
Chaehyun Lim2f797582015-11-08 16:49:13 +09003245 if (tx_mic)
Chaehyun Limd002fcc2015-11-08 16:49:15 +09003246 key_len += TX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003247
Chaehyun Lim982859c2015-11-08 16:49:11 +09003248 if (key_rsc) {
Chaehyun Lim9bfda382015-11-08 16:49:16 +09003249 msg.body.key_info.attr.wpa.seq = kmemdup(key_rsc,
3250 key_rsc_len,
3251 GFP_KERNEL);
3252 if (!msg.body.key_info.attr.wpa.seq)
3253 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003254 }
3255
Tony Choa9f812a2015-09-21 12:16:33 +09003256 msg.id = HOST_IF_MSG_KEY;
Leo Kim5cd8f7a2015-10-29 12:05:34 +09003257 msg.body.key_info.type = WPA_RX_GTK;
Glen Leecf601062015-12-21 14:18:39 +09003258 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003259
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003260 if (mode == AP_MODE) {
Leo Kim0d17e382015-10-13 19:49:28 +09003261 msg.body.key_info.action = ADDKEY_AP;
Chaehyun Lim57bfcbc2015-11-08 16:49:14 +09003262 msg.body.key_info.attr.wpa.mode = cipher_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003263 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003264 if (mode == STATION_MODE)
Leo Kim0d17e382015-10-13 19:49:28 +09003265 msg.body.key_info.action = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003266
Chaehyun Lim9bfda382015-11-08 16:49:16 +09003267 msg.body.key_info.attr.wpa.key = kmemdup(rx_gtk,
3268 key_len,
3269 GFP_KERNEL);
3270 if (!msg.body.key_info.attr.wpa.key)
3271 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003272
Chaehyun Lim6d36c272015-11-08 16:49:12 +09003273 if (rx_mic)
3274 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic,
Leo Kimd1666e22015-10-28 15:59:22 +09003275 RX_MIC_KEY_LEN);
Leo Kim91109e12015-10-19 18:26:13 +09003276
Chaehyun Lim2f797582015-11-08 16:49:13 +09003277 if (tx_mic)
3278 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic,
Leo Kimd1666e22015-10-28 15:59:22 +09003279 TX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003280
Chaehyun Lim9a5e57362015-11-08 16:49:09 +09003281 msg.body.key_info.attr.wpa.index = index;
Chaehyun Limd002fcc2015-11-08 16:49:15 +09003282 msg.body.key_info.attr.wpa.key_len = key_len;
Chaehyun Lim18bef992015-11-08 16:49:10 +09003283 msg.body.key_info.attr.wpa.seq_len = key_rsc_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003284
Leo Kim31390ee2015-10-19 18:26:08 +09003285 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3286 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003287 PRINT_ER("Error in sending message queue: RX GTK\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09003288
Leo Kim9ea47132015-10-29 11:58:28 +09003289 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003290
Leo Kim31390ee2015-10-19 18:26:08 +09003291 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003292}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003293
Glen Leefbf53792015-12-21 14:18:40 +09003294s32 wilc_set_pmkid_info(struct wilc_vif *vif,
Glen Leecf601062015-12-21 14:18:39 +09003295 struct host_if_pmkid_attr *pu8PmkidInfoArray)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003296{
Leo Kim31390ee2015-10-19 18:26:08 +09003297 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003298 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003299 struct host_if_drv *hif_drv = vif->hif_drv;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003300 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003301
Tony Choa4ab1ad2015-10-12 16:56:05 +09003302 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003303 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003304 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003305 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003306
Tony Cho143eb952015-09-21 12:16:32 +09003307 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003308
Tony Choa9f812a2015-09-21 12:16:33 +09003309 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003310 msg.body.key_info.type = PMKSA;
Leo Kim0d17e382015-10-13 19:49:28 +09003311 msg.body.key_info.action = ADDKEY;
Glen Leecf601062015-12-21 14:18:39 +09003312 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003313
3314 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
Leo Kim8c8360b2015-10-19 18:26:12 +09003315 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid,
3316 &pu8PmkidInfoArray->pmkidlist[i].bssid, ETH_ALEN);
3317 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid,
3318 &pu8PmkidInfoArray->pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003319 }
3320
Leo Kim31390ee2015-10-19 18:26:08 +09003321 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3322 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003323 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3324
Leo Kim31390ee2015-10-19 18:26:08 +09003325 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003326}
3327
Glen Leefbf53792015-12-21 14:18:40 +09003328s32 wilc_get_mac_address(struct wilc_vif *vif, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003329{
Leo Kim31390ee2015-10-19 18:26:08 +09003330 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003331 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003332
Tony Cho143eb952015-09-21 12:16:32 +09003333 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003334
Tony Choa9f812a2015-09-21 12:16:33 +09003335 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
Leo Kim6ceba0a2015-10-28 15:59:32 +09003336 msg.body.get_mac_info.mac_addr = pu8MacAddress;
Glen Leecf601062015-12-21 14:18:39 +09003337 msg.vif = vif;
Leo Kimae4dfa52015-10-13 19:49:26 +09003338
Leo Kim31390ee2015-10-19 18:26:08 +09003339 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3340 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003341 PRINT_ER("Failed to send get mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +09003342 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003343 }
3344
Leo Kim2d25af82015-10-15 13:24:56 +09003345 down(&hif_sema_wait_response);
Leo Kim31390ee2015-10-19 18:26:08 +09003346 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003347}
3348
Glen Leefbf53792015-12-21 14:18:40 +09003349s32 wilc_set_mac_address(struct wilc_vif *vif, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003350{
Leo Kim31390ee2015-10-19 18:26:08 +09003351 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003352 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003353
3354 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
3355
Tony Cho143eb952015-09-21 12:16:32 +09003356 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003357 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
Leo Kimae5e4522015-10-28 15:59:31 +09003358 memcpy(msg.body.set_mac_info.mac_addr, pu8MacAddress, ETH_ALEN);
Glen Leecf601062015-12-21 14:18:39 +09003359 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003360
Leo Kim31390ee2015-10-19 18:26:08 +09003361 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3362 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003363 PRINT_ER("Failed to send message queue: Set mac address\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003364
Leo Kim31390ee2015-10-19 18:26:08 +09003365 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003366}
3367
Glen Leefbf53792015-12-21 14:18:40 +09003368s32 wilc_set_join_req(struct wilc_vif *vif, u8 *pu8bssid, const u8 *pu8ssid,
3369 size_t ssidLen, const u8 *pu8IEs, size_t IEsLen,
Glen Leecf601062015-12-21 14:18:39 +09003370 wilc_connect_result pfConnectResult, void *pvUserArg,
3371 u8 u8security, enum AUTHTYPE tenuAuth_type,
3372 u8 u8channel, void *pJoinParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003373{
Leo Kim31390ee2015-10-19 18:26:08 +09003374 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003375 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003376 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003377
Leo Kim91109e12015-10-19 18:26:13 +09003378 if (!hif_drv || !pfConnectResult) {
Leo Kim24db7132015-09-16 18:36:01 +09003379 PRINT_ER("Driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003380 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003381 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003382
Leo Kim91109e12015-10-19 18:26:13 +09003383 if (!pJoinParams) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003384 PRINT_ER("Unable to Join - JoinParams is NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003385 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003386 }
Leo Kim24db7132015-09-16 18:36:01 +09003387
Tony Cho143eb952015-09-21 12:16:32 +09003388 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003389
Tony Choa9f812a2015-09-21 12:16:33 +09003390 msg.id = HOST_IF_MSG_CONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003391
Leo Kima64fd672015-10-13 19:49:54 +09003392 msg.body.con_info.security = u8security;
Leo Kim61b4fd02015-10-13 19:49:57 +09003393 msg.body.con_info.auth_type = tenuAuth_type;
Leo Kim0d1527e2015-10-13 19:49:58 +09003394 msg.body.con_info.ch = u8channel;
Leo Kim6abcc112015-10-13 19:49:55 +09003395 msg.body.con_info.result = pfConnectResult;
Leo Kim8f38db82015-10-13 19:49:56 +09003396 msg.body.con_info.arg = pvUserArg;
Leo Kimf2bed2c2015-10-13 19:49:59 +09003397 msg.body.con_info.params = pJoinParams;
Glen Leecf601062015-12-21 14:18:39 +09003398 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003399
Leo Kim91109e12015-10-19 18:26:13 +09003400 if (pu8bssid) {
Leo Kim9254db02015-10-13 19:49:49 +09003401 msg.body.con_info.bssid = kmalloc(6, GFP_KERNEL);
3402 memcpy(msg.body.con_info.bssid, pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003403 }
3404
Leo Kim91109e12015-10-19 18:26:13 +09003405 if (pu8ssid) {
Leo Kim8b3c9fa2015-10-13 19:49:51 +09003406 msg.body.con_info.ssid_len = ssidLen;
Leo Kimf7bbd9c2015-10-13 19:49:50 +09003407 msg.body.con_info.ssid = kmalloc(ssidLen, GFP_KERNEL);
3408 memcpy(msg.body.con_info.ssid, pu8ssid, ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003409 }
3410
Leo Kim91109e12015-10-19 18:26:13 +09003411 if (pu8IEs) {
Leo Kimb59d5c52015-10-13 19:49:53 +09003412 msg.body.con_info.ies_len = IEsLen;
Leo Kim2ea158c2015-10-13 19:49:52 +09003413 msg.body.con_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3414 memcpy(msg.body.con_info.ies, pu8IEs, IEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003415 }
Leo Kimb60005a2015-10-29 11:58:24 +09003416 if (hif_drv->hif_state < HOST_IF_CONNECTING)
3417 hif_drv->hif_state = HOST_IF_CONNECTING;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05303418 else
Leo Kimb60005a2015-10-29 11:58:24 +09003419 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' : %d\n",
3420 hif_drv->hif_state);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003421
Leo Kim31390ee2015-10-19 18:26:08 +09003422 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3423 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003424 PRINT_ER("Failed to send message queue: Set join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09003425 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003426 }
3427
Glen Lee71130e82015-12-21 14:18:41 +09003428 hif_drv->connect_timer.data = (unsigned long)vif;
Leo Kim81a59502015-10-29 11:58:35 +09003429 mod_timer(&hif_drv->connect_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003430 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003431
Leo Kim31390ee2015-10-19 18:26:08 +09003432 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003433}
3434
Glen Leefbf53792015-12-21 14:18:40 +09003435s32 wilc_flush_join_req(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003436{
Leo Kim31390ee2015-10-19 18:26:08 +09003437 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003438 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003439 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003440
Leo Kim7717880782015-10-19 18:26:11 +09003441 if (!join_req)
3442 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003443
Tony Choa4ab1ad2015-10-12 16:56:05 +09003444 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003445 PRINT_ER("Driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003446 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003447 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003448
Tony Choa9f812a2015-09-21 12:16:33 +09003449 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
Glen Leecf601062015-12-21 14:18:39 +09003450 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003451
Leo Kim31390ee2015-10-19 18:26:08 +09003452 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3453 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003454 PRINT_ER("Failed to send message queue: Flush join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09003455 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003456 }
3457
Leo Kim31390ee2015-10-19 18:26:08 +09003458 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003459}
3460
Glen Leefbf53792015-12-21 14:18:40 +09003461s32 wilc_disconnect(struct wilc_vif *vif, u16 u16ReasonCode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003462{
Leo Kim31390ee2015-10-19 18:26:08 +09003463 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003464 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003465 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003466
Tony Choa4ab1ad2015-10-12 16:56:05 +09003467 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003468 PRINT_ER("Driver is null\n");
3469 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003470 }
3471
Tony Cho143eb952015-09-21 12:16:32 +09003472 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003473
Tony Choa9f812a2015-09-21 12:16:33 +09003474 msg.id = HOST_IF_MSG_DISCONNECT;
Glen Leecf601062015-12-21 14:18:39 +09003475 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003476
Leo Kim31390ee2015-10-19 18:26:08 +09003477 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3478 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003479 PRINT_ER("Failed to send message queue: disconnect\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09003480
Leo Kime55e4962015-10-29 11:58:29 +09003481 down(&hif_drv->sem_test_disconn_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003482
Leo Kim31390ee2015-10-19 18:26:08 +09003483 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003484}
3485
Glen Lee71130e82015-12-21 14:18:41 +09003486static s32 host_int_get_assoc_res_info(struct wilc_vif *vif,
Arnd Bergmann1608c402015-11-16 15:04:53 +01003487 u8 *pu8AssocRespInfo,
3488 u32 u32MaxAssocRespInfoLen,
3489 u32 *pu32RcvdAssocRespInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003490{
Leo Kim31390ee2015-10-19 18:26:08 +09003491 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09003492 struct wid wid;
Glen Lee71130e82015-12-21 14:18:41 +09003493 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003494
Tony Choa4ab1ad2015-10-12 16:56:05 +09003495 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003496 PRINT_ER("Driver is null\n");
3497 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003498 }
3499
Leo Kim45102f82015-10-28 15:59:28 +09003500 wid.id = (u16)WID_ASSOC_RES_INFO;
3501 wid.type = WID_STR;
3502 wid.val = pu8AssocRespInfo;
3503 wid.size = u32MaxAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003504
Glen Leecd2920a2015-12-21 14:18:48 +09003505 result = wilc_send_config_pkt(vif->wilc, GET_CFG, &wid, 1,
Glen Leeeb9939b2015-12-21 14:18:43 +09003506 wilc_get_vif_idx(vif));
Leo Kim31390ee2015-10-19 18:26:08 +09003507 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003508 *pu32RcvdAssocRespInfoLen = 0;
Leo Kim24db7132015-09-16 18:36:01 +09003509 PRINT_ER("Failed to send association response config packet\n");
3510 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003511 } else {
Leo Kim45102f82015-10-28 15:59:28 +09003512 *pu32RcvdAssocRespInfoLen = wid.size;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003513 }
3514
Leo Kim31390ee2015-10-19 18:26:08 +09003515 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003516}
3517
Glen Leefbf53792015-12-21 14:18:40 +09003518int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003519{
Chaehyun Lim792fb252015-10-05 11:07:22 +09003520 int result;
Tony Cho143eb952015-09-21 12:16:32 +09003521 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003522 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003523
Tony Choa4ab1ad2015-10-12 16:56:05 +09003524 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003525 PRINT_ER("driver is null\n");
3526 return -EFAULT;
3527 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003528
Tony Cho143eb952015-09-21 12:16:32 +09003529 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003530 msg.id = HOST_IF_MSG_SET_CHANNEL;
Leo Kim730ee052015-10-13 19:50:02 +09003531 msg.body.channel_info.set_ch = channel;
Glen Leecf601062015-12-21 14:18:39 +09003532 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003533
Leo Kimcb067dc2015-10-15 13:24:53 +09003534 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lim1ef58e42015-10-02 21:44:49 +09003535 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003536 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim792fb252015-10-05 11:07:22 +09003537 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003538 }
3539
Chaehyun Lim792fb252015-10-05 11:07:22 +09003540 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003541}
3542
Arnd Bergmann0e1af732015-11-16 15:04:54 +01003543int wilc_wait_msg_queue_idle(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003544{
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003545 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003546 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003547
Tony Cho143eb952015-09-21 12:16:32 +09003548 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003549 msg.id = HOST_IF_MSG_Q_IDLE;
Leo Kimcb067dc2015-10-15 13:24:53 +09003550 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003551 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003552 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003553 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003554 }
3555
Leo Kim2d25af82015-10-15 13:24:56 +09003556 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003557
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003558 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003559}
3560
Glen Lee31f0f692015-12-21 14:18:44 +09003561int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003562{
Chaehyun Lima0941012015-10-05 19:34:47 +09003563 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003564 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003565
Tony Cho143eb952015-09-21 12:16:32 +09003566 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003567 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
Glen Lee31f0f692015-12-21 14:18:44 +09003568 msg.body.drv.handler = index;
Glen Leecf601062015-12-21 14:18:39 +09003569 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003570
Leo Kimcb067dc2015-10-15 13:24:53 +09003571 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lima0941012015-10-05 19:34:47 +09003572 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003573 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0941012015-10-05 19:34:47 +09003574 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003575 }
3576
Chaehyun Lima0941012015-10-05 19:34:47 +09003577 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003578}
3579
Glen Leefbf53792015-12-21 14:18:40 +09003580int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003581{
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003582 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003583 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003584
Tony Cho143eb952015-09-21 12:16:32 +09003585 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003586 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
Leo Kimc96debf2015-10-28 15:59:30 +09003587 msg.body.mode.mode = mode;
Glen Leecf601062015-12-21 14:18:39 +09003588 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003589
Leo Kimcb067dc2015-10-15 13:24:53 +09003590 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003591 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003592 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003593 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003594 }
3595
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003596 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003597}
3598
Glen Leefbf53792015-12-21 14:18:40 +09003599s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
3600 u32 *pu32InactiveTime)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003601{
Leo Kim31390ee2015-10-19 18:26:08 +09003602 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003603 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003604 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003605
Tony Choa4ab1ad2015-10-12 16:56:05 +09003606 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003607 PRINT_ER("driver is null\n");
3608 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003609 }
3610
Tony Cho143eb952015-09-21 12:16:32 +09003611 memset(&msg, 0, sizeof(struct host_if_msg));
Leo Kim8c8360b2015-10-19 18:26:12 +09003612 memcpy(msg.body.mac_info.mac, mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003613
Tony Choa9f812a2015-09-21 12:16:33 +09003614 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
Glen Leecf601062015-12-21 14:18:39 +09003615 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003616
Leo Kim31390ee2015-10-19 18:26:08 +09003617 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3618 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003619 PRINT_ER("Failed to send get host channel param's message queue ");
3620
Leo Kim569a3c62015-10-29 11:58:33 +09003621 down(&hif_drv->sem_inactive_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003622
Leo Kimad269062015-10-15 13:25:06 +09003623 *pu32InactiveTime = inactive_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003624
Leo Kim31390ee2015-10-19 18:26:08 +09003625 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003626}
Glen Lee108b3432015-09-16 18:53:20 +09003627
Glen Leefbf53792015-12-21 14:18:40 +09003628s32 wilc_get_rssi(struct wilc_vif *vif, s8 *ps8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003629{
Leo Kim31390ee2015-10-19 18:26:08 +09003630 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003631 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003632 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003633
Leo Kimc09389a2015-10-28 15:59:24 +09003634 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003635 msg.id = HOST_IF_MSG_GET_RSSI;
Glen Leecf601062015-12-21 14:18:39 +09003636 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003637
Leo Kim31390ee2015-10-19 18:26:08 +09003638 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3639 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003640 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003641 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003642 }
3643
Leo Kim7e111f92015-10-29 11:58:30 +09003644 down(&hif_drv->sem_get_rssi);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003645
Leo Kim91109e12015-10-19 18:26:13 +09003646 if (!ps8Rssi) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003647 PRINT_ER("RSS pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09003648 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003649 }
3650
Leo Kim144b7b22015-10-15 13:25:01 +09003651 *ps8Rssi = rssi;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003652
Leo Kim31390ee2015-10-19 18:26:08 +09003653 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003654}
3655
Glen Leefbf53792015-12-21 14:18:40 +09003656s32 wilc_get_statistics(struct wilc_vif *vif, struct rf_info *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003657{
Leo Kim31390ee2015-10-19 18:26:08 +09003658 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003659 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003660
Leo Kimc09389a2015-10-28 15:59:24 +09003661 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003662 msg.id = HOST_IF_MSG_GET_STATISTICS;
Tony Choe60831e2015-10-05 13:50:45 +09003663 msg.body.data = (char *)pstrStatistics;
Glen Leecf601062015-12-21 14:18:39 +09003664 msg.vif = vif;
Leo Kimae4dfa52015-10-13 19:49:26 +09003665
Leo Kim31390ee2015-10-19 18:26:08 +09003666 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3667 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003668 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003669 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003670 }
3671
Leo Kim2d25af82015-10-15 13:24:56 +09003672 down(&hif_sema_wait_response);
Leo Kim31390ee2015-10-19 18:26:08 +09003673 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003674}
3675
Glen Leefbf53792015-12-21 14:18:40 +09003676s32 wilc_scan(struct wilc_vif *vif, u8 u8ScanSource, u8 u8ScanType,
3677 u8 *pu8ChnlFreqList, u8 u8ChnlListLen, const u8 *pu8IEs,
3678 size_t IEsLen, wilc_scan_result ScanResult, void *pvUserArg,
3679 struct hidden_network *pstrHiddenNetwork)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003680{
Leo Kim31390ee2015-10-19 18:26:08 +09003681 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003682 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003683 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003684
Leo Kim91109e12015-10-19 18:26:13 +09003685 if (!hif_drv || !ScanResult) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09003686 PRINT_ER("hif_drv or ScanResult = NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003687 return -EFAULT;
3688 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003689
Tony Cho143eb952015-09-21 12:16:32 +09003690 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003691
Tony Choa9f812a2015-09-21 12:16:33 +09003692 msg.id = HOST_IF_MSG_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003693
Leo Kim91109e12015-10-19 18:26:13 +09003694 if (pstrHiddenNetwork) {
Leo Kim629b9ca2015-10-13 19:49:46 +09003695 msg.body.scan_info.hidden_network.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
3696 msg.body.scan_info.hidden_network.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003697
3698 } else
3699 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
3700
Glen Leecf601062015-12-21 14:18:39 +09003701 msg.vif = vif;
Leo Kim42568892015-10-13 19:49:37 +09003702 msg.body.scan_info.src = u8ScanSource;
Leo Kim1e276c82015-10-13 19:49:38 +09003703 msg.body.scan_info.type = u8ScanType;
Leo Kimc17c6da2015-10-13 19:49:44 +09003704 msg.body.scan_info.result = ScanResult;
Leo Kim5f2b50c2015-10-13 19:49:45 +09003705 msg.body.scan_info.arg = pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003706
Leo Kimf97bd9c2015-10-13 19:49:41 +09003707 msg.body.scan_info.ch_list_len = u8ChnlListLen;
Leo Kim82eeb0a2015-10-13 19:49:40 +09003708 msg.body.scan_info.ch_freq_list = kmalloc(u8ChnlListLen, GFP_KERNEL);
3709 memcpy(msg.body.scan_info.ch_freq_list, pu8ChnlFreqList, u8ChnlListLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003710
Leo Kim7b1f76c2015-10-13 19:49:43 +09003711 msg.body.scan_info.ies_len = IEsLen;
Leo Kimd6f19aa2015-10-13 19:49:42 +09003712 msg.body.scan_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3713 memcpy(msg.body.scan_info.ies, pu8IEs, IEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003714
Leo Kim31390ee2015-10-19 18:26:08 +09003715 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3716 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003717 PRINT_ER("Error in sending message queue\n");
3718 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003719 }
3720
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003721 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
Glen Lee71130e82015-12-21 14:18:41 +09003722 hif_drv->scan_timer.data = (unsigned long)vif;
Leo Kim13b313e2015-10-29 11:58:34 +09003723 mod_timer(&hif_drv->scan_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003724 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003725
Leo Kim31390ee2015-10-19 18:26:08 +09003726 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003727}
Leo Kimae4dfa52015-10-13 19:49:26 +09003728
Glen Leefbf53792015-12-21 14:18:40 +09003729s32 wilc_hif_set_cfg(struct wilc_vif *vif,
3730 struct cfg_param_val *pstrCfgParamVal)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003731{
Leo Kim31390ee2015-10-19 18:26:08 +09003732 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003733 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003734 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003735
Tony Choa4ab1ad2015-10-12 16:56:05 +09003736 if (!hif_drv) {
3737 PRINT_ER("hif_drv NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003738 return -EFAULT;
3739 }
Leo Kimae4dfa52015-10-13 19:49:26 +09003740
Tony Cho143eb952015-09-21 12:16:32 +09003741 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003742 msg.id = HOST_IF_MSG_CFG_PARAMS;
Tony Cho221371e2015-10-12 16:56:06 +09003743 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
Glen Leecf601062015-12-21 14:18:39 +09003744 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003745
Leo Kim31390ee2015-10-19 18:26:08 +09003746 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003747
Leo Kim31390ee2015-10-19 18:26:08 +09003748 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003749}
3750
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003751static void GetPeriodicRSSI(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003752{
Glen Lee71130e82015-12-21 14:18:41 +09003753 struct wilc_vif *vif = (struct wilc_vif *)arg;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003754
Glen Lee71130e82015-12-21 14:18:41 +09003755 if (!vif->hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003756 PRINT_ER("Driver handler is NULL\n");
3757 return;
3758 }
3759
Glen Lee71130e82015-12-21 14:18:41 +09003760 if (vif->hif_drv->hif_state == HOST_IF_CONNECTED) {
Leo Kim31390ee2015-10-19 18:26:08 +09003761 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003762 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003763
Tony Cho143eb952015-09-21 12:16:32 +09003764 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003765
Tony Choa9f812a2015-09-21 12:16:33 +09003766 msg.id = HOST_IF_MSG_GET_RSSI;
Glen Lee71130e82015-12-21 14:18:41 +09003767 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003768
Leo Kim31390ee2015-10-19 18:26:08 +09003769 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3770 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003771 PRINT_ER("Failed to send get host channel param's message queue ");
3772 return;
3773 }
3774 }
Glen Lee71130e82015-12-21 14:18:41 +09003775 periodic_rssi.data = (unsigned long)vif;
Leo Kim262f55e2015-10-15 13:24:58 +09003776 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003777}
3778
Arnd Bergmann0e1af732015-11-16 15:04:54 +01003779s32 wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003780{
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09003781 s32 result = 0;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003782 struct host_if_drv *hif_drv;
Glen Leea4cac482015-12-21 14:18:36 +09003783 struct wilc_vif *vif;
Glen Leed53822192015-10-27 18:27:49 +09003784 struct wilc *wilc;
Glen Lee03efae32015-12-21 14:18:49 +09003785 int i;
Glen Leed53822192015-10-27 18:27:49 +09003786
Glen Leea4cac482015-12-21 14:18:36 +09003787 vif = netdev_priv(dev);
3788 wilc = vif->wilc;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003789
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003790 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
3791
Leo Kimca8540e42015-10-15 13:25:00 +09003792 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003793
Leo Kim2d25af82015-10-15 13:24:56 +09003794 sema_init(&hif_sema_wait_response, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003795
Tony Choa4ab1ad2015-10-12 16:56:05 +09003796 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
3797 if (!hif_drv) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09003798 result = -ENOMEM;
Vincent Stehlé17db84e2015-10-07 07:08:25 +02003799 goto _fail_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003800 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09003801 *hif_drv_handler = hif_drv;
Glen Lee03efae32015-12-21 14:18:49 +09003802 for (i = 0; i < wilc->vif_num; i++)
3803 if (dev == wilc->vif[i]->ndev) {
3804 wilc->vif[i]->hif_drv = hif_drv;
3805 break;
3806 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003807
Arnd Bergmann0e1af732015-11-16 15:04:54 +01003808 wilc_optaining_ip = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003809
Tony Choa4ab1ad2015-10-12 16:56:05 +09003810 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003811 if (clients_count == 0) {
Leo Kim834e0cb2015-10-15 13:24:54 +09003812 sema_init(&hif_sema_thread, 0);
Leo Kim27ff2162015-10-15 13:24:55 +09003813 sema_init(&hif_sema_driver, 0);
Leo Kim440e89932015-10-15 13:24:57 +09003814 sema_init(&hif_sema_deinit, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003815 }
3816
Leo Kim9ea47132015-10-29 11:58:28 +09003817 sema_init(&hif_drv->sem_test_key_block, 0);
Leo Kime55e4962015-10-29 11:58:29 +09003818 sema_init(&hif_drv->sem_test_disconn_block, 0);
Leo Kim7e111f92015-10-29 11:58:30 +09003819 sema_init(&hif_drv->sem_get_rssi, 0);
Leo Kimbc34da62015-10-29 11:58:31 +09003820 sema_init(&hif_drv->sem_get_link_speed, 0);
Leo Kim4ea90002015-10-29 11:58:32 +09003821 sema_init(&hif_drv->sem_get_chnl, 0);
Leo Kim569a3c62015-10-29 11:58:33 +09003822 sema_init(&hif_drv->sem_inactive_time, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003823
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003824 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
3825
3826 if (clients_count == 0) {
Leo Kimcb067dc2015-10-15 13:24:53 +09003827 result = wilc_mq_create(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003828
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09003829 if (result < 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003830 PRINT_ER("Failed to creat MQ\n");
3831 goto _fail_;
3832 }
Leo Kimc2115d82015-10-15 13:24:52 +09003833
Glen Leed53822192015-10-27 18:27:49 +09003834 hif_thread_handler = kthread_run(hostIFthread, wilc,
3835 "WILC_kthread");
Leo Kimc2115d82015-10-15 13:24:52 +09003836
3837 if (IS_ERR(hif_thread_handler)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003838 PRINT_ER("Failed to creat Thread\n");
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09003839 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003840 goto _fail_mq_;
3841 }
Leo Kim262f55e2015-10-15 13:24:58 +09003842 setup_timer(&periodic_rssi, GetPeriodicRSSI,
Glen Lee71130e82015-12-21 14:18:41 +09003843 (unsigned long)vif);
Leo Kim262f55e2015-10-15 13:24:58 +09003844 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003845 }
3846
Leo Kim13b313e2015-10-29 11:58:34 +09003847 setup_timer(&hif_drv->scan_timer, TimerCB_Scan, 0);
Leo Kim81a59502015-10-29 11:58:35 +09003848 setup_timer(&hif_drv->connect_timer, TimerCB_Connect, 0);
Leo Kimcc2d7e92015-10-29 11:58:36 +09003849 setup_timer(&hif_drv->remain_on_ch_timer, ListenTimerCB, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003850
Leo Kim33110ad2015-10-29 11:58:27 +09003851 sema_init(&hif_drv->sem_cfg_values, 1);
3852 down(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003853
Leo Kimb60005a2015-10-29 11:58:24 +09003854 hif_drv->hif_state = HOST_IF_IDLE;
Leo Kimace303f2015-10-29 11:58:26 +09003855 hif_drv->cfg_values.site_survey_enabled = SITE_SURVEY_OFF;
3856 hif_drv->cfg_values.scan_source = DEFAULT_SCAN;
3857 hif_drv->cfg_values.active_scan_time = ACTIVE_SCAN_TIME;
3858 hif_drv->cfg_values.passive_scan_time = PASSIVE_SCAN_TIME;
3859 hif_drv->cfg_values.curr_tx_rate = AUTORATE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003860
Leo Kim1229b1a2015-10-29 12:05:39 +09003861 hif_drv->p2p_timeout = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003862
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003863 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 +09003864 hif_drv->cfg_values.site_survey_enabled,
3865 hif_drv->cfg_values.scan_source,
3866 hif_drv->cfg_values.active_scan_time,
3867 hif_drv->cfg_values.passive_scan_time,
3868 hif_drv->cfg_values.curr_tx_rate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003869
Leo Kim33110ad2015-10-29 11:58:27 +09003870 up(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003871
Leo Kimae4dfa52015-10-13 19:49:26 +09003872 clients_count++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003873
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09003874 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003875
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003876_fail_mq_:
Leo Kimcb067dc2015-10-15 13:24:53 +09003877 wilc_mq_destroy(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003878_fail_:
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09003879 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003880}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003881
Glen Leefbf53792015-12-21 14:18:40 +09003882s32 wilc_deinit(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003883{
Leo Kim31390ee2015-10-19 18:26:08 +09003884 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003885 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09003886 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003887
Tony Choa4ab1ad2015-10-12 16:56:05 +09003888 if (!hif_drv) {
3889 PRINT_ER("hif_drv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003890 return 0;
3891 }
3892
Leo Kim440e89932015-10-15 13:24:57 +09003893 down(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003894
Tony Choa4ab1ad2015-10-12 16:56:05 +09003895 terminated_handle = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003896 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
3897
Leo Kim13b313e2015-10-29 11:58:34 +09003898 if (del_timer_sync(&hif_drv->scan_timer))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003899 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003900
Leo Kim81a59502015-10-29 11:58:35 +09003901 if (del_timer_sync(&hif_drv->connect_timer))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003902 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003903
Leo Kim262f55e2015-10-15 13:24:58 +09003904 if (del_timer_sync(&periodic_rssi))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003905 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003906
Leo Kimcc2d7e92015-10-29 11:58:36 +09003907 del_timer_sync(&hif_drv->remain_on_ch_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003908
Glen Lee31f0f692015-12-21 14:18:44 +09003909 wilc_set_wfi_drv_handler(vif, 0);
Leo Kim27ff2162015-10-15 13:24:55 +09003910 down(&hif_sema_driver);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003911
Leo Kimbc801852015-10-29 11:58:50 +09003912 if (hif_drv->usr_scan_req.scan_result) {
3913 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL,
Leo Kim66eaea32015-10-29 11:58:51 +09003914 hif_drv->usr_scan_req.arg, NULL);
Leo Kimbc801852015-10-29 11:58:50 +09003915 hif_drv->usr_scan_req.scan_result = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003916 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003917
Leo Kimb60005a2015-10-29 11:58:24 +09003918 hif_drv->hif_state = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003919
Leo Kimca8540e42015-10-15 13:25:00 +09003920 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003921
Tony Cho143eb952015-09-21 12:16:32 +09003922 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003923
3924 if (clients_count == 1) {
Leo Kim262f55e2015-10-15 13:24:58 +09003925 if (del_timer_sync(&periodic_rssi))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003926 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Leo Kim262f55e2015-10-15 13:24:58 +09003927
Tony Choa9f812a2015-09-21 12:16:33 +09003928 msg.id = HOST_IF_MSG_EXIT;
Glen Leecf601062015-12-21 14:18:39 +09003929 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003930
Leo Kim31390ee2015-10-19 18:26:08 +09003931 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3932 if (result != 0)
3933 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003934
Leo Kim834e0cb2015-10-15 13:24:54 +09003935 down(&hif_sema_thread);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003936
Leo Kimcb067dc2015-10-15 13:24:53 +09003937 wilc_mq_destroy(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003938 }
3939
Tony Choa4ab1ad2015-10-12 16:56:05 +09003940 kfree(hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003941
Leo Kimae4dfa52015-10-13 19:49:26 +09003942 clients_count--;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09003943 terminated_handle = NULL;
Leo Kim440e89932015-10-15 13:24:57 +09003944 up(&hif_sema_deinit);
Leo Kim31390ee2015-10-19 18:26:08 +09003945 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003946}
3947
Glen Leecd04d222015-12-21 14:18:42 +09003948void wilc_network_info_received(struct wilc *wilc, u8 *pu8Buffer,
3949 u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003950{
Leo Kim31390ee2015-10-19 18:26:08 +09003951 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003952 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09003953 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003954 struct host_if_drv *hif_drv = NULL;
Glen Leeeb9939b2015-12-21 14:18:43 +09003955 struct wilc_vif *vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003956
Johnny Kimd42ab082015-08-20 16:32:52 +09003957 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Glen Leeeb9939b2015-12-21 14:18:43 +09003958 vif = wilc_get_vif_from_idx(wilc, id);
3959 if (!vif)
3960 return;
3961 hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003962
Tony Choa4ab1ad2015-10-12 16:56:05 +09003963 if (!hif_drv || hif_drv == terminated_handle) {
3964 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003965 return;
3966 }
3967
Tony Cho143eb952015-09-21 12:16:32 +09003968 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003969
Tony Choa9f812a2015-09-21 12:16:33 +09003970 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
Glen Leeeb9939b2015-12-21 14:18:43 +09003971 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003972
Leo Kim3bffac62015-10-13 20:02:11 +09003973 msg.body.net_info.len = u32Length;
Leo Kimb021b802015-10-13 20:02:10 +09003974 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
3975 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003976
Leo Kim31390ee2015-10-19 18:26:08 +09003977 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3978 if (result)
3979 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003980}
3981
Glen Leecd04d222015-12-21 14:18:42 +09003982void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *pu8Buffer,
3983 u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003984{
Leo Kim31390ee2015-10-19 18:26:08 +09003985 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003986 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09003987 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003988 struct host_if_drv *hif_drv = NULL;
Glen Leeeb9939b2015-12-21 14:18:43 +09003989 struct wilc_vif *vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003990
Leo Kim440e89932015-10-15 13:24:57 +09003991 down(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003992
Johnny Kimd42ab082015-08-20 16:32:52 +09003993 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Glen Leeeb9939b2015-12-21 14:18:43 +09003994 vif = wilc_get_vif_from_idx(wilc, id);
3995 if (!vif) {
3996 up(&hif_sema_deinit);
3997 return;
3998 }
3999
4000 hif_drv = vif->hif_drv;
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004001 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004002
Tony Choa4ab1ad2015-10-12 16:56:05 +09004003 if (!hif_drv || hif_drv == terminated_handle) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004004 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
Leo Kim440e89932015-10-15 13:24:57 +09004005 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004006 return;
4007 }
4008
Leo Kim33bfb192015-10-29 11:58:56 +09004009 if (!hif_drv->usr_conn_req.conn_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004010 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
Leo Kim440e89932015-10-15 13:24:57 +09004011 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004012 return;
4013 }
4014
Tony Cho143eb952015-09-21 12:16:32 +09004015 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004016
Tony Choa9f812a2015-09-21 12:16:33 +09004017 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
Glen Leeeb9939b2015-12-21 14:18:43 +09004018 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004019
Leo Kimf94f4882015-10-13 19:50:01 +09004020 msg.body.async_info.len = u32Length;
Leo Kim33722ac72015-10-13 19:50:00 +09004021 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4022 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004023
Leo Kim31390ee2015-10-19 18:26:08 +09004024 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4025 if (result)
4026 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004027
Leo Kim440e89932015-10-15 13:24:57 +09004028 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004029}
4030
Glen Leecd04d222015-12-21 14:18:42 +09004031void wilc_scan_complete_received(struct wilc *wilc, u8 *pu8Buffer,
4032 u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004033{
Leo Kim31390ee2015-10-19 18:26:08 +09004034 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004035 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004036 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004037 struct host_if_drv *hif_drv = NULL;
Glen Leeeb9939b2015-12-21 14:18:43 +09004038 struct wilc_vif *vif;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004039
Johnny Kimd42ab082015-08-20 16:32:52 +09004040 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Glen Leeeb9939b2015-12-21 14:18:43 +09004041 vif = wilc_get_vif_from_idx(wilc, id);
4042 if (!vif)
4043 return;
4044 hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004045
Tony Choa4ab1ad2015-10-12 16:56:05 +09004046 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004047
Tony Choa4ab1ad2015-10-12 16:56:05 +09004048 if (!hif_drv || hif_drv == terminated_handle)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004049 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004050
Leo Kimbc801852015-10-29 11:58:50 +09004051 if (hif_drv->usr_scan_req.scan_result) {
Tony Cho143eb952015-09-21 12:16:32 +09004052 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004053
Tony Choa9f812a2015-09-21 12:16:33 +09004054 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
Glen Leeeb9939b2015-12-21 14:18:43 +09004055 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004056
Leo Kim31390ee2015-10-19 18:26:08 +09004057 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4058 if (result)
4059 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004060 }
4061
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004062 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004063}
4064
Glen Leefbf53792015-12-21 14:18:40 +09004065s32 wilc_remain_on_channel(struct wilc_vif *vif, u32 u32SessionID,
4066 u32 u32duration, u16 chan,
Glen Leecf601062015-12-21 14:18:39 +09004067 wilc_remain_on_chan_expired RemainOnChanExpired,
4068 wilc_remain_on_chan_ready RemainOnChanReady,
4069 void *pvUserArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004070{
Leo Kim31390ee2015-10-19 18:26:08 +09004071 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004072 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09004073 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004074
Tony Choa4ab1ad2015-10-12 16:56:05 +09004075 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004076 PRINT_ER("driver is null\n");
4077 return -EFAULT;
4078 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004079
Tony Cho143eb952015-09-21 12:16:32 +09004080 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004081
Tony Choa9f812a2015-09-21 12:16:33 +09004082 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
Leo Kim839ab702015-10-29 11:58:41 +09004083 msg.body.remain_on_ch.ch = chan;
Leo Kimbfb62ab2015-10-29 11:58:42 +09004084 msg.body.remain_on_ch.expired = RemainOnChanExpired;
Leo Kim5e5f7912015-10-29 11:58:43 +09004085 msg.body.remain_on_ch.ready = RemainOnChanReady;
Leo Kimc5cc4b12015-10-29 11:58:44 +09004086 msg.body.remain_on_ch.arg = pvUserArg;
Tony Cho070d3652015-09-30 18:55:10 +09004087 msg.body.remain_on_ch.u32duration = u32duration;
Leo Kim9d764e32015-10-29 12:05:38 +09004088 msg.body.remain_on_ch.id = u32SessionID;
Glen Leecf601062015-12-21 14:18:39 +09004089 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004090
Leo Kim31390ee2015-10-19 18:26:08 +09004091 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4092 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004093 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004094
Leo Kim31390ee2015-10-19 18:26:08 +09004095 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004096}
4097
Glen Leefbf53792015-12-21 14:18:40 +09004098s32 wilc_listen_state_expired(struct wilc_vif *vif, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004099{
Leo Kim31390ee2015-10-19 18:26:08 +09004100 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004101 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09004102 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004103
Tony Choa4ab1ad2015-10-12 16:56:05 +09004104 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004105 PRINT_ER("driver is null\n");
4106 return -EFAULT;
4107 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004108
Leo Kimcc2d7e92015-10-29 11:58:36 +09004109 del_timer(&hif_drv->remain_on_ch_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004110
Tony Cho143eb952015-09-21 12:16:32 +09004111 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09004112 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Glen Leecf601062015-12-21 14:18:39 +09004113 msg.vif = vif;
Leo Kim9d764e32015-10-29 12:05:38 +09004114 msg.body.remain_on_ch.id = u32SessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004115
Leo Kim31390ee2015-10-19 18:26:08 +09004116 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4117 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004118 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004119
Leo Kim31390ee2015-10-19 18:26:08 +09004120 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004121}
4122
Glen Leefbf53792015-12-21 14:18:40 +09004123s32 wilc_frame_register(struct wilc_vif *vif, u16 u16FrameType, bool bReg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004124{
Leo Kim31390ee2015-10-19 18:26:08 +09004125 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004126 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09004127 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004128
Tony Choa4ab1ad2015-10-12 16:56:05 +09004129 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004130 PRINT_ER("driver is null\n");
4131 return -EFAULT;
4132 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004133
Tony Cho143eb952015-09-21 12:16:32 +09004134 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004135
Tony Choa9f812a2015-09-21 12:16:33 +09004136 msg.id = HOST_IF_MSG_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004137 switch (u16FrameType) {
4138 case ACTION:
4139 PRINT_D(HOSTINF_DBG, "ACTION\n");
Leo Kimbcb410b2015-10-29 11:58:40 +09004140 msg.body.reg_frame.reg_id = ACTION_FRM_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004141 break;
4142
4143 case PROBE_REQ:
4144 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
Leo Kimbcb410b2015-10-29 11:58:40 +09004145 msg.body.reg_frame.reg_id = PROBE_REQ_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004146 break;
4147
4148 default:
4149 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
4150 break;
4151 }
Leo Kimd5f654c2015-10-29 11:58:39 +09004152 msg.body.reg_frame.frame_type = u16FrameType;
Leo Kim6abf8682015-10-29 11:58:38 +09004153 msg.body.reg_frame.reg = bReg;
Glen Leecf601062015-12-21 14:18:39 +09004154 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004155
Leo Kim31390ee2015-10-19 18:26:08 +09004156 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4157 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004158 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004159
Leo Kim31390ee2015-10-19 18:26:08 +09004160 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004161}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004162
Glen Leefbf53792015-12-21 14:18:40 +09004163s32 wilc_add_beacon(struct wilc_vif *vif, u32 u32Interval, u32 u32DTIMPeriod,
4164 u32 u32HeadLen, u8 *pu8Head, u32 u32TailLen, u8 *pu8Tail)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004165{
Leo Kim31390ee2015-10-19 18:26:08 +09004166 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004167 struct host_if_msg msg;
Tony Choa98491e2015-09-30 18:44:31 +09004168 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
Glen Leefbf53792015-12-21 14:18:40 +09004169 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004170
Tony Choa4ab1ad2015-10-12 16:56:05 +09004171 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004172 PRINT_ER("driver is null\n");
4173 return -EFAULT;
4174 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004175
Tony Cho143eb952015-09-21 12:16:32 +09004176 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004177
4178 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
4179
Tony Choa9f812a2015-09-21 12:16:33 +09004180 msg.id = HOST_IF_MSG_ADD_BEACON;
Glen Leecf601062015-12-21 14:18:39 +09004181 msg.vif = vif;
Leo Kim12262dd2015-10-13 19:50:03 +09004182 pstrSetBeaconParam->interval = u32Interval;
Leo Kime76ab772015-10-13 19:50:04 +09004183 pstrSetBeaconParam->dtim_period = u32DTIMPeriod;
Leo Kim51c66182015-10-13 19:50:05 +09004184 pstrSetBeaconParam->head_len = u32HeadLen;
Shraddha Barke543f5b12015-10-16 10:47:11 +05304185 pstrSetBeaconParam->head = kmemdup(pu8Head, u32HeadLen, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09004186 if (!pstrSetBeaconParam->head) {
Leo Kim31390ee2015-10-19 18:26:08 +09004187 result = -ENOMEM;
Leo Kim24db7132015-09-16 18:36:01 +09004188 goto ERRORHANDLER;
4189 }
Leo Kim030c57e2015-10-13 19:50:07 +09004190 pstrSetBeaconParam->tail_len = u32TailLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004191
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004192 if (u32TailLen > 0) {
Shraddha Barke543f5b12015-10-16 10:47:11 +05304193 pstrSetBeaconParam->tail = kmemdup(pu8Tail, u32TailLen,
4194 GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09004195 if (!pstrSetBeaconParam->tail) {
Leo Kim31390ee2015-10-19 18:26:08 +09004196 result = -ENOMEM;
Leo Kim24db7132015-09-16 18:36:01 +09004197 goto ERRORHANDLER;
4198 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004199 } else {
Leo Kim7dbcb6d32015-10-13 19:50:08 +09004200 pstrSetBeaconParam->tail = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004201 }
4202
Leo Kim31390ee2015-10-19 18:26:08 +09004203 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4204 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004205 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004206
Leo Kim24db7132015-09-16 18:36:01 +09004207ERRORHANDLER:
Leo Kim31390ee2015-10-19 18:26:08 +09004208 if (result) {
Shraddha Barke95f840f2015-10-14 07:29:19 +05304209 kfree(pstrSetBeaconParam->head);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004210
Shraddha Barke95f840f2015-10-14 07:29:19 +05304211 kfree(pstrSetBeaconParam->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004212 }
4213
Leo Kim31390ee2015-10-19 18:26:08 +09004214 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004215}
4216
Glen Leefbf53792015-12-21 14:18:40 +09004217int wilc_del_beacon(struct wilc_vif *vif)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004218{
Chaehyun Lim0a5298c2015-11-06 19:11:10 +09004219 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004220 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09004221 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004222
Tony Choa4ab1ad2015-10-12 16:56:05 +09004223 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004224 PRINT_ER("driver is null\n");
4225 return -EFAULT;
4226 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004227
Tony Choa9f812a2015-09-21 12:16:33 +09004228 msg.id = HOST_IF_MSG_DEL_BEACON;
Glen Leecf601062015-12-21 14:18:39 +09004229 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004230 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
4231
Leo Kim31390ee2015-10-19 18:26:08 +09004232 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4233 if (result)
Leo Kim7dc1d0c2015-09-16 18:36:00 +09004234 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004235
Leo Kim31390ee2015-10-19 18:26:08 +09004236 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004237}
4238
Glen Leefbf53792015-12-21 14:18:40 +09004239int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004240{
Chaehyun Lim18cfbd32015-11-06 19:11:16 +09004241 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004242 struct host_if_msg msg;
Chaehyun Lim773e02e2015-11-06 19:11:19 +09004243 struct add_sta_param *add_sta_info = &msg.body.add_sta_info;
Glen Leefbf53792015-12-21 14:18:40 +09004244 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004245
Tony Choa4ab1ad2015-10-12 16:56:05 +09004246 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004247 PRINT_ER("driver is null\n");
4248 return -EFAULT;
4249 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004250
Tony Cho143eb952015-09-21 12:16:32 +09004251 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004252
4253 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
4254
Tony Choa9f812a2015-09-21 12:16:33 +09004255 msg.id = HOST_IF_MSG_ADD_STATION;
Glen Leecf601062015-12-21 14:18:39 +09004256 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004257
Chaehyun Lim773e02e2015-11-06 19:11:19 +09004258 memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
4259 if (add_sta_info->rates_len > 0) {
Chaehyun Lim90623052015-11-06 19:11:21 +09004260 add_sta_info->rates = kmemdup(sta_param->rates,
4261 add_sta_info->rates_len,
4262 GFP_KERNEL);
4263 if (!add_sta_info->rates)
Leo Kim7ae43362015-09-16 18:35:59 +09004264 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004265 }
4266
Leo Kim31390ee2015-10-19 18:26:08 +09004267 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4268 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004269 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004270 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004271}
4272
Glen Leefbf53792015-12-21 14:18:40 +09004273int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004274{
Chaehyun Lim79a0c0a2015-11-06 19:11:12 +09004275 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004276 struct host_if_msg msg;
Chaehyun Limc87fbed2015-11-06 19:11:15 +09004277 struct del_sta *del_sta_info = &msg.body.del_sta_info;
Glen Leefbf53792015-12-21 14:18:40 +09004278 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004279
Tony Choa4ab1ad2015-10-12 16:56:05 +09004280 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004281 PRINT_ER("driver is null\n");
4282 return -EFAULT;
4283 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004284
Tony Cho143eb952015-09-21 12:16:32 +09004285 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004286
4287 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
4288
Tony Choa9f812a2015-09-21 12:16:33 +09004289 msg.id = HOST_IF_MSG_DEL_STATION;
Glen Leecf601062015-12-21 14:18:39 +09004290 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004291
Chaehyun Limc9c4eb42015-11-06 19:11:14 +09004292 if (!mac_addr)
Chaehyun Limc87fbed2015-11-06 19:11:15 +09004293 eth_broadcast_addr(del_sta_info->mac_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004294 else
Chaehyun Limc87fbed2015-11-06 19:11:15 +09004295 memcpy(del_sta_info->mac_addr, mac_addr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004296
Leo Kim31390ee2015-10-19 18:26:08 +09004297 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4298 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004299 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004300 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004301}
Leo Kimae4dfa52015-10-13 19:49:26 +09004302
Glen Leefbf53792015-12-21 14:18:40 +09004303s32 wilc_del_allstation(struct wilc_vif *vif, u8 pu8MacAddr[][ETH_ALEN])
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004304{
Leo Kim31390ee2015-10-19 18:26:08 +09004305 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004306 struct host_if_msg msg;
Tony Chob0c1e802015-10-05 13:50:46 +09004307 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
Glen Leefbf53792015-12-21 14:18:40 +09004308 struct host_if_drv *hif_drv = vif->hif_drv;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004309 u8 au8Zero_Buff[ETH_ALEN] = {0};
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004310 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004311 u8 u8AssocNumb = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004312
Tony Choa4ab1ad2015-10-12 16:56:05 +09004313 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004314 PRINT_ER("driver is null\n");
4315 return -EFAULT;
4316 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004317
Tony Cho143eb952015-09-21 12:16:32 +09004318 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004319
4320 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
4321
Tony Choa9f812a2015-09-21 12:16:33 +09004322 msg.id = HOST_IF_MSG_DEL_ALL_STA;
Glen Leecf601062015-12-21 14:18:39 +09004323 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004324
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004325 for (i = 0; i < MAX_NUM_STA; i++) {
4326 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
Leo Kime51b9212015-10-13 19:50:09 +09004327 memcpy(pstrDelAllStationMsg->del_all_sta[i], pu8MacAddr[i], ETH_ALEN);
4328 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
4329 pstrDelAllStationMsg->del_all_sta[i][0],
4330 pstrDelAllStationMsg->del_all_sta[i][1],
4331 pstrDelAllStationMsg->del_all_sta[i][2],
4332 pstrDelAllStationMsg->del_all_sta[i][3],
4333 pstrDelAllStationMsg->del_all_sta[i][4],
4334 pstrDelAllStationMsg->del_all_sta[i][5]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004335 u8AssocNumb++;
4336 }
4337 }
4338 if (!u8AssocNumb) {
4339 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004340 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004341 }
4342
Leo Kim8ba18032015-10-13 19:50:10 +09004343 pstrDelAllStationMsg->assoc_sta = u8AssocNumb;
Leo Kim31390ee2015-10-19 18:26:08 +09004344 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004345
Leo Kim31390ee2015-10-19 18:26:08 +09004346 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004347 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004348
Leo Kim2d25af82015-10-15 13:24:56 +09004349 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004350
Leo Kim31390ee2015-10-19 18:26:08 +09004351 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004352}
4353
Glen Leefbf53792015-12-21 14:18:40 +09004354s32 wilc_edit_station(struct wilc_vif *vif,
4355 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004356{
Leo Kim31390ee2015-10-19 18:26:08 +09004357 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004358 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09004359 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Glen Leefbf53792015-12-21 14:18:40 +09004360 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004361
Tony Choa4ab1ad2015-10-12 16:56:05 +09004362 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004363 PRINT_ER("driver is null\n");
4364 return -EFAULT;
4365 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004366
4367 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
4368
Tony Cho143eb952015-09-21 12:16:32 +09004369 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004370
Tony Choa9f812a2015-09-21 12:16:33 +09004371 msg.id = HOST_IF_MSG_EDIT_STATION;
Glen Leecf601062015-12-21 14:18:39 +09004372 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004373
Tony Cho6a89ba92015-09-21 12:16:46 +09004374 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Leo Kime7342232015-10-29 12:05:43 +09004375 if (pstrAddStationMsg->rates_len > 0) {
4376 u8 *rates = kmalloc(pstrAddStationMsg->rates_len, GFP_KERNEL);
Leo Kimc09389a2015-10-28 15:59:24 +09004377
Leo Kim7ae43362015-09-16 18:35:59 +09004378 if (!rates)
4379 return -ENOMEM;
4380
Leo Kima622e012015-10-29 12:05:44 +09004381 memcpy(rates, pstrStaParams->rates,
Leo Kime7342232015-10-29 12:05:43 +09004382 pstrAddStationMsg->rates_len);
Leo Kima622e012015-10-29 12:05:44 +09004383 pstrAddStationMsg->rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004384 }
4385
Leo Kim31390ee2015-10-19 18:26:08 +09004386 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4387 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004388 PRINT_ER("wilc_mq_send fail\n");
4389
Leo Kim31390ee2015-10-19 18:26:08 +09004390 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004391}
Glen Lee108b3432015-09-16 18:53:20 +09004392
Glen Leefbf53792015-12-21 14:18:40 +09004393s32 wilc_set_power_mgmt(struct wilc_vif *vif, bool bIsEnabled, u32 u32Timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004394{
Leo Kim31390ee2015-10-19 18:26:08 +09004395 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004396 struct host_if_msg msg;
Tony Cho49e1f812015-09-30 18:44:36 +09004397 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
Glen Leefbf53792015-12-21 14:18:40 +09004398 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004399
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004400 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004401
Tony Choa4ab1ad2015-10-12 16:56:05 +09004402 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004403 PRINT_ER("driver is null\n");
4404 return -EFAULT;
4405 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004406
4407 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
4408
Tony Cho143eb952015-09-21 12:16:32 +09004409 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004410
Tony Choa9f812a2015-09-21 12:16:33 +09004411 msg.id = HOST_IF_MSG_POWER_MGMT;
Glen Leecf601062015-12-21 14:18:39 +09004412 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004413
Leo Kim33c70c12015-10-13 20:02:07 +09004414 pstrPowerMgmtParam->enabled = bIsEnabled;
Leo Kim937918f2015-10-13 20:02:08 +09004415 pstrPowerMgmtParam->timeout = u32Timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004416
Leo Kim31390ee2015-10-19 18:26:08 +09004417 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4418 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004419 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004420 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004421}
4422
Glen Leefbf53792015-12-21 14:18:40 +09004423s32 wilc_setup_multicast_filter(struct wilc_vif *vif, bool bIsEnabled,
Glen Leecf601062015-12-21 14:18:39 +09004424 u32 u32count)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004425{
Leo Kim31390ee2015-10-19 18:26:08 +09004426 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004427 struct host_if_msg msg;
Tony Choa079cf4d2015-09-30 18:55:05 +09004428 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
Glen Leefbf53792015-12-21 14:18:40 +09004429 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004430
Tony Choa4ab1ad2015-10-12 16:56:05 +09004431 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004432 PRINT_ER("driver is null\n");
4433 return -EFAULT;
4434 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004435
4436 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
4437
Tony Cho143eb952015-09-21 12:16:32 +09004438 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004439
Tony Choa9f812a2015-09-21 12:16:33 +09004440 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
Glen Leecf601062015-12-21 14:18:39 +09004441 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004442
Leo Kimbae636eb2015-10-13 20:02:04 +09004443 pstrMulticastFilterParam->enabled = bIsEnabled;
Leo Kimadab2f72015-10-13 20:02:05 +09004444 pstrMulticastFilterParam->cnt = u32count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004445
Leo Kim31390ee2015-10-19 18:26:08 +09004446 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4447 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004448 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004449 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004450}
4451
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004452static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
4453{
Leo Kime0a12212015-10-12 16:55:49 +09004454 struct join_bss_param *pNewJoinBssParam = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004455 u8 *pu8IEs;
Chaehyun Limd85f5322015-06-11 14:35:54 +09004456 u16 u16IEsLen;
4457 u16 index = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004458 u8 suppRatesNo = 0;
4459 u8 extSuppRatesNo;
Chaehyun Limd85f5322015-06-11 14:35:54 +09004460 u16 jumpOffset;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004461 u8 pcipherCount;
4462 u8 authCount;
4463 u8 pcipherTotalCount = 0;
4464 u8 authTotalCount = 0;
4465 u8 i, j;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004466
4467 pu8IEs = ptstrNetworkInfo->pu8IEs;
4468 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4469
Shraddha Barkeb156f1e2015-10-13 23:07:00 +05304470 pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09004471 if (pNewJoinBssParam) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004472 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4473 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
4474 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004475 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004476 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
Leo Kim619d27b2015-10-15 13:24:42 +09004477 pNewJoinBssParam->ssid_len = ptstrNetworkInfo->u8SsidLen;
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004478 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4479 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004480
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004481 while (index < u16IEsLen) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004482 if (pu8IEs[index] == SUPP_RATES_IE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004483 suppRatesNo = pu8IEs[index + 1];
4484 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
Leo Kimae4dfa52015-10-13 19:49:26 +09004485 index += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004486
Leo Kimd1666e22015-10-28 15:59:22 +09004487 for (i = 0; i < suppRatesNo; i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004488 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
Leo Kimd1666e22015-10-28 15:59:22 +09004489
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004490 index += suppRatesNo;
4491 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004492 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004493 extSuppRatesNo = pu8IEs[index + 1];
4494 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4495 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4496 else
4497 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4498 index += 2;
Leo Kimd1666e22015-10-28 15:59:22 +09004499 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004500 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
Leo Kimd1666e22015-10-28 15:59:22 +09004501
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004502 index += extSuppRatesNo;
4503 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004504 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004505 pNewJoinBssParam->ht_capable = true;
Leo Kimae4dfa52015-10-13 19:49:26 +09004506 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004507 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004508 } else if ((pu8IEs[index] == WMM_IE) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004509 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
Leo Kimae4dfa52015-10-13 19:49:26 +09004510 (pu8IEs[index + 4] == 0xF2) &&
4511 (pu8IEs[index + 5] == 0x02) &&
4512 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004513 (pu8IEs[index + 7] == 0x01)) {
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004514 pNewJoinBssParam->wmm_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004515
Anish Bhattffda2032015-09-29 12:15:49 -07004516 if (pu8IEs[index + 8] & BIT(7))
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004517 pNewJoinBssParam->uapsd_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004518 index += pu8IEs[index + 1] + 2;
4519 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004520 } else if ((pu8IEs[index] == P2P_IE) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004521 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
Leo Kimae4dfa52015-10-13 19:49:26 +09004522 (pu8IEs[index + 4] == 0x9a) &&
4523 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09004524 u16 u16P2P_count;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004525
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004526 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
Leo Kim7a8d51d2015-10-15 13:24:43 +09004527 pNewJoinBssParam->noa_enabled = 1;
Leo Kimcc179002015-10-15 13:24:47 +09004528 pNewJoinBssParam->idx = pu8IEs[index + 9];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004529
Anish Bhattffda2032015-09-29 12:15:49 -07004530 if (pu8IEs[index + 10] & BIT(7)) {
Leo Kimd72b33c2015-10-15 13:24:44 +09004531 pNewJoinBssParam->opp_enabled = 1;
Leo Kim99b66942015-10-15 13:24:45 +09004532 pNewJoinBssParam->ct_window = pu8IEs[index + 10];
Leo Kimd72b33c2015-10-15 13:24:44 +09004533 } else {
4534 pNewJoinBssParam->opp_enabled = 0;
4535 }
Leo Kimae4dfa52015-10-13 19:49:26 +09004536
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004537 PRINT_D(GENERIC_DBG, "P2P Dump\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004538 for (i = 0; i < pu8IEs[index + 7]; i++)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004539 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004540
Leo Kimc21047e2015-10-15 13:24:46 +09004541 pNewJoinBssParam->cnt = pu8IEs[index + 11];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004542 u16P2P_count = index + 12;
4543
Leo Kim109e6ca2015-10-15 13:24:48 +09004544 memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004545 u16P2P_count += 4;
4546
Leo Kim1d8b76b2015-10-15 13:24:49 +09004547 memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004548 u16P2P_count += 4;
4549
Leo Kim4be55e22015-10-28 15:59:27 +09004550 memcpy(pNewJoinBssParam->start_time, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004551
4552 index += pu8IEs[index + 1] + 2;
4553 continue;
4554
Leo Kimae4dfa52015-10-13 19:49:26 +09004555 } else if ((pu8IEs[index] == RSN_IE) ||
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004556 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
4557 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
4558 (pu8IEs[index + 5] == 0x01))) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09004559 u16 rsnIndex = index;
Leo Kimae4dfa52015-10-13 19:49:26 +09004560
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004561 if (pu8IEs[rsnIndex] == RSN_IE) {
4562 pNewJoinBssParam->mode_802_11i = 2;
Leo Kimae4dfa52015-10-13 19:49:26 +09004563 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004564 if (pNewJoinBssParam->mode_802_11i == 0)
4565 pNewJoinBssParam->mode_802_11i = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004566 rsnIndex += 4;
4567 }
Leo Kimae4dfa52015-10-13 19:49:26 +09004568
4569 rsnIndex += 7;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004570 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
4571 rsnIndex++;
Leo Kimae4dfa52015-10-13 19:49:26 +09004572 jumpOffset = pu8IEs[rsnIndex] * 4;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004573 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
Leo Kimae4dfa52015-10-13 19:49:26 +09004574 rsnIndex += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004575
Leo Kimd1666e22015-10-28 15:59:22 +09004576 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004577 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
Leo Kimd1666e22015-10-28 15:59:22 +09004578
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004579 pcipherTotalCount += pcipherCount;
4580 rsnIndex += jumpOffset;
4581
4582 jumpOffset = pu8IEs[rsnIndex] * 4;
4583
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004584 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
Leo Kimae4dfa52015-10-13 19:49:26 +09004585 rsnIndex += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004586
Leo Kimd1666e22015-10-28 15:59:22 +09004587 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004588 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
Leo Kimd1666e22015-10-28 15:59:22 +09004589
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004590 authTotalCount += authCount;
4591 rsnIndex += jumpOffset;
Leo Kimae4dfa52015-10-13 19:49:26 +09004592
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004593 if (pu8IEs[index] == RSN_IE) {
4594 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
4595 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
4596 rsnIndex += 2;
4597 }
Abdul Hussainf717c0eb2015-06-16 09:49:49 +00004598 pNewJoinBssParam->rsn_found = true;
Leo Kimae4dfa52015-10-13 19:49:26 +09004599 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004600 continue;
4601 } else
Leo Kimae4dfa52015-10-13 19:49:26 +09004602 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004603 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004604 }
4605
4606 return (void *)pNewJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004607}
4608
Arnd Bergmann0e1af732015-11-16 15:04:54 +01004609void wilc_free_join_params(void *pJoinParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004610{
Leo Kim91109e12015-10-19 18:26:13 +09004611 if ((struct bss_param *)pJoinParams)
Leo Kime0a12212015-10-12 16:55:49 +09004612 kfree((struct bss_param *)pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004613 else
4614 PRINT_ER("Unable to FREE null pointer\n");
4615}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004616
Glen Leefbf53792015-12-21 14:18:40 +09004617s32 wilc_del_all_rx_ba_session(struct wilc_vif *vif, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004618{
Leo Kim31390ee2015-10-19 18:26:08 +09004619 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004620 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09004621 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Glen Leefbf53792015-12-21 14:18:40 +09004622 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004623
Tony Choa4ab1ad2015-10-12 16:56:05 +09004624 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004625 PRINT_ER("driver is null\n");
4626 return -EFAULT;
4627 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004628
Tony Cho143eb952015-09-21 12:16:32 +09004629 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004630
Tony Choa9f812a2015-09-21 12:16:33 +09004631 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004632
Leo Kim3fc49992015-10-29 11:58:45 +09004633 memcpy(pBASessionInfo->bssid, pBSSID, ETH_ALEN);
Leo Kim16c9b392015-10-29 11:58:46 +09004634 pBASessionInfo->tid = TID;
Glen Leecf601062015-12-21 14:18:39 +09004635 msg.vif = vif;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004636
Leo Kim31390ee2015-10-19 18:26:08 +09004637 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4638 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004639 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004640
Leo Kim2d25af82015-10-15 13:24:56 +09004641 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004642
Leo Kim31390ee2015-10-19 18:26:08 +09004643 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004644}
4645
Glen Leefbf53792015-12-21 14:18:40 +09004646s32 wilc_setup_ipaddress(struct wilc_vif *vif, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004647{
Leo Kim31390ee2015-10-19 18:26:08 +09004648 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004649 struct host_if_msg msg;
Glen Leefbf53792015-12-21 14:18:40 +09004650 struct host_if_drv *hif_drv = vif->hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004651
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004652 return 0;
4653
Tony Choa4ab1ad2015-10-12 16:56:05 +09004654 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004655 PRINT_ER("driver is null\n");
4656 return -EFAULT;
4657 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004658
Tony Cho143eb952015-09-21 12:16:32 +09004659 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004660
Tony Choa9f812a2015-09-21 12:16:33 +09004661 msg.id = HOST_IF_MSG_SET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004662
Leo Kim78675be2015-10-13 20:02:09 +09004663 msg.body.ip_info.ip_addr = u16ipadd;
Glen Leecf601062015-12-21 14:18:39 +09004664 msg.vif = vif;
Tony Chofb2d65e2015-09-30 18:44:39 +09004665 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004666
Leo Kim31390ee2015-10-19 18:26:08 +09004667 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4668 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004669 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004670
Leo Kim31390ee2015-10-19 18:26:08 +09004671 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004672}
4673
Glen Leecf601062015-12-21 14:18:39 +09004674static s32 host_int_get_ipaddress(struct wilc_vif *vif,
4675 struct host_if_drv *hif_drv,
4676 u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004677{
Leo Kim31390ee2015-10-19 18:26:08 +09004678 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004679 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004680
Tony Choa4ab1ad2015-10-12 16:56:05 +09004681 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004682 PRINT_ER("driver is null\n");
4683 return -EFAULT;
4684 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004685
Tony Cho143eb952015-09-21 12:16:32 +09004686 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004687
Tony Choa9f812a2015-09-21 12:16:33 +09004688 msg.id = HOST_IF_MSG_GET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004689
Leo Kim78675be2015-10-13 20:02:09 +09004690 msg.body.ip_info.ip_addr = u16ipadd;
Glen Leecf601062015-12-21 14:18:39 +09004691 msg.vif = vif;
Tony Chofb2d65e2015-09-30 18:44:39 +09004692 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004693
Leo Kim31390ee2015-10-19 18:26:08 +09004694 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4695 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004696 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004697
Leo Kim31390ee2015-10-19 18:26:08 +09004698 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004699}