blob: 601558282ac4232e66ddff7d3d71af08600a9e93 [file] [log] [blame]
Chaehyun Lime215a872015-09-30 08:15:41 +09001#include <linux/slab.h>
2#include <linux/time.h>
3#include <linux/kthread.h>
4#include <linux/delay.h>
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005#include "host_interface.h"
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006#include "coreconfigurator.h"
Chaehyun Lim53660122015-09-17 16:48:49 +09007#include "wilc_wlan_if.h"
Chaehyun Limf23eb982015-09-23 18:03:47 +09008#include "wilc_msgqueue.h"
Shraddha Barke281dd5a2015-10-05 17:00:33 +05309#include <linux/etherdevice.h>
Glen Leed53822192015-10-27 18:27:49 +090010#include "wilc_wfi_netdevice.h"
Johnny Kimc5c77ba2015-05-11 14:30:56 +090011
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090012extern u8 connecting;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090013
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -070014extern struct timer_list hDuringIpTimer;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090015
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090016extern u8 g_wilc_initialized;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090017
Chaehyun Lim9eac3a12015-06-18 22:08:51 +090018#define HOST_IF_MSG_SCAN 0
19#define HOST_IF_MSG_CONNECT 1
20#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
21#define HOST_IF_MSG_KEY 3
22#define HOST_IF_MSG_RCVD_NTWRK_INFO 4
23#define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
24#define HOST_IF_MSG_CFG_PARAMS 6
25#define HOST_IF_MSG_SET_CHANNEL 7
26#define HOST_IF_MSG_DISCONNECT 8
27#define HOST_IF_MSG_GET_RSSI 9
28#define HOST_IF_MSG_GET_CHNL 10
29#define HOST_IF_MSG_ADD_BEACON 11
30#define HOST_IF_MSG_DEL_BEACON 12
31#define HOST_IF_MSG_ADD_STATION 13
32#define HOST_IF_MSG_DEL_STATION 14
33#define HOST_IF_MSG_EDIT_STATION 15
34#define HOST_IF_MSG_SCAN_TIMER_FIRED 16
35#define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
36#define HOST_IF_MSG_POWER_MGMT 18
37#define HOST_IF_MSG_GET_INACTIVETIME 19
38#define HOST_IF_MSG_REMAIN_ON_CHAN 20
39#define HOST_IF_MSG_REGISTER_FRAME 21
40#define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
41#define HOST_IF_MSG_GET_LINKSPEED 23
42#define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
43#define HOST_IF_MSG_SET_MAC_ADDRESS 25
44#define HOST_IF_MSG_GET_MAC_ADDRESS 26
45#define HOST_IF_MSG_SET_OPERATION_MODE 27
46#define HOST_IF_MSG_SET_IPADDRESS 28
47#define HOST_IF_MSG_GET_IPADDRESS 29
48#define HOST_IF_MSG_FLUSH_CONNECT 30
49#define HOST_IF_MSG_GET_STATISTICS 31
50#define HOST_IF_MSG_SET_MULTICAST_FILTER 32
51#define HOST_IF_MSG_ADD_BA_SESSION 33
52#define HOST_IF_MSG_DEL_BA_SESSION 34
53#define HOST_IF_MSG_Q_IDLE 35
54#define HOST_IF_MSG_DEL_ALL_STA 36
55#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
56#define HOST_IF_MSG_EXIT 100
Johnny Kimc5c77ba2015-05-11 14:30:56 +090057
Chaehyun Lime54d5b72015-06-18 22:08:50 +090058#define HOST_IF_SCAN_TIMEOUT 4000
59#define HOST_IF_CONNECT_TIMEOUT 9500
Johnny Kimc5c77ba2015-05-11 14:30:56 +090060
Chaehyun Lime54d5b72015-06-18 22:08:50 +090061#define BA_SESSION_DEFAULT_BUFFER_SIZE 16
62#define BA_SESSION_DEFAULT_TIMEOUT 1000
63#define BLOCK_ACK_REQ_SIZE 0x14
Leo Kim9f3295a2015-10-19 18:26:10 +090064#define FALSE_FRMWR_CHANNEL 100
Johnny Kimc5c77ba2015-05-11 14:30:56 +090065
Tony Cho361ff842015-09-21 12:16:41 +090066struct cfg_param_attr {
Tony Cho221371e2015-10-12 16:56:06 +090067 struct cfg_param_val cfg_attr_info;
Tony Cho361ff842015-09-21 12:16:41 +090068};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090069
Leo Kim4372d3d2015-10-05 15:25:43 +090070struct host_if_wpa_attr {
Leo Kim124968fc2015-10-13 19:49:30 +090071 u8 *key;
Leo Kim248080a2015-10-13 19:49:31 +090072 const u8 *mac_addr;
Leo Kim0e74c002015-10-13 19:49:32 +090073 u8 *seq;
Leo Kimdacc5942015-10-13 19:49:33 +090074 u8 seq_len;
Leo Kime2dfbac2015-10-13 19:49:34 +090075 u8 index;
Leo Kim6acf2912015-10-13 19:49:35 +090076 u8 key_len;
Leo Kim7b2ebb22015-10-13 19:49:36 +090077 u8 mode;
Leo Kim4372d3d2015-10-05 15:25:43 +090078};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090079
Leo Kimc276c442015-10-05 15:25:42 +090080struct host_if_wep_attr {
Tony Choe5538d32015-10-12 16:56:11 +090081 u8 *key;
Tony Chod520e352015-10-12 16:56:12 +090082 u8 key_len;
Tony Cho259b3aa2015-10-12 16:56:13 +090083 u8 index;
Tony Chob5eaff12015-10-12 16:56:14 +090084 u8 mode;
Tony Cho7fa252e2015-10-12 16:56:15 +090085 enum AUTHTYPE auth_type;
Leo Kimc276c442015-10-05 15:25:42 +090086};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090087
Leo Kim40cc2c92015-10-05 15:25:41 +090088union host_if_key_attr {
Tony Cho2ed7a2f2015-10-12 16:56:08 +090089 struct host_if_wep_attr wep;
Tony Choe3501a42015-10-12 16:56:09 +090090 struct host_if_wpa_attr wpa;
Tony Cho610e3862015-10-12 16:56:10 +090091 struct host_if_pmkid_attr pmkid;
Leo Kim40cc2c92015-10-05 15:25:41 +090092};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090093
Tony Choc98387a2015-09-21 12:16:40 +090094struct key_attr {
Leo Kim8e9f4272015-10-13 19:49:27 +090095 enum KEY_TYPE type;
Leo Kim0d17e382015-10-13 19:49:28 +090096 u8 action;
Leo Kim73b2e382015-10-13 19:49:29 +090097 union host_if_key_attr attr;
Tony Choc98387a2015-09-21 12:16:40 +090098};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090099
Tony Choc476feb2015-09-21 12:16:36 +0900100struct scan_attr {
Leo Kim42568892015-10-13 19:49:37 +0900101 u8 src;
Leo Kim1e276c82015-10-13 19:49:38 +0900102 u8 type;
Leo Kim82eeb0a2015-10-13 19:49:40 +0900103 u8 *ch_freq_list;
Leo Kimf97bd9c2015-10-13 19:49:41 +0900104 u8 ch_list_len;
Leo Kimd6f19aa2015-10-13 19:49:42 +0900105 u8 *ies;
Leo Kim7b1f76c2015-10-13 19:49:43 +0900106 size_t ies_len;
Leo Kimc17c6da2015-10-13 19:49:44 +0900107 wilc_scan_result result;
Leo Kim5f2b50c2015-10-13 19:49:45 +0900108 void *arg;
Leo Kim629b9ca2015-10-13 19:49:46 +0900109 struct hidden_network hidden_network;
Tony Choc476feb2015-09-21 12:16:36 +0900110};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900111
Tony Cho120ae592015-09-21 12:16:37 +0900112struct connect_attr {
Leo Kim9254db02015-10-13 19:49:49 +0900113 u8 *bssid;
Leo Kimf7bbd9c2015-10-13 19:49:50 +0900114 u8 *ssid;
Leo Kim8b3c9fa2015-10-13 19:49:51 +0900115 size_t ssid_len;
Leo Kim2ea158c2015-10-13 19:49:52 +0900116 u8 *ies;
Leo Kimb59d5c52015-10-13 19:49:53 +0900117 size_t ies_len;
Leo Kima64fd672015-10-13 19:49:54 +0900118 u8 security;
Leo Kim6abcc112015-10-13 19:49:55 +0900119 wilc_connect_result result;
Leo Kim8f38db82015-10-13 19:49:56 +0900120 void *arg;
Leo Kim61b4fd02015-10-13 19:49:57 +0900121 enum AUTHTYPE auth_type;
Leo Kim0d1527e2015-10-13 19:49:58 +0900122 u8 ch;
Leo Kimf2bed2c2015-10-13 19:49:59 +0900123 void *params;
Tony Cho120ae592015-09-21 12:16:37 +0900124};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900125
Tony Chof23a9ea2015-09-21 12:16:39 +0900126struct rcvd_async_info {
Leo Kim33722ac72015-10-13 19:50:00 +0900127 u8 *buffer;
Leo Kimf94f4882015-10-13 19:50:01 +0900128 u32 len;
Tony Chof23a9ea2015-09-21 12:16:39 +0900129};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900130
Tony Cho94bdfe42015-09-30 18:44:27 +0900131struct channel_attr {
Leo Kim730ee052015-10-13 19:50:02 +0900132 u8 set_ch;
Tony Cho326b3232015-09-21 12:16:42 +0900133};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900134
Tony Cho7f33fec2015-09-30 18:44:30 +0900135struct beacon_attr {
Leo Kim12262dd2015-10-13 19:50:03 +0900136 u32 interval;
Leo Kime76ab772015-10-13 19:50:04 +0900137 u32 dtim_period;
Leo Kim51c66182015-10-13 19:50:05 +0900138 u32 head_len;
Leo Kim8ce528b2015-10-13 19:50:06 +0900139 u8 *head;
Leo Kim030c57e2015-10-13 19:50:07 +0900140 u32 tail_len;
Leo Kim7dbcb6d32015-10-13 19:50:08 +0900141 u8 *tail;
Tony Cho902362b2015-09-21 12:16:44 +0900142};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900143
Tony Cho641210a2015-09-21 12:16:52 +0900144struct set_multicast {
Leo Kimbae636eb2015-10-13 20:02:04 +0900145 bool enabled;
Leo Kimadab2f72015-10-13 20:02:05 +0900146 u32 cnt;
Tony Cho641210a2015-09-21 12:16:52 +0900147};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900148
Tony Chob4e644e2015-09-21 12:17:00 +0900149struct del_all_sta {
Leo Kime51b9212015-10-13 19:50:09 +0900150 u8 del_all_sta[MAX_NUM_STA][ETH_ALEN];
Leo Kim8ba18032015-10-13 19:50:10 +0900151 u8 assoc_sta;
Tony Chob4e644e2015-09-21 12:17:00 +0900152};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900153
Tony Chofb93a1e2015-09-21 12:16:57 +0900154struct del_sta {
Leo Kime4839d32015-10-13 20:02:06 +0900155 u8 mac_addr[ETH_ALEN];
Tony Chofb93a1e2015-09-21 12:16:57 +0900156};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900157
Tony Cho5a008f12015-09-21 12:16:48 +0900158struct power_mgmt_param {
Leo Kim33c70c12015-10-13 20:02:07 +0900159 bool enabled;
Leo Kim937918f2015-10-13 20:02:08 +0900160 u32 timeout;
Tony Cho5a008f12015-09-21 12:16:48 +0900161};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900162
Tony Cho15191ea2015-09-21 12:16:50 +0900163struct set_ip_addr {
Leo Kim78675be2015-10-13 20:02:09 +0900164 u8 *ip_addr;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900165 u8 idx;
Tony Cho15191ea2015-09-21 12:16:50 +0900166};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900167
Tony Cho3d1eac02015-09-21 12:16:49 +0900168struct sta_inactive_t {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900169 u8 mac[6];
Tony Cho3d1eac02015-09-21 12:16:49 +0900170};
Leo Kimae4dfa52015-10-13 19:49:26 +0900171
Tony Chodfc76632015-09-21 12:16:34 +0900172union message_body {
Tony Cho4528bdb2015-09-30 18:44:20 +0900173 struct scan_attr scan_info;
Tony Cho3f501972015-09-30 18:44:21 +0900174 struct connect_attr con_info;
Tony Cho02d19462015-09-30 18:44:22 +0900175 struct rcvd_net_info net_info;
Tony Cho66add622015-09-30 18:44:23 +0900176 struct rcvd_async_info async_info;
Tony Cho18990bf2015-09-30 18:44:24 +0900177 struct key_attr key_info;
Tony Choa2340c32015-09-30 18:44:25 +0900178 struct cfg_param_attr cfg_info;
Tony Choffd6dbc2015-09-30 18:44:28 +0900179 struct channel_attr channel_info;
Tony Choa98491e2015-09-30 18:44:31 +0900180 struct beacon_attr beacon_info;
Tony Choca8f47f2015-09-30 18:44:32 +0900181 struct add_sta_param add_sta_info;
Tony Cho889c25b2015-09-30 18:44:33 +0900182 struct del_sta del_sta_info;
Tony Cho4a930962015-09-30 18:44:34 +0900183 struct add_sta_param edit_sta_info;
Tony Cho49e1f812015-09-30 18:44:36 +0900184 struct power_mgmt_param pwr_mgmt_info;
Tony Cho66bac7f2015-09-30 18:44:37 +0900185 struct sta_inactive_t mac_info;
Tony Chofb2d65e2015-09-30 18:44:39 +0900186 struct set_ip_addr ip_info;
Tony Cho5e4377e2015-09-30 18:44:38 +0900187 struct drv_handler drv;
Tony Choa079cf4d2015-09-30 18:55:05 +0900188 struct set_multicast multicast_info;
Tony Cho00c46302015-09-30 18:55:06 +0900189 struct op_mode mode;
Tony Cho15326e22015-09-30 18:55:07 +0900190 struct set_mac_addr set_mac_info;
Tony Choa5848692015-09-30 18:55:08 +0900191 struct get_mac_addr get_mac_info;
Tony Choc833b472015-09-30 18:55:09 +0900192 struct ba_session_info session_info;
Tony Cho070d3652015-09-30 18:55:10 +0900193 struct remain_ch remain_on_ch;
Tony Cho5c4008d2015-10-05 13:50:44 +0900194 struct reg_frame reg_frame;
Tony Choe60831e2015-10-05 13:50:45 +0900195 char *data;
Tony Chob0c1e802015-10-05 13:50:46 +0900196 struct del_all_sta del_all_sta_info;
Tony Chodfc76632015-09-21 12:16:34 +0900197};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900198
Tony Cho3a8c41b2015-09-18 18:11:04 +0900199struct host_if_msg {
Leo Kimae4dfa52015-10-13 19:49:26 +0900200 u16 id;
201 union message_body body;
Leo Kim2482a792015-10-12 16:55:36 +0900202 struct host_if_drv *drv;
Tony Cho3a8c41b2015-09-18 18:11:04 +0900203};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900204
Leo Kime0a12212015-10-12 16:55:49 +0900205struct join_bss_param {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900206 BSSTYPE_T bss_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900207 u8 dtim_period;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900208 u16 beacon_period;
209 u16 cap_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900210 u8 au8bssid[6];
Dean Lee576917a2015-06-15 11:58:57 +0900211 char ssid[MAX_SSID_LEN];
Leo Kim619d27b2015-10-15 13:24:42 +0900212 u8 ssid_len;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900213 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
214 u8 ht_capable;
215 u8 wmm_cap;
216 u8 uapsd_cap;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900217 bool rsn_found;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900218 u8 rsn_grp_policy;
219 u8 mode_802_11i;
220 u8 rsn_pcip_policy[3];
221 u8 rsn_auth_policy[3];
222 u8 rsn_cap[2];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900223 u32 tsf;
Leo Kim7a8d51d2015-10-15 13:24:43 +0900224 u8 noa_enabled;
Leo Kimd72b33c2015-10-15 13:24:44 +0900225 u8 opp_enabled;
Leo Kim99b66942015-10-15 13:24:45 +0900226 u8 ct_window;
Leo Kimc21047e2015-10-15 13:24:46 +0900227 u8 cnt;
Leo Kimcc179002015-10-15 13:24:47 +0900228 u8 idx;
Leo Kim109e6ca2015-10-15 13:24:48 +0900229 u8 duration[4];
Leo Kim1d8b76b2015-10-15 13:24:49 +0900230 u8 interval[4];
Leo Kim4be55e22015-10-28 15:59:27 +0900231 u8 start_time[4];
Leo Kime0a12212015-10-12 16:55:49 +0900232};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900233
Leo Kim441dc602015-10-12 16:55:35 +0900234static struct host_if_drv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
235struct host_if_drv *terminated_handle;
Leo Kimf2fc9f62015-10-13 19:49:47 +0900236bool g_obtainingIP;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900237u8 P2P_LISTEN_STATE;
Leo Kimc2115d82015-10-15 13:24:52 +0900238static struct task_struct *hif_thread_handler;
Leo Kimcb067dc2015-10-15 13:24:53 +0900239static WILC_MsgQueueHandle hif_msg_q;
Leo Kim834e0cb2015-10-15 13:24:54 +0900240static struct semaphore hif_sema_thread;
kbuild test robot413f9302015-10-15 14:07:41 +0800241static struct semaphore hif_sema_driver;
Leo Kim2d25af82015-10-15 13:24:56 +0900242static struct semaphore hif_sema_wait_response;
kbuild test robot17225002015-10-15 14:21:32 +0800243static struct semaphore hif_sema_deinit;
kbuild test robot24aadb82015-10-15 14:32:40 +0800244static struct timer_list periodic_rssi;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900245
Leo Kimfb70e9f2015-11-05 14:36:09 +0900246u8 multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900247
Leo Kima633c0b2015-10-15 13:24:59 +0900248static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900249
kbuild test robotf64321c2015-10-15 14:46:26 +0800250static bool scan_while_connected;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900251
Leo Kim144b7b22015-10-15 13:25:01 +0900252static s8 rssi;
Leo Kim75327a02015-10-15 13:25:02 +0900253static s8 link_speed;
Leo Kim95ebb0f2015-10-15 13:25:03 +0900254static u8 ch_no;
Leo Kim078b1e92015-10-15 13:25:04 +0900255static u8 set_ip[2][4];
Leo Kim1e75d012015-10-15 13:25:05 +0900256static u8 get_ip[2][4];
Leo Kimad269062015-10-15 13:25:06 +0900257static u32 inactive_time;
Leo Kima74c7bf2015-10-15 13:25:07 +0900258static u8 del_beacon;
Leo Kim7178aed2015-10-19 18:26:09 +0900259static u32 clients_count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900260
kbuild test robotef599192015-10-15 15:04:15 +0800261static u8 *join_req;
Leo Kim48ce2462015-10-15 13:25:10 +0900262u8 *info_element;
kbuild test robot23047d52015-10-15 15:18:34 +0800263static u8 mode_11i;
Leo Kimfba49892015-10-15 13:25:12 +0900264u8 auth_type;
Leo Kim0626baa2015-10-15 13:25:13 +0900265u32 join_req_size;
kbuild test robot5e0e7c22015-10-15 15:47:44 +0800266static u32 info_element_size;
kbuild test robot23fba592015-10-15 15:59:53 +0800267static struct host_if_drv *join_req_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900268#define REAL_JOIN_REQ 0
269#define FLUSHED_JOIN_REQ 1
Leo Kimae4dfa52015-10-13 19:49:26 +0900270#define FLUSHED_BYTE_POS 79
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900271
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900272static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900273
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900274extern int linux_wlan_get_num_conn_ifcs(void);
275
Leo Kim441dc602015-10-12 16:55:35 +0900276static int add_handler_in_list(struct host_if_drv *handler)
Johnny Kimd42ab082015-08-20 16:32:52 +0900277{
278 int i;
279
280 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
281 if (!wfidrv_list[i]) {
282 wfidrv_list[i] = handler;
283 return 0;
284 }
285 }
286
287 return -ENOBUFS;
288}
289
Leo Kim441dc602015-10-12 16:55:35 +0900290static int remove_handler_in_list(struct host_if_drv *handler)
Johnny Kimd42ab082015-08-20 16:32:52 +0900291{
292 int i;
293
294 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
295 if (wfidrv_list[i] == handler) {
296 wfidrv_list[i] = NULL;
297 return 0;
298 }
299 }
300
301 return -EINVAL;
302}
303
Leo Kim441dc602015-10-12 16:55:35 +0900304static int get_id_from_handler(struct host_if_drv *handler)
Johnny Kimd42ab082015-08-20 16:32:52 +0900305{
306 int i;
307
308 if (!handler)
309 return 0;
310
311 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
312 if (wfidrv_list[i] == handler)
313 return i;
314 }
315
316 return 0;
317}
318
Leo Kim441dc602015-10-12 16:55:35 +0900319static struct host_if_drv *get_handler_from_id(int id)
Johnny Kimd42ab082015-08-20 16:32:52 +0900320{
Dan Carpenter6ae9ac02015-09-15 09:54:33 +0300321 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
Johnny Kimd42ab082015-08-20 16:32:52 +0900322 return NULL;
323 return wfidrv_list[id];
324}
325
Leo Kim3eec50c2015-11-06 11:20:03 +0900326static s32 handle_set_channel(struct host_if_drv *hif_drv,
Leo Kim9cf78782015-10-29 12:05:54 +0900327 struct channel_attr *hif_set_ch)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900328{
Leo Kim31390ee2015-10-19 18:26:08 +0900329 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900330 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900331
Leo Kim45102f82015-10-28 15:59:28 +0900332 wid.id = (u16)WID_CURRENT_CHANNEL;
333 wid.type = WID_CHAR;
Leo Kim9cf78782015-10-29 12:05:54 +0900334 wid.val = (char *)&hif_set_ch->set_ch;
Leo Kim45102f82015-10-28 15:59:28 +0900335 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900336
337 PRINT_D(HOSTINF_DBG, "Setting channel\n");
Leo Kimae4dfa52015-10-13 19:49:26 +0900338
Leo Kim45102f82015-10-28 15:59:28 +0900339 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +0900340 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +0900341
342 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900343 PRINT_ER("Failed to set channel\n");
Leo Kim24db7132015-09-16 18:36:01 +0900344 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900345 }
346
Leo Kim31390ee2015-10-19 18:26:08 +0900347 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900348}
Leo Kimae4dfa52015-10-13 19:49:26 +0900349
Leo Kim23f2bad2015-11-06 11:20:04 +0900350static s32 handle_set_wfi_drv_handler(struct host_if_drv *hif_drv,
351 struct drv_handler *hif_drv_handler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900352{
Leo Kim31390ee2015-10-19 18:26:08 +0900353 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900354 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900355
Leo Kim45102f82015-10-28 15:59:28 +0900356 wid.id = (u16)WID_SET_DRV_HANDLER;
357 wid.type = WID_INT;
Leo Kim6b73c742015-10-29 12:05:55 +0900358 wid.val = (s8 *)&hif_drv_handler->handler;
Leo Kim45102f82015-10-28 15:59:28 +0900359 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900360
Leo Kim6b73c742015-10-29 12:05:55 +0900361 result = send_config_pkt(SET_CFG, &wid, 1, hif_drv_handler->handler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900362
Tony Choa4ab1ad2015-10-12 16:56:05 +0900363 if (!hif_drv)
Leo Kim27ff2162015-10-15 13:24:55 +0900364 up(&hif_sema_driver);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900365
Leo Kim31390ee2015-10-19 18:26:08 +0900366 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900367 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900368 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900369 }
370
Leo Kim31390ee2015-10-19 18:26:08 +0900371 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900372}
373
Leo Kim97b5c592015-11-06 11:20:05 +0900374static s32 handle_set_operation_mode(struct host_if_drv *hif_drv,
375 struct op_mode *hif_op_mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900376{
Leo Kim31390ee2015-10-19 18:26:08 +0900377 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900378 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900379
Leo Kim45102f82015-10-28 15:59:28 +0900380 wid.id = (u16)WID_SET_OPERATION_MODE;
381 wid.type = WID_INT;
Leo Kimacff1d72015-10-29 12:05:56 +0900382 wid.val = (s8 *)&hif_op_mode->mode;
Leo Kim45102f82015-10-28 15:59:28 +0900383 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900384
Leo Kim45102f82015-10-28 15:59:28 +0900385 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +0900386 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900387
Leo Kimacff1d72015-10-29 12:05:56 +0900388 if ((hif_op_mode->mode) == IDLE_MODE)
Leo Kim27ff2162015-10-15 13:24:55 +0900389 up(&hif_sema_driver);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900390
Leo Kim31390ee2015-10-19 18:26:08 +0900391 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900392 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900393 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900394 }
395
Leo Kim31390ee2015-10-19 18:26:08 +0900396 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900397}
398
Leo Kima6e6d482015-11-06 11:20:06 +0900399s32 handle_set_ip_address(struct host_if_drv *hif_drv, u8 *ip_addr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900400{
Leo Kim31390ee2015-10-19 18:26:08 +0900401 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900402 struct wid wid;
Leo Kimebc57d12015-11-05 14:36:03 +0900403 char firmware_ip_addr[4] = {0};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900404
Leo Kima6527c32015-11-05 14:36:02 +0900405 if (ip_addr[0] < 192)
406 ip_addr[0] = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900407
Leo Kima6527c32015-11-05 14:36:02 +0900408 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n",
409 idx, ip_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900410
Leo Kima6527c32015-11-05 14:36:02 +0900411 memcpy(set_ip[idx], ip_addr, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900412
Leo Kim45102f82015-10-28 15:59:28 +0900413 wid.id = (u16)WID_IP_ADDRESS;
414 wid.type = WID_STR;
Leo Kima6527c32015-11-05 14:36:02 +0900415 wid.val = (u8 *)ip_addr;
Leo Kim45102f82015-10-28 15:59:28 +0900416 wid.size = IP_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900417
Leo Kim45102f82015-10-28 15:59:28 +0900418 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +0900419 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900420
Leo Kimebc57d12015-11-05 14:36:03 +0900421 host_int_get_ipaddress(hif_drv, firmware_ip_addr, idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900422
Leo Kim31390ee2015-10-19 18:26:08 +0900423 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +0900424 PRINT_ER("Failed to set IP address\n");
425 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900426 }
427
Leo Kim24db7132015-09-16 18:36:01 +0900428 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900429
Leo Kim31390ee2015-10-19 18:26:08 +0900430 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900431}
432
Leo Kimd4516952015-11-06 11:20:07 +0900433s32 handle_get_ip_address(struct host_if_drv *hif_drv, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900434{
Leo Kim31390ee2015-10-19 18:26:08 +0900435 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900436 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900437
Leo Kim45102f82015-10-28 15:59:28 +0900438 wid.id = (u16)WID_IP_ADDRESS;
439 wid.type = WID_STR;
440 wid.val = kmalloc(IP_ALEN, GFP_KERNEL);
441 wid.size = IP_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900442
Leo Kim45102f82015-10-28 15:59:28 +0900443 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +0900444 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900445
Leo Kim45102f82015-10-28 15:59:28 +0900446 PRINT_INFO(HOSTINF_DBG, "%pI4\n", wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900447
Leo Kim45102f82015-10-28 15:59:28 +0900448 memcpy(get_ip[idx], wid.val, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900449
Leo Kim45102f82015-10-28 15:59:28 +0900450 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900451
Leo Kim1e75d012015-10-15 13:25:05 +0900452 if (memcmp(get_ip[idx], set_ip[idx], IP_ALEN) != 0)
Leo Kim078b1e92015-10-15 13:25:04 +0900453 host_int_setup_ipaddress(hif_drv, set_ip[idx], idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900454
Leo Kim31390ee2015-10-19 18:26:08 +0900455 if (result != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900456 PRINT_ER("Failed to get IP address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900457 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900458 }
459
Leo Kim24db7132015-09-16 18:36:01 +0900460 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
Leo Kim1e75d012015-10-15 13:25:05 +0900461 PRINT_INFO(HOSTINF_DBG, "%pI4\n", get_ip[idx]);
Leo Kim24db7132015-09-16 18:36:01 +0900462 PRINT_INFO(HOSTINF_DBG, "\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900463
Leo Kim31390ee2015-10-19 18:26:08 +0900464 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900465}
466
Leo Kima8267422015-11-06 11:20:08 +0900467static s32 handle_set_mac_address(struct host_if_drv *hif_drv,
468 struct set_mac_addr *set_mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900469{
Leo Kim31390ee2015-10-19 18:26:08 +0900470 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900471 struct wid wid;
Glen Leef3052582015-09-10 12:03:04 +0900472 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
Leo Kimc09389a2015-10-28 15:59:24 +0900473
Leo Kim91109e12015-10-19 18:26:13 +0900474 if (!mac_buf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900475 PRINT_ER("No buffer to send mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +0900476 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900477 }
Leo Kim090dbb12015-11-05 14:36:05 +0900478 memcpy(mac_buf, set_mac_addr->mac_addr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900479
Leo Kim45102f82015-10-28 15:59:28 +0900480 wid.id = (u16)WID_MAC_ADDR;
481 wid.type = WID_STR;
482 wid.val = mac_buf;
483 wid.size = ETH_ALEN;
484 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", wid.val);
Leo Kimae4dfa52015-10-13 19:49:26 +0900485
Leo Kim45102f82015-10-28 15:59:28 +0900486 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +0900487 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +0900488 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900489 PRINT_ER("Failed to set mac address\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900490 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900491 }
492
Chaehyun Lim49188af2015-08-11 10:32:41 +0900493 kfree(mac_buf);
Leo Kim31390ee2015-10-19 18:26:08 +0900494 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900495}
496
Leo Kimb3bf8fd2015-11-06 11:20:09 +0900497static s32 handle_get_mac_address(struct host_if_drv *hif_drv,
498 struct get_mac_addr *get_mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900499{
Leo Kim31390ee2015-10-19 18:26:08 +0900500 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900501 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900502
Leo Kim45102f82015-10-28 15:59:28 +0900503 wid.id = (u16)WID_MAC_ADDR;
504 wid.type = WID_STR;
Leo Kim7f0ee9a2015-11-05 14:36:06 +0900505 wid.val = get_mac_addr->mac_addr;
Leo Kim45102f82015-10-28 15:59:28 +0900506 wid.size = ETH_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900507
Leo Kim45102f82015-10-28 15:59:28 +0900508 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +0900509 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +0900510
511 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900512 PRINT_ER("Failed to get mac address\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900513 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900514 }
Leo Kim2d25af82015-10-15 13:24:56 +0900515 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900516
Leo Kim31390ee2015-10-19 18:26:08 +0900517 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900518}
519
Leo Kimdc276662015-11-06 11:20:10 +0900520static s32 handle_cfg_param(struct host_if_drv *hif_drv,
521 struct cfg_param_attr *cfg_param_attr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900522{
Leo Kim31390ee2015-10-19 18:26:08 +0900523 s32 result = 0;
Leo Kim13ca52a2015-11-06 11:20:11 +0900524 struct wid wid_list[32];
Leo Kim540c3e82015-11-06 11:20:12 +0900525 u8 wid_cnt = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900526
Leo Kim33110ad2015-10-29 11:58:27 +0900527 down(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900528
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900529 PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
530
Leo Kim02ae2bd2015-11-05 14:36:07 +0900531 if (cfg_param_attr->cfg_attr_info.flag & BSS_TYPE) {
532 if (cfg_param_attr->cfg_attr_info.bss_type < 6) {
Leo Kim540c3e82015-11-06 11:20:12 +0900533 wid_list[wid_cnt].id = WID_BSS_TYPE;
534 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.bss_type;
535 wid_list[wid_cnt].type = WID_CHAR;
536 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900537 hif_drv->cfg_values.bss_type = (u8)cfg_param_attr->cfg_attr_info.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900538 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900539 PRINT_ER("check value 6 over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900540 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900541 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900542 }
Leo Kim540c3e82015-11-06 11:20:12 +0900543 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900544 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900545 if (cfg_param_attr->cfg_attr_info.flag & AUTH_TYPE) {
546 if (cfg_param_attr->cfg_attr_info.auth_type == 1 ||
547 cfg_param_attr->cfg_attr_info.auth_type == 2 ||
548 cfg_param_attr->cfg_attr_info.auth_type == 5) {
Leo Kim540c3e82015-11-06 11:20:12 +0900549 wid_list[wid_cnt].id = WID_AUTH_TYPE;
550 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.auth_type;
551 wid_list[wid_cnt].type = WID_CHAR;
552 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900553 hif_drv->cfg_values.auth_type = (u8)cfg_param_attr->cfg_attr_info.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900554 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900555 PRINT_ER("Impossible value \n");
Leo Kim31390ee2015-10-19 18:26:08 +0900556 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900557 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900558 }
Leo Kim540c3e82015-11-06 11:20:12 +0900559 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900560 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900561 if (cfg_param_attr->cfg_attr_info.flag & AUTHEN_TIMEOUT) {
562 if (cfg_param_attr->cfg_attr_info.auth_timeout > 0 &&
563 cfg_param_attr->cfg_attr_info.auth_timeout < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900564 wid_list[wid_cnt].id = WID_AUTH_TIMEOUT;
565 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.auth_timeout;
566 wid_list[wid_cnt].type = WID_SHORT;
567 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900568 hif_drv->cfg_values.auth_timeout = cfg_param_attr->cfg_attr_info.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900569 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900570 PRINT_ER("Range(1 ~ 65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900571 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900572 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900573 }
Leo Kim540c3e82015-11-06 11:20:12 +0900574 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900575 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900576 if (cfg_param_attr->cfg_attr_info.flag & POWER_MANAGEMENT) {
577 if (cfg_param_attr->cfg_attr_info.power_mgmt_mode < 5) {
Leo Kim540c3e82015-11-06 11:20:12 +0900578 wid_list[wid_cnt].id = WID_POWER_MANAGEMENT;
579 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.power_mgmt_mode;
580 wid_list[wid_cnt].type = WID_CHAR;
581 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900582 hif_drv->cfg_values.power_mgmt_mode = (u8)cfg_param_attr->cfg_attr_info.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900583 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900584 PRINT_ER("Invalide power mode\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900585 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900586 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900587 }
Leo Kim540c3e82015-11-06 11:20:12 +0900588 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900589 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900590 if (cfg_param_attr->cfg_attr_info.flag & RETRY_SHORT) {
591 if (cfg_param_attr->cfg_attr_info.short_retry_limit > 0 &&
592 cfg_param_attr->cfg_attr_info.short_retry_limit < 256) {
Leo Kim540c3e82015-11-06 11:20:12 +0900593 wid_list[wid_cnt].id = WID_SHORT_RETRY_LIMIT;
594 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.short_retry_limit;
595 wid_list[wid_cnt].type = WID_SHORT;
596 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900597 hif_drv->cfg_values.short_retry_limit = cfg_param_attr->cfg_attr_info.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900598 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900599 PRINT_ER("Range(1~256) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900600 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900601 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900602 }
Leo Kim540c3e82015-11-06 11:20:12 +0900603 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900604 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900605 if (cfg_param_attr->cfg_attr_info.flag & RETRY_LONG) {
606 if (cfg_param_attr->cfg_attr_info.long_retry_limit > 0 &&
607 cfg_param_attr->cfg_attr_info.long_retry_limit < 256) {
Leo Kim540c3e82015-11-06 11:20:12 +0900608 wid_list[wid_cnt].id = WID_LONG_RETRY_LIMIT;
609 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.long_retry_limit;
610 wid_list[wid_cnt].type = WID_SHORT;
611 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900612 hif_drv->cfg_values.long_retry_limit = cfg_param_attr->cfg_attr_info.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900613 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900614 PRINT_ER("Range(1~256) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900615 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900616 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900617 }
Leo Kim540c3e82015-11-06 11:20:12 +0900618 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900619 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900620 if (cfg_param_attr->cfg_attr_info.flag & FRAG_THRESHOLD) {
621 if (cfg_param_attr->cfg_attr_info.frag_threshold > 255 &&
622 cfg_param_attr->cfg_attr_info.frag_threshold < 7937) {
Leo Kim540c3e82015-11-06 11:20:12 +0900623 wid_list[wid_cnt].id = WID_FRAG_THRESHOLD;
624 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.frag_threshold;
625 wid_list[wid_cnt].type = WID_SHORT;
626 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900627 hif_drv->cfg_values.frag_threshold = cfg_param_attr->cfg_attr_info.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900628 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900629 PRINT_ER("Threshold Range fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900630 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900631 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900632 }
Leo Kim540c3e82015-11-06 11:20:12 +0900633 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900634 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900635 if (cfg_param_attr->cfg_attr_info.flag & RTS_THRESHOLD) {
636 if (cfg_param_attr->cfg_attr_info.rts_threshold > 255 &&
637 cfg_param_attr->cfg_attr_info.rts_threshold < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900638 wid_list[wid_cnt].id = WID_RTS_THRESHOLD;
639 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.rts_threshold;
640 wid_list[wid_cnt].type = WID_SHORT;
641 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900642 hif_drv->cfg_values.rts_threshold = cfg_param_attr->cfg_attr_info.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900643 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900644 PRINT_ER("Threshold Range fail\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 & PREAMBLE) {
651 if (cfg_param_attr->cfg_attr_info.preamble_type < 3) {
Leo Kim540c3e82015-11-06 11:20:12 +0900652 wid_list[wid_cnt].id = WID_PREAMBLE;
653 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.preamble_type;
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.preamble_type = cfg_param_attr->cfg_attr_info.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900657 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900658 PRINT_ER("Preamle Range(0~2) over\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 & SHORT_SLOT_ALLOWED) {
665 if (cfg_param_attr->cfg_attr_info.short_slot_allowed < 2) {
Leo Kim540c3e82015-11-06 11:20:12 +0900666 wid_list[wid_cnt].id = WID_SHORT_SLOT_ALLOWED;
667 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.short_slot_allowed;
668 wid_list[wid_cnt].type = WID_CHAR;
669 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900670 hif_drv->cfg_values.short_slot_allowed = (u8)cfg_param_attr->cfg_attr_info.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900671 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900672 PRINT_ER("Short slot(2) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900673 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900674 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900675 }
Leo Kim540c3e82015-11-06 11:20:12 +0900676 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900677 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900678 if (cfg_param_attr->cfg_attr_info.flag & TXOP_PROT_DISABLE) {
679 if (cfg_param_attr->cfg_attr_info.txop_prot_disabled < 2) {
Leo Kim540c3e82015-11-06 11:20:12 +0900680 wid_list[wid_cnt].id = WID_11N_TXOP_PROT_DISABLE;
681 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.txop_prot_disabled;
682 wid_list[wid_cnt].type = WID_CHAR;
683 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900684 hif_drv->cfg_values.txop_prot_disabled = (u8)cfg_param_attr->cfg_attr_info.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900685 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900686 PRINT_ER("TXOP prot disable\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900687 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900688 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900689 }
Leo Kim540c3e82015-11-06 11:20:12 +0900690 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900691 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900692 if (cfg_param_attr->cfg_attr_info.flag & BEACON_INTERVAL) {
693 if (cfg_param_attr->cfg_attr_info.beacon_interval > 0 &&
694 cfg_param_attr->cfg_attr_info.beacon_interval < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900695 wid_list[wid_cnt].id = WID_BEACON_INTERVAL;
696 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.beacon_interval;
697 wid_list[wid_cnt].type = WID_SHORT;
698 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900699 hif_drv->cfg_values.beacon_interval = cfg_param_attr->cfg_attr_info.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900700 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900701 PRINT_ER("Beacon interval(1~65535) fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900702 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900703 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900704 }
Leo Kim540c3e82015-11-06 11:20:12 +0900705 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900706 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900707 if (cfg_param_attr->cfg_attr_info.flag & DTIM_PERIOD) {
708 if (cfg_param_attr->cfg_attr_info.dtim_period > 0 &&
709 cfg_param_attr->cfg_attr_info.dtim_period < 256) {
Leo Kim540c3e82015-11-06 11:20:12 +0900710 wid_list[wid_cnt].id = WID_DTIM_PERIOD;
711 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.dtim_period;
712 wid_list[wid_cnt].type = WID_CHAR;
713 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900714 hif_drv->cfg_values.dtim_period = cfg_param_attr->cfg_attr_info.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900715 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900716 PRINT_ER("DTIM range(1~255) fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900717 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900718 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900719 }
Leo Kim540c3e82015-11-06 11:20:12 +0900720 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900721 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900722 if (cfg_param_attr->cfg_attr_info.flag & SITE_SURVEY) {
723 if (cfg_param_attr->cfg_attr_info.site_survey_enabled < 3) {
Leo Kim540c3e82015-11-06 11:20:12 +0900724 wid_list[wid_cnt].id = WID_SITE_SURVEY;
725 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.site_survey_enabled;
726 wid_list[wid_cnt].type = WID_CHAR;
727 wid_list[wid_cnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900728 hif_drv->cfg_values.site_survey_enabled = (u8)cfg_param_attr->cfg_attr_info.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900729 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900730 PRINT_ER("Site survey disable\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900731 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900732 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900733 }
Leo Kim540c3e82015-11-06 11:20:12 +0900734 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900735 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900736 if (cfg_param_attr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) {
737 if (cfg_param_attr->cfg_attr_info.site_survey_scan_time > 0 &&
738 cfg_param_attr->cfg_attr_info.site_survey_scan_time < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900739 wid_list[wid_cnt].id = WID_SITE_SURVEY_SCAN_TIME;
740 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.site_survey_scan_time;
741 wid_list[wid_cnt].type = WID_SHORT;
742 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900743 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 +0900744 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900745 PRINT_ER("Site survey scan time(1~65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900746 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900747 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900748 }
Leo Kim540c3e82015-11-06 11:20:12 +0900749 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900750 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900751 if (cfg_param_attr->cfg_attr_info.flag & ACTIVE_SCANTIME) {
752 if (cfg_param_attr->cfg_attr_info.active_scan_time > 0 &&
753 cfg_param_attr->cfg_attr_info.active_scan_time < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900754 wid_list[wid_cnt].id = WID_ACTIVE_SCAN_TIME;
755 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.active_scan_time;
756 wid_list[wid_cnt].type = WID_SHORT;
757 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900758 hif_drv->cfg_values.active_scan_time = cfg_param_attr->cfg_attr_info.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900759 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900760 PRINT_ER("Active scan time(1~65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900761 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900762 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900763 }
Leo Kim540c3e82015-11-06 11:20:12 +0900764 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900765 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900766 if (cfg_param_attr->cfg_attr_info.flag & PASSIVE_SCANTIME) {
767 if (cfg_param_attr->cfg_attr_info.passive_scan_time > 0 &&
768 cfg_param_attr->cfg_attr_info.passive_scan_time < 65536) {
Leo Kim540c3e82015-11-06 11:20:12 +0900769 wid_list[wid_cnt].id = WID_PASSIVE_SCAN_TIME;
770 wid_list[wid_cnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.passive_scan_time;
771 wid_list[wid_cnt].type = WID_SHORT;
772 wid_list[wid_cnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900773 hif_drv->cfg_values.passive_scan_time = cfg_param_attr->cfg_attr_info.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900774 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900775 PRINT_ER("Passive scan time(1~65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900776 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900777 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900778 }
Leo Kim540c3e82015-11-06 11:20:12 +0900779 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900780 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900781 if (cfg_param_attr->cfg_attr_info.flag & CURRENT_TX_RATE) {
782 enum CURRENT_TXRATE curr_tx_rate = cfg_param_attr->cfg_attr_info.curr_tx_rate;
Leo Kimc09389a2015-10-28 15:59:24 +0900783
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900784 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
785 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
786 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
787 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
788 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
789 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
Leo Kim540c3e82015-11-06 11:20:12 +0900790 wid_list[wid_cnt].id = WID_CURRENT_TX_RATE;
791 wid_list[wid_cnt].val = (s8 *)&curr_tx_rate;
792 wid_list[wid_cnt].type = WID_SHORT;
793 wid_list[wid_cnt].size = sizeof(u16);
Leo Kimace303f2015-10-29 11:58:26 +0900794 hif_drv->cfg_values.curr_tx_rate = (u8)curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900795 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900796 PRINT_ER("out of TX rate\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900797 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900798 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900799 }
Leo Kim540c3e82015-11-06 11:20:12 +0900800 wid_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900801 }
Leo Kim31390ee2015-10-19 18:26:08 +0900802
Leo Kim540c3e82015-11-06 11:20:12 +0900803 result = send_config_pkt(SET_CFG, wid_list, wid_cnt,
Leo Kim8c8360b2015-10-19 18:26:12 +0900804 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900805
Leo Kim31390ee2015-10-19 18:26:08 +0900806 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900807 PRINT_ER("Error in setting CFG params\n");
808
Leo Kim24db7132015-09-16 18:36:01 +0900809ERRORHANDLER:
Leo Kim33110ad2015-10-29 11:58:27 +0900810 up(&hif_drv->sem_cfg_values);
Leo Kim31390ee2015-10-19 18:26:08 +0900811 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900812}
813
Leo Kim3b840e42015-11-05 14:36:08 +0900814static void Handle_wait_msg_q_empty(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900815{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900816 g_wilc_initialized = 0;
Leo Kim2d25af82015-10-15 13:24:56 +0900817 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900818}
819
Tony Choa4ab1ad2015-10-12 16:56:05 +0900820static s32 Handle_Scan(struct host_if_drv *hif_drv,
Tony Choc476feb2015-09-21 12:16:36 +0900821 struct scan_attr *pstrHostIFscanAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900822{
Leo Kim31390ee2015-10-19 18:26:08 +0900823 s32 result = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900824 struct wid strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900825 u32 u32WidsCount = 0;
826 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900827 u8 *pu8Buffer;
828 u8 valuesize = 0;
829 u8 *pu8HdnNtwrksWidVal = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900830
831 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
Leo Kimb60005a2015-10-29 11:58:24 +0900832 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", hif_drv->hif_state);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900833
Leo Kimbc801852015-10-29 11:58:50 +0900834 hif_drv->usr_scan_req.scan_result = pstrHostIFscanAttr->result;
Leo Kim66eaea32015-10-29 11:58:51 +0900835 hif_drv->usr_scan_req.arg = pstrHostIFscanAttr->arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900836
Leo Kimb60005a2015-10-29 11:58:24 +0900837 if ((hif_drv->hif_state >= HOST_IF_SCANNING) &&
838 (hif_drv->hif_state < HOST_IF_CONNECTED)) {
839 PRINT_D(GENERIC_DBG, "Don't scan already in [%d] state\n",
840 hif_drv->hif_state);
Leo Kim24db7132015-09-16 18:36:01 +0900841 PRINT_ER("Already scan\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900842 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +0900843 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900844 }
845
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900846 if (g_obtainingIP || connecting) {
847 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +0900848 PRINT_ER("Don't do obss scan\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900849 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +0900850 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900851 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900852
853 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
854
Leo Kimf79756e2015-10-29 12:05:36 +0900855 hif_drv->usr_scan_req.rcvd_ch_cnt = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900856
Leo Kimdaaf16b2015-10-12 16:55:44 +0900857 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
Leo Kim416d8322015-10-12 16:55:43 +0900858 strWIDList[u32WidsCount].type = WID_STR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900859
Leo Kim629b9ca2015-10-13 19:49:46 +0900860 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++)
861 valuesize += ((pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
Glen Leef3052582015-09-10 12:03:04 +0900862 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
Leo Kim900bb4a2015-10-12 16:55:46 +0900863 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
Leo Kim91109e12015-10-19 18:26:13 +0900864 if (strWIDList[u32WidsCount].val) {
Leo Kim900bb4a2015-10-12 16:55:46 +0900865 pu8Buffer = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900866
Leo Kim629b9ca2015-10-13 19:49:46 +0900867 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900868
Leo Kim629b9ca2015-10-13 19:49:46 +0900869 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->hidden_network.u8ssidnum);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900870
Leo Kim629b9ca2015-10-13 19:49:46 +0900871 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++) {
872 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
873 memcpy(pu8Buffer, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen);
874 pu8Buffer += pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900875 }
876
Leo Kim2fd3e442015-10-12 16:55:45 +0900877 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900878 u32WidsCount++;
879 }
880
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900881 {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900882 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
Leo Kim416d8322015-10-12 16:55:43 +0900883 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kimd6f19aa2015-10-13 19:49:42 +0900884 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ies;
Leo Kim7b1f76c2015-10-13 19:49:43 +0900885 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ies_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900886 u32WidsCount++;
887 }
888
Leo Kimdaaf16b2015-10-12 16:55:44 +0900889 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +0900890 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900891 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +0900892 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900893 u32WidsCount++;
894
Leo Kimdaaf16b2015-10-12 16:55:44 +0900895 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
Leo Kim416d8322015-10-12 16:55:43 +0900896 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900897
Leo Kim91109e12015-10-19 18:26:13 +0900898 if (pstrHostIFscanAttr->ch_freq_list &&
899 pstrHostIFscanAttr->ch_list_len > 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900900 int i;
901
Leo Kimf97bd9c2015-10-13 19:49:41 +0900902 for (i = 0; i < pstrHostIFscanAttr->ch_list_len; i++) {
Leo Kim82eeb0a2015-10-13 19:49:40 +0900903 if (pstrHostIFscanAttr->ch_freq_list[i] > 0)
904 pstrHostIFscanAttr->ch_freq_list[i] = pstrHostIFscanAttr->ch_freq_list[i] - 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900905 }
906 }
907
Leo Kim82eeb0a2015-10-13 19:49:40 +0900908 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
Leo Kimf97bd9c2015-10-13 19:49:41 +0900909 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900910 u32WidsCount++;
911
Leo Kimdaaf16b2015-10-12 16:55:44 +0900912 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
Leo Kim416d8322015-10-12 16:55:43 +0900913 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900914 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +0900915 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->src;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900916 u32WidsCount++;
917
Leo Kimb60005a2015-10-29 11:58:24 +0900918 if (hif_drv->hif_state == HOST_IF_CONNECTED)
Leo Kimca8540e42015-10-15 13:25:00 +0900919 scan_while_connected = true;
Leo Kimb60005a2015-10-29 11:58:24 +0900920 else if (hif_drv->hif_state == HOST_IF_IDLE)
Leo Kimca8540e42015-10-15 13:25:00 +0900921 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900922
Leo Kim31390ee2015-10-19 18:26:08 +0900923 result = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
Leo Kim8c8360b2015-10-19 18:26:12 +0900924 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900925
Leo Kim31390ee2015-10-19 18:26:08 +0900926 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900927 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +0900928 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900929 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900930
Leo Kim24db7132015-09-16 18:36:01 +0900931ERRORHANDLER:
Leo Kim31390ee2015-10-19 18:26:08 +0900932 if (result) {
Leo Kim13b313e2015-10-29 11:58:34 +0900933 del_timer(&hif_drv->scan_timer);
Tony Choa4ab1ad2015-10-12 16:56:05 +0900934 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900935 }
936
Shraddha Barke95f840f2015-10-14 07:29:19 +0530937 kfree(pstrHostIFscanAttr->ch_freq_list);
938 pstrHostIFscanAttr->ch_freq_list = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900939
Shraddha Barke95f840f2015-10-14 07:29:19 +0530940 kfree(pstrHostIFscanAttr->ies);
941 pstrHostIFscanAttr->ies = NULL;
942 kfree(pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo);
943 pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900944
Shraddha Barke95f840f2015-10-14 07:29:19 +0530945 kfree(pu8HdnNtwrksWidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900946
Leo Kim31390ee2015-10-19 18:26:08 +0900947 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900948}
949
Tony Choa4ab1ad2015-10-12 16:56:05 +0900950static s32 Handle_ScanDone(struct host_if_drv *hif_drv,
951 enum scan_event enuEvent)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900952{
Leo Kim31390ee2015-10-19 18:26:08 +0900953 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900954 u8 u8abort_running_scan;
Leo Kim45102f82015-10-28 15:59:28 +0900955 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900956
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900957 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
958
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900959 if (enuEvent == SCAN_EVENT_ABORTED) {
960 PRINT_D(GENERIC_DBG, "Abort running scan\n");
961 u8abort_running_scan = 1;
Leo Kim45102f82015-10-28 15:59:28 +0900962 wid.id = (u16)WID_ABORT_RUNNING_SCAN;
963 wid.type = WID_CHAR;
964 wid.val = (s8 *)&u8abort_running_scan;
965 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900966
Leo Kim45102f82015-10-28 15:59:28 +0900967 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +0900968 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +0900969
970 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900971 PRINT_ER("Failed to set abort running scan\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900972 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900973 }
974 }
975
Tony Choa4ab1ad2015-10-12 16:56:05 +0900976 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900977 PRINT_ER("Driver handler is NULL\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900978 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900979 }
980
Leo Kimbc801852015-10-29 11:58:50 +0900981 if (hif_drv->usr_scan_req.scan_result) {
982 hif_drv->usr_scan_req.scan_result(enuEvent, NULL,
Leo Kim66eaea32015-10-29 11:58:51 +0900983 hif_drv->usr_scan_req.arg, NULL);
Leo Kimbc801852015-10-29 11:58:50 +0900984 hif_drv->usr_scan_req.scan_result = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900985 }
986
Leo Kim31390ee2015-10-19 18:26:08 +0900987 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900988}
989
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900990u8 u8ConnectedSSID[6] = {0};
Tony Choa4ab1ad2015-10-12 16:56:05 +0900991static s32 Handle_Connect(struct host_if_drv *hif_drv,
Tony Cho120ae592015-09-21 12:16:37 +0900992 struct connect_attr *pstrHostIFconnectAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900993{
Leo Kim31390ee2015-10-19 18:26:08 +0900994 s32 result = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900995 struct wid strWIDList[8];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900996 u32 u32WidsCount = 0, dummyval = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900997 u8 *pu8CurrByte = NULL;
Leo Kime0a12212015-10-12 16:55:49 +0900998 struct join_bss_param *ptstrJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900999
1000 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1001
Leo Kim9254db02015-10-13 19:49:49 +09001002 if (memcmp(pstrHostIFconnectAttr->bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
Leo Kim31390ee2015-10-19 18:26:08 +09001003 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001004 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001005 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001006 }
1007
1008 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1009
Leo Kimf2bed2c2015-10-13 19:49:59 +09001010 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->params;
Leo Kim91109e12015-10-19 18:26:13 +09001011 if (!ptstrJoinBssParam) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001012 PRINT_ER("Required BSSID not found\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001013 result = -ENOENT;
Leo Kim24db7132015-09-16 18:36:01 +09001014 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001015 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001016
Leo Kim91109e12015-10-19 18:26:13 +09001017 if (pstrHostIFconnectAttr->bssid) {
Leo Kimf8b17132015-10-28 15:59:34 +09001018 hif_drv->usr_conn_req.pu8bssid = kmalloc(6, GFP_KERNEL);
1019 memcpy(hif_drv->usr_conn_req.pu8bssid, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001020 }
1021
Leo Kim74ab5e42015-10-29 11:58:53 +09001022 hif_drv->usr_conn_req.ssid_len = pstrHostIFconnectAttr->ssid_len;
Leo Kim91109e12015-10-19 18:26:13 +09001023 if (pstrHostIFconnectAttr->ssid) {
Leo Kimf8b17132015-10-28 15:59:34 +09001024 hif_drv->usr_conn_req.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
1025 memcpy(hif_drv->usr_conn_req.pu8ssid,
Leo Kim8c8360b2015-10-19 18:26:12 +09001026 pstrHostIFconnectAttr->ssid,
1027 pstrHostIFconnectAttr->ssid_len);
Leo Kimf8b17132015-10-28 15:59:34 +09001028 hif_drv->usr_conn_req.pu8ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001029 }
1030
Leo Kim331ed082015-10-29 11:58:55 +09001031 hif_drv->usr_conn_req.ies_len = pstrHostIFconnectAttr->ies_len;
Leo Kim91109e12015-10-19 18:26:13 +09001032 if (pstrHostIFconnectAttr->ies) {
Leo Kima3b2f4b2015-10-29 11:58:54 +09001033 hif_drv->usr_conn_req.ies = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1034 memcpy(hif_drv->usr_conn_req.ies,
Leo Kim8c8360b2015-10-19 18:26:12 +09001035 pstrHostIFconnectAttr->ies,
1036 pstrHostIFconnectAttr->ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001037 }
1038
Leo Kimf8b17132015-10-28 15:59:34 +09001039 hif_drv->usr_conn_req.u8security = pstrHostIFconnectAttr->security;
Leo Kim7d069722015-10-29 12:05:37 +09001040 hif_drv->usr_conn_req.auth_type = pstrHostIFconnectAttr->auth_type;
Leo Kim33bfb192015-10-29 11:58:56 +09001041 hif_drv->usr_conn_req.conn_result = pstrHostIFconnectAttr->result;
Leo Kim73abaa42015-10-29 12:05:27 +09001042 hif_drv->usr_conn_req.arg = pstrHostIFconnectAttr->arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001043
Leo Kimdaaf16b2015-10-12 16:55:44 +09001044 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001045 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001046 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001047 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001048 u32WidsCount++;
1049
Leo Kimdaaf16b2015-10-12 16:55:44 +09001050 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001051 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001052 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001053 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001054 u32WidsCount++;
1055
Leo Kimdaaf16b2015-10-12 16:55:44 +09001056 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001057 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001058 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001059 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001060 u32WidsCount++;
1061
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001062 {
Leo Kimdaaf16b2015-10-12 16:55:44 +09001063 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
Leo Kim416d8322015-10-12 16:55:43 +09001064 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001065 strWIDList[u32WidsCount].val = hif_drv->usr_conn_req.ies;
Leo Kim331ed082015-10-29 11:58:55 +09001066 strWIDList[u32WidsCount].size = hif_drv->usr_conn_req.ies_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001067 u32WidsCount++;
1068
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001069 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Leo Kim331ed082015-10-29 11:58:55 +09001070 info_element_size = hif_drv->usr_conn_req.ies_len;
Leo Kimdfef7b82015-10-15 13:25:14 +09001071 info_element = kmalloc(info_element_size, GFP_KERNEL);
Leo Kima3b2f4b2015-10-29 11:58:54 +09001072 memcpy(info_element, hif_drv->usr_conn_req.ies,
Leo Kimdfef7b82015-10-15 13:25:14 +09001073 info_element_size);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001074 }
1075 }
Leo Kimdaaf16b2015-10-12 16:55:44 +09001076 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001077 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001078 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimf8b17132015-10-28 15:59:34 +09001079 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001080 u32WidsCount++;
1081
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001082 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
Leo Kimf8b17132015-10-28 15:59:34 +09001083 mode_11i = hif_drv->usr_conn_req.u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001084
Leo Kimf8b17132015-10-28 15:59:34 +09001085 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", hif_drv->usr_conn_req.u8security);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001086
Leo Kimdaaf16b2015-10-12 16:55:44 +09001087 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001088 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001089 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim7d069722015-10-29 12:05:37 +09001090 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001091 u32WidsCount++;
1092
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001093 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
Leo Kim7d069722015-10-29 12:05:37 +09001094 auth_type = (u8)hif_drv->usr_conn_req.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001095
Leo Kim7d069722015-10-29 12:05:37 +09001096 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n",
1097 hif_drv->usr_conn_req.auth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001098 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
Leo Kimf8b17132015-10-28 15:59:34 +09001099 hif_drv->usr_conn_req.pu8ssid, pstrHostIFconnectAttr->ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001100
Leo Kimdaaf16b2015-10-12 16:55:44 +09001101 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
Leo Kim416d8322015-10-12 16:55:43 +09001102 strWIDList[u32WidsCount].type = WID_STR;
Leo Kimae4dfa52015-10-13 19:49:26 +09001103 strWIDList[u32WidsCount].size = 112;
Leo Kim900bb4a2015-10-12 16:55:46 +09001104 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001105
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001106 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Leo Kim0626baa2015-10-15 13:25:13 +09001107 join_req_size = strWIDList[u32WidsCount].size;
1108 join_req = kmalloc(join_req_size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001109 }
Leo Kim91109e12015-10-19 18:26:13 +09001110 if (!strWIDList[u32WidsCount].val) {
Leo Kim31390ee2015-10-19 18:26:08 +09001111 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09001112 goto ERRORHANDLER;
1113 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001114
Leo Kim900bb4a2015-10-12 16:55:46 +09001115 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001116
Leo Kim91109e12015-10-19 18:26:13 +09001117 if (pstrHostIFconnectAttr->ssid) {
Leo Kim8b3c9fa2015-10-13 19:49:51 +09001118 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1119 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001120 }
1121 pu8CurrByte += MAX_SSID_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001122 *(pu8CurrByte++) = INFRASTRUCTURE;
Leo Kimae4dfa52015-10-13 19:49:26 +09001123
Leo Kim0d1527e2015-10-13 19:49:58 +09001124 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1125 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001126 } else {
1127 PRINT_ER("Channel out of range\n");
1128 *(pu8CurrByte++) = 0xFF;
1129 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001130 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1131 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1132 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1133
Leo Kim91109e12015-10-19 18:26:13 +09001134 if (pstrHostIFconnectAttr->bssid)
Leo Kim9254db02015-10-13 19:49:49 +09001135 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001136 pu8CurrByte += 6;
1137
Tony Choc0f52fb2015-10-20 17:10:46 +09001138 if (pstrHostIFconnectAttr->bssid)
1139 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1140 pu8CurrByte += 6;
1141
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001142 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1143 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1144 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001145 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1146 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
Leo Kimae4dfa52015-10-13 19:49:26 +09001147
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001148 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001149 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1150
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001151 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1152 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001153 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1154
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001155 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
Leo Kimff069822015-10-29 12:05:26 +09001156 hif_drv->usr_conn_req.ht_capable = ptstrJoinBssParam->ht_capable;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001157
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001158 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1159 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001160 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1161 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001162 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1163 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
Leo Kimae4dfa52015-10-13 19:49:26 +09001164
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001165 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001166 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1167
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001168 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001169 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1170
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001171 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001172 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1173
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001174 *(pu8CurrByte++) = REAL_JOIN_REQ;
Leo Kim7a8d51d2015-10-15 13:24:43 +09001175 *(pu8CurrByte++) = ptstrJoinBssParam->noa_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001176
Leo Kim7a8d51d2015-10-15 13:24:43 +09001177 if (ptstrJoinBssParam->noa_enabled) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001178 PRINT_D(HOSTINF_DBG, "NOA present\n");
1179
1180 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1181 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1182 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1183 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1184
Leo Kimd72b33c2015-10-15 13:24:44 +09001185 *(pu8CurrByte++) = ptstrJoinBssParam->opp_enabled;
Leo Kimcc179002015-10-15 13:24:47 +09001186 *(pu8CurrByte++) = ptstrJoinBssParam->idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001187
Leo Kimd72b33c2015-10-15 13:24:44 +09001188 if (ptstrJoinBssParam->opp_enabled)
Leo Kim99b66942015-10-15 13:24:45 +09001189 *(pu8CurrByte++) = ptstrJoinBssParam->ct_window;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001190
Leo Kimc21047e2015-10-15 13:24:46 +09001191 *(pu8CurrByte++) = ptstrJoinBssParam->cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001192
Leo Kim109e6ca2015-10-15 13:24:48 +09001193 memcpy(pu8CurrByte, ptstrJoinBssParam->duration, sizeof(ptstrJoinBssParam->duration));
1194 pu8CurrByte += sizeof(ptstrJoinBssParam->duration);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001195
Leo Kim1d8b76b2015-10-15 13:24:49 +09001196 memcpy(pu8CurrByte, ptstrJoinBssParam->interval, sizeof(ptstrJoinBssParam->interval));
1197 pu8CurrByte += sizeof(ptstrJoinBssParam->interval);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001198
Leo Kim4be55e22015-10-28 15:59:27 +09001199 memcpy(pu8CurrByte, ptstrJoinBssParam->start_time, sizeof(ptstrJoinBssParam->start_time));
1200 pu8CurrByte += sizeof(ptstrJoinBssParam->start_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001201 } else
1202 PRINT_D(HOSTINF_DBG, "NOA not present\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001203
Leo Kim900bb4a2015-10-12 16:55:46 +09001204 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001205 u32WidsCount++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001206
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001207 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Leo Kim0626baa2015-10-15 13:25:13 +09001208 memcpy(join_req, pu8CurrByte, join_req_size);
Leo Kim870515c2015-10-15 13:25:15 +09001209 join_req_drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001210 }
1211
1212 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1213
Leo Kim91109e12015-10-19 18:26:13 +09001214 if (pstrHostIFconnectAttr->bssid) {
Leo Kim9254db02015-10-13 19:49:49 +09001215 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001216
Leo Kim9254db02015-10-13 19:49:49 +09001217 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->bssid);
Alexander Kuleshov310a28f2015-09-04 00:48:14 +06001218 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001219 }
1220
Leo Kim31390ee2015-10-19 18:26:08 +09001221 result = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
Leo Kim8c8360b2015-10-19 18:26:12 +09001222 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09001223 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09001224 PRINT_ER("failed to send config packet\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001225 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09001226 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001227 } else {
1228 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
Leo Kimb60005a2015-10-29 11:58:24 +09001229 hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001230 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001231
Leo Kim24db7132015-09-16 18:36:01 +09001232ERRORHANDLER:
Leo Kim31390ee2015-10-19 18:26:08 +09001233 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001234 tstrConnectInfo strConnectInfo;
1235
Leo Kim81a59502015-10-29 11:58:35 +09001236 del_timer(&hif_drv->connect_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001237
1238 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1239
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001240 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001241
Leo Kim91109e12015-10-19 18:26:13 +09001242 if (pstrHostIFconnectAttr->result) {
1243 if (pstrHostIFconnectAttr->bssid)
Leo Kim9254db02015-10-13 19:49:49 +09001244 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001245
Leo Kim91109e12015-10-19 18:26:13 +09001246 if (pstrHostIFconnectAttr->ies) {
Leo Kimb59d5c52015-10-13 19:49:53 +09001247 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->ies_len;
1248 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001249 memcpy(strConnectInfo.pu8ReqIEs,
Leo Kim8c8360b2015-10-19 18:26:12 +09001250 pstrHostIFconnectAttr->ies,
1251 pstrHostIFconnectAttr->ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001252 }
1253
Leo Kim6abcc112015-10-13 19:49:55 +09001254 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001255 &strConnectInfo,
1256 MAC_DISCONNECTED,
1257 NULL,
Leo Kim8f38db82015-10-13 19:49:56 +09001258 pstrHostIFconnectAttr->arg);
Leo Kimb60005a2015-10-29 11:58:24 +09001259 hif_drv->hif_state = HOST_IF_IDLE;
Shraddha Barke95f840f2015-10-14 07:29:19 +05301260 kfree(strConnectInfo.pu8ReqIEs);
1261 strConnectInfo.pu8ReqIEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001262
1263 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001264 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001265 }
1266 }
1267
1268 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
Shraddha Barke95f840f2015-10-14 07:29:19 +05301269 kfree(pstrHostIFconnectAttr->bssid);
1270 pstrHostIFconnectAttr->bssid = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001271
Shraddha Barke95f840f2015-10-14 07:29:19 +05301272 kfree(pstrHostIFconnectAttr->ssid);
1273 pstrHostIFconnectAttr->ssid = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001274
Shraddha Barke95f840f2015-10-14 07:29:19 +05301275 kfree(pstrHostIFconnectAttr->ies);
1276 pstrHostIFconnectAttr->ies = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001277
Shraddha Barke95f840f2015-10-14 07:29:19 +05301278 kfree(pu8CurrByte);
Leo Kim31390ee2015-10-19 18:26:08 +09001279 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001280}
1281
Tony Choa4ab1ad2015-10-12 16:56:05 +09001282static s32 Handle_FlushConnect(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001283{
Leo Kim31390ee2015-10-19 18:26:08 +09001284 s32 result = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09001285 struct wid strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001286 u32 u32WidsCount = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001287 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001288
Leo Kimdaaf16b2015-10-12 16:55:44 +09001289 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
Leo Kim416d8322015-10-12 16:55:43 +09001290 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kim48ce2462015-10-15 13:25:10 +09001291 strWIDList[u32WidsCount].val = info_element;
Leo Kimdfef7b82015-10-15 13:25:14 +09001292 strWIDList[u32WidsCount].size = info_element_size;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001293 u32WidsCount++;
1294
Leo Kimdaaf16b2015-10-12 16:55:44 +09001295 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001296 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001297 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim1bd9d442015-10-15 13:25:11 +09001298 strWIDList[u32WidsCount].val = (s8 *)(&(mode_11i));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001299 u32WidsCount++;
1300
Leo Kimdaaf16b2015-10-12 16:55:44 +09001301 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001302 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001303 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimfba49892015-10-15 13:25:12 +09001304 strWIDList[u32WidsCount].val = (s8 *)(&auth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001305 u32WidsCount++;
1306
Leo Kimdaaf16b2015-10-12 16:55:44 +09001307 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
Leo Kim416d8322015-10-12 16:55:43 +09001308 strWIDList[u32WidsCount].type = WID_STR;
Leo Kim0626baa2015-10-15 13:25:13 +09001309 strWIDList[u32WidsCount].size = join_req_size;
Leo Kim044a64102015-10-15 13:25:09 +09001310 strWIDList[u32WidsCount].val = (s8 *)join_req;
Leo Kim900bb4a2015-10-12 16:55:46 +09001311 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001312
1313 pu8CurrByte += FLUSHED_BYTE_POS;
1314 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1315
1316 u32WidsCount++;
1317
Leo Kim31390ee2015-10-19 18:26:08 +09001318 result = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
Leo Kim8c8360b2015-10-19 18:26:12 +09001319 get_id_from_handler(join_req_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09001320 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09001321 PRINT_ER("failed to send config packet\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001322 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001323 }
1324
Leo Kim31390ee2015-10-19 18:26:08 +09001325 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001326}
1327
Tony Choa4ab1ad2015-10-12 16:56:05 +09001328static s32 Handle_ConnectTimeout(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001329{
Leo Kim31390ee2015-10-19 18:26:08 +09001330 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001331 tstrConnectInfo strConnectInfo;
Leo Kim45102f82015-10-28 15:59:28 +09001332 struct wid wid;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001333 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001334
Tony Choa4ab1ad2015-10-12 16:56:05 +09001335 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001336 PRINT_ER("Driver handler is NULL\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001337 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001338 }
1339
Leo Kimb60005a2015-10-29 11:58:24 +09001340 hif_drv->hif_state = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001341
Leo Kimca8540e42015-10-15 13:25:00 +09001342 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001343
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001344 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001345
Leo Kim33bfb192015-10-29 11:58:56 +09001346 if (hif_drv->usr_conn_req.conn_result) {
Leo Kimf8b17132015-10-28 15:59:34 +09001347 if (hif_drv->usr_conn_req.pu8bssid) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001348 memcpy(strConnectInfo.au8bssid,
Leo Kimf8b17132015-10-28 15:59:34 +09001349 hif_drv->usr_conn_req.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001350 }
1351
Leo Kima3b2f4b2015-10-29 11:58:54 +09001352 if (hif_drv->usr_conn_req.ies) {
Leo Kim331ed082015-10-29 11:58:55 +09001353 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len;
1354 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001355 memcpy(strConnectInfo.pu8ReqIEs,
Leo Kima3b2f4b2015-10-29 11:58:54 +09001356 hif_drv->usr_conn_req.ies,
Leo Kim331ed082015-10-29 11:58:55 +09001357 hif_drv->usr_conn_req.ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001358 }
1359
Leo Kim33bfb192015-10-29 11:58:56 +09001360 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1361 &strConnectInfo,
1362 MAC_DISCONNECTED,
1363 NULL,
Leo Kim73abaa42015-10-29 12:05:27 +09001364 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001365
Shraddha Barke95f840f2015-10-14 07:29:19 +05301366 kfree(strConnectInfo.pu8ReqIEs);
1367 strConnectInfo.pu8ReqIEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001368 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001369 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001370 }
1371
Leo Kim45102f82015-10-28 15:59:28 +09001372 wid.id = (u16)WID_DISCONNECT;
1373 wid.type = WID_CHAR;
1374 wid.val = (s8 *)&u16DummyReasonCode;
1375 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001376
1377 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1378
Leo Kim45102f82015-10-28 15:59:28 +09001379 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001380 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09001381 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001382 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001383
Leo Kim74ab5e42015-10-29 11:58:53 +09001384 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09001385 kfree(hif_drv->usr_conn_req.pu8ssid);
1386 kfree(hif_drv->usr_conn_req.pu8bssid);
Leo Kim331ed082015-10-29 11:58:55 +09001387 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001388 kfree(hif_drv->usr_conn_req.ies);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001389
Shraddha Barke281dd5a2015-10-05 17:00:33 +05301390 eth_zero_addr(u8ConnectedSSID);
Leo Kimae4dfa52015-10-13 19:49:26 +09001391
Leo Kim91109e12015-10-19 18:26:13 +09001392 if (join_req && join_req_drv == hif_drv) {
Leo Kim044a64102015-10-15 13:25:09 +09001393 kfree(join_req);
1394 join_req = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001395 }
Leo Kim48ce2462015-10-15 13:25:10 +09001396
Leo Kim91109e12015-10-19 18:26:13 +09001397 if (info_element && join_req_drv == hif_drv) {
Leo Kim48ce2462015-10-15 13:25:10 +09001398 kfree(info_element);
1399 info_element = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001400 }
1401
Leo Kim31390ee2015-10-19 18:26:08 +09001402 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001403}
1404
Tony Choa4ab1ad2015-10-12 16:56:05 +09001405static s32 Handle_RcvdNtwrkInfo(struct host_if_drv *hif_drv,
Tony Cho3bbd59f2015-09-21 12:16:38 +09001406 struct rcvd_net_info *pstrRcvdNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001407{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001408 u32 i;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001409 bool bNewNtwrkFound;
Leo Kim31390ee2015-10-19 18:26:08 +09001410 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001411 tstrNetworkInfo *pstrNetworkInfo = NULL;
1412 void *pJoinParams = NULL;
1413
Dean Lee72ed4dc2015-06-12 14:11:44 +09001414 bNewNtwrkFound = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001415 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1416
Leo Kimbc801852015-10-29 11:58:50 +09001417 if (hif_drv->usr_scan_req.scan_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001418 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
Leo Kimb021b802015-10-13 20:02:10 +09001419 parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo);
Leo Kim91109e12015-10-19 18:26:13 +09001420 if ((!pstrNetworkInfo) ||
Leo Kimbc801852015-10-29 11:58:50 +09001421 (!hif_drv->usr_scan_req.scan_result)) {
Leo Kim24db7132015-09-16 18:36:01 +09001422 PRINT_ER("driver is null\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001423 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +09001424 goto done;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001425 }
1426
Leo Kimf79756e2015-10-29 12:05:36 +09001427 for (i = 0; i < hif_drv->usr_scan_req.rcvd_ch_cnt; i++) {
Leo Kimaf973f32015-10-29 11:58:52 +09001428 if ((hif_drv->usr_scan_req.net_info[i].au8bssid) &&
Leo Kim91109e12015-10-19 18:26:13 +09001429 (pstrNetworkInfo->au8bssid)) {
Leo Kimaf973f32015-10-29 11:58:52 +09001430 if (memcmp(hif_drv->usr_scan_req.net_info[i].au8bssid,
Leo Kim8c8360b2015-10-19 18:26:12 +09001431 pstrNetworkInfo->au8bssid, 6) == 0) {
Leo Kimaf973f32015-10-29 11:58:52 +09001432 if (pstrNetworkInfo->s8rssi <= hif_drv->usr_scan_req.net_info[i].s8rssi) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001433 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
1434 goto done;
1435 } else {
Leo Kimaf973f32015-10-29 11:58:52 +09001436 hif_drv->usr_scan_req.net_info[i].s8rssi = pstrNetworkInfo->s8rssi;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001437 bNewNtwrkFound = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001438 break;
1439 }
1440 }
1441 }
1442 }
1443
Punit Vara047e6642015-10-25 04:01:25 +05301444 if (bNewNtwrkFound) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001445 PRINT_D(HOSTINF_DBG, "New network found\n");
1446
Leo Kimf79756e2015-10-29 12:05:36 +09001447 if (hif_drv->usr_scan_req.rcvd_ch_cnt < MAX_NUM_SCANNED_NETWORKS) {
1448 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 +09001449
Leo Kimf79756e2015-10-29 12:05:36 +09001450 if (hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].au8bssid &&
Leo Kim91109e12015-10-19 18:26:13 +09001451 pstrNetworkInfo->au8bssid) {
Leo Kimf79756e2015-10-29 12:05:36 +09001452 memcpy(hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].au8bssid,
Leo Kim8c8360b2015-10-19 18:26:12 +09001453 pstrNetworkInfo->au8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001454
Leo Kimf79756e2015-10-29 12:05:36 +09001455 hif_drv->usr_scan_req.rcvd_ch_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001456
Dean Lee72ed4dc2015-06-12 14:11:44 +09001457 pstrNetworkInfo->bNewNetwork = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001458 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001459
Leo Kimbc801852015-10-29 11:58:50 +09001460 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
Leo Kim66eaea32015-10-29 11:58:51 +09001461 hif_drv->usr_scan_req.arg,
Leo Kimbc801852015-10-29 11:58:50 +09001462 pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001463 }
1464 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001465 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001466 }
1467 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001468 pstrNetworkInfo->bNewNetwork = false;
Leo Kimbc801852015-10-29 11:58:50 +09001469 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
Leo Kim66eaea32015-10-29 11:58:51 +09001470 hif_drv->usr_scan_req.arg, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001471 }
1472 }
1473
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001474done:
Shraddha Barke95f840f2015-10-14 07:29:19 +05301475 kfree(pstrRcvdNetworkInfo->buffer);
1476 pstrRcvdNetworkInfo->buffer = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001477
Leo Kim91109e12015-10-19 18:26:13 +09001478 if (pstrNetworkInfo) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001479 DeallocateNetworkInfo(pstrNetworkInfo);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001480 pstrNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001481 }
1482
Leo Kim31390ee2015-10-19 18:26:08 +09001483 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001484}
1485
Tony Choa4ab1ad2015-10-12 16:56:05 +09001486static s32 Handle_RcvdGnrlAsyncInfo(struct host_if_drv *hif_drv,
Tony Chof23a9ea2015-09-21 12:16:39 +09001487 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001488{
Leo Kim31390ee2015-10-19 18:26:08 +09001489 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001490 u8 u8MsgType = 0;
1491 u8 u8MsgID = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001492 u16 u16MsgLen = 0;
1493 u16 u16WidID = (u16)WID_NIL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001494 u8 u8WidLen = 0;
1495 u8 u8MacStatus;
1496 u8 u8MacStatusReasonCode;
1497 u8 u8MacStatusAdditionalInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001498 tstrConnectInfo strConnectInfo;
1499 tstrDisconnectNotifInfo strDisconnectNotifInfo;
Leo Kime6e12662015-09-16 18:36:03 +09001500 s32 s32Err = 0;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02001501
Tony Choa4ab1ad2015-10-12 16:56:05 +09001502 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001503 PRINT_ER("Driver handler is NULL\n");
Leo Kim234837d2015-09-22 14:34:43 +09001504 return -ENODEV;
1505 }
Leo Kimb60005a2015-10-29 11:58:24 +09001506 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n",
1507 hif_drv->hif_state, pstrRcvdGnrlAsyncInfo->buffer[7]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001508
Leo Kimb60005a2015-10-29 11:58:24 +09001509 if ((hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
1510 (hif_drv->hif_state == HOST_IF_CONNECTED) ||
Leo Kimbc801852015-10-29 11:58:50 +09001511 hif_drv->usr_scan_req.scan_result) {
Leo Kim91109e12015-10-19 18:26:13 +09001512 if (!pstrRcvdGnrlAsyncInfo->buffer ||
Leo Kim33bfb192015-10-29 11:58:56 +09001513 !hif_drv->usr_conn_req.conn_result) {
Leo Kim24db7132015-09-16 18:36:01 +09001514 PRINT_ER("driver is null\n");
1515 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001516 }
1517
Leo Kim33722ac72015-10-13 19:50:00 +09001518 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001519
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001520 if ('I' != u8MsgType) {
1521 PRINT_ER("Received Message format incorrect.\n");
Leo Kim24db7132015-09-16 18:36:01 +09001522 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001523 }
1524
Leo Kim33722ac72015-10-13 19:50:00 +09001525 u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1];
1526 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]);
1527 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]);
1528 u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6];
1529 u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7];
1530 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8];
1531 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001532 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
Leo Kimb60005a2015-10-29 11:58:24 +09001533 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001534 u32 u32RcvdAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001535 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
1536
1537 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1538
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001539 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001540
1541 if (u8MacStatus == MAC_CONNECTED) {
Leo Kima633c0b2015-10-15 13:24:59 +09001542 memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001543
Tony Choa4ab1ad2015-10-12 16:56:05 +09001544 host_int_get_assoc_res_info(hif_drv,
Leo Kima633c0b2015-10-15 13:24:59 +09001545 rcv_assoc_resp,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001546 MAX_ASSOC_RESP_FRAME_SIZE,
1547 &u32RcvdAssocRespInfoLen);
1548
1549 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
1550
1551 if (u32RcvdAssocRespInfoLen != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001552 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
Leo Kima633c0b2015-10-15 13:24:59 +09001553 s32Err = ParseAssocRespInfo(rcv_assoc_resp, u32RcvdAssocRespInfoLen,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001554 &pstrConnectRespInfo);
1555 if (s32Err) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001556 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001557 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001558 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
1559
1560 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
1561 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
Leo Kim91109e12015-10-19 18:26:13 +09001562 if (pstrConnectRespInfo->pu8RespIEs) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001563 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001564 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001565 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001566 pstrConnectRespInfo->u16RespIEsLen);
1567 }
1568 }
1569
Leo Kim91109e12015-10-19 18:26:13 +09001570 if (pstrConnectRespInfo) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001571 DeallocateAssocRespInfo(pstrConnectRespInfo);
1572 pstrConnectRespInfo = NULL;
1573 }
1574 }
1575 }
1576 }
1577
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001578 if ((u8MacStatus == MAC_CONNECTED) &&
1579 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001580 PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n");
Shraddha Barke281dd5a2015-10-05 17:00:33 +05301581 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001582
1583 } else if (u8MacStatus == MAC_DISCONNECTED) {
1584 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
Shraddha Barke281dd5a2015-10-05 17:00:33 +05301585 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001586 }
1587
Leo Kimf8b17132015-10-28 15:59:34 +09001588 if (hif_drv->usr_conn_req.pu8bssid) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001589 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
Leo Kimf8b17132015-10-28 15:59:34 +09001590 memcpy(strConnectInfo.au8bssid, hif_drv->usr_conn_req.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001591
1592 if ((u8MacStatus == MAC_CONNECTED) &&
1593 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Leo Kim2a4eded2015-10-29 11:58:25 +09001594 memcpy(hif_drv->assoc_bssid,
Leo Kimf8b17132015-10-28 15:59:34 +09001595 hif_drv->usr_conn_req.pu8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001596 }
1597 }
1598
Leo Kima3b2f4b2015-10-29 11:58:54 +09001599 if (hif_drv->usr_conn_req.ies) {
Leo Kim331ed082015-10-29 11:58:55 +09001600 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len;
1601 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001602 memcpy(strConnectInfo.pu8ReqIEs,
Leo Kima3b2f4b2015-10-29 11:58:54 +09001603 hif_drv->usr_conn_req.ies,
Leo Kim331ed082015-10-29 11:58:55 +09001604 hif_drv->usr_conn_req.ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001605 }
1606
Leo Kim81a59502015-10-29 11:58:35 +09001607 del_timer(&hif_drv->connect_timer);
Leo Kim33bfb192015-10-29 11:58:56 +09001608 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1609 &strConnectInfo,
1610 u8MacStatus,
1611 NULL,
Leo Kim73abaa42015-10-29 12:05:27 +09001612 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001613
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001614 if ((u8MacStatus == MAC_CONNECTED) &&
1615 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09001616 host_int_set_power_mgmt(hif_drv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001617
1618 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
Leo Kimb60005a2015-10-29 11:58:24 +09001619 hif_drv->hif_state = HOST_IF_CONNECTED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001620
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001621 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +09001622 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07001623 mod_timer(&hDuringIpTimer,
1624 jiffies + msecs_to_jiffies(10000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001625 } else {
1626 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
Leo Kimb60005a2015-10-29 11:58:24 +09001627 hif_drv->hif_state = HOST_IF_IDLE;
Leo Kimca8540e42015-10-15 13:25:00 +09001628 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001629 }
1630
Shraddha Barke95f840f2015-10-14 07:29:19 +05301631 kfree(strConnectInfo.pu8RespIEs);
1632 strConnectInfo.pu8RespIEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001633
Shraddha Barke95f840f2015-10-14 07:29:19 +05301634 kfree(strConnectInfo.pu8ReqIEs);
1635 strConnectInfo.pu8ReqIEs = NULL;
Leo Kim74ab5e42015-10-29 11:58:53 +09001636 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09001637 kfree(hif_drv->usr_conn_req.pu8ssid);
1638 kfree(hif_drv->usr_conn_req.pu8bssid);
Leo Kim331ed082015-10-29 11:58:55 +09001639 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001640 kfree(hif_drv->usr_conn_req.ies);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001641 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
Leo Kimb60005a2015-10-29 11:58:24 +09001642 (hif_drv->hif_state == HOST_IF_CONNECTED)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001643 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
1644
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001645 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001646
Leo Kimbc801852015-10-29 11:58:50 +09001647 if (hif_drv->usr_scan_req.scan_result) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001648 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
Leo Kim13b313e2015-10-29 11:58:34 +09001649 del_timer(&hif_drv->scan_timer);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001650 Handle_ScanDone((void *)hif_drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001651 }
1652
1653 strDisconnectNotifInfo.u16reason = 0;
1654 strDisconnectNotifInfo.ie = NULL;
1655 strDisconnectNotifInfo.ie_len = 0;
1656
Leo Kim33bfb192015-10-29 11:58:56 +09001657 if (hif_drv->usr_conn_req.conn_result) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001658 g_obtainingIP = false;
Tony Choa4ab1ad2015-10-12 16:56:05 +09001659 host_int_set_power_mgmt(hif_drv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001660
Leo Kim33bfb192015-10-29 11:58:56 +09001661 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1662 NULL,
1663 0,
1664 &strDisconnectNotifInfo,
Leo Kim73abaa42015-10-29 12:05:27 +09001665 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001666 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001667 PRINT_ER("Connect result callback function is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001668 }
1669
Leo Kim2a4eded2015-10-29 11:58:25 +09001670 eth_zero_addr(hif_drv->assoc_bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001671
Leo Kim74ab5e42015-10-29 11:58:53 +09001672 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09001673 kfree(hif_drv->usr_conn_req.pu8ssid);
1674 kfree(hif_drv->usr_conn_req.pu8bssid);
Leo Kim331ed082015-10-29 11:58:55 +09001675 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001676 kfree(hif_drv->usr_conn_req.ies);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001677
Leo Kim91109e12015-10-19 18:26:13 +09001678 if (join_req && join_req_drv == hif_drv) {
Leo Kim044a64102015-10-15 13:25:09 +09001679 kfree(join_req);
1680 join_req = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001681 }
Leo Kim48ce2462015-10-15 13:25:10 +09001682
Leo Kim91109e12015-10-19 18:26:13 +09001683 if (info_element && join_req_drv == hif_drv) {
Leo Kim48ce2462015-10-15 13:25:10 +09001684 kfree(info_element);
1685 info_element = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001686 }
1687
Leo Kimb60005a2015-10-29 11:58:24 +09001688 hif_drv->hif_state = HOST_IF_IDLE;
Leo Kimca8540e42015-10-15 13:25:00 +09001689 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001690
1691 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
Leo Kimbc801852015-10-29 11:58:50 +09001692 (hif_drv->usr_scan_req.scan_result)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001693 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001694 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09001695
Leo Kim13b313e2015-10-29 11:58:34 +09001696 del_timer(&hif_drv->scan_timer);
Leo Kimbc801852015-10-29 11:58:50 +09001697 if (hif_drv->usr_scan_req.scan_result)
Tony Choa4ab1ad2015-10-12 16:56:05 +09001698 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001699 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001700 }
1701
Shraddha Barke95f840f2015-10-14 07:29:19 +05301702 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1703 pstrRcvdGnrlAsyncInfo->buffer = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001704
Leo Kim31390ee2015-10-19 18:26:08 +09001705 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001706}
1707
Tony Choa4ab1ad2015-10-12 16:56:05 +09001708static int Handle_Key(struct host_if_drv *hif_drv,
Tony Choc98387a2015-09-21 12:16:40 +09001709 struct key_attr *pstrHostIFkeyAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001710{
Leo Kim31390ee2015-10-19 18:26:08 +09001711 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09001712 struct wid wid;
Leo Kime9e0c262015-10-12 16:55:41 +09001713 struct wid strWIDList[5];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001714 u8 i;
1715 u8 *pu8keybuf;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001716 s8 s8idxarray[1];
1717 s8 ret = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001718
Leo Kim8e9f4272015-10-13 19:49:27 +09001719 switch (pstrHostIFkeyAttr->type) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001720 case WEP:
1721
Leo Kim0d17e382015-10-13 19:49:28 +09001722 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001723 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Leo Kimbafaa692015-10-28 15:59:21 +09001724 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", pstrHostIFkeyAttr->attr.wep.index);
Leo Kimdaaf16b2015-10-12 16:55:44 +09001725 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001726 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001727 strWIDList[0].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001728 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001729
Leo Kimdaaf16b2015-10-12 16:55:44 +09001730 strWIDList[1].id = WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001731 strWIDList[1].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001732 strWIDList[1].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001733 strWIDList[1].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001734
Leo Kimdaaf16b2015-10-12 16:55:44 +09001735 strWIDList[2].id = (u16)WID_KEY_ID;
Leo Kim416d8322015-10-12 16:55:43 +09001736 strWIDList[2].type = WID_CHAR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001737
Leo Kimbafaa692015-10-28 15:59:21 +09001738 strWIDList[2].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
Leo Kim2fd3e442015-10-12 16:55:45 +09001739 strWIDList[2].size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001740
Shraddha Barke543f5b12015-10-16 10:47:11 +05301741 pu8keybuf = kmemdup(pstrHostIFkeyAttr->attr.wep.key,
1742 pstrHostIFkeyAttr->attr.wep.key_len,
1743 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001744
1745 if (pu8keybuf == NULL) {
1746 PRINT_ER("No buffer to send Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001747 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001748 }
1749
Leo Kim73b2e382015-10-13 19:49:29 +09001750 kfree(pstrHostIFkeyAttr->attr.wep.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001751
Leo Kimdaaf16b2015-10-12 16:55:44 +09001752 strWIDList[3].id = (u16)WID_WEP_KEY_VALUE;
Leo Kim416d8322015-10-12 16:55:43 +09001753 strWIDList[3].type = WID_STR;
Leo Kim73b2e382015-10-13 19:49:29 +09001754 strWIDList[3].size = pstrHostIFkeyAttr->attr.wep.key_len;
Leo Kim900bb4a2015-10-12 16:55:46 +09001755 strWIDList[3].val = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001756
Leo Kim31390ee2015-10-19 18:26:08 +09001757 result = send_config_pkt(SET_CFG, strWIDList, 4,
Leo Kim8c8360b2015-10-19 18:26:12 +09001758 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001759 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001760 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001761
Leo Kim0d17e382015-10-13 19:49:28 +09001762 if (pstrHostIFkeyAttr->action & ADDKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001763 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Leo Kim73b2e382015-10-13 19:49:29 +09001764 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001765 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001766 PRINT_ER("No buffer to send Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001767 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001768 }
Leo Kim73b2e382015-10-13 19:49:29 +09001769 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1770 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1771 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001772 pstrHostIFkeyAttr->attr.wep.key_len);
Leo Kim73b2e382015-10-13 19:49:29 +09001773 kfree(pstrHostIFkeyAttr->attr.wep.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001774
Leo Kim45102f82015-10-28 15:59:28 +09001775 wid.id = (u16)WID_ADD_WEP_KEY;
1776 wid.type = WID_STR;
1777 wid.val = (s8 *)pu8keybuf;
1778 wid.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001779
Leo Kim45102f82015-10-28 15:59:28 +09001780 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001781 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001782 kfree(pu8keybuf);
Leo Kim0d17e382015-10-13 19:49:28 +09001783 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001784 PRINT_D(HOSTINF_DBG, "Removing key\n");
Leo Kim45102f82015-10-28 15:59:28 +09001785 wid.id = (u16)WID_REMOVE_WEP_KEY;
1786 wid.type = WID_STR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001787
Leo Kim73b2e382015-10-13 19:49:29 +09001788 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
Leo Kim45102f82015-10-28 15:59:28 +09001789 wid.val = s8idxarray;
1790 wid.size = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001791
Leo Kim45102f82015-10-28 15:59:28 +09001792 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001793 get_id_from_handler(hif_drv));
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
Leo Kim45102f82015-10-28 15:59:28 +09001802 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001803 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001804 }
Leo Kim9ea47132015-10-29 11:58:28 +09001805 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001806 break;
1807
Leo Kim5cd8f7a2015-10-29 12:05:34 +09001808 case WPA_RX_GTK:
Leo Kim0d17e382015-10-13 19:49:28 +09001809 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Shraddha Barkeb156f1e2015-10-13 23:07:00 +05301810 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001811 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001812 PRINT_ER("No buffer to send RxGTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001813 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001814 goto _WPARxGtk_end_case_;
1815 }
1816
Leo Kim91109e12015-10-19 18:26:13 +09001817 if (pstrHostIFkeyAttr->attr.wpa.seq)
Leo Kim0e74c002015-10-13 19:49:32 +09001818 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001819
Leo Kime2dfbac2015-10-13 19:49:34 +09001820 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
Leo Kim6acf2912015-10-13 19:49:35 +09001821 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001822 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001823 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001824
Leo Kimdaaf16b2015-10-12 16:55:44 +09001825 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001826 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001827 strWIDList[0].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001828 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001829
Leo Kimdaaf16b2015-10-12 16:55:44 +09001830 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
Leo Kim416d8322015-10-12 16:55:43 +09001831 strWIDList[1].type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09001832 strWIDList[1].val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09001833 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001834
Leo Kim31390ee2015-10-19 18:26:08 +09001835 result = send_config_pkt(SET_CFG, strWIDList, 2,
Leo Kim8c8360b2015-10-19 18:26:12 +09001836 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001837
Chaehyun Lim49188af2015-08-11 10:32:41 +09001838 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001839 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001840 }
1841
Leo Kim0d17e382015-10-13 19:49:28 +09001842 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
Leo Kim45102f82015-10-28 15:59:28 +09001868 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001869 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001870
Chaehyun Lim49188af2015-08-11 10:32:41 +09001871 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001872 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001873 }
1874_WPARxGtk_end_case_:
Leo Kim124968fc2015-10-13 19:49:30 +09001875 kfree(pstrHostIFkeyAttr->attr.wpa.key);
Leo Kim0e74c002015-10-13 19:49:32 +09001876 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
Luis de Bethencourt90819872015-10-26 05:52:50 +00001877 if (ret)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001878 return ret;
1879
1880 break;
1881
Leo Kim2141fe32015-10-29 12:05:35 +09001882 case WPA_PTK:
Leo Kim0d17e382015-10-13 19:49:28 +09001883 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Glen Leef3052582015-09-10 12:03:04 +09001884 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001885 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001886 PRINT_ER("No buffer to send PTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001887 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001888 goto _WPAPtk_end_case_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001889 }
1890
Leo Kim248080a2015-10-13 19:49:31 +09001891 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
Leo Kime2dfbac2015-10-13 19:49:34 +09001892 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
Leo Kim6acf2912015-10-13 19:49:35 +09001893 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001894 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001895 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001896
Leo Kimdaaf16b2015-10-12 16:55:44 +09001897 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001898 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001899 strWIDList[0].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001900 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001901
Leo Kimdaaf16b2015-10-12 16:55:44 +09001902 strWIDList[1].id = (u16)WID_ADD_PTK;
Leo Kim416d8322015-10-12 16:55:43 +09001903 strWIDList[1].type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09001904 strWIDList[1].val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09001905 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001906
Leo Kim31390ee2015-10-19 18:26:08 +09001907 result = send_config_pkt(SET_CFG, strWIDList, 2,
Leo Kim8c8360b2015-10-19 18:26:12 +09001908 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001909 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001910 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001911 }
Leo Kim0d17e382015-10-13 19:49:28 +09001912 if (pstrHostIFkeyAttr->action & ADDKEY) {
Glen Leef3052582015-09-10 12:03:04 +09001913 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001914 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001915 PRINT_ER("No buffer to send PTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001916 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001917 goto _WPAPtk_end_case_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001918 }
1919
Leo Kim248080a2015-10-13 19:49:31 +09001920 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
Leo Kim6acf2912015-10-13 19:49:35 +09001921 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001922 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001923 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001924
Leo Kim45102f82015-10-28 15:59:28 +09001925 wid.id = (u16)WID_ADD_PTK;
1926 wid.type = WID_STR;
1927 wid.val = (s8 *)pu8keybuf;
1928 wid.size = PTK_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001929
Leo Kim45102f82015-10-28 15:59:28 +09001930 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001931 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001932 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001933 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001934 }
1935
1936_WPAPtk_end_case_:
Leo Kim124968fc2015-10-13 19:49:30 +09001937 kfree(pstrHostIFkeyAttr->attr.wpa.key);
Luis de Bethencourt90819872015-10-26 05:52:50 +00001938 if (ret)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001939 return ret;
1940
1941 break;
1942
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001943 case PMKSA:
1944
1945 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
1946
Leo Kim73b2e382015-10-13 19:49:29 +09001947 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001948 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001949 PRINT_ER("No buffer to send PMKSA Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001950 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001951 }
1952
Leo Kim73b2e382015-10-13 19:49:29 +09001953 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001954
Leo Kim73b2e382015-10-13 19:49:29 +09001955 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
1956 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
1957 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001958 }
1959
Leo Kim45102f82015-10-28 15:59:28 +09001960 wid.id = (u16)WID_PMKID_INFO;
1961 wid.type = WID_STR;
1962 wid.val = (s8 *)pu8keybuf;
1963 wid.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001964
Leo Kim45102f82015-10-28 15:59:28 +09001965 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001966 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001967
Chaehyun Lim49188af2015-08-11 10:32:41 +09001968 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001969 break;
1970 }
1971
Leo Kim31390ee2015-10-19 18:26:08 +09001972 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001973 PRINT_ER("Failed to send key config packet\n");
1974
Leo Kim31390ee2015-10-19 18:26:08 +09001975 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001976}
1977
Tony Choa4ab1ad2015-10-12 16:56:05 +09001978static void Handle_Disconnect(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001979{
Leo Kim45102f82015-10-28 15:59:28 +09001980 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001981
Leo Kim31390ee2015-10-19 18:26:08 +09001982 s32 result = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001983 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001984
Leo Kim45102f82015-10-28 15:59:28 +09001985 wid.id = (u16)WID_DISCONNECT;
1986 wid.type = WID_CHAR;
1987 wid.val = (s8 *)&u16DummyReasonCode;
1988 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001989
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001990 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1991
Dean Lee72ed4dc2015-06-12 14:11:44 +09001992 g_obtainingIP = false;
Tony Choa4ab1ad2015-10-12 16:56:05 +09001993 host_int_set_power_mgmt(hif_drv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001994
Shraddha Barke281dd5a2015-10-05 17:00:33 +05301995 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001996
Leo Kim45102f82015-10-28 15:59:28 +09001997 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001998 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001999
Leo Kim31390ee2015-10-19 18:26:08 +09002000 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002001 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002002 } else {
2003 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2004
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002005 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002006
2007 strDisconnectNotifInfo.u16reason = 0;
2008 strDisconnectNotifInfo.ie = NULL;
2009 strDisconnectNotifInfo.ie_len = 0;
2010
Leo Kimbc801852015-10-29 11:58:50 +09002011 if (hif_drv->usr_scan_req.scan_result) {
Leo Kim13b313e2015-10-29 11:58:34 +09002012 del_timer(&hif_drv->scan_timer);
Leo Kim33bfb192015-10-29 11:58:56 +09002013 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED,
2014 NULL,
2015 hif_drv->usr_scan_req.arg,
2016 NULL);
Leo Kimbc801852015-10-29 11:58:50 +09002017 hif_drv->usr_scan_req.scan_result = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002018 }
2019
Leo Kim33bfb192015-10-29 11:58:56 +09002020 if (hif_drv->usr_conn_req.conn_result) {
Leo Kimb60005a2015-10-29 11:58:24 +09002021 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002022 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
Leo Kim81a59502015-10-29 11:58:35 +09002023 del_timer(&hif_drv->connect_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002024 }
2025
Leo Kim33bfb192015-10-29 11:58:56 +09002026 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2027 NULL,
2028 0,
2029 &strDisconnectNotifInfo,
Leo Kim73abaa42015-10-29 12:05:27 +09002030 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002031 } else {
Leo Kim33bfb192015-10-29 11:58:56 +09002032 PRINT_ER("usr_conn_req.conn_result = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002033 }
2034
Leo Kimca8540e42015-10-15 13:25:00 +09002035 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002036
Leo Kimb60005a2015-10-29 11:58:24 +09002037 hif_drv->hif_state = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002038
Leo Kim2a4eded2015-10-29 11:58:25 +09002039 eth_zero_addr(hif_drv->assoc_bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002040
Leo Kim74ab5e42015-10-29 11:58:53 +09002041 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09002042 kfree(hif_drv->usr_conn_req.pu8ssid);
2043 kfree(hif_drv->usr_conn_req.pu8bssid);
Leo Kim331ed082015-10-29 11:58:55 +09002044 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09002045 kfree(hif_drv->usr_conn_req.ies);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002046
Leo Kim91109e12015-10-19 18:26:13 +09002047 if (join_req && join_req_drv == hif_drv) {
Leo Kim044a64102015-10-15 13:25:09 +09002048 kfree(join_req);
2049 join_req = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002050 }
Leo Kim48ce2462015-10-15 13:25:10 +09002051
Leo Kim91109e12015-10-19 18:26:13 +09002052 if (info_element && join_req_drv == hif_drv) {
Leo Kim48ce2462015-10-15 13:25:10 +09002053 kfree(info_element);
2054 info_element = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002055 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002056 }
2057
Leo Kime55e4962015-10-29 11:58:29 +09002058 up(&hif_drv->sem_test_disconn_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002059}
2060
Tony Choa4ab1ad2015-10-12 16:56:05 +09002061void resolve_disconnect_aberration(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002062{
Tony Choa4ab1ad2015-10-12 16:56:05 +09002063 if (!hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002064 return;
Leo Kimb60005a2015-10-29 11:58:24 +09002065 if ((hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
2066 (hif_drv->hif_state == HOST_IF_CONNECTING)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002067 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09002068 host_int_disconnect(hif_drv, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002069 }
2070}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002071
Tony Choa4ab1ad2015-10-12 16:56:05 +09002072static s32 Handle_GetChnl(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002073{
Leo Kim31390ee2015-10-19 18:26:08 +09002074 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002075 struct wid wid;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002076
Leo Kim45102f82015-10-28 15:59:28 +09002077 wid.id = (u16)WID_CURRENT_CHANNEL;
2078 wid.type = WID_CHAR;
2079 wid.val = (s8 *)&ch_no;
2080 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002081
2082 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2083
Leo Kim45102f82015-10-28 15:59:28 +09002084 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002085 get_id_from_handler(hif_drv));
Leo Kimae4dfa52015-10-13 19:49:26 +09002086
Leo Kim31390ee2015-10-19 18:26:08 +09002087 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002088 PRINT_ER("Failed to get channel number\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002089 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002090 }
2091
Leo Kim4ea90002015-10-29 11:58:32 +09002092 up(&hif_drv->sem_get_chnl);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002093
Leo Kim31390ee2015-10-19 18:26:08 +09002094 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002095}
2096
Tony Choa4ab1ad2015-10-12 16:56:05 +09002097static void Handle_GetRssi(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002098{
Leo Kim31390ee2015-10-19 18:26:08 +09002099 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002100 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002101
Leo Kim45102f82015-10-28 15:59:28 +09002102 wid.id = (u16)WID_RSSI;
2103 wid.type = WID_CHAR;
2104 wid.val = &rssi;
2105 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002106
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002107 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2108
Leo Kim45102f82015-10-28 15:59:28 +09002109 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002110 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002111 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002112 PRINT_ER("Failed to get RSSI value\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002113 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002114 }
2115
Leo Kim7e111f92015-10-29 11:58:30 +09002116 up(&hif_drv->sem_get_rssi);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002117}
2118
Tony Choa4ab1ad2015-10-12 16:56:05 +09002119static void Handle_GetLinkspeed(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002120{
Leo Kim31390ee2015-10-19 18:26:08 +09002121 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002122 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002123
Leo Kim75327a02015-10-15 13:25:02 +09002124 link_speed = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002125
Leo Kim45102f82015-10-28 15:59:28 +09002126 wid.id = (u16)WID_LINKSPEED;
2127 wid.type = WID_CHAR;
2128 wid.val = &link_speed;
2129 wid.size = sizeof(char);
Leo Kimae4dfa52015-10-13 19:49:26 +09002130
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002131 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2132
Leo Kim45102f82015-10-28 15:59:28 +09002133 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002134 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002135 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002136 PRINT_ER("Failed to get LINKSPEED value\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002137 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002138 }
2139
Leo Kimbc34da62015-10-29 11:58:31 +09002140 up(&hif_drv->sem_get_link_speed);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002141}
2142
Tony Choa4ab1ad2015-10-12 16:56:05 +09002143s32 Handle_GetStatistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002144{
Leo Kime9e0c262015-10-12 16:55:41 +09002145 struct wid strWIDList[5];
Leo Kim31390ee2015-10-19 18:26:08 +09002146 u32 u32WidsCount = 0, result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002147
Leo Kimdaaf16b2015-10-12 16:55:44 +09002148 strWIDList[u32WidsCount].id = WID_LINKSPEED;
Leo Kim416d8322015-10-12 16:55:43 +09002149 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002150 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim5babeec2015-10-29 12:05:29 +09002151 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->link_speed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002152 u32WidsCount++;
2153
Leo Kimdaaf16b2015-10-12 16:55:44 +09002154 strWIDList[u32WidsCount].id = WID_RSSI;
Leo Kim416d8322015-10-12 16:55:43 +09002155 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002156 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim00c8dfc2015-10-29 12:05:30 +09002157 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rssi;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002158 u32WidsCount++;
2159
Leo Kimdaaf16b2015-10-12 16:55:44 +09002160 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002161 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002162 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim7e84ff42015-10-29 12:05:31 +09002163 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002164 u32WidsCount++;
2165
Leo Kimdaaf16b2015-10-12 16:55:44 +09002166 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002167 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002168 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim9b992742015-10-29 12:05:32 +09002169 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rx_cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002170 u32WidsCount++;
2171
Leo Kimdaaf16b2015-10-12 16:55:44 +09002172 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002173 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002174 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim54160372015-10-29 12:05:33 +09002175 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_fail_cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002176 u32WidsCount++;
2177
Leo Kim31390ee2015-10-19 18:26:08 +09002178 result = send_config_pkt(GET_CFG, strWIDList, u32WidsCount,
Leo Kim8c8360b2015-10-19 18:26:12 +09002179 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002180
Leo Kim31390ee2015-10-19 18:26:08 +09002181 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002182 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09002183
Leo Kim2d25af82015-10-15 13:24:56 +09002184 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002185 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002186}
2187
Tony Choa4ab1ad2015-10-12 16:56:05 +09002188static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,
Tony Cho3d1eac02015-09-21 12:16:49 +09002189 struct sta_inactive_t *strHostIfStaInactiveT)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002190{
Leo Kim31390ee2015-10-19 18:26:08 +09002191 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002192 u8 *stamac;
Leo Kim45102f82015-10-28 15:59:28 +09002193 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002194
Leo Kim45102f82015-10-28 15:59:28 +09002195 wid.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2196 wid.type = WID_STR;
2197 wid.size = ETH_ALEN;
2198 wid.val = kmalloc(wid.size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002199
Leo Kim45102f82015-10-28 15:59:28 +09002200 stamac = wid.val;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002201 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002202
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002203 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2204
Leo Kim45102f82015-10-28 15:59:28 +09002205 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002206 get_id_from_handler(hif_drv));
Leo Kimae4dfa52015-10-13 19:49:26 +09002207
Leo Kim31390ee2015-10-19 18:26:08 +09002208 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002209 PRINT_ER("Failed to SET incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09002210 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002211 }
2212
Leo Kim45102f82015-10-28 15:59:28 +09002213 wid.id = (u16)WID_GET_INACTIVE_TIME;
2214 wid.type = WID_INT;
2215 wid.val = (s8 *)&inactive_time;
2216 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002217
Leo Kim45102f82015-10-28 15:59:28 +09002218 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002219 get_id_from_handler(hif_drv));
Leo Kimae4dfa52015-10-13 19:49:26 +09002220
Leo Kim31390ee2015-10-19 18:26:08 +09002221 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002222 PRINT_ER("Failed to get incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09002223 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002224 }
2225
Leo Kimad269062015-10-15 13:25:06 +09002226 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", inactive_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002227
Leo Kim569a3c62015-10-29 11:58:33 +09002228 up(&hif_drv->sem_inactive_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002229
Leo Kim31390ee2015-10-19 18:26:08 +09002230 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002231}
2232
Tony Choa4ab1ad2015-10-12 16:56:05 +09002233static void Handle_AddBeacon(struct host_if_drv *hif_drv,
Tony Cho7f33fec2015-09-30 18:44:30 +09002234 struct beacon_attr *pstrSetBeaconParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002235{
Leo Kim31390ee2015-10-19 18:26:08 +09002236 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002237 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002238 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002239
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002240 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
2241
Leo Kim45102f82015-10-28 15:59:28 +09002242 wid.id = (u16)WID_ADD_BEACON;
2243 wid.type = WID_BIN;
2244 wid.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
2245 wid.val = kmalloc(wid.size, GFP_KERNEL);
2246 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002247 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002248
Leo Kim45102f82015-10-28 15:59:28 +09002249 pu8CurrByte = wid.val;
Leo Kim12262dd2015-10-13 19:50:03 +09002250 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2251 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2252 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2253 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002254
Leo Kime76ab772015-10-13 19:50:04 +09002255 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2256 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2257 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2258 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002259
Leo Kim51c66182015-10-13 19:50:05 +09002260 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2261 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2262 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2263 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002264
Leo Kim8ce528b2015-10-13 19:50:06 +09002265 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
Leo Kim51c66182015-10-13 19:50:05 +09002266 pu8CurrByte += pstrSetBeaconParam->head_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002267
Leo Kim030c57e2015-10-13 19:50:07 +09002268 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2269 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2270 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2271 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002272
Leo Kim7dbcb6d32015-10-13 19:50:08 +09002273 if (pstrSetBeaconParam->tail > 0)
2274 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
Leo Kim030c57e2015-10-13 19:50:07 +09002275 pu8CurrByte += pstrSetBeaconParam->tail_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002276
Leo Kim45102f82015-10-28 15:59:28 +09002277 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002278 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002279 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002280 PRINT_ER("Failed to send add beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002281
Leo Kim24db7132015-09-16 18:36:01 +09002282ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002283 kfree(wid.val);
Leo Kim8ce528b2015-10-13 19:50:06 +09002284 kfree(pstrSetBeaconParam->head);
Leo Kim7dbcb6d32015-10-13 19:50:08 +09002285 kfree(pstrSetBeaconParam->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002286}
2287
Tony Choa4ab1ad2015-10-12 16:56:05 +09002288static void Handle_DelBeacon(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002289{
Leo Kim31390ee2015-10-19 18:26:08 +09002290 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002291 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002292 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002293
Leo Kim45102f82015-10-28 15:59:28 +09002294 wid.id = (u16)WID_DEL_BEACON;
2295 wid.type = WID_CHAR;
2296 wid.size = sizeof(char);
2297 wid.val = &del_beacon;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002298
Leo Kim45102f82015-10-28 15:59:28 +09002299 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002300 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002301
Leo Kim45102f82015-10-28 15:59:28 +09002302 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002303
2304 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002305
Leo Kim45102f82015-10-28 15:59:28 +09002306 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002307 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002308 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002309 PRINT_ER("Failed to send delete beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002310}
2311
Tony Cho6a89ba92015-09-21 12:16:46 +09002312static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2313 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002314{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002315 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002316
2317 pu8CurrByte = pu8Buffer;
2318
2319 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
Leo Kim2353c382015-10-29 12:05:41 +09002320 memcpy(pu8CurrByte, pstrStationParam->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002321 pu8CurrByte += ETH_ALEN;
2322
Leo Kim4101eb82015-10-29 12:05:42 +09002323 *pu8CurrByte++ = pstrStationParam->aid & 0xFF;
2324 *pu8CurrByte++ = (pstrStationParam->aid >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002325
Leo Kime7342232015-10-29 12:05:43 +09002326 *pu8CurrByte++ = pstrStationParam->rates_len;
2327 if (pstrStationParam->rates_len > 0)
Leo Kima622e012015-10-29 12:05:44 +09002328 memcpy(pu8CurrByte, pstrStationParam->rates,
Leo Kime7342232015-10-29 12:05:43 +09002329 pstrStationParam->rates_len);
2330 pu8CurrByte += pstrStationParam->rates_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002331
Leo Kim22520122015-10-29 12:05:45 +09002332 *pu8CurrByte++ = pstrStationParam->ht_supported;
Leo Kim0d073f62015-10-29 12:05:46 +09002333 *pu8CurrByte++ = pstrStationParam->ht_capa_info & 0xFF;
2334 *pu8CurrByte++ = (pstrStationParam->ht_capa_info >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002335
Leo Kimfba1f2d2015-10-29 12:05:47 +09002336 *pu8CurrByte++ = pstrStationParam->ht_ampdu_params;
Leo Kim5ebbf4f2015-10-29 12:05:48 +09002337 memcpy(pu8CurrByte, pstrStationParam->ht_supp_mcs_set,
2338 WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002339 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2340
Leo Kim223741d2015-10-29 12:05:49 +09002341 *pu8CurrByte++ = pstrStationParam->ht_ext_params & 0xFF;
2342 *pu8CurrByte++ = (pstrStationParam->ht_ext_params >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002343
Leo Kim74fe73c2015-10-29 12:05:50 +09002344 *pu8CurrByte++ = pstrStationParam->ht_tx_bf_cap & 0xFF;
2345 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 8) & 0xFF;
2346 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 16) & 0xFF;
2347 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 24) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002348
Leo Kima486baf2015-10-29 12:05:51 +09002349 *pu8CurrByte++ = pstrStationParam->ht_ante_sel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002350
Leo Kimf676e172015-10-29 12:05:52 +09002351 *pu8CurrByte++ = pstrStationParam->flags_mask & 0xFF;
2352 *pu8CurrByte++ = (pstrStationParam->flags_mask >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002353
Leo Kim67ab64e2015-10-29 12:05:53 +09002354 *pu8CurrByte++ = pstrStationParam->flags_set & 0xFF;
2355 *pu8CurrByte++ = (pstrStationParam->flags_set >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002356
2357 return pu8CurrByte - pu8Buffer;
2358}
2359
Tony Choa4ab1ad2015-10-12 16:56:05 +09002360static void Handle_AddStation(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09002361 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002362{
Leo Kim31390ee2015-10-19 18:26:08 +09002363 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002364 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002365 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002366
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002367 PRINT_D(HOSTINF_DBG, "Handling add station\n");
Leo Kim45102f82015-10-28 15:59:28 +09002368 wid.id = (u16)WID_ADD_STA;
2369 wid.type = WID_BIN;
Leo Kime7342232015-10-29 12:05:43 +09002370 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002371
Leo Kim45102f82015-10-28 15:59:28 +09002372 wid.val = kmalloc(wid.size, GFP_KERNEL);
2373 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002374 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002375
Leo Kim45102f82015-10-28 15:59:28 +09002376 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002377 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2378
Leo Kim45102f82015-10-28 15:59:28 +09002379 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002380 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002381 if (result != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002382 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002383
Leo Kim24db7132015-09-16 18:36:01 +09002384ERRORHANDLER:
Leo Kima622e012015-10-29 12:05:44 +09002385 kfree(pstrStationParam->rates);
Leo Kim45102f82015-10-28 15:59:28 +09002386 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002387}
2388
Tony Choa4ab1ad2015-10-12 16:56:05 +09002389static void Handle_DelAllSta(struct host_if_drv *hif_drv,
Tony Chob4e644e2015-09-21 12:17:00 +09002390 struct del_all_sta *pstrDelAllStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002391{
Leo Kim31390ee2015-10-19 18:26:08 +09002392 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002393 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002394 u8 *pu8CurrByte;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002395 u8 i;
Chaehyun Lim37034802015-06-11 14:34:32 +09002396 u8 au8Zero_Buff[6] = {0};
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002397
Leo Kim45102f82015-10-28 15:59:28 +09002398 wid.id = (u16)WID_DEL_ALL_STA;
2399 wid.type = WID_STR;
2400 wid.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002401
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002402 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002403
Leo Kim45102f82015-10-28 15:59:28 +09002404 wid.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2405 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002406 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002407
Leo Kim45102f82015-10-28 15:59:28 +09002408 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002409
Leo Kim8ba18032015-10-13 19:50:10 +09002410 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002411
2412 for (i = 0; i < MAX_NUM_STA; i++) {
Leo Kime51b9212015-10-13 19:50:09 +09002413 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2414 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002415 else
2416 continue;
2417
2418 pu8CurrByte += ETH_ALEN;
2419 }
2420
Leo Kim45102f82015-10-28 15:59:28 +09002421 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002422 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002423 if (result)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02002424 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002425
Leo Kim24db7132015-09-16 18:36:01 +09002426ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002427 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002428
Leo Kim2d25af82015-10-15 13:24:56 +09002429 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002430}
2431
Tony Choa4ab1ad2015-10-12 16:56:05 +09002432static void Handle_DelStation(struct host_if_drv *hif_drv,
Tony Chofb93a1e2015-09-21 12:16:57 +09002433 struct del_sta *pstrDelStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002434{
Leo Kim31390ee2015-10-19 18:26:08 +09002435 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002436 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002437 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002438
Leo Kim45102f82015-10-28 15:59:28 +09002439 wid.id = (u16)WID_REMOVE_STA;
2440 wid.type = WID_BIN;
2441 wid.size = ETH_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002442
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002443 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002444
Leo Kim45102f82015-10-28 15:59:28 +09002445 wid.val = kmalloc(wid.size, GFP_KERNEL);
2446 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002447 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002448
Leo Kim45102f82015-10-28 15:59:28 +09002449 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002450
Leo Kime4839d32015-10-13 20:02:06 +09002451 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002452
Leo Kim45102f82015-10-28 15:59:28 +09002453 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002454 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002455 if (result)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02002456 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002457
Leo Kim24db7132015-09-16 18:36:01 +09002458ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002459 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002460}
2461
Tony Choa4ab1ad2015-10-12 16:56:05 +09002462static void Handle_EditStation(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09002463 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002464{
Leo Kim31390ee2015-10-19 18:26:08 +09002465 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002466 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002467 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002468
Leo Kim45102f82015-10-28 15:59:28 +09002469 wid.id = (u16)WID_EDIT_STA;
2470 wid.type = WID_BIN;
Leo Kime7342232015-10-29 12:05:43 +09002471 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002472
2473 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
Leo Kim45102f82015-10-28 15:59:28 +09002474 wid.val = kmalloc(wid.size, GFP_KERNEL);
2475 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002476 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002477
Leo Kim45102f82015-10-28 15:59:28 +09002478 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002479 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2480
Leo Kim45102f82015-10-28 15:59:28 +09002481 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002482 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002483 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002484 PRINT_ER("Failed to send edit station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002485
Leo Kim24db7132015-09-16 18:36:01 +09002486ERRORHANDLER:
Leo Kima622e012015-10-29 12:05:44 +09002487 kfree(pstrStationParam->rates);
Leo Kim45102f82015-10-28 15:59:28 +09002488 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002489}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002490
Tony Choa4ab1ad2015-10-12 16:56:05 +09002491static int Handle_RemainOnChan(struct host_if_drv *hif_drv,
Tony Cho2f9c03f2015-09-21 12:16:58 +09002492 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002493{
Leo Kim31390ee2015-10-19 18:26:08 +09002494 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002495 u8 u8remain_on_chan_flag;
Leo Kim45102f82015-10-28 15:59:28 +09002496 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002497
Leo Kim5beef2c2015-10-28 15:59:36 +09002498 if (!hif_drv->remain_on_ch_pending) {
Leo Kimc5cc4b12015-10-29 11:58:44 +09002499 hif_drv->remain_on_ch.arg = pstrHostIfRemainOnChan->arg;
Leo Kimbfb62ab2015-10-29 11:58:42 +09002500 hif_drv->remain_on_ch.expired = pstrHostIfRemainOnChan->expired;
Leo Kim5e5f7912015-10-29 11:58:43 +09002501 hif_drv->remain_on_ch.ready = pstrHostIfRemainOnChan->ready;
Leo Kim839ab702015-10-29 11:58:41 +09002502 hif_drv->remain_on_ch.ch = pstrHostIfRemainOnChan->ch;
Leo Kim9d764e32015-10-29 12:05:38 +09002503 hif_drv->remain_on_ch.id = pstrHostIfRemainOnChan->id;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002504 } else {
Leo Kim839ab702015-10-29 11:58:41 +09002505 pstrHostIfRemainOnChan->ch = hif_drv->remain_on_ch.ch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002506 }
2507
Leo Kimbc801852015-10-29 11:58:50 +09002508 if (hif_drv->usr_scan_req.scan_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002509 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
Leo Kim5beef2c2015-10-28 15:59:36 +09002510 hif_drv->remain_on_ch_pending = 1;
Leo Kim31390ee2015-10-19 18:26:08 +09002511 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +09002512 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002513 }
Leo Kimb60005a2015-10-29 11:58:24 +09002514 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002515 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002516 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +09002517 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002518 }
2519
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002520 if (g_obtainingIP || connecting) {
2521 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002522 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +09002523 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002524 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002525
Leo Kim839ab702015-10-29 11:58:41 +09002526 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n",
2527 pstrHostIfRemainOnChan->ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002528
Dean Lee72ed4dc2015-06-12 14:11:44 +09002529 u8remain_on_chan_flag = true;
Leo Kim45102f82015-10-28 15:59:28 +09002530 wid.id = (u16)WID_REMAIN_ON_CHAN;
2531 wid.type = WID_STR;
2532 wid.size = 2;
2533 wid.val = kmalloc(wid.size, GFP_KERNEL);
2534 if (!wid.val) {
Leo Kim31390ee2015-10-19 18:26:08 +09002535 result = -ENOMEM;
Leo Kim24db7132015-09-16 18:36:01 +09002536 goto ERRORHANDLER;
2537 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002538
Leo Kim45102f82015-10-28 15:59:28 +09002539 wid.val[0] = u8remain_on_chan_flag;
Leo Kim839ab702015-10-29 11:58:41 +09002540 wid.val[1] = (s8)pstrHostIfRemainOnChan->ch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002541
Leo Kim45102f82015-10-28 15:59:28 +09002542 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002543 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002544 if (result != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002545 PRINT_ER("Failed to set remain on channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002546
Leo Kim24db7132015-09-16 18:36:01 +09002547ERRORHANDLER:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002548 {
2549 P2P_LISTEN_STATE = 1;
Leo Kimcc2d7e92015-10-29 11:58:36 +09002550 hif_drv->remain_on_ch_timer.data = (unsigned long)hif_drv;
2551 mod_timer(&hif_drv->remain_on_ch_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002552 jiffies +
2553 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002554
Leo Kim5e5f7912015-10-29 11:58:43 +09002555 if (hif_drv->remain_on_ch.ready)
Leo Kimc5cc4b12015-10-29 11:58:44 +09002556 hif_drv->remain_on_ch.ready(hif_drv->remain_on_ch.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002557
Leo Kim5beef2c2015-10-28 15:59:36 +09002558 if (hif_drv->remain_on_ch_pending)
2559 hif_drv->remain_on_ch_pending = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002560 }
Leo Kim31390ee2015-10-19 18:26:08 +09002561
2562 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002563}
2564
Tony Choa4ab1ad2015-10-12 16:56:05 +09002565static int Handle_RegisterFrame(struct host_if_drv *hif_drv,
Tony Chobc37c5d2015-09-21 12:16:59 +09002566 struct reg_frame *pstrHostIfRegisterFrame)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002567{
Leo Kim31390ee2015-10-19 18:26:08 +09002568 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002569 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002570 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002571
Leo Kim6abf8682015-10-29 11:58:38 +09002572 PRINT_D(HOSTINF_DBG, "Handling frame register : %d FrameType: %d\n",
2573 pstrHostIfRegisterFrame->reg,
Leo Kimd5f654c2015-10-29 11:58:39 +09002574 pstrHostIfRegisterFrame->frame_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002575
Leo Kim45102f82015-10-28 15:59:28 +09002576 wid.id = (u16)WID_REGISTER_FRAME;
2577 wid.type = WID_STR;
2578 wid.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2579 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002580 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002581
Leo Kim45102f82015-10-28 15:59:28 +09002582 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002583
Leo Kim6abf8682015-10-29 11:58:38 +09002584 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg;
Leo Kimbcb410b2015-10-29 11:58:40 +09002585 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg_id;
Leo Kimd5f654c2015-10-29 11:58:39 +09002586 memcpy(pu8CurrByte, &pstrHostIfRegisterFrame->frame_type, sizeof(u16));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002587
Leo Kim45102f82015-10-28 15:59:28 +09002588 wid.size = sizeof(u16) + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002589
Leo Kim45102f82015-10-28 15:59:28 +09002590 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002591 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002592 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002593 PRINT_ER("Failed to frame register config packet\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002594 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002595 }
2596
Leo Kim31390ee2015-10-19 18:26:08 +09002597 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002598}
2599
Tony Choa4ab1ad2015-10-12 16:56:05 +09002600static u32 Handle_ListenStateExpired(struct host_if_drv *hif_drv,
Tony Cho2f9c03f2015-09-21 12:16:58 +09002601 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002602{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002603 u8 u8remain_on_chan_flag;
Leo Kim45102f82015-10-28 15:59:28 +09002604 struct wid wid;
Leo Kim31390ee2015-10-19 18:26:08 +09002605 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002606
2607 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
2608
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002609 if (P2P_LISTEN_STATE) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002610 u8remain_on_chan_flag = false;
Leo Kim45102f82015-10-28 15:59:28 +09002611 wid.id = (u16)WID_REMAIN_ON_CHAN;
2612 wid.type = WID_STR;
2613 wid.size = 2;
2614 wid.val = kmalloc(wid.size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002615
Leo Kim45102f82015-10-28 15:59:28 +09002616 if (!wid.val)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002617 PRINT_ER("Failed to allocate memory\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002618
Leo Kim45102f82015-10-28 15:59:28 +09002619 wid.val[0] = u8remain_on_chan_flag;
2620 wid.val[1] = FALSE_FRMWR_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002621
Leo Kim45102f82015-10-28 15:59:28 +09002622 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002623 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002624 if (result != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002625 PRINT_ER("Failed to set remain on channel\n");
2626 goto _done_;
2627 }
2628
Leo Kimbfb62ab2015-10-29 11:58:42 +09002629 if (hif_drv->remain_on_ch.expired) {
Leo Kimc5cc4b12015-10-29 11:58:44 +09002630 hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg,
Leo Kim9d764e32015-10-29 12:05:38 +09002631 pstrHostIfRemainOnChan->id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002632 }
2633 P2P_LISTEN_STATE = 0;
2634 } else {
2635 PRINT_D(GENERIC_DBG, "Not in listen state\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002636 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002637 }
2638
2639_done_:
Leo Kim31390ee2015-10-19 18:26:08 +09002640 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002641}
2642
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07002643static void ListenTimerCB(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002644{
Leo Kim31390ee2015-10-19 18:26:08 +09002645 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09002646 struct host_if_msg msg;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002647 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
Leo Kimae4dfa52015-10-13 19:49:26 +09002648
Leo Kimcc2d7e92015-10-29 11:58:36 +09002649 del_timer(&hif_drv->remain_on_ch_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002650
Tony Cho143eb952015-09-21 12:16:32 +09002651 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09002652 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002653 msg.drv = hif_drv;
Leo Kim9d764e32015-10-29 12:05:38 +09002654 msg.body.remain_on_ch.id = hif_drv->remain_on_ch.id;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002655
Leo Kim31390ee2015-10-19 18:26:08 +09002656 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2657 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09002658 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002659}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002660
Tony Choa4ab1ad2015-10-12 16:56:05 +09002661static void Handle_PowerManagement(struct host_if_drv *hif_drv,
Tony Cho5a008f12015-09-21 12:16:48 +09002662 struct power_mgmt_param *strPowerMgmtParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002663{
Leo Kim31390ee2015-10-19 18:26:08 +09002664 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002665 struct wid wid;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002666 s8 s8PowerMode;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002667
Leo Kim45102f82015-10-28 15:59:28 +09002668 wid.id = (u16)WID_POWER_MANAGEMENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002669
Punit Vara047e6642015-10-25 04:01:25 +05302670 if (strPowerMgmtParam->enabled)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002671 s8PowerMode = MIN_FAST_PS;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302672 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002673 s8PowerMode = NO_POWERSAVE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002674 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
Leo Kim45102f82015-10-28 15:59:28 +09002675 wid.val = &s8PowerMode;
2676 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002677
2678 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
2679
Leo Kim45102f82015-10-28 15:59:28 +09002680 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002681 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002682 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002683 PRINT_ER("Failed to send power management config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002684}
2685
Tony Choa4ab1ad2015-10-12 16:56:05 +09002686static void Handle_SetMulticastFilter(struct host_if_drv *hif_drv,
Tony Cho641210a2015-09-21 12:16:52 +09002687 struct set_multicast *strHostIfSetMulti)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002688{
Leo Kim31390ee2015-10-19 18:26:08 +09002689 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002690 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002691 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002692
2693 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
2694
Leo Kim45102f82015-10-28 15:59:28 +09002695 wid.id = (u16)WID_SETUP_MULTICAST_FILTER;
2696 wid.type = WID_BIN;
2697 wid.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2698 wid.val = kmalloc(wid.size, GFP_KERNEL);
2699 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002700 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002701
Leo Kim45102f82015-10-28 15:59:28 +09002702 pu8CurrByte = wid.val;
Leo Kimbae636eb2015-10-13 20:02:04 +09002703 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
2704 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 8) & 0xFF);
2705 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 16) & 0xFF);
2706 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002707
Leo Kimadab2f72015-10-13 20:02:05 +09002708 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2709 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2710 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2711 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002712
Leo Kimadab2f72015-10-13 20:02:05 +09002713 if ((strHostIfSetMulti->cnt) > 0)
Leo Kimfb70e9f2015-11-05 14:36:09 +09002714 memcpy(pu8CurrByte, multicast_mac_addr_list,
2715 ((strHostIfSetMulti->cnt) * ETH_ALEN));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002716
Leo Kim45102f82015-10-28 15:59:28 +09002717 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002718 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002719 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002720 PRINT_ER("Failed to send setup multicast config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002721
Leo Kim24db7132015-09-16 18:36:01 +09002722ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002723 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002724}
2725
Tony Choa4ab1ad2015-10-12 16:56:05 +09002726static s32 Handle_AddBASession(struct host_if_drv *hif_drv,
Tony Cho54265472015-09-21 12:16:56 +09002727 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002728{
Leo Kim31390ee2015-10-19 18:26:08 +09002729 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002730 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002731 int AddbaTimeout = 100;
2732 char *ptr = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002733
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002734 PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\nBufferSize == %d\nSessionTimeOut = %d\n",
Leo Kim3fc49992015-10-29 11:58:45 +09002735 strHostIfBASessionInfo->bssid[0],
2736 strHostIfBASessionInfo->bssid[1],
2737 strHostIfBASessionInfo->bssid[2],
Leo Kim277c2132015-10-29 11:58:47 +09002738 strHostIfBASessionInfo->buf_size,
Leo Kim23d0bfa2015-10-29 11:58:48 +09002739 strHostIfBASessionInfo->time_out,
Leo Kim16c9b392015-10-29 11:58:46 +09002740 strHostIfBASessionInfo->tid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002741
Leo Kim45102f82015-10-28 15:59:28 +09002742 wid.id = (u16)WID_11E_P_ACTION_REQ;
2743 wid.type = WID_STR;
2744 wid.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2745 wid.size = BLOCK_ACK_REQ_SIZE;
2746 ptr = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002747 *ptr++ = 0x14;
2748 *ptr++ = 0x3;
2749 *ptr++ = 0x0;
Leo Kim3fc49992015-10-29 11:58:45 +09002750 memcpy(ptr, strHostIfBASessionInfo->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002751 ptr += ETH_ALEN;
Leo Kim16c9b392015-10-29 11:58:46 +09002752 *ptr++ = strHostIfBASessionInfo->tid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002753 *ptr++ = 1;
Leo Kim277c2132015-10-29 11:58:47 +09002754 *ptr++ = (strHostIfBASessionInfo->buf_size & 0xFF);
2755 *ptr++ = ((strHostIfBASessionInfo->buf_size >> 16) & 0xFF);
Leo Kim23d0bfa2015-10-29 11:58:48 +09002756 *ptr++ = (strHostIfBASessionInfo->time_out & 0xFF);
2757 *ptr++ = ((strHostIfBASessionInfo->time_out >> 16) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002758 *ptr++ = (AddbaTimeout & 0xFF);
2759 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002760 *ptr++ = 8;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002761 *ptr++ = 0;
2762
Leo Kim45102f82015-10-28 15:59:28 +09002763 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002764 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002765 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002766 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
2767
Leo Kim45102f82015-10-28 15:59:28 +09002768 wid.id = (u16)WID_11E_P_ACTION_REQ;
2769 wid.type = WID_STR;
2770 wid.size = 15;
2771 ptr = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002772 *ptr++ = 15;
2773 *ptr++ = 7;
2774 *ptr++ = 0x2;
Leo Kim3fc49992015-10-29 11:58:45 +09002775 memcpy(ptr, strHostIfBASessionInfo->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002776 ptr += ETH_ALEN;
Leo Kim16c9b392015-10-29 11:58:46 +09002777 *ptr++ = strHostIfBASessionInfo->tid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002778 *ptr++ = 8;
Leo Kim277c2132015-10-29 11:58:47 +09002779 *ptr++ = (strHostIfBASessionInfo->buf_size & 0xFF);
Leo Kim23d0bfa2015-10-29 11:58:48 +09002780 *ptr++ = ((strHostIfBASessionInfo->time_out >> 16) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002781 *ptr++ = 3;
Leo Kim45102f82015-10-28 15:59:28 +09002782 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002783 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002784
Leo Kim45102f82015-10-28 15:59:28 +09002785 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002786
Leo Kim31390ee2015-10-19 18:26:08 +09002787 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002788}
2789
Tony Choa4ab1ad2015-10-12 16:56:05 +09002790static s32 Handle_DelAllRxBASessions(struct host_if_drv *hif_drv,
Tony Cho54265472015-09-21 12:16:56 +09002791 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002792{
Leo Kim31390ee2015-10-19 18:26:08 +09002793 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002794 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002795 char *ptr = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002796
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002797 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Leo Kim3fc49992015-10-29 11:58:45 +09002798 strHostIfBASessionInfo->bssid[0],
2799 strHostIfBASessionInfo->bssid[1],
2800 strHostIfBASessionInfo->bssid[2],
Leo Kim16c9b392015-10-29 11:58:46 +09002801 strHostIfBASessionInfo->tid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002802
Leo Kim45102f82015-10-28 15:59:28 +09002803 wid.id = (u16)WID_DEL_ALL_RX_BA;
2804 wid.type = WID_STR;
2805 wid.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2806 wid.size = BLOCK_ACK_REQ_SIZE;
2807 ptr = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002808 *ptr++ = 0x14;
2809 *ptr++ = 0x3;
2810 *ptr++ = 0x2;
Leo Kim3fc49992015-10-29 11:58:45 +09002811 memcpy(ptr, strHostIfBASessionInfo->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002812 ptr += ETH_ALEN;
Leo Kim16c9b392015-10-29 11:58:46 +09002813 *ptr++ = strHostIfBASessionInfo->tid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002814 *ptr++ = 0;
Leo Kimae4dfa52015-10-13 19:49:26 +09002815 *ptr++ = 32;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002816
Leo Kim45102f82015-10-28 15:59:28 +09002817 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002818 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002819 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002820 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
2821
Leo Kim45102f82015-10-28 15:59:28 +09002822 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002823
Leo Kim2d25af82015-10-15 13:24:56 +09002824 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002825
Leo Kim31390ee2015-10-19 18:26:08 +09002826 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002827}
2828
Arnd Bergmann1999bd52015-05-29 22:52:14 +02002829static int hostIFthread(void *pvArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002830{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002831 u32 u32Ret;
Tony Cho143eb952015-09-21 12:16:32 +09002832 struct host_if_msg msg;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002833 struct host_if_drv *hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002834
Tony Cho143eb952015-09-21 12:16:32 +09002835 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002836
2837 while (1) {
Leo Kimcb067dc2015-10-15 13:24:53 +09002838 wilc_mq_recv(&hif_msg_q, &msg, sizeof(struct host_if_msg), &u32Ret);
Tony Choa4ab1ad2015-10-12 16:56:05 +09002839 hif_drv = (struct host_if_drv *)msg.drv;
Tony Choa9f812a2015-09-21 12:16:33 +09002840 if (msg.id == HOST_IF_MSG_EXIT) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002841 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
2842 break;
2843 }
2844
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002845 if ((!g_wilc_initialized)) {
2846 PRINT_D(GENERIC_DBG, "--WAIT--");
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07002847 usleep_range(200 * 1000, 200 * 1000);
Leo Kimcb067dc2015-10-15 13:24:53 +09002848 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002849 continue;
2850 }
2851
Leo Kim91109e12015-10-19 18:26:13 +09002852 if (msg.id == HOST_IF_MSG_CONNECT &&
Leo Kimbc801852015-10-29 11:58:50 +09002853 hif_drv->usr_scan_req.scan_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002854 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
Leo Kimcb067dc2015-10-15 13:24:53 +09002855 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07002856 usleep_range(2 * 1000, 2 * 1000);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002857 continue;
2858 }
2859
Tony Choa9f812a2015-09-21 12:16:33 +09002860 switch (msg.id) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002861 case HOST_IF_MSG_Q_IDLE:
2862 Handle_wait_msg_q_empty();
2863 break;
2864
2865 case HOST_IF_MSG_SCAN:
Leo Kim2482a792015-10-12 16:55:36 +09002866 Handle_Scan(msg.drv, &msg.body.scan_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002867 break;
2868
2869 case HOST_IF_MSG_CONNECT:
Leo Kim2482a792015-10-12 16:55:36 +09002870 Handle_Connect(msg.drv, &msg.body.con_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002871 break;
2872
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002873 case HOST_IF_MSG_FLUSH_CONNECT:
Leo Kim2482a792015-10-12 16:55:36 +09002874 Handle_FlushConnect(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002875 break;
2876
2877 case HOST_IF_MSG_RCVD_NTWRK_INFO:
Leo Kim2482a792015-10-12 16:55:36 +09002878 Handle_RcvdNtwrkInfo(msg.drv, &msg.body.net_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002879 break;
2880
2881 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
Leo Kim2482a792015-10-12 16:55:36 +09002882 Handle_RcvdGnrlAsyncInfo(msg.drv, &msg.body.async_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002883 break;
2884
2885 case HOST_IF_MSG_KEY:
Leo Kim2482a792015-10-12 16:55:36 +09002886 Handle_Key(msg.drv, &msg.body.key_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002887 break;
2888
2889 case HOST_IF_MSG_CFG_PARAMS:
Leo Kimdc276662015-11-06 11:20:10 +09002890 handle_cfg_param(msg.drv, &msg.body.cfg_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002891 break;
2892
2893 case HOST_IF_MSG_SET_CHANNEL:
Leo Kim3eec50c2015-11-06 11:20:03 +09002894 handle_set_channel(msg.drv, &msg.body.channel_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002895 break;
2896
2897 case HOST_IF_MSG_DISCONNECT:
Leo Kim2482a792015-10-12 16:55:36 +09002898 Handle_Disconnect(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002899 break;
2900
2901 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
Leo Kim13b313e2015-10-29 11:58:34 +09002902 del_timer(&hif_drv->scan_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002903 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
2904
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002905 if (!linux_wlan_get_num_conn_ifcs())
Leo Kim1b721bf2015-11-06 11:13:00 +09002906 chip_sleep_manually();
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002907
Leo Kim2482a792015-10-12 16:55:36 +09002908 Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002909
Leo Kim5beef2c2015-10-28 15:59:36 +09002910 if (hif_drv->remain_on_ch_pending)
Leo Kim2482a792015-10-12 16:55:36 +09002911 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002912
2913 break;
2914
2915 case HOST_IF_MSG_GET_RSSI:
Leo Kim2482a792015-10-12 16:55:36 +09002916 Handle_GetRssi(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002917 break;
2918
2919 case HOST_IF_MSG_GET_LINKSPEED:
Leo Kim2482a792015-10-12 16:55:36 +09002920 Handle_GetLinkspeed(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002921 break;
2922
2923 case HOST_IF_MSG_GET_STATISTICS:
Leo Kim03e7b9c2015-10-12 16:55:58 +09002924 Handle_GetStatistics(msg.drv, (struct rf_info *)msg.body.data);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002925 break;
2926
2927 case HOST_IF_MSG_GET_CHNL:
Leo Kim2482a792015-10-12 16:55:36 +09002928 Handle_GetChnl(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002929 break;
2930
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002931 case HOST_IF_MSG_ADD_BEACON:
Leo Kim2482a792015-10-12 16:55:36 +09002932 Handle_AddBeacon(msg.drv, &msg.body.beacon_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002933 break;
2934
2935 case HOST_IF_MSG_DEL_BEACON:
Leo Kim2482a792015-10-12 16:55:36 +09002936 Handle_DelBeacon(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002937 break;
2938
2939 case HOST_IF_MSG_ADD_STATION:
Leo Kim2482a792015-10-12 16:55:36 +09002940 Handle_AddStation(msg.drv, &msg.body.add_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002941 break;
2942
2943 case HOST_IF_MSG_DEL_STATION:
Leo Kim2482a792015-10-12 16:55:36 +09002944 Handle_DelStation(msg.drv, &msg.body.del_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002945 break;
2946
2947 case HOST_IF_MSG_EDIT_STATION:
Leo Kim2482a792015-10-12 16:55:36 +09002948 Handle_EditStation(msg.drv, &msg.body.edit_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002949 break;
2950
2951 case HOST_IF_MSG_GET_INACTIVETIME:
Leo Kim2482a792015-10-12 16:55:36 +09002952 Handle_Get_InActiveTime(msg.drv, &msg.body.mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002953 break;
2954
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002955 case HOST_IF_MSG_SCAN_TIMER_FIRED:
2956 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
2957
Leo Kim2482a792015-10-12 16:55:36 +09002958 Handle_ScanDone(msg.drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002959 break;
2960
2961 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002962 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
Leo Kim2482a792015-10-12 16:55:36 +09002963 Handle_ConnectTimeout(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002964 break;
2965
2966 case HOST_IF_MSG_POWER_MGMT:
Leo Kim2482a792015-10-12 16:55:36 +09002967 Handle_PowerManagement(msg.drv, &msg.body.pwr_mgmt_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002968 break;
2969
2970 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
Leo Kim23f2bad2015-11-06 11:20:04 +09002971 handle_set_wfi_drv_handler(msg.drv, &msg.body.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002972 break;
2973
2974 case HOST_IF_MSG_SET_OPERATION_MODE:
Leo Kim97b5c592015-11-06 11:20:05 +09002975 handle_set_operation_mode(msg.drv, &msg.body.mode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002976 break;
2977
2978 case HOST_IF_MSG_SET_IPADDRESS:
2979 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Leo Kima6e6d482015-11-06 11:20:06 +09002980 handle_set_ip_address(msg.drv,
2981 msg.body.ip_info.ip_addr,
2982 msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002983 break;
2984
2985 case HOST_IF_MSG_GET_IPADDRESS:
2986 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Leo Kimd4516952015-11-06 11:20:07 +09002987 handle_get_ip_address(msg.drv, msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002988 break;
2989
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002990 case HOST_IF_MSG_SET_MAC_ADDRESS:
Leo Kima8267422015-11-06 11:20:08 +09002991 handle_set_mac_address(msg.drv,
2992 &msg.body.set_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002993 break;
2994
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002995 case HOST_IF_MSG_GET_MAC_ADDRESS:
Leo Kimb3bf8fd2015-11-06 11:20:09 +09002996 handle_get_mac_address(msg.drv,
2997 &msg.body.get_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002998 break;
2999
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003000 case HOST_IF_MSG_REMAIN_ON_CHAN:
3001 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
Leo Kim2482a792015-10-12 16:55:36 +09003002 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003003 break;
3004
3005 case HOST_IF_MSG_REGISTER_FRAME:
3006 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
Leo Kim2482a792015-10-12 16:55:36 +09003007 Handle_RegisterFrame(msg.drv, &msg.body.reg_frame);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003008 break;
3009
3010 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
Leo Kim2482a792015-10-12 16:55:36 +09003011 Handle_ListenStateExpired(msg.drv, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003012 break;
3013
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003014 case HOST_IF_MSG_SET_MULTICAST_FILTER:
3015 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
Leo Kim2482a792015-10-12 16:55:36 +09003016 Handle_SetMulticastFilter(msg.drv, &msg.body.multicast_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003017 break;
3018
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003019 case HOST_IF_MSG_ADD_BA_SESSION:
Leo Kim2482a792015-10-12 16:55:36 +09003020 Handle_AddBASession(msg.drv, &msg.body.session_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003021 break;
3022
3023 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
Leo Kim2482a792015-10-12 16:55:36 +09003024 Handle_DelAllRxBASessions(msg.drv, &msg.body.session_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003025 break;
3026
3027 case HOST_IF_MSG_DEL_ALL_STA:
Leo Kim2482a792015-10-12 16:55:36 +09003028 Handle_DelAllSta(msg.drv, &msg.body.del_all_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003029 break;
3030
3031 default:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003032 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003033 break;
3034 }
3035 }
3036
3037 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
Leo Kim834e0cb2015-10-15 13:24:54 +09003038 up(&hif_sema_thread);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02003039 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003040}
3041
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003042static void TimerCB_Scan(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003043{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003044 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09003045 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003046
Tony Cho143eb952015-09-21 12:16:32 +09003047 memset(&msg, 0, sizeof(struct host_if_msg));
Leo Kim2482a792015-10-12 16:55:36 +09003048 msg.drv = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09003049 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003050
Leo Kimcb067dc2015-10-15 13:24:53 +09003051 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003052}
3053
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003054static void TimerCB_Connect(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003055{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003056 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09003057 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003058
Tony Cho143eb952015-09-21 12:16:32 +09003059 memset(&msg, 0, sizeof(struct host_if_msg));
Leo Kim2482a792015-10-12 16:55:36 +09003060 msg.drv = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09003061 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003062
Leo Kimcb067dc2015-10-15 13:24:53 +09003063 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003064}
3065
Tony Choa4ab1ad2015-10-12 16:56:05 +09003066s32 host_int_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003067{
Leo Kim45102f82015-10-28 15:59:28 +09003068 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003069
Leo Kim45102f82015-10-28 15:59:28 +09003070 wid.id = (u16)WID_REMOVE_KEY;
3071 wid.type = WID_STR;
3072 wid.val = (s8 *)pu8StaAddress;
3073 wid.size = 6;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003074
Leo Kimb68d820b2015-10-12 16:55:37 +09003075 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003076}
3077
Tony Choa4ab1ad2015-10-12 16:56:05 +09003078int host_int_remove_wep_key(struct host_if_drv *hif_drv, u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003079{
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003080 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003081 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003082
Tony Choa4ab1ad2015-10-12 16:56:05 +09003083 if (!hif_drv) {
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003084 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003085 PRINT_ER("Failed to send setup multicast config packet\n");
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003086 return result;
Leo Kim24db7132015-09-16 18:36:01 +09003087 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003088
Tony Cho143eb952015-09-21 12:16:32 +09003089 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003090
Tony Choa9f812a2015-09-21 12:16:33 +09003091 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003092 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003093 msg.body.key_info.action = REMOVEKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003094 msg.drv = hif_drv;
Leo Kim73b2e382015-10-13 19:49:29 +09003095 msg.body.key_info.attr.wep.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003096
Leo Kimcb067dc2015-10-15 13:24:53 +09003097 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003098 if (result)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003099 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003100 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003101
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003102 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003103}
3104
Chaehyun Limdf8b4832015-10-26 09:44:45 +09003105int host_int_set_wep_default_key(struct host_if_drv *hif_drv, u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003106{
Chaehyun Lim5b41c7c2015-10-26 09:44:42 +09003107 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003108 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003109
Tony Choa4ab1ad2015-10-12 16:56:05 +09003110 if (!hif_drv) {
Leo Kim31390ee2015-10-19 18:26:08 +09003111 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003112 PRINT_ER("driver is null\n");
Leo Kim31390ee2015-10-19 18:26:08 +09003113 return result;
Leo Kim24db7132015-09-16 18:36:01 +09003114 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003115
Tony Cho143eb952015-09-21 12:16:32 +09003116 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003117
Tony Choa9f812a2015-09-21 12:16:33 +09003118 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003119 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003120 msg.body.key_info.action = DEFAULTKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003121 msg.drv = hif_drv;
Chaehyun Lime91d0342015-10-26 09:44:44 +09003122 msg.body.key_info.attr.wep.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003123
Leo Kim31390ee2015-10-19 18:26:08 +09003124 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3125 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003126 PRINT_ER("Error in sending message queue : Default key index\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003127 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003128
Leo Kim31390ee2015-10-19 18:26:08 +09003129 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003130}
3131
Chaehyun Lim66b8cb82015-10-27 20:40:32 +09003132int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
Chaehyun Limfba778b2015-10-27 20:40:34 +09003133 const u8 *key,
Chaehyun Limdbc53192015-10-27 20:40:35 +09003134 u8 len,
Chaehyun Lim0b2cc3e2015-10-27 20:40:36 +09003135 u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003136{
Chaehyun Lim66b8cb82015-10-27 20:40:32 +09003137 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003138 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003139
Tony Choa4ab1ad2015-10-12 16:56:05 +09003140 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003141 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003142 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003143 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003144
Tony Cho143eb952015-09-21 12:16:32 +09003145 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003146
Tony Choa9f812a2015-09-21 12:16:33 +09003147 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003148 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003149 msg.body.key_info.action = ADDKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003150 msg.drv = hif_drv;
Chaehyun Lim1cc0c322015-10-27 20:40:37 +09003151 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3152 if (!msg.body.key_info.attr.wep.key)
3153 return -ENOMEM;
3154
Chaehyun Limdbc53192015-10-27 20:40:35 +09003155 msg.body.key_info.attr.wep.key_len = len;
Chaehyun Lim0b2cc3e2015-10-27 20:40:36 +09003156 msg.body.key_info.attr.wep.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003157
Leo Kim31390ee2015-10-19 18:26:08 +09003158 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3159 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003160 PRINT_ER("Error in sending message queue :WEP Key\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003161 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003162
Leo Kim31390ee2015-10-19 18:26:08 +09003163 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003164}
3165
Chaehyun Lim641c20a2015-10-28 08:19:19 +09003166int host_int_add_wep_key_bss_ap(struct host_if_drv *hif_drv,
Chaehyun Lim81117252015-10-28 08:19:22 +09003167 const u8 *key,
Chaehyun Lima5389b02015-10-28 08:19:23 +09003168 u8 len,
Chaehyun Lima76dc952015-10-28 08:19:24 +09003169 u8 index,
Chaehyun Lim730a28d2015-10-28 08:19:25 +09003170 u8 mode,
Chaehyun Limff3bce22015-10-28 08:19:26 +09003171 enum AUTHTYPE auth_type)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003172{
Chaehyun Lim641c20a2015-10-28 08:19:19 +09003173 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003174 struct host_if_msg msg;
Chaehyun Limfd741462015-10-28 08:19:21 +09003175 int i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003176
Tony Choa4ab1ad2015-10-12 16:56:05 +09003177 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003178 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003179 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003180 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003181
Tony Cho143eb952015-09-21 12:16:32 +09003182 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003183
3184 if (INFO) {
Chaehyun Lima5389b02015-10-28 08:19:23 +09003185 for (i = 0; i < len; i++)
Chaehyun Lim81117252015-10-28 08:19:22 +09003186 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", key[i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003187 }
Tony Choa9f812a2015-09-21 12:16:33 +09003188 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003189 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003190 msg.body.key_info.action = ADDKEY_AP;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003191 msg.drv = hif_drv;
Chaehyun Lim58eabd62015-10-28 08:19:27 +09003192 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3193 if (!msg.body.key_info.attr.wep.key)
3194 return -ENOMEM;
3195
Chaehyun Lima5389b02015-10-28 08:19:23 +09003196 msg.body.key_info.attr.wep.key_len = len;
Chaehyun Lima76dc952015-10-28 08:19:24 +09003197 msg.body.key_info.attr.wep.index = index;
Chaehyun Lim730a28d2015-10-28 08:19:25 +09003198 msg.body.key_info.attr.wep.mode = mode;
Chaehyun Limff3bce22015-10-28 08:19:26 +09003199 msg.body.key_info.attr.wep.auth_type = auth_type;
Leo Kimae4dfa52015-10-13 19:49:26 +09003200
Leo Kim31390ee2015-10-19 18:26:08 +09003201 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003202
Leo Kim31390ee2015-10-19 18:26:08 +09003203 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003204 PRINT_ER("Error in sending message queue :WEP Key\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003205 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003206
Leo Kim31390ee2015-10-19 18:26:08 +09003207 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003208}
Glen Lee108b3432015-09-16 18:53:20 +09003209
Chaehyun Limd1705362015-11-08 16:48:56 +09003210int host_int_add_ptk(struct host_if_drv *hif_drv, const u8 *ptk,
Chaehyun Lim0743b7e2015-11-08 16:48:57 +09003211 u8 ptk_key_len, const u8 *mac_addr,
Chaehyun Limd7c02422015-11-08 16:48:59 +09003212 const u8 *rx_mic, const u8 *tx_mic,
Chaehyun Lim3e5c4ab2015-11-08 16:49:01 +09003213 u8 mode, u8 cipher_mode, u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003214{
Chaehyun Lim706ab422015-11-08 16:48:54 +09003215 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003216 struct host_if_msg msg;
Chaehyun Lim53bbbb52015-11-08 16:49:03 +09003217 u8 key_len = ptk_key_len;
Chaehyun Limfa269072015-11-08 16:49:02 +09003218 int i;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003219
Tony Choa4ab1ad2015-10-12 16:56:05 +09003220 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003221 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003222 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003223 }
Leo Kim91109e12015-10-19 18:26:13 +09003224
Chaehyun Lim38f66292015-11-08 16:48:58 +09003225 if (rx_mic)
Chaehyun Lim53bbbb52015-11-08 16:49:03 +09003226 key_len += RX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003227
Chaehyun Limd7c02422015-11-08 16:48:59 +09003228 if (tx_mic)
Chaehyun Lim53bbbb52015-11-08 16:49:03 +09003229 key_len += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003230
Tony Cho143eb952015-09-21 12:16:32 +09003231 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003232
Tony Choa9f812a2015-09-21 12:16:33 +09003233 msg.id = HOST_IF_MSG_KEY;
Leo Kim2141fe32015-10-29 12:05:35 +09003234 msg.body.key_info.type = WPA_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003235 if (mode == AP_MODE) {
Leo Kim0d17e382015-10-13 19:49:28 +09003236 msg.body.key_info.action = ADDKEY_AP;
Chaehyun Lim3e5c4ab2015-11-08 16:49:01 +09003237 msg.body.key_info.attr.wpa.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003238 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003239 if (mode == STATION_MODE)
Leo Kim0d17e382015-10-13 19:49:28 +09003240 msg.body.key_info.action = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003241
Chaehyun Lim8ab8c592015-11-08 16:49:04 +09003242 msg.body.key_info.attr.wpa.key = kmemdup(ptk, ptk_key_len, GFP_KERNEL);
3243 if (!msg.body.key_info.attr.wpa.key)
3244 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003245
Chaehyun Lim38f66292015-11-08 16:48:58 +09003246 if (rx_mic) {
3247 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic, RX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003248 if (INFO) {
3249 for (i = 0; i < RX_MIC_KEY_LEN; i++)
Chaehyun Lim38f66292015-11-08 16:48:58 +09003250 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, rx_mic[i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003251 }
3252 }
Chaehyun Limd7c02422015-11-08 16:48:59 +09003253 if (tx_mic) {
3254 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic, TX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003255 if (INFO) {
3256 for (i = 0; i < TX_MIC_KEY_LEN; i++)
Chaehyun Limd7c02422015-11-08 16:48:59 +09003257 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, tx_mic[i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003258 }
3259 }
3260
Chaehyun Lim53bbbb52015-11-08 16:49:03 +09003261 msg.body.key_info.attr.wpa.key_len = key_len;
Leo Kim248080a2015-10-13 19:49:31 +09003262 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
Chaehyun Limf0c82572015-11-08 16:49:00 +09003263 msg.body.key_info.attr.wpa.mode = cipher_mode;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003264 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003265
Leo Kim31390ee2015-10-19 18:26:08 +09003266 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003267
Leo Kim31390ee2015-10-19 18:26:08 +09003268 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003269 PRINT_ER("Error in sending message queue: PTK Key\n");
3270
Leo Kim9ea47132015-10-29 11:58:28 +09003271 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003272
Leo Kim31390ee2015-10-19 18:26:08 +09003273 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003274}
3275
Chaehyun Lim3c0bf6b2015-11-08 16:49:07 +09003276int host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *rx_gtk,
Chaehyun Lim9a5e57362015-11-08 16:49:09 +09003277 u8 gtk_key_len, u8 index,
Chaehyun Lim982859c2015-11-08 16:49:11 +09003278 u32 key_rsc_len, const u8 *key_rsc,
Chaehyun Lim2f797582015-11-08 16:49:13 +09003279 const u8 *rx_mic, const u8 *tx_mic,
Chaehyun Lim57bfcbc2015-11-08 16:49:14 +09003280 u8 mode, u8 cipher_mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003281{
Chaehyun Lim15034572015-11-08 16:49:05 +09003282 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003283 struct host_if_msg msg;
Chaehyun Limd002fcc2015-11-08 16:49:15 +09003284 u8 key_len = gtk_key_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003285
Tony Choa4ab1ad2015-10-12 16:56:05 +09003286 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003287 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003288 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003289 }
Tony Cho143eb952015-09-21 12:16:32 +09003290 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003291
Chaehyun Lim6d36c272015-11-08 16:49:12 +09003292 if (rx_mic)
Chaehyun Limd002fcc2015-11-08 16:49:15 +09003293 key_len += RX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003294
Chaehyun Lim2f797582015-11-08 16:49:13 +09003295 if (tx_mic)
Chaehyun Limd002fcc2015-11-08 16:49:15 +09003296 key_len += TX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003297
Chaehyun Lim982859c2015-11-08 16:49:11 +09003298 if (key_rsc) {
Chaehyun Lim9bfda382015-11-08 16:49:16 +09003299 msg.body.key_info.attr.wpa.seq = kmemdup(key_rsc,
3300 key_rsc_len,
3301 GFP_KERNEL);
3302 if (!msg.body.key_info.attr.wpa.seq)
3303 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003304 }
3305
Tony Choa9f812a2015-09-21 12:16:33 +09003306 msg.id = HOST_IF_MSG_KEY;
Leo Kim5cd8f7a2015-10-29 12:05:34 +09003307 msg.body.key_info.type = WPA_RX_GTK;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003308 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003309
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003310 if (mode == AP_MODE) {
Leo Kim0d17e382015-10-13 19:49:28 +09003311 msg.body.key_info.action = ADDKEY_AP;
Chaehyun Lim57bfcbc2015-11-08 16:49:14 +09003312 msg.body.key_info.attr.wpa.mode = cipher_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003313 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003314 if (mode == STATION_MODE)
Leo Kim0d17e382015-10-13 19:49:28 +09003315 msg.body.key_info.action = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003316
Chaehyun Lim9bfda382015-11-08 16:49:16 +09003317 msg.body.key_info.attr.wpa.key = kmemdup(rx_gtk,
3318 key_len,
3319 GFP_KERNEL);
3320 if (!msg.body.key_info.attr.wpa.key)
3321 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003322
Chaehyun Lim6d36c272015-11-08 16:49:12 +09003323 if (rx_mic)
3324 memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic,
Leo Kimd1666e22015-10-28 15:59:22 +09003325 RX_MIC_KEY_LEN);
Leo Kim91109e12015-10-19 18:26:13 +09003326
Chaehyun Lim2f797582015-11-08 16:49:13 +09003327 if (tx_mic)
3328 memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic,
Leo Kimd1666e22015-10-28 15:59:22 +09003329 TX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003330
Chaehyun Lim9a5e57362015-11-08 16:49:09 +09003331 msg.body.key_info.attr.wpa.index = index;
Chaehyun Limd002fcc2015-11-08 16:49:15 +09003332 msg.body.key_info.attr.wpa.key_len = key_len;
Chaehyun Lim18bef992015-11-08 16:49:10 +09003333 msg.body.key_info.attr.wpa.seq_len = key_rsc_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003334
Leo Kim31390ee2015-10-19 18:26:08 +09003335 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3336 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003337 PRINT_ER("Error in sending message queue: RX GTK\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09003338
Leo Kim9ea47132015-10-29 11:58:28 +09003339 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003340
Leo Kim31390ee2015-10-19 18:26:08 +09003341 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003342}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003343
Tony Choa4ab1ad2015-10-12 16:56:05 +09003344s32 host_int_set_pmkid_info(struct host_if_drv *hif_drv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003345{
Leo Kim31390ee2015-10-19 18:26:08 +09003346 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003347 struct host_if_msg msg;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003348 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003349
Tony Choa4ab1ad2015-10-12 16:56:05 +09003350 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003351 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003352 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003353 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003354
Tony Cho143eb952015-09-21 12:16:32 +09003355 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003356
Tony Choa9f812a2015-09-21 12:16:33 +09003357 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003358 msg.body.key_info.type = PMKSA;
Leo Kim0d17e382015-10-13 19:49:28 +09003359 msg.body.key_info.action = ADDKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003360 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003361
3362 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
Leo Kim8c8360b2015-10-19 18:26:12 +09003363 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid,
3364 &pu8PmkidInfoArray->pmkidlist[i].bssid, ETH_ALEN);
3365 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid,
3366 &pu8PmkidInfoArray->pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003367 }
3368
Leo Kim31390ee2015-10-19 18:26:08 +09003369 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3370 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003371 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3372
Leo Kim31390ee2015-10-19 18:26:08 +09003373 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003374}
3375
Tony Choa4ab1ad2015-10-12 16:56:05 +09003376s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3377 u8 *pu8PassPhrase,
3378 u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003379{
Leo Kim45102f82015-10-28 15:59:28 +09003380 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003381
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003382 if ((u8Psklength > 7) && (u8Psklength < 65)) {
Leo Kim45102f82015-10-28 15:59:28 +09003383 wid.id = (u16)WID_11I_PSK;
3384 wid.type = WID_STR;
3385 wid.val = pu8PassPhrase;
3386 wid.size = u8Psklength;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003387 }
3388
Leo Kimb68d820b2015-10-12 16:55:37 +09003389 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003390}
Leo Kimae4dfa52015-10-13 19:49:26 +09003391
Leo Kime5f35242015-11-05 14:36:36 +09003392s32 hif_get_mac_address(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003393{
Leo Kim31390ee2015-10-19 18:26:08 +09003394 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003395 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003396
Tony Cho143eb952015-09-21 12:16:32 +09003397 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003398
Tony Choa9f812a2015-09-21 12:16:33 +09003399 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
Leo Kim6ceba0a2015-10-28 15:59:32 +09003400 msg.body.get_mac_info.mac_addr = pu8MacAddress;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003401 msg.drv = hif_drv;
Leo Kimae4dfa52015-10-13 19:49:26 +09003402
Leo Kim31390ee2015-10-19 18:26:08 +09003403 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3404 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003405 PRINT_ER("Failed to send get mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +09003406 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003407 }
3408
Leo Kim2d25af82015-10-15 13:24:56 +09003409 down(&hif_sema_wait_response);
Leo Kim31390ee2015-10-19 18:26:08 +09003410 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003411}
3412
Tony Choa4ab1ad2015-10-12 16:56:05 +09003413s32 host_int_set_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003414{
Leo Kim31390ee2015-10-19 18:26:08 +09003415 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003416 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003417
3418 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
3419
Tony Cho143eb952015-09-21 12:16:32 +09003420 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003421 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
Leo Kimae5e4522015-10-28 15:59:31 +09003422 memcpy(msg.body.set_mac_info.mac_addr, pu8MacAddress, ETH_ALEN);
Tony Choa4ab1ad2015-10-12 16:56:05 +09003423 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003424
Leo Kim31390ee2015-10-19 18:26:08 +09003425 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3426 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003427 PRINT_ER("Failed to send message queue: Set mac address\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003428
Leo Kim31390ee2015-10-19 18:26:08 +09003429 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003430}
3431
Tony Choa4ab1ad2015-10-12 16:56:05 +09003432s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3433 u8 *pu8PassPhrase, u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003434{
Leo Kim45102f82015-10-28 15:59:28 +09003435 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003436
Leo Kim45102f82015-10-28 15:59:28 +09003437 wid.id = (u16)WID_11I_PSK;
3438 wid.type = WID_STR;
3439 wid.size = u8Psklength;
3440 wid.val = pu8PassPhrase;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003441
Leo Kimb68d820b2015-10-12 16:55:37 +09003442 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003443}
3444
Tony Choa4ab1ad2015-10-12 16:56:05 +09003445s32 host_int_set_start_scan_req(struct host_if_drv *hif_drv, u8 scanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003446{
Leo Kim45102f82015-10-28 15:59:28 +09003447 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003448
Leo Kim45102f82015-10-28 15:59:28 +09003449 wid.id = (u16)WID_START_SCAN_REQ;
3450 wid.type = WID_CHAR;
3451 wid.val = (s8 *)&scanSource;
3452 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003453
Leo Kimb68d820b2015-10-12 16:55:37 +09003454 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003455}
3456
Tony Choa4ab1ad2015-10-12 16:56:05 +09003457s32 host_int_get_start_scan_req(struct host_if_drv *hif_drv, u8 *pu8ScanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003458{
Leo Kim45102f82015-10-28 15:59:28 +09003459 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003460
Leo Kim45102f82015-10-28 15:59:28 +09003461 wid.id = (u16)WID_START_SCAN_REQ;
3462 wid.type = WID_CHAR;
3463 wid.val = (s8 *)pu8ScanSource;
3464 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003465
Leo Kimb68d820b2015-10-12 16:55:37 +09003466 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003467}
3468
Tony Choa4ab1ad2015-10-12 16:56:05 +09003469s32 host_int_set_join_req(struct host_if_drv *hif_drv, u8 *pu8bssid,
3470 const u8 *pu8ssid, size_t ssidLen,
3471 const u8 *pu8IEs, size_t IEsLen,
3472 wilc_connect_result pfConnectResult, void *pvUserArg,
3473 u8 u8security, enum AUTHTYPE tenuAuth_type,
3474 u8 u8channel, void *pJoinParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003475{
Leo Kim31390ee2015-10-19 18:26:08 +09003476 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003477 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003478
Leo Kim91109e12015-10-19 18:26:13 +09003479 if (!hif_drv || !pfConnectResult) {
Leo Kim24db7132015-09-16 18:36:01 +09003480 PRINT_ER("Driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003481 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003482 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003483
Leo Kim91109e12015-10-19 18:26:13 +09003484 if (!pJoinParams) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003485 PRINT_ER("Unable to Join - JoinParams is NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003486 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003487 }
Leo Kim24db7132015-09-16 18:36:01 +09003488
Tony Cho143eb952015-09-21 12:16:32 +09003489 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003490
Tony Choa9f812a2015-09-21 12:16:33 +09003491 msg.id = HOST_IF_MSG_CONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003492
Leo Kima64fd672015-10-13 19:49:54 +09003493 msg.body.con_info.security = u8security;
Leo Kim61b4fd02015-10-13 19:49:57 +09003494 msg.body.con_info.auth_type = tenuAuth_type;
Leo Kim0d1527e2015-10-13 19:49:58 +09003495 msg.body.con_info.ch = u8channel;
Leo Kim6abcc112015-10-13 19:49:55 +09003496 msg.body.con_info.result = pfConnectResult;
Leo Kim8f38db82015-10-13 19:49:56 +09003497 msg.body.con_info.arg = pvUserArg;
Leo Kimf2bed2c2015-10-13 19:49:59 +09003498 msg.body.con_info.params = pJoinParams;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003499 msg.drv = hif_drv ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003500
Leo Kim91109e12015-10-19 18:26:13 +09003501 if (pu8bssid) {
Leo Kim9254db02015-10-13 19:49:49 +09003502 msg.body.con_info.bssid = kmalloc(6, GFP_KERNEL);
3503 memcpy(msg.body.con_info.bssid, pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003504 }
3505
Leo Kim91109e12015-10-19 18:26:13 +09003506 if (pu8ssid) {
Leo Kim8b3c9fa2015-10-13 19:49:51 +09003507 msg.body.con_info.ssid_len = ssidLen;
Leo Kimf7bbd9c2015-10-13 19:49:50 +09003508 msg.body.con_info.ssid = kmalloc(ssidLen, GFP_KERNEL);
3509 memcpy(msg.body.con_info.ssid, pu8ssid, ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003510 }
3511
Leo Kim91109e12015-10-19 18:26:13 +09003512 if (pu8IEs) {
Leo Kimb59d5c52015-10-13 19:49:53 +09003513 msg.body.con_info.ies_len = IEsLen;
Leo Kim2ea158c2015-10-13 19:49:52 +09003514 msg.body.con_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3515 memcpy(msg.body.con_info.ies, pu8IEs, IEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003516 }
Leo Kimb60005a2015-10-29 11:58:24 +09003517 if (hif_drv->hif_state < HOST_IF_CONNECTING)
3518 hif_drv->hif_state = HOST_IF_CONNECTING;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05303519 else
Leo Kimb60005a2015-10-29 11:58:24 +09003520 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' : %d\n",
3521 hif_drv->hif_state);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003522
Leo Kim31390ee2015-10-19 18:26:08 +09003523 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3524 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003525 PRINT_ER("Failed to send message queue: Set join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09003526 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003527 }
3528
Leo Kim81a59502015-10-29 11:58:35 +09003529 hif_drv->connect_timer.data = (unsigned long)hif_drv;
3530 mod_timer(&hif_drv->connect_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003531 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003532
Leo Kim31390ee2015-10-19 18:26:08 +09003533 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003534}
3535
Tony Choa4ab1ad2015-10-12 16:56:05 +09003536s32 host_int_flush_join_req(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003537{
Leo Kim31390ee2015-10-19 18:26:08 +09003538 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003539 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003540
Leo Kim7717880782015-10-19 18:26:11 +09003541 if (!join_req)
3542 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003543
Tony Choa4ab1ad2015-10-12 16:56:05 +09003544 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003545 PRINT_ER("Driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003546 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003547 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003548
Tony Choa9f812a2015-09-21 12:16:33 +09003549 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003550 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003551
Leo Kim31390ee2015-10-19 18:26:08 +09003552 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3553 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003554 PRINT_ER("Failed to send message queue: Flush join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09003555 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003556 }
3557
Leo Kim31390ee2015-10-19 18:26:08 +09003558 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003559}
3560
Tony Choa4ab1ad2015-10-12 16:56:05 +09003561s32 host_int_disconnect(struct host_if_drv *hif_drv, u16 u16ReasonCode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003562{
Leo Kim31390ee2015-10-19 18:26:08 +09003563 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003564 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003565
Tony Choa4ab1ad2015-10-12 16:56:05 +09003566 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003567 PRINT_ER("Driver is null\n");
3568 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003569 }
3570
Tony Cho143eb952015-09-21 12:16:32 +09003571 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003572
Tony Choa9f812a2015-09-21 12:16:33 +09003573 msg.id = HOST_IF_MSG_DISCONNECT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003574 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003575
Leo Kim31390ee2015-10-19 18:26:08 +09003576 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3577 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003578 PRINT_ER("Failed to send message queue: disconnect\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09003579
Leo Kime55e4962015-10-29 11:58:29 +09003580 down(&hif_drv->sem_test_disconn_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003581
Leo Kim31390ee2015-10-19 18:26:08 +09003582 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003583}
3584
Tony Choa4ab1ad2015-10-12 16:56:05 +09003585s32 host_int_disconnect_station(struct host_if_drv *hif_drv, u8 assoc_id)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003586{
Leo Kim45102f82015-10-28 15:59:28 +09003587 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003588
Leo Kim45102f82015-10-28 15:59:28 +09003589 wid.id = (u16)WID_DISCONNECT;
3590 wid.type = WID_CHAR;
3591 wid.val = (s8 *)&assoc_id;
3592 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003593
Leo Kimb68d820b2015-10-12 16:55:37 +09003594 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003595}
3596
Leo Kim8c8360b2015-10-19 18:26:12 +09003597s32 host_int_get_assoc_req_info(struct host_if_drv *hif_drv,
3598 u8 *pu8AssocReqInfo,
3599 u32 u32AssocReqInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003600{
Leo Kim45102f82015-10-28 15:59:28 +09003601 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003602
Leo Kim45102f82015-10-28 15:59:28 +09003603 wid.id = (u16)WID_ASSOC_REQ_INFO;
3604 wid.type = WID_STR;
3605 wid.val = pu8AssocReqInfo;
3606 wid.size = u32AssocReqInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003607
Leo Kimb68d820b2015-10-12 16:55:37 +09003608 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003609}
3610
Leo Kim8c8360b2015-10-19 18:26:12 +09003611s32 host_int_get_assoc_res_info(struct host_if_drv *hif_drv,
3612 u8 *pu8AssocRespInfo,
3613 u32 u32MaxAssocRespInfoLen,
3614 u32 *pu32RcvdAssocRespInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003615{
Leo Kim31390ee2015-10-19 18:26:08 +09003616 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09003617 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003618
Tony Choa4ab1ad2015-10-12 16:56:05 +09003619 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003620 PRINT_ER("Driver is null\n");
3621 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003622 }
3623
Leo Kim45102f82015-10-28 15:59:28 +09003624 wid.id = (u16)WID_ASSOC_RES_INFO;
3625 wid.type = WID_STR;
3626 wid.val = pu8AssocRespInfo;
3627 wid.size = u32MaxAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003628
Leo Kim45102f82015-10-28 15:59:28 +09003629 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09003630 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09003631 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003632 *pu32RcvdAssocRespInfoLen = 0;
Leo Kim24db7132015-09-16 18:36:01 +09003633 PRINT_ER("Failed to send association response config packet\n");
3634 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003635 } else {
Leo Kim45102f82015-10-28 15:59:28 +09003636 *pu32RcvdAssocRespInfoLen = wid.size;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003637 }
3638
Leo Kim31390ee2015-10-19 18:26:08 +09003639 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003640}
3641
Leo Kim8c8360b2015-10-19 18:26:12 +09003642s32 host_int_get_rx_power_level(struct host_if_drv *hif_drv,
3643 u8 *pu8RxPowerLevel,
3644 u32 u32RxPowerLevelLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003645{
Leo Kim45102f82015-10-28 15:59:28 +09003646 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003647
Leo Kim45102f82015-10-28 15:59:28 +09003648 wid.id = (u16)WID_RX_POWER_LEVEL;
3649 wid.type = WID_STR;
3650 wid.val = pu8RxPowerLevel;
3651 wid.size = u32RxPowerLevelLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003652
Leo Kimb68d820b2015-10-12 16:55:37 +09003653 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003654}
3655
Tony Choa4ab1ad2015-10-12 16:56:05 +09003656int host_int_set_mac_chnl_num(struct host_if_drv *hif_drv, u8 channel)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003657{
Chaehyun Lim792fb252015-10-05 11:07:22 +09003658 int result;
Tony Cho143eb952015-09-21 12:16:32 +09003659 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003660
Tony Choa4ab1ad2015-10-12 16:56:05 +09003661 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003662 PRINT_ER("driver is null\n");
3663 return -EFAULT;
3664 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003665
Tony Cho143eb952015-09-21 12:16:32 +09003666 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003667 msg.id = HOST_IF_MSG_SET_CHANNEL;
Leo Kim730ee052015-10-13 19:50:02 +09003668 msg.body.channel_info.set_ch = channel;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003669 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003670
Leo Kimcb067dc2015-10-15 13:24:53 +09003671 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lim1ef58e42015-10-02 21:44:49 +09003672 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003673 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim792fb252015-10-05 11:07:22 +09003674 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003675 }
3676
Chaehyun Lim792fb252015-10-05 11:07:22 +09003677 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003678}
3679
Chaehyun Lim244efb12015-10-02 21:44:53 +09003680int host_int_wait_msg_queue_idle(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003681{
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003682 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003683 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003684
Tony Cho143eb952015-09-21 12:16:32 +09003685 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003686 msg.id = HOST_IF_MSG_Q_IDLE;
Leo Kimcb067dc2015-10-15 13:24:53 +09003687 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003688 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003689 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003690 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003691 }
3692
Leo Kim2d25af82015-10-15 13:24:56 +09003693 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003694
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003695 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003696}
3697
Tony Choa4ab1ad2015-10-12 16:56:05 +09003698int host_int_set_wfi_drv_handler(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003699{
Chaehyun Lima0941012015-10-05 19:34:47 +09003700 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003701 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003702
Tony Cho143eb952015-09-21 12:16:32 +09003703 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003704 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
Leo Kima7f3b122015-10-28 15:59:29 +09003705 msg.body.drv.handler = get_id_from_handler(hif_drv);
Tony Choa4ab1ad2015-10-12 16:56:05 +09003706 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003707
Leo Kimcb067dc2015-10-15 13:24:53 +09003708 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lima0941012015-10-05 19:34:47 +09003709 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003710 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0941012015-10-05 19:34:47 +09003711 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003712 }
3713
Chaehyun Lima0941012015-10-05 19:34:47 +09003714 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003715}
3716
Tony Choa4ab1ad2015-10-12 16:56:05 +09003717int host_int_set_operation_mode(struct host_if_drv *hif_drv, u32 mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003718{
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003719 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003720 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003721
Tony Cho143eb952015-09-21 12:16:32 +09003722 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003723 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
Leo Kimc96debf2015-10-28 15:59:30 +09003724 msg.body.mode.mode = mode;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003725 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003726
Leo Kimcb067dc2015-10-15 13:24:53 +09003727 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003728 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003729 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003730 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003731 }
3732
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003733 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003734}
3735
Tony Choa4ab1ad2015-10-12 16:56:05 +09003736s32 host_int_get_host_chnl_num(struct host_if_drv *hif_drv, u8 *pu8ChNo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003737{
Leo Kim31390ee2015-10-19 18:26:08 +09003738 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003739 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003740
Tony Choa4ab1ad2015-10-12 16:56:05 +09003741 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003742 PRINT_ER("driver is null\n");
3743 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003744 }
3745
Tony Cho143eb952015-09-21 12:16:32 +09003746 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003747
Tony Choa9f812a2015-09-21 12:16:33 +09003748 msg.id = HOST_IF_MSG_GET_CHNL;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003749 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003750
Leo Kim31390ee2015-10-19 18:26:08 +09003751 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3752 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09003753 PRINT_ER("wilc mq send fail\n");
Leo Kim4ea90002015-10-29 11:58:32 +09003754 down(&hif_drv->sem_get_chnl);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003755
Leo Kim95ebb0f2015-10-15 13:25:03 +09003756 *pu8ChNo = ch_no;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003757
Leo Kim31390ee2015-10-19 18:26:08 +09003758 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003759}
3760
Tony Choa4ab1ad2015-10-12 16:56:05 +09003761s32 host_int_get_inactive_time(struct host_if_drv *hif_drv,
3762 const u8 *mac, u32 *pu32InactiveTime)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003763{
Leo Kim31390ee2015-10-19 18:26:08 +09003764 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003765 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003766
Tony Choa4ab1ad2015-10-12 16:56:05 +09003767 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003768 PRINT_ER("driver is null\n");
3769 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003770 }
3771
Tony Cho143eb952015-09-21 12:16:32 +09003772 memset(&msg, 0, sizeof(struct host_if_msg));
Leo Kim8c8360b2015-10-19 18:26:12 +09003773 memcpy(msg.body.mac_info.mac, mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003774
Tony Choa9f812a2015-09-21 12:16:33 +09003775 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003776 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003777
Leo Kim31390ee2015-10-19 18:26:08 +09003778 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3779 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003780 PRINT_ER("Failed to send get host channel param's message queue ");
3781
Leo Kim569a3c62015-10-29 11:58:33 +09003782 down(&hif_drv->sem_inactive_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003783
Leo Kimad269062015-10-15 13:25:06 +09003784 *pu32InactiveTime = inactive_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003785
Leo Kim31390ee2015-10-19 18:26:08 +09003786 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003787}
Glen Lee108b3432015-09-16 18:53:20 +09003788
Tony Choa4ab1ad2015-10-12 16:56:05 +09003789s32 host_int_test_get_int_wid(struct host_if_drv *hif_drv, u32 *pu32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003790{
Leo Kim31390ee2015-10-19 18:26:08 +09003791 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09003792 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003793
Tony Choa4ab1ad2015-10-12 16:56:05 +09003794 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003795 PRINT_ER("driver is null\n");
3796 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003797 }
3798
Leo Kim45102f82015-10-28 15:59:28 +09003799 wid.id = (u16)WID_MEMORY_ADDRESS;
3800 wid.type = WID_INT;
3801 wid.val = (s8 *)pu32TestMemAddr;
3802 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003803
Leo Kim45102f82015-10-28 15:59:28 +09003804 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09003805 get_id_from_handler(hif_drv));
Leo Kimae4dfa52015-10-13 19:49:26 +09003806
Leo Kim31390ee2015-10-19 18:26:08 +09003807 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003808 PRINT_ER("Failed to get wid value\n");
3809 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003810 } else {
3811 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003812 }
3813
Leo Kim31390ee2015-10-19 18:26:08 +09003814 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003815}
3816
Tony Choa4ab1ad2015-10-12 16:56:05 +09003817s32 host_int_get_rssi(struct host_if_drv *hif_drv, s8 *ps8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003818{
Leo Kim31390ee2015-10-19 18:26:08 +09003819 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003820 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003821
Leo Kimc09389a2015-10-28 15:59:24 +09003822 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003823 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003824 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003825
Leo Kim31390ee2015-10-19 18:26:08 +09003826 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3827 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003828 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003829 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003830 }
3831
Leo Kim7e111f92015-10-29 11:58:30 +09003832 down(&hif_drv->sem_get_rssi);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003833
Leo Kim91109e12015-10-19 18:26:13 +09003834 if (!ps8Rssi) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003835 PRINT_ER("RSS pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09003836 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003837 }
3838
Leo Kim144b7b22015-10-15 13:25:01 +09003839 *ps8Rssi = rssi;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003840
Leo Kim31390ee2015-10-19 18:26:08 +09003841 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003842}
3843
Tony Choa4ab1ad2015-10-12 16:56:05 +09003844s32 host_int_get_link_speed(struct host_if_drv *hif_drv, s8 *ps8lnkspd)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003845{
Tony Cho143eb952015-09-21 12:16:32 +09003846 struct host_if_msg msg;
Leo Kim31390ee2015-10-19 18:26:08 +09003847 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003848
Leo Kimc09389a2015-10-28 15:59:24 +09003849 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003850 msg.id = HOST_IF_MSG_GET_LINKSPEED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003851 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003852
Leo Kim31390ee2015-10-19 18:26:08 +09003853 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3854 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003855 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003856 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003857 }
3858
Leo Kimbc34da62015-10-29 11:58:31 +09003859 down(&hif_drv->sem_get_link_speed);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003860
Leo Kim91109e12015-10-19 18:26:13 +09003861 if (!ps8lnkspd) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003862 PRINT_ER("LINKSPEED pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09003863 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003864 }
3865
Leo Kim75327a02015-10-15 13:25:02 +09003866 *ps8lnkspd = link_speed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003867
Leo Kim31390ee2015-10-19 18:26:08 +09003868 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003869}
3870
Tony Choa4ab1ad2015-10-12 16:56:05 +09003871s32 host_int_get_statistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003872{
Leo Kim31390ee2015-10-19 18:26:08 +09003873 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003874 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003875
Leo Kimc09389a2015-10-28 15:59:24 +09003876 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003877 msg.id = HOST_IF_MSG_GET_STATISTICS;
Tony Choe60831e2015-10-05 13:50:45 +09003878 msg.body.data = (char *)pstrStatistics;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003879 msg.drv = hif_drv;
Leo Kimae4dfa52015-10-13 19:49:26 +09003880
Leo Kim31390ee2015-10-19 18:26:08 +09003881 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3882 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003883 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003884 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003885 }
3886
Leo Kim2d25af82015-10-15 13:24:56 +09003887 down(&hif_sema_wait_response);
Leo Kim31390ee2015-10-19 18:26:08 +09003888 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003889}
3890
Tony Choa4ab1ad2015-10-12 16:56:05 +09003891s32 host_int_scan(struct host_if_drv *hif_drv, u8 u8ScanSource,
3892 u8 u8ScanType, u8 *pu8ChnlFreqList,
3893 u8 u8ChnlListLen, const u8 *pu8IEs,
3894 size_t IEsLen, wilc_scan_result ScanResult,
3895 void *pvUserArg, struct hidden_network *pstrHiddenNetwork)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003896{
Leo Kim31390ee2015-10-19 18:26:08 +09003897 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003898 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003899
Leo Kim91109e12015-10-19 18:26:13 +09003900 if (!hif_drv || !ScanResult) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09003901 PRINT_ER("hif_drv or ScanResult = NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003902 return -EFAULT;
3903 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003904
Tony Cho143eb952015-09-21 12:16:32 +09003905 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003906
Tony Choa9f812a2015-09-21 12:16:33 +09003907 msg.id = HOST_IF_MSG_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003908
Leo Kim91109e12015-10-19 18:26:13 +09003909 if (pstrHiddenNetwork) {
Leo Kim629b9ca2015-10-13 19:49:46 +09003910 msg.body.scan_info.hidden_network.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
3911 msg.body.scan_info.hidden_network.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003912
3913 } else
3914 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
3915
Tony Choa4ab1ad2015-10-12 16:56:05 +09003916 msg.drv = hif_drv;
Leo Kim42568892015-10-13 19:49:37 +09003917 msg.body.scan_info.src = u8ScanSource;
Leo Kim1e276c82015-10-13 19:49:38 +09003918 msg.body.scan_info.type = u8ScanType;
Leo Kimc17c6da2015-10-13 19:49:44 +09003919 msg.body.scan_info.result = ScanResult;
Leo Kim5f2b50c2015-10-13 19:49:45 +09003920 msg.body.scan_info.arg = pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003921
Leo Kimf97bd9c2015-10-13 19:49:41 +09003922 msg.body.scan_info.ch_list_len = u8ChnlListLen;
Leo Kim82eeb0a2015-10-13 19:49:40 +09003923 msg.body.scan_info.ch_freq_list = kmalloc(u8ChnlListLen, GFP_KERNEL);
3924 memcpy(msg.body.scan_info.ch_freq_list, pu8ChnlFreqList, u8ChnlListLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003925
Leo Kim7b1f76c2015-10-13 19:49:43 +09003926 msg.body.scan_info.ies_len = IEsLen;
Leo Kimd6f19aa2015-10-13 19:49:42 +09003927 msg.body.scan_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3928 memcpy(msg.body.scan_info.ies, pu8IEs, IEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003929
Leo Kim31390ee2015-10-19 18:26:08 +09003930 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3931 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003932 PRINT_ER("Error in sending message queue\n");
3933 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003934 }
3935
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003936 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
Leo Kim13b313e2015-10-29 11:58:34 +09003937 hif_drv->scan_timer.data = (unsigned long)hif_drv;
3938 mod_timer(&hif_drv->scan_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003939 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003940
Leo Kim31390ee2015-10-19 18:26:08 +09003941 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003942}
Leo Kimae4dfa52015-10-13 19:49:26 +09003943
Tony Choa4ab1ad2015-10-12 16:56:05 +09003944s32 hif_set_cfg(struct host_if_drv *hif_drv,
3945 struct cfg_param_val *pstrCfgParamVal)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003946{
Leo Kim31390ee2015-10-19 18:26:08 +09003947 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003948 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003949
Tony Choa4ab1ad2015-10-12 16:56:05 +09003950 if (!hif_drv) {
3951 PRINT_ER("hif_drv NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003952 return -EFAULT;
3953 }
Leo Kimae4dfa52015-10-13 19:49:26 +09003954
Tony Cho143eb952015-09-21 12:16:32 +09003955 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003956 msg.id = HOST_IF_MSG_CFG_PARAMS;
Tony Cho221371e2015-10-12 16:56:06 +09003957 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003958 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003959
Leo Kim31390ee2015-10-19 18:26:08 +09003960 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003961
Leo Kim31390ee2015-10-19 18:26:08 +09003962 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003963}
3964
Tony Choa4ab1ad2015-10-12 16:56:05 +09003965s32 hif_get_cfg(struct host_if_drv *hif_drv, u16 u16WID, u16 *pu16WID_Value)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003966{
Leo Kim31390ee2015-10-19 18:26:08 +09003967 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003968
Leo Kim33110ad2015-10-29 11:58:27 +09003969 down(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003970
Tony Choa4ab1ad2015-10-12 16:56:05 +09003971 if (!hif_drv) {
3972 PRINT_ER("hif_drv NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003973 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003974 }
3975 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
3976 switch (u16WID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003977 case WID_BSS_TYPE:
Leo Kimace303f2015-10-29 11:58:26 +09003978 *pu16WID_Value = (u16)hif_drv->cfg_values.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003979 break;
3980
3981 case WID_AUTH_TYPE:
Leo Kimace303f2015-10-29 11:58:26 +09003982 *pu16WID_Value = (u16)hif_drv->cfg_values.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003983 break;
3984
3985 case WID_AUTH_TIMEOUT:
Leo Kimace303f2015-10-29 11:58:26 +09003986 *pu16WID_Value = hif_drv->cfg_values.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003987 break;
3988
3989 case WID_POWER_MANAGEMENT:
Leo Kimace303f2015-10-29 11:58:26 +09003990 *pu16WID_Value = (u16)hif_drv->cfg_values.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003991 break;
3992
3993 case WID_SHORT_RETRY_LIMIT:
Leo Kimace303f2015-10-29 11:58:26 +09003994 *pu16WID_Value = hif_drv->cfg_values.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003995 break;
3996
3997 case WID_LONG_RETRY_LIMIT:
Leo Kimace303f2015-10-29 11:58:26 +09003998 *pu16WID_Value = hif_drv->cfg_values.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003999 break;
4000
4001 case WID_FRAG_THRESHOLD:
Leo Kimace303f2015-10-29 11:58:26 +09004002 *pu16WID_Value = hif_drv->cfg_values.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004003 break;
4004
4005 case WID_RTS_THRESHOLD:
Leo Kimace303f2015-10-29 11:58:26 +09004006 *pu16WID_Value = hif_drv->cfg_values.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004007 break;
4008
4009 case WID_PREAMBLE:
Leo Kimace303f2015-10-29 11:58:26 +09004010 *pu16WID_Value = (u16)hif_drv->cfg_values.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004011 break;
4012
4013 case WID_SHORT_SLOT_ALLOWED:
Leo Kimace303f2015-10-29 11:58:26 +09004014 *pu16WID_Value = (u16)hif_drv->cfg_values.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004015 break;
4016
4017 case WID_11N_TXOP_PROT_DISABLE:
Leo Kimace303f2015-10-29 11:58:26 +09004018 *pu16WID_Value = (u16)hif_drv->cfg_values.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004019 break;
4020
4021 case WID_BEACON_INTERVAL:
Leo Kimace303f2015-10-29 11:58:26 +09004022 *pu16WID_Value = hif_drv->cfg_values.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004023 break;
4024
4025 case WID_DTIM_PERIOD:
Leo Kimace303f2015-10-29 11:58:26 +09004026 *pu16WID_Value = (u16)hif_drv->cfg_values.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004027 break;
4028
4029 case WID_SITE_SURVEY:
Leo Kimace303f2015-10-29 11:58:26 +09004030 *pu16WID_Value = (u16)hif_drv->cfg_values.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004031 break;
4032
4033 case WID_SITE_SURVEY_SCAN_TIME:
Leo Kimace303f2015-10-29 11:58:26 +09004034 *pu16WID_Value = hif_drv->cfg_values.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004035 break;
4036
4037 case WID_ACTIVE_SCAN_TIME:
Leo Kimace303f2015-10-29 11:58:26 +09004038 *pu16WID_Value = hif_drv->cfg_values.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004039 break;
4040
4041 case WID_PASSIVE_SCAN_TIME:
Leo Kimace303f2015-10-29 11:58:26 +09004042 *pu16WID_Value = hif_drv->cfg_values.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004043 break;
4044
4045 case WID_CURRENT_TX_RATE:
Leo Kimace303f2015-10-29 11:58:26 +09004046 *pu16WID_Value = hif_drv->cfg_values.curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004047 break;
4048
4049 default:
4050 break;
4051 }
4052
Leo Kim33110ad2015-10-29 11:58:27 +09004053 up(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004054
Leo Kim31390ee2015-10-19 18:26:08 +09004055 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004056}
4057
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004058static void GetPeriodicRSSI(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004059{
Tony Choa4ab1ad2015-10-12 16:56:05 +09004060 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004061
Tony Choa4ab1ad2015-10-12 16:56:05 +09004062 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004063 PRINT_ER("Driver handler is NULL\n");
4064 return;
4065 }
4066
Leo Kimb60005a2015-10-29 11:58:24 +09004067 if (hif_drv->hif_state == HOST_IF_CONNECTED) {
Leo Kim31390ee2015-10-19 18:26:08 +09004068 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004069 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004070
Tony Cho143eb952015-09-21 12:16:32 +09004071 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004072
Tony Choa9f812a2015-09-21 12:16:33 +09004073 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004074 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004075
Leo Kim31390ee2015-10-19 18:26:08 +09004076 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4077 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004078 PRINT_ER("Failed to send get host channel param's message queue ");
4079 return;
4080 }
4081 }
Leo Kim262f55e2015-10-15 13:24:58 +09004082 periodic_rssi.data = (unsigned long)hif_drv;
4083 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004084}
4085
Glen Leed53822192015-10-27 18:27:49 +09004086s32 host_int_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004087{
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004088 s32 result = 0;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004089 struct host_if_drv *hif_drv;
Johnny Kimd42ab082015-08-20 16:32:52 +09004090 int err;
Glen Leed53822192015-10-27 18:27:49 +09004091 perInterface_wlan_t *nic;
4092 struct wilc *wilc;
4093
4094 nic = netdev_priv(dev);
4095 wilc = nic->wilc;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004096
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004097 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
4098
Leo Kimca8540e42015-10-15 13:25:00 +09004099 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004100
Leo Kim2d25af82015-10-15 13:24:56 +09004101 sema_init(&hif_sema_wait_response, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004102
Tony Choa4ab1ad2015-10-12 16:56:05 +09004103 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
4104 if (!hif_drv) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004105 result = -ENOMEM;
Vincent Stehlé17db84e2015-10-07 07:08:25 +02004106 goto _fail_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004107 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09004108 *hif_drv_handler = hif_drv;
4109 err = add_handler_in_list(hif_drv);
Johnny Kimd42ab082015-08-20 16:32:52 +09004110 if (err) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004111 result = -EFAULT;
Johnny Kimd42ab082015-08-20 16:32:52 +09004112 goto _fail_timer_2;
4113 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004114
Dean Lee72ed4dc2015-06-12 14:11:44 +09004115 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004116
Tony Choa4ab1ad2015-10-12 16:56:05 +09004117 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004118 if (clients_count == 0) {
Leo Kim834e0cb2015-10-15 13:24:54 +09004119 sema_init(&hif_sema_thread, 0);
Leo Kim27ff2162015-10-15 13:24:55 +09004120 sema_init(&hif_sema_driver, 0);
Leo Kim440e89932015-10-15 13:24:57 +09004121 sema_init(&hif_sema_deinit, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004122 }
4123
Leo Kim9ea47132015-10-29 11:58:28 +09004124 sema_init(&hif_drv->sem_test_key_block, 0);
Leo Kime55e4962015-10-29 11:58:29 +09004125 sema_init(&hif_drv->sem_test_disconn_block, 0);
Leo Kim7e111f92015-10-29 11:58:30 +09004126 sema_init(&hif_drv->sem_get_rssi, 0);
Leo Kimbc34da62015-10-29 11:58:31 +09004127 sema_init(&hif_drv->sem_get_link_speed, 0);
Leo Kim4ea90002015-10-29 11:58:32 +09004128 sema_init(&hif_drv->sem_get_chnl, 0);
Leo Kim569a3c62015-10-29 11:58:33 +09004129 sema_init(&hif_drv->sem_inactive_time, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004130
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004131 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
4132
4133 if (clients_count == 0) {
Leo Kimcb067dc2015-10-15 13:24:53 +09004134 result = wilc_mq_create(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004135
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004136 if (result < 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004137 PRINT_ER("Failed to creat MQ\n");
4138 goto _fail_;
4139 }
Leo Kimc2115d82015-10-15 13:24:52 +09004140
Glen Leed53822192015-10-27 18:27:49 +09004141 hif_thread_handler = kthread_run(hostIFthread, wilc,
4142 "WILC_kthread");
Leo Kimc2115d82015-10-15 13:24:52 +09004143
4144 if (IS_ERR(hif_thread_handler)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004145 PRINT_ER("Failed to creat Thread\n");
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004146 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004147 goto _fail_mq_;
4148 }
Leo Kim262f55e2015-10-15 13:24:58 +09004149 setup_timer(&periodic_rssi, GetPeriodicRSSI,
Tony Choa4ab1ad2015-10-12 16:56:05 +09004150 (unsigned long)hif_drv);
Leo Kim262f55e2015-10-15 13:24:58 +09004151 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004152 }
4153
Leo Kim13b313e2015-10-29 11:58:34 +09004154 setup_timer(&hif_drv->scan_timer, TimerCB_Scan, 0);
Leo Kim81a59502015-10-29 11:58:35 +09004155 setup_timer(&hif_drv->connect_timer, TimerCB_Connect, 0);
Leo Kimcc2d7e92015-10-29 11:58:36 +09004156 setup_timer(&hif_drv->remain_on_ch_timer, ListenTimerCB, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004157
Leo Kim33110ad2015-10-29 11:58:27 +09004158 sema_init(&hif_drv->sem_cfg_values, 1);
4159 down(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004160
Leo Kimb60005a2015-10-29 11:58:24 +09004161 hif_drv->hif_state = HOST_IF_IDLE;
Leo Kimace303f2015-10-29 11:58:26 +09004162 hif_drv->cfg_values.site_survey_enabled = SITE_SURVEY_OFF;
4163 hif_drv->cfg_values.scan_source = DEFAULT_SCAN;
4164 hif_drv->cfg_values.active_scan_time = ACTIVE_SCAN_TIME;
4165 hif_drv->cfg_values.passive_scan_time = PASSIVE_SCAN_TIME;
4166 hif_drv->cfg_values.curr_tx_rate = AUTORATE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004167
Leo Kim1229b1a2015-10-29 12:05:39 +09004168 hif_drv->p2p_timeout = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004169
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004170 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 +09004171 hif_drv->cfg_values.site_survey_enabled,
4172 hif_drv->cfg_values.scan_source,
4173 hif_drv->cfg_values.active_scan_time,
4174 hif_drv->cfg_values.passive_scan_time,
4175 hif_drv->cfg_values.curr_tx_rate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004176
Leo Kim33110ad2015-10-29 11:58:27 +09004177 up(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004178
Leo Kimae4dfa52015-10-13 19:49:26 +09004179 clients_count++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004180
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004181 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004182
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004183_fail_timer_2:
Leo Kim33110ad2015-10-29 11:58:27 +09004184 up(&hif_drv->sem_cfg_values);
Leo Kim81a59502015-10-29 11:58:35 +09004185 del_timer_sync(&hif_drv->connect_timer);
Leo Kim13b313e2015-10-29 11:58:34 +09004186 del_timer_sync(&hif_drv->scan_timer);
Leo Kimc2115d82015-10-15 13:24:52 +09004187 kthread_stop(hif_thread_handler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004188_fail_mq_:
Leo Kimcb067dc2015-10-15 13:24:53 +09004189 wilc_mq_destroy(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004190_fail_:
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004191 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004192}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004193
Tony Choa4ab1ad2015-10-12 16:56:05 +09004194s32 host_int_deinit(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004195{
Leo Kim31390ee2015-10-19 18:26:08 +09004196 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004197 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004198 int ret;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004199
Tony Choa4ab1ad2015-10-12 16:56:05 +09004200 if (!hif_drv) {
4201 PRINT_ER("hif_drv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004202 return 0;
4203 }
4204
Leo Kim440e89932015-10-15 13:24:57 +09004205 down(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004206
Tony Choa4ab1ad2015-10-12 16:56:05 +09004207 terminated_handle = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004208 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
4209
Leo Kim13b313e2015-10-29 11:58:34 +09004210 if (del_timer_sync(&hif_drv->scan_timer))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004211 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004212
Leo Kim81a59502015-10-29 11:58:35 +09004213 if (del_timer_sync(&hif_drv->connect_timer))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004214 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004215
Leo Kim262f55e2015-10-15 13:24:58 +09004216 if (del_timer_sync(&periodic_rssi))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004217 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004218
Leo Kimcc2d7e92015-10-29 11:58:36 +09004219 del_timer_sync(&hif_drv->remain_on_ch_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004220
Johnny Kim218dc402015-08-13 13:41:19 +09004221 host_int_set_wfi_drv_handler(NULL);
Leo Kim27ff2162015-10-15 13:24:55 +09004222 down(&hif_sema_driver);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004223
Leo Kimbc801852015-10-29 11:58:50 +09004224 if (hif_drv->usr_scan_req.scan_result) {
4225 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL,
Leo Kim66eaea32015-10-29 11:58:51 +09004226 hif_drv->usr_scan_req.arg, NULL);
Leo Kimbc801852015-10-29 11:58:50 +09004227 hif_drv->usr_scan_req.scan_result = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004228 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004229
Leo Kimb60005a2015-10-29 11:58:24 +09004230 hif_drv->hif_state = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004231
Leo Kimca8540e42015-10-15 13:25:00 +09004232 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004233
Tony Cho143eb952015-09-21 12:16:32 +09004234 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004235
4236 if (clients_count == 1) {
Leo Kim262f55e2015-10-15 13:24:58 +09004237 if (del_timer_sync(&periodic_rssi))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004238 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Leo Kim262f55e2015-10-15 13:24:58 +09004239
Tony Choa9f812a2015-09-21 12:16:33 +09004240 msg.id = HOST_IF_MSG_EXIT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004241 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004242
Leo Kim31390ee2015-10-19 18:26:08 +09004243 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4244 if (result != 0)
4245 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004246
Leo Kim834e0cb2015-10-15 13:24:54 +09004247 down(&hif_sema_thread);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004248
Leo Kimcb067dc2015-10-15 13:24:53 +09004249 wilc_mq_destroy(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004250 }
4251
Leo Kim33110ad2015-10-29 11:58:27 +09004252 down(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004253
Tony Choa4ab1ad2015-10-12 16:56:05 +09004254 ret = remove_handler_in_list(hif_drv);
Johnny Kimd42ab082015-08-20 16:32:52 +09004255 if (ret)
Leo Kim31390ee2015-10-19 18:26:08 +09004256 result = -ENOENT;
Johnny Kimd42ab082015-08-20 16:32:52 +09004257
Tony Choa4ab1ad2015-10-12 16:56:05 +09004258 kfree(hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004259
Leo Kimae4dfa52015-10-13 19:49:26 +09004260 clients_count--;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09004261 terminated_handle = NULL;
Leo Kim440e89932015-10-15 13:24:57 +09004262 up(&hif_sema_deinit);
Leo Kim31390ee2015-10-19 18:26:08 +09004263 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004264}
4265
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004266void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004267{
Leo Kim31390ee2015-10-19 18:26:08 +09004268 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004269 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004270 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004271 struct host_if_drv *hif_drv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004272
Johnny Kimd42ab082015-08-20 16:32:52 +09004273 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09004274 hif_drv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004275
Tony Choa4ab1ad2015-10-12 16:56:05 +09004276 if (!hif_drv || hif_drv == terminated_handle) {
4277 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004278 return;
4279 }
4280
Tony Cho143eb952015-09-21 12:16:32 +09004281 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004282
Tony Choa9f812a2015-09-21 12:16:33 +09004283 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004284 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004285
Leo Kim3bffac62015-10-13 20:02:11 +09004286 msg.body.net_info.len = u32Length;
Leo Kimb021b802015-10-13 20:02:10 +09004287 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4288 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004289
Leo Kim31390ee2015-10-19 18:26:08 +09004290 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4291 if (result)
4292 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004293}
4294
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004295void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004296{
Leo Kim31390ee2015-10-19 18:26:08 +09004297 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004298 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004299 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004300 struct host_if_drv *hif_drv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004301
Leo Kim440e89932015-10-15 13:24:57 +09004302 down(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004303
Johnny Kimd42ab082015-08-20 16:32:52 +09004304 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09004305 hif_drv = get_handler_from_id(id);
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004306 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004307
Tony Choa4ab1ad2015-10-12 16:56:05 +09004308 if (!hif_drv || hif_drv == terminated_handle) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004309 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
Leo Kim440e89932015-10-15 13:24:57 +09004310 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004311 return;
4312 }
4313
Leo Kim33bfb192015-10-29 11:58:56 +09004314 if (!hif_drv->usr_conn_req.conn_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004315 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
Leo Kim440e89932015-10-15 13:24:57 +09004316 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004317 return;
4318 }
4319
Tony Cho143eb952015-09-21 12:16:32 +09004320 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004321
Tony Choa9f812a2015-09-21 12:16:33 +09004322 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004323 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004324
Leo Kimf94f4882015-10-13 19:50:01 +09004325 msg.body.async_info.len = u32Length;
Leo Kim33722ac72015-10-13 19:50:00 +09004326 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4327 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004328
Leo Kim31390ee2015-10-19 18:26:08 +09004329 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4330 if (result)
4331 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004332
Leo Kim440e89932015-10-15 13:24:57 +09004333 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004334}
4335
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004336void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004337{
Leo Kim31390ee2015-10-19 18:26:08 +09004338 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004339 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004340 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004341 struct host_if_drv *hif_drv = NULL;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004342
Johnny Kimd42ab082015-08-20 16:32:52 +09004343 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09004344 hif_drv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004345
Tony Choa4ab1ad2015-10-12 16:56:05 +09004346 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004347
Tony Choa4ab1ad2015-10-12 16:56:05 +09004348 if (!hif_drv || hif_drv == terminated_handle)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004349 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004350
Leo Kimbc801852015-10-29 11:58:50 +09004351 if (hif_drv->usr_scan_req.scan_result) {
Tony Cho143eb952015-09-21 12:16:32 +09004352 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004353
Tony Choa9f812a2015-09-21 12:16:33 +09004354 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004355 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004356
Leo Kim31390ee2015-10-19 18:26:08 +09004357 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4358 if (result)
4359 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004360 }
4361
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004362 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004363}
4364
Tony Choa4ab1ad2015-10-12 16:56:05 +09004365s32 host_int_remain_on_channel(struct host_if_drv *hif_drv, u32 u32SessionID,
4366 u32 u32duration, u16 chan,
4367 wilc_remain_on_chan_expired RemainOnChanExpired,
4368 wilc_remain_on_chan_ready RemainOnChanReady,
4369 void *pvUserArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004370{
Leo Kim31390ee2015-10-19 18:26:08 +09004371 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004372 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004373
Tony Choa4ab1ad2015-10-12 16:56:05 +09004374 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004375 PRINT_ER("driver is null\n");
4376 return -EFAULT;
4377 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004378
Tony Cho143eb952015-09-21 12:16:32 +09004379 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004380
Tony Choa9f812a2015-09-21 12:16:33 +09004381 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
Leo Kim839ab702015-10-29 11:58:41 +09004382 msg.body.remain_on_ch.ch = chan;
Leo Kimbfb62ab2015-10-29 11:58:42 +09004383 msg.body.remain_on_ch.expired = RemainOnChanExpired;
Leo Kim5e5f7912015-10-29 11:58:43 +09004384 msg.body.remain_on_ch.ready = RemainOnChanReady;
Leo Kimc5cc4b12015-10-29 11:58:44 +09004385 msg.body.remain_on_ch.arg = pvUserArg;
Tony Cho070d3652015-09-30 18:55:10 +09004386 msg.body.remain_on_ch.u32duration = u32duration;
Leo Kim9d764e32015-10-29 12:05:38 +09004387 msg.body.remain_on_ch.id = u32SessionID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004388 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004389
Leo Kim31390ee2015-10-19 18:26:08 +09004390 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4391 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004392 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004393
Leo Kim31390ee2015-10-19 18:26:08 +09004394 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004395}
4396
Tony Choa4ab1ad2015-10-12 16:56:05 +09004397s32 host_int_ListenStateExpired(struct host_if_drv *hif_drv, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004398{
Leo Kim31390ee2015-10-19 18:26:08 +09004399 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004400 struct host_if_msg msg;
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
Leo Kimcc2d7e92015-10-29 11:58:36 +09004407 del_timer(&hif_drv->remain_on_ch_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004408
Tony Cho143eb952015-09-21 12:16:32 +09004409 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09004410 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004411 msg.drv = hif_drv;
Leo Kim9d764e32015-10-29 12:05:38 +09004412 msg.body.remain_on_ch.id = u32SessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004413
Leo Kim31390ee2015-10-19 18:26:08 +09004414 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4415 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004416 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004417
Leo Kim31390ee2015-10-19 18:26:08 +09004418 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004419}
4420
Tony Choa4ab1ad2015-10-12 16:56:05 +09004421s32 host_int_frame_register(struct host_if_drv *hif_drv, u16 u16FrameType, bool bReg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004422{
Leo Kim31390ee2015-10-19 18:26:08 +09004423 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004424 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004425
Tony Choa4ab1ad2015-10-12 16:56:05 +09004426 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004427 PRINT_ER("driver is null\n");
4428 return -EFAULT;
4429 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004430
Tony Cho143eb952015-09-21 12:16:32 +09004431 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004432
Tony Choa9f812a2015-09-21 12:16:33 +09004433 msg.id = HOST_IF_MSG_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004434 switch (u16FrameType) {
4435 case ACTION:
4436 PRINT_D(HOSTINF_DBG, "ACTION\n");
Leo Kimbcb410b2015-10-29 11:58:40 +09004437 msg.body.reg_frame.reg_id = ACTION_FRM_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004438 break;
4439
4440 case PROBE_REQ:
4441 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
Leo Kimbcb410b2015-10-29 11:58:40 +09004442 msg.body.reg_frame.reg_id = PROBE_REQ_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004443 break;
4444
4445 default:
4446 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
4447 break;
4448 }
Leo Kimd5f654c2015-10-29 11:58:39 +09004449 msg.body.reg_frame.frame_type = u16FrameType;
Leo Kim6abf8682015-10-29 11:58:38 +09004450 msg.body.reg_frame.reg = bReg;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004451 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004452
Leo Kim31390ee2015-10-19 18:26:08 +09004453 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4454 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004455 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004456
Leo Kim31390ee2015-10-19 18:26:08 +09004457 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004458}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004459
Tony Choa4ab1ad2015-10-12 16:56:05 +09004460s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
4461 u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head,
4462 u32 u32TailLen, u8 *pu8Tail)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004463{
Leo Kim31390ee2015-10-19 18:26:08 +09004464 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004465 struct host_if_msg msg;
Tony Choa98491e2015-09-30 18:44:31 +09004466 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004467
Tony Choa4ab1ad2015-10-12 16:56:05 +09004468 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004469 PRINT_ER("driver is null\n");
4470 return -EFAULT;
4471 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004472
Tony Cho143eb952015-09-21 12:16:32 +09004473 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004474
4475 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
4476
Tony Choa9f812a2015-09-21 12:16:33 +09004477 msg.id = HOST_IF_MSG_ADD_BEACON;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004478 msg.drv = hif_drv;
Leo Kim12262dd2015-10-13 19:50:03 +09004479 pstrSetBeaconParam->interval = u32Interval;
Leo Kime76ab772015-10-13 19:50:04 +09004480 pstrSetBeaconParam->dtim_period = u32DTIMPeriod;
Leo Kim51c66182015-10-13 19:50:05 +09004481 pstrSetBeaconParam->head_len = u32HeadLen;
Shraddha Barke543f5b12015-10-16 10:47:11 +05304482 pstrSetBeaconParam->head = kmemdup(pu8Head, u32HeadLen, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09004483 if (!pstrSetBeaconParam->head) {
Leo Kim31390ee2015-10-19 18:26:08 +09004484 result = -ENOMEM;
Leo Kim24db7132015-09-16 18:36:01 +09004485 goto ERRORHANDLER;
4486 }
Leo Kim030c57e2015-10-13 19:50:07 +09004487 pstrSetBeaconParam->tail_len = u32TailLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004488
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004489 if (u32TailLen > 0) {
Shraddha Barke543f5b12015-10-16 10:47:11 +05304490 pstrSetBeaconParam->tail = kmemdup(pu8Tail, u32TailLen,
4491 GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09004492 if (!pstrSetBeaconParam->tail) {
Leo Kim31390ee2015-10-19 18:26:08 +09004493 result = -ENOMEM;
Leo Kim24db7132015-09-16 18:36:01 +09004494 goto ERRORHANDLER;
4495 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004496 } else {
Leo Kim7dbcb6d32015-10-13 19:50:08 +09004497 pstrSetBeaconParam->tail = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004498 }
4499
Leo Kim31390ee2015-10-19 18:26:08 +09004500 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4501 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004502 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004503
Leo Kim24db7132015-09-16 18:36:01 +09004504ERRORHANDLER:
Leo Kim31390ee2015-10-19 18:26:08 +09004505 if (result) {
Shraddha Barke95f840f2015-10-14 07:29:19 +05304506 kfree(pstrSetBeaconParam->head);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004507
Shraddha Barke95f840f2015-10-14 07:29:19 +05304508 kfree(pstrSetBeaconParam->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004509 }
4510
Leo Kim31390ee2015-10-19 18:26:08 +09004511 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004512}
4513
Chaehyun Lim0a5298c2015-11-06 19:11:10 +09004514int host_int_del_beacon(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004515{
Chaehyun Lim0a5298c2015-11-06 19:11:10 +09004516 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004517 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004518
Tony Choa4ab1ad2015-10-12 16:56:05 +09004519 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004520 PRINT_ER("driver is null\n");
4521 return -EFAULT;
4522 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004523
Tony Choa9f812a2015-09-21 12:16:33 +09004524 msg.id = HOST_IF_MSG_DEL_BEACON;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004525 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004526 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
4527
Leo Kim31390ee2015-10-19 18:26:08 +09004528 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4529 if (result)
Leo Kim7dc1d0c2015-09-16 18:36:00 +09004530 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004531
Leo Kim31390ee2015-10-19 18:26:08 +09004532 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004533}
4534
Chaehyun Lim18cfbd32015-11-06 19:11:16 +09004535int host_int_add_station(struct host_if_drv *hif_drv,
Chaehyun Lime3378542015-11-06 19:11:18 +09004536 struct add_sta_param *sta_param)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004537{
Chaehyun Lim18cfbd32015-11-06 19:11:16 +09004538 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004539 struct host_if_msg msg;
Chaehyun Lim773e02e2015-11-06 19:11:19 +09004540 struct add_sta_param *add_sta_info = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004541
Tony Choa4ab1ad2015-10-12 16:56:05 +09004542 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004543 PRINT_ER("driver is null\n");
4544 return -EFAULT;
4545 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004546
Tony Cho143eb952015-09-21 12:16:32 +09004547 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004548
4549 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
4550
Tony Choa9f812a2015-09-21 12:16:33 +09004551 msg.id = HOST_IF_MSG_ADD_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004552 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004553
Chaehyun Lim773e02e2015-11-06 19:11:19 +09004554 memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
4555 if (add_sta_info->rates_len > 0) {
Chaehyun Lim90623052015-11-06 19:11:21 +09004556 add_sta_info->rates = kmemdup(sta_param->rates,
4557 add_sta_info->rates_len,
4558 GFP_KERNEL);
4559 if (!add_sta_info->rates)
Leo Kim7ae43362015-09-16 18:35:59 +09004560 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004561 }
4562
Leo Kim31390ee2015-10-19 18:26:08 +09004563 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4564 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004565 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004566 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004567}
4568
Chaehyun Limc9c4eb42015-11-06 19:11:14 +09004569int host_int_del_station(struct host_if_drv *hif_drv, const u8 *mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004570{
Chaehyun Lim79a0c0a2015-11-06 19:11:12 +09004571 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004572 struct host_if_msg msg;
Chaehyun Limc87fbed2015-11-06 19:11:15 +09004573 struct del_sta *del_sta_info = &msg.body.del_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004574
Tony Choa4ab1ad2015-10-12 16:56:05 +09004575 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004576 PRINT_ER("driver is null\n");
4577 return -EFAULT;
4578 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004579
Tony Cho143eb952015-09-21 12:16:32 +09004580 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004581
4582 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
4583
Tony Choa9f812a2015-09-21 12:16:33 +09004584 msg.id = HOST_IF_MSG_DEL_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004585 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004586
Chaehyun Limc9c4eb42015-11-06 19:11:14 +09004587 if (!mac_addr)
Chaehyun Limc87fbed2015-11-06 19:11:15 +09004588 eth_broadcast_addr(del_sta_info->mac_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004589 else
Chaehyun Limc87fbed2015-11-06 19:11:15 +09004590 memcpy(del_sta_info->mac_addr, mac_addr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004591
Leo Kim31390ee2015-10-19 18:26:08 +09004592 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4593 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004594 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004595 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004596}
Leo Kimae4dfa52015-10-13 19:49:26 +09004597
Tony Choa4ab1ad2015-10-12 16:56:05 +09004598s32 host_int_del_allstation(struct host_if_drv *hif_drv,
Leo Kim441dc602015-10-12 16:55:35 +09004599 u8 pu8MacAddr[][ETH_ALEN])
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004600{
Leo Kim31390ee2015-10-19 18:26:08 +09004601 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004602 struct host_if_msg msg;
Tony Chob0c1e802015-10-05 13:50:46 +09004603 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004604 u8 au8Zero_Buff[ETH_ALEN] = {0};
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004605 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004606 u8 u8AssocNumb = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004607
Tony Choa4ab1ad2015-10-12 16:56:05 +09004608 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004609 PRINT_ER("driver is null\n");
4610 return -EFAULT;
4611 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004612
Tony Cho143eb952015-09-21 12:16:32 +09004613 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004614
4615 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
4616
Tony Choa9f812a2015-09-21 12:16:33 +09004617 msg.id = HOST_IF_MSG_DEL_ALL_STA;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004618 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004619
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004620 for (i = 0; i < MAX_NUM_STA; i++) {
4621 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
Leo Kime51b9212015-10-13 19:50:09 +09004622 memcpy(pstrDelAllStationMsg->del_all_sta[i], pu8MacAddr[i], ETH_ALEN);
4623 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
4624 pstrDelAllStationMsg->del_all_sta[i][0],
4625 pstrDelAllStationMsg->del_all_sta[i][1],
4626 pstrDelAllStationMsg->del_all_sta[i][2],
4627 pstrDelAllStationMsg->del_all_sta[i][3],
4628 pstrDelAllStationMsg->del_all_sta[i][4],
4629 pstrDelAllStationMsg->del_all_sta[i][5]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004630 u8AssocNumb++;
4631 }
4632 }
4633 if (!u8AssocNumb) {
4634 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004635 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004636 }
4637
Leo Kim8ba18032015-10-13 19:50:10 +09004638 pstrDelAllStationMsg->assoc_sta = u8AssocNumb;
Leo Kim31390ee2015-10-19 18:26:08 +09004639 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004640
Leo Kim31390ee2015-10-19 18:26:08 +09004641 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004642 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004643
Leo Kim2d25af82015-10-15 13:24:56 +09004644 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004645
Leo Kim31390ee2015-10-19 18:26:08 +09004646 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004647}
4648
Tony Choa4ab1ad2015-10-12 16:56:05 +09004649s32 host_int_edit_station(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09004650 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004651{
Leo Kim31390ee2015-10-19 18:26:08 +09004652 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004653 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09004654 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004655
Tony Choa4ab1ad2015-10-12 16:56:05 +09004656 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004657 PRINT_ER("driver is null\n");
4658 return -EFAULT;
4659 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004660
4661 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
4662
Tony Cho143eb952015-09-21 12:16:32 +09004663 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004664
Tony Choa9f812a2015-09-21 12:16:33 +09004665 msg.id = HOST_IF_MSG_EDIT_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004666 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004667
Tony Cho6a89ba92015-09-21 12:16:46 +09004668 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Leo Kime7342232015-10-29 12:05:43 +09004669 if (pstrAddStationMsg->rates_len > 0) {
4670 u8 *rates = kmalloc(pstrAddStationMsg->rates_len, GFP_KERNEL);
Leo Kimc09389a2015-10-28 15:59:24 +09004671
Leo Kim7ae43362015-09-16 18:35:59 +09004672 if (!rates)
4673 return -ENOMEM;
4674
Leo Kima622e012015-10-29 12:05:44 +09004675 memcpy(rates, pstrStaParams->rates,
Leo Kime7342232015-10-29 12:05:43 +09004676 pstrAddStationMsg->rates_len);
Leo Kima622e012015-10-29 12:05:44 +09004677 pstrAddStationMsg->rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004678 }
4679
Leo Kim31390ee2015-10-19 18:26:08 +09004680 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4681 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004682 PRINT_ER("wilc_mq_send fail\n");
4683
Leo Kim31390ee2015-10-19 18:26:08 +09004684 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004685}
Glen Lee108b3432015-09-16 18:53:20 +09004686
Tony Choa4ab1ad2015-10-12 16:56:05 +09004687s32 host_int_set_power_mgmt(struct host_if_drv *hif_drv,
4688 bool bIsEnabled,
4689 u32 u32Timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004690{
Leo Kim31390ee2015-10-19 18:26:08 +09004691 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004692 struct host_if_msg msg;
Tony Cho49e1f812015-09-30 18:44:36 +09004693 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004694
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004695 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004696
Tony Choa4ab1ad2015-10-12 16:56:05 +09004697 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004698 PRINT_ER("driver is null\n");
4699 return -EFAULT;
4700 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004701
4702 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
4703
Tony Cho143eb952015-09-21 12:16:32 +09004704 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004705
Tony Choa9f812a2015-09-21 12:16:33 +09004706 msg.id = HOST_IF_MSG_POWER_MGMT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004707 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004708
Leo Kim33c70c12015-10-13 20:02:07 +09004709 pstrPowerMgmtParam->enabled = bIsEnabled;
Leo Kim937918f2015-10-13 20:02:08 +09004710 pstrPowerMgmtParam->timeout = u32Timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004711
Leo Kim31390ee2015-10-19 18:26:08 +09004712 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4713 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004714 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004715 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004716}
4717
Tony Choa4ab1ad2015-10-12 16:56:05 +09004718s32 host_int_setup_multicast_filter(struct host_if_drv *hif_drv,
4719 bool bIsEnabled,
4720 u32 u32count)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004721{
Leo Kim31390ee2015-10-19 18:26:08 +09004722 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004723 struct host_if_msg msg;
Tony Choa079cf4d2015-09-30 18:55:05 +09004724 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004725
Tony Choa4ab1ad2015-10-12 16:56:05 +09004726 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004727 PRINT_ER("driver is null\n");
4728 return -EFAULT;
4729 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004730
4731 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
4732
Tony Cho143eb952015-09-21 12:16:32 +09004733 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004734
Tony Choa9f812a2015-09-21 12:16:33 +09004735 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004736 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004737
Leo Kimbae636eb2015-10-13 20:02:04 +09004738 pstrMulticastFilterParam->enabled = bIsEnabled;
Leo Kimadab2f72015-10-13 20:02:05 +09004739 pstrMulticastFilterParam->cnt = u32count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004740
Leo Kim31390ee2015-10-19 18:26:08 +09004741 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4742 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004743 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004744 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004745}
4746
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004747static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
4748{
Leo Kime0a12212015-10-12 16:55:49 +09004749 struct join_bss_param *pNewJoinBssParam = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004750 u8 *pu8IEs;
Chaehyun Limd85f5322015-06-11 14:35:54 +09004751 u16 u16IEsLen;
4752 u16 index = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004753 u8 suppRatesNo = 0;
4754 u8 extSuppRatesNo;
Chaehyun Limd85f5322015-06-11 14:35:54 +09004755 u16 jumpOffset;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004756 u8 pcipherCount;
4757 u8 authCount;
4758 u8 pcipherTotalCount = 0;
4759 u8 authTotalCount = 0;
4760 u8 i, j;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004761
4762 pu8IEs = ptstrNetworkInfo->pu8IEs;
4763 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4764
Shraddha Barkeb156f1e2015-10-13 23:07:00 +05304765 pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09004766 if (pNewJoinBssParam) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004767 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4768 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
4769 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004770 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004771 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
Leo Kim619d27b2015-10-15 13:24:42 +09004772 pNewJoinBssParam->ssid_len = ptstrNetworkInfo->u8SsidLen;
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004773 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4774 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004775
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004776 while (index < u16IEsLen) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004777 if (pu8IEs[index] == SUPP_RATES_IE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004778 suppRatesNo = pu8IEs[index + 1];
4779 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
Leo Kimae4dfa52015-10-13 19:49:26 +09004780 index += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004781
Leo Kimd1666e22015-10-28 15:59:22 +09004782 for (i = 0; i < suppRatesNo; i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004783 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
Leo Kimd1666e22015-10-28 15:59:22 +09004784
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004785 index += suppRatesNo;
4786 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004787 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004788 extSuppRatesNo = pu8IEs[index + 1];
4789 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4790 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4791 else
4792 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4793 index += 2;
Leo Kimd1666e22015-10-28 15:59:22 +09004794 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004795 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
Leo Kimd1666e22015-10-28 15:59:22 +09004796
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004797 index += extSuppRatesNo;
4798 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004799 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004800 pNewJoinBssParam->ht_capable = true;
Leo Kimae4dfa52015-10-13 19:49:26 +09004801 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004802 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004803 } else if ((pu8IEs[index] == WMM_IE) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004804 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
Leo Kimae4dfa52015-10-13 19:49:26 +09004805 (pu8IEs[index + 4] == 0xF2) &&
4806 (pu8IEs[index + 5] == 0x02) &&
4807 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004808 (pu8IEs[index + 7] == 0x01)) {
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004809 pNewJoinBssParam->wmm_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004810
Anish Bhattffda2032015-09-29 12:15:49 -07004811 if (pu8IEs[index + 8] & BIT(7))
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004812 pNewJoinBssParam->uapsd_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004813 index += pu8IEs[index + 1] + 2;
4814 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004815 } else if ((pu8IEs[index] == P2P_IE) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004816 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
Leo Kimae4dfa52015-10-13 19:49:26 +09004817 (pu8IEs[index + 4] == 0x9a) &&
4818 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09004819 u16 u16P2P_count;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004820
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004821 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
Leo Kim7a8d51d2015-10-15 13:24:43 +09004822 pNewJoinBssParam->noa_enabled = 1;
Leo Kimcc179002015-10-15 13:24:47 +09004823 pNewJoinBssParam->idx = pu8IEs[index + 9];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004824
Anish Bhattffda2032015-09-29 12:15:49 -07004825 if (pu8IEs[index + 10] & BIT(7)) {
Leo Kimd72b33c2015-10-15 13:24:44 +09004826 pNewJoinBssParam->opp_enabled = 1;
Leo Kim99b66942015-10-15 13:24:45 +09004827 pNewJoinBssParam->ct_window = pu8IEs[index + 10];
Leo Kimd72b33c2015-10-15 13:24:44 +09004828 } else {
4829 pNewJoinBssParam->opp_enabled = 0;
4830 }
Leo Kimae4dfa52015-10-13 19:49:26 +09004831
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004832 PRINT_D(GENERIC_DBG, "P2P Dump\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004833 for (i = 0; i < pu8IEs[index + 7]; i++)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004834 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004835
Leo Kimc21047e2015-10-15 13:24:46 +09004836 pNewJoinBssParam->cnt = pu8IEs[index + 11];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004837 u16P2P_count = index + 12;
4838
Leo Kim109e6ca2015-10-15 13:24:48 +09004839 memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004840 u16P2P_count += 4;
4841
Leo Kim1d8b76b2015-10-15 13:24:49 +09004842 memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004843 u16P2P_count += 4;
4844
Leo Kim4be55e22015-10-28 15:59:27 +09004845 memcpy(pNewJoinBssParam->start_time, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004846
4847 index += pu8IEs[index + 1] + 2;
4848 continue;
4849
Leo Kimae4dfa52015-10-13 19:49:26 +09004850 } else if ((pu8IEs[index] == RSN_IE) ||
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004851 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
4852 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
4853 (pu8IEs[index + 5] == 0x01))) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09004854 u16 rsnIndex = index;
Leo Kimae4dfa52015-10-13 19:49:26 +09004855
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004856 if (pu8IEs[rsnIndex] == RSN_IE) {
4857 pNewJoinBssParam->mode_802_11i = 2;
Leo Kimae4dfa52015-10-13 19:49:26 +09004858 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004859 if (pNewJoinBssParam->mode_802_11i == 0)
4860 pNewJoinBssParam->mode_802_11i = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004861 rsnIndex += 4;
4862 }
Leo Kimae4dfa52015-10-13 19:49:26 +09004863
4864 rsnIndex += 7;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004865 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
4866 rsnIndex++;
Leo Kimae4dfa52015-10-13 19:49:26 +09004867 jumpOffset = pu8IEs[rsnIndex] * 4;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004868 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
Leo Kimae4dfa52015-10-13 19:49:26 +09004869 rsnIndex += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004870
Leo Kimd1666e22015-10-28 15:59:22 +09004871 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004872 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
Leo Kimd1666e22015-10-28 15:59:22 +09004873
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004874 pcipherTotalCount += pcipherCount;
4875 rsnIndex += jumpOffset;
4876
4877 jumpOffset = pu8IEs[rsnIndex] * 4;
4878
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004879 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
Leo Kimae4dfa52015-10-13 19:49:26 +09004880 rsnIndex += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004881
Leo Kimd1666e22015-10-28 15:59:22 +09004882 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004883 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
Leo Kimd1666e22015-10-28 15:59:22 +09004884
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004885 authTotalCount += authCount;
4886 rsnIndex += jumpOffset;
Leo Kimae4dfa52015-10-13 19:49:26 +09004887
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004888 if (pu8IEs[index] == RSN_IE) {
4889 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
4890 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
4891 rsnIndex += 2;
4892 }
Abdul Hussainf717c0eb2015-06-16 09:49:49 +00004893 pNewJoinBssParam->rsn_found = true;
Leo Kimae4dfa52015-10-13 19:49:26 +09004894 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004895 continue;
4896 } else
Leo Kimae4dfa52015-10-13 19:49:26 +09004897 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004898 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004899 }
4900
4901 return (void *)pNewJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004902}
4903
4904void host_int_freeJoinParams(void *pJoinParams)
4905{
Leo Kim91109e12015-10-19 18:26:13 +09004906 if ((struct bss_param *)pJoinParams)
Leo Kime0a12212015-10-12 16:55:49 +09004907 kfree((struct bss_param *)pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004908 else
4909 PRINT_ER("Unable to FREE null pointer\n");
4910}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004911
Tony Choa4ab1ad2015-10-12 16:56:05 +09004912s32 host_int_delBASession(struct host_if_drv *hif_drv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004913{
Leo Kim31390ee2015-10-19 18:26:08 +09004914 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004915 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09004916 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004917
Tony Choa4ab1ad2015-10-12 16:56:05 +09004918 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004919 PRINT_ER("driver is null\n");
4920 return -EFAULT;
4921 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004922
Tony Cho143eb952015-09-21 12:16:32 +09004923 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004924
Tony Choa9f812a2015-09-21 12:16:33 +09004925 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004926
Leo Kim3fc49992015-10-29 11:58:45 +09004927 memcpy(pBASessionInfo->bssid, pBSSID, ETH_ALEN);
Leo Kim16c9b392015-10-29 11:58:46 +09004928 pBASessionInfo->tid = TID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004929 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004930
Leo Kim31390ee2015-10-19 18:26:08 +09004931 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4932 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004933 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004934
Leo Kim2d25af82015-10-15 13:24:56 +09004935 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004936
Leo Kim31390ee2015-10-19 18:26:08 +09004937 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004938}
4939
Tony Choa4ab1ad2015-10-12 16:56:05 +09004940s32 host_int_del_All_Rx_BASession(struct host_if_drv *hif_drv,
4941 char *pBSSID,
4942 char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004943{
Leo Kim31390ee2015-10-19 18:26:08 +09004944 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004945 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09004946 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004947
Tony Choa4ab1ad2015-10-12 16:56:05 +09004948 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004949 PRINT_ER("driver is null\n");
4950 return -EFAULT;
4951 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004952
Tony Cho143eb952015-09-21 12:16:32 +09004953 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004954
Tony Choa9f812a2015-09-21 12:16:33 +09004955 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004956
Leo Kim3fc49992015-10-29 11:58:45 +09004957 memcpy(pBASessionInfo->bssid, pBSSID, ETH_ALEN);
Leo Kim16c9b392015-10-29 11:58:46 +09004958 pBASessionInfo->tid = TID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004959 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004960
Leo Kim31390ee2015-10-19 18:26:08 +09004961 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4962 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004963 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004964
Leo Kim2d25af82015-10-15 13:24:56 +09004965 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004966
Leo Kim31390ee2015-10-19 18:26:08 +09004967 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004968}
4969
Tony Choa4ab1ad2015-10-12 16:56:05 +09004970s32 host_int_setup_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004971{
Leo Kim31390ee2015-10-19 18:26:08 +09004972 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004973 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004974
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004975 return 0;
4976
Tony Choa4ab1ad2015-10-12 16:56:05 +09004977 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004978 PRINT_ER("driver is null\n");
4979 return -EFAULT;
4980 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004981
Tony Cho143eb952015-09-21 12:16:32 +09004982 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004983
Tony Choa9f812a2015-09-21 12:16:33 +09004984 msg.id = HOST_IF_MSG_SET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004985
Leo Kim78675be2015-10-13 20:02:09 +09004986 msg.body.ip_info.ip_addr = u16ipadd;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004987 msg.drv = hif_drv;
Tony Chofb2d65e2015-09-30 18:44:39 +09004988 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004989
Leo Kim31390ee2015-10-19 18:26:08 +09004990 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4991 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004992 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004993
Leo Kim31390ee2015-10-19 18:26:08 +09004994 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004995}
4996
Tony Choa4ab1ad2015-10-12 16:56:05 +09004997s32 host_int_get_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004998{
Leo Kim31390ee2015-10-19 18:26:08 +09004999 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005000 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005001
Tony Choa4ab1ad2015-10-12 16:56:05 +09005002 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005003 PRINT_ER("driver is null\n");
5004 return -EFAULT;
5005 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005006
Tony Cho143eb952015-09-21 12:16:32 +09005007 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005008
Tony Choa9f812a2015-09-21 12:16:33 +09005009 msg.id = HOST_IF_MSG_GET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005010
Leo Kim78675be2015-10-13 20:02:09 +09005011 msg.body.ip_info.ip_addr = u16ipadd;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005012 msg.drv = hif_drv;
Tony Chofb2d65e2015-09-30 18:44:39 +09005013 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005014
Leo Kim31390ee2015-10-19 18:26:08 +09005015 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5016 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09005017 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005018
Leo Kim31390ee2015-10-19 18:26:08 +09005019 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005020}