blob: cce95177b515a118b20f04854ccd94d821d7fbb8 [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
Tony Choa4ab1ad2015-10-12 16:56:05 +09003210s32 host_int_add_ptk(struct host_if_drv *hif_drv, const u8 *pu8Ptk,
3211 u8 u8PtkKeylen, const u8 *mac_addr,
3212 const u8 *pu8RxMic, const u8 *pu8TxMic,
3213 u8 mode, u8 u8Ciphermode, u8 u8Idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003214{
Leo Kim31390ee2015-10-19 18:26:08 +09003215 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003216 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003217 u8 u8KeyLen = u8PtkKeylen;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003218 u32 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
3225 if (pu8RxMic)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003226 u8KeyLen += RX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003227
3228 if (pu8TxMic)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003229 u8KeyLen += 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;
Leo Kime2dfbac2015-10-13 19:49:34 +09003237 msg.body.key_info.attr.wpa.index = u8Idx;
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
Leo Kim124968fc2015-10-13 19:49:30 +09003242 msg.body.key_info.attr.wpa.key = kmalloc(u8PtkKeylen, GFP_KERNEL);
3243 memcpy(msg.body.key_info.attr.wpa.key, pu8Ptk, u8PtkKeylen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003244
Leo Kim91109e12015-10-19 18:26:13 +09003245 if (pu8RxMic) {
Leo Kim124968fc2015-10-13 19:49:30 +09003246 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003247 if (INFO) {
3248 for (i = 0; i < RX_MIC_KEY_LEN; i++)
3249 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
3250 }
3251 }
Leo Kim91109e12015-10-19 18:26:13 +09003252 if (pu8TxMic) {
Leo Kim124968fc2015-10-13 19:49:30 +09003253 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003254 if (INFO) {
3255 for (i = 0; i < TX_MIC_KEY_LEN; i++)
3256 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
3257 }
3258 }
3259
Leo Kim6acf2912015-10-13 19:49:35 +09003260 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
Leo Kim248080a2015-10-13 19:49:31 +09003261 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
Leo Kim7b2ebb22015-10-13 19:49:36 +09003262 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003263 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003264
Leo Kim31390ee2015-10-19 18:26:08 +09003265 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003266
Leo Kim31390ee2015-10-19 18:26:08 +09003267 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003268 PRINT_ER("Error in sending message queue: PTK Key\n");
3269
Leo Kim9ea47132015-10-29 11:58:28 +09003270 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003271
Leo Kim31390ee2015-10-19 18:26:08 +09003272 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003273}
3274
Tony Choa4ab1ad2015-10-12 16:56:05 +09003275s32 host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *pu8RxGtk,
3276 u8 u8GtkKeylen, u8 u8KeyIdx,
3277 u32 u32KeyRSClen, const u8 *KeyRSC,
3278 const u8 *pu8RxMic, const u8 *pu8TxMic,
3279 u8 mode, u8 u8Ciphermode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003280{
Leo Kim31390ee2015-10-19 18:26:08 +09003281 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003282 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003283 u8 u8KeyLen = u8GtkKeylen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003284
Tony Choa4ab1ad2015-10-12 16:56:05 +09003285 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003286 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003287 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003288 }
Tony Cho143eb952015-09-21 12:16:32 +09003289 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003290
Leo Kim91109e12015-10-19 18:26:13 +09003291 if (pu8RxMic)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003292 u8KeyLen += RX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003293
3294 if (pu8TxMic)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003295 u8KeyLen += TX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003296
3297 if (KeyRSC) {
Leo Kim0e74c002015-10-13 19:49:32 +09003298 msg.body.key_info.attr.wpa.seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
3299 memcpy(msg.body.key_info.attr.wpa.seq, KeyRSC, u32KeyRSClen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003300 }
3301
Tony Choa9f812a2015-09-21 12:16:33 +09003302 msg.id = HOST_IF_MSG_KEY;
Leo Kim5cd8f7a2015-10-29 12:05:34 +09003303 msg.body.key_info.type = WPA_RX_GTK;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003304 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003305
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003306 if (mode == AP_MODE) {
Leo Kim0d17e382015-10-13 19:49:28 +09003307 msg.body.key_info.action = ADDKEY_AP;
Leo Kim7b2ebb22015-10-13 19:49:36 +09003308 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003309 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003310 if (mode == STATION_MODE)
Leo Kim0d17e382015-10-13 19:49:28 +09003311 msg.body.key_info.action = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003312
Leo Kim124968fc2015-10-13 19:49:30 +09003313 msg.body.key_info.attr.wpa.key = kmalloc(u8KeyLen, GFP_KERNEL);
3314 memcpy(msg.body.key_info.attr.wpa.key, pu8RxGtk, u8GtkKeylen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003315
Leo Kimd1666e22015-10-28 15:59:22 +09003316 if (pu8RxMic)
3317 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic,
3318 RX_MIC_KEY_LEN);
Leo Kim91109e12015-10-19 18:26:13 +09003319
Leo Kimd1666e22015-10-28 15:59:22 +09003320 if (pu8TxMic)
3321 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic,
3322 TX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003323
Leo Kime2dfbac2015-10-13 19:49:34 +09003324 msg.body.key_info.attr.wpa.index = u8KeyIdx;
Leo Kim6acf2912015-10-13 19:49:35 +09003325 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
Leo Kimdacc5942015-10-13 19:49:33 +09003326 msg.body.key_info.attr.wpa.seq_len = u32KeyRSClen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003327
Leo Kim31390ee2015-10-19 18:26:08 +09003328 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3329 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003330 PRINT_ER("Error in sending message queue: RX GTK\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09003331
Leo Kim9ea47132015-10-29 11:58:28 +09003332 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003333
Leo Kim31390ee2015-10-19 18:26:08 +09003334 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003335}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003336
Tony Choa4ab1ad2015-10-12 16:56:05 +09003337s32 host_int_set_pmkid_info(struct host_if_drv *hif_drv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003338{
Leo Kim31390ee2015-10-19 18:26:08 +09003339 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003340 struct host_if_msg msg;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003341 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003342
Tony Choa4ab1ad2015-10-12 16:56:05 +09003343 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003344 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003345 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003346 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003347
Tony Cho143eb952015-09-21 12:16:32 +09003348 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003349
Tony Choa9f812a2015-09-21 12:16:33 +09003350 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003351 msg.body.key_info.type = PMKSA;
Leo Kim0d17e382015-10-13 19:49:28 +09003352 msg.body.key_info.action = ADDKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003353 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003354
3355 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
Leo Kim8c8360b2015-10-19 18:26:12 +09003356 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid,
3357 &pu8PmkidInfoArray->pmkidlist[i].bssid, ETH_ALEN);
3358 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid,
3359 &pu8PmkidInfoArray->pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003360 }
3361
Leo Kim31390ee2015-10-19 18:26:08 +09003362 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3363 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003364 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3365
Leo Kim31390ee2015-10-19 18:26:08 +09003366 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003367}
3368
Tony Choa4ab1ad2015-10-12 16:56:05 +09003369s32 host_int_get_pmkid_info(struct host_if_drv *hif_drv,
3370 u8 *pu8PmkidInfoArray,
3371 u32 u32PmkidInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003372{
Leo Kim45102f82015-10-28 15:59:28 +09003373 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003374
Leo Kim45102f82015-10-28 15:59:28 +09003375 wid.id = (u16)WID_PMKID_INFO;
3376 wid.type = WID_STR;
3377 wid.size = u32PmkidInfoLen;
3378 wid.val = pu8PmkidInfoArray;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003379
Leo Kimb68d820b2015-10-12 16:55:37 +09003380 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003381}
3382
Tony Choa4ab1ad2015-10-12 16:56:05 +09003383s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3384 u8 *pu8PassPhrase,
3385 u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003386{
Leo Kim45102f82015-10-28 15:59:28 +09003387 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003388
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003389 if ((u8Psklength > 7) && (u8Psklength < 65)) {
Leo Kim45102f82015-10-28 15:59:28 +09003390 wid.id = (u16)WID_11I_PSK;
3391 wid.type = WID_STR;
3392 wid.val = pu8PassPhrase;
3393 wid.size = u8Psklength;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003394 }
3395
Leo Kimb68d820b2015-10-12 16:55:37 +09003396 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003397}
Leo Kimae4dfa52015-10-13 19:49:26 +09003398
Leo Kime5f35242015-11-05 14:36:36 +09003399s32 hif_get_mac_address(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003400{
Leo Kim31390ee2015-10-19 18:26:08 +09003401 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003402 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003403
Tony Cho143eb952015-09-21 12:16:32 +09003404 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003405
Tony Choa9f812a2015-09-21 12:16:33 +09003406 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
Leo Kim6ceba0a2015-10-28 15:59:32 +09003407 msg.body.get_mac_info.mac_addr = pu8MacAddress;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003408 msg.drv = hif_drv;
Leo Kimae4dfa52015-10-13 19:49:26 +09003409
Leo Kim31390ee2015-10-19 18:26:08 +09003410 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3411 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003412 PRINT_ER("Failed to send get mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +09003413 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003414 }
3415
Leo Kim2d25af82015-10-15 13:24:56 +09003416 down(&hif_sema_wait_response);
Leo Kim31390ee2015-10-19 18:26:08 +09003417 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003418}
3419
Tony Choa4ab1ad2015-10-12 16:56:05 +09003420s32 host_int_set_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003421{
Leo Kim31390ee2015-10-19 18:26:08 +09003422 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003423 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003424
3425 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
3426
Tony Cho143eb952015-09-21 12:16:32 +09003427 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003428 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
Leo Kimae5e4522015-10-28 15:59:31 +09003429 memcpy(msg.body.set_mac_info.mac_addr, pu8MacAddress, ETH_ALEN);
Tony Choa4ab1ad2015-10-12 16:56:05 +09003430 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003431
Leo Kim31390ee2015-10-19 18:26:08 +09003432 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3433 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003434 PRINT_ER("Failed to send message queue: Set mac address\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003435
Leo Kim31390ee2015-10-19 18:26:08 +09003436 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003437}
3438
Tony Choa4ab1ad2015-10-12 16:56:05 +09003439s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3440 u8 *pu8PassPhrase, u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003441{
Leo Kim45102f82015-10-28 15:59:28 +09003442 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003443
Leo Kim45102f82015-10-28 15:59:28 +09003444 wid.id = (u16)WID_11I_PSK;
3445 wid.type = WID_STR;
3446 wid.size = u8Psklength;
3447 wid.val = pu8PassPhrase;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003448
Leo Kimb68d820b2015-10-12 16:55:37 +09003449 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003450}
3451
Tony Choa4ab1ad2015-10-12 16:56:05 +09003452s32 host_int_set_start_scan_req(struct host_if_drv *hif_drv, u8 scanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003453{
Leo Kim45102f82015-10-28 15:59:28 +09003454 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003455
Leo Kim45102f82015-10-28 15:59:28 +09003456 wid.id = (u16)WID_START_SCAN_REQ;
3457 wid.type = WID_CHAR;
3458 wid.val = (s8 *)&scanSource;
3459 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003460
Leo Kimb68d820b2015-10-12 16:55:37 +09003461 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003462}
3463
Tony Choa4ab1ad2015-10-12 16:56:05 +09003464s32 host_int_get_start_scan_req(struct host_if_drv *hif_drv, u8 *pu8ScanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003465{
Leo Kim45102f82015-10-28 15:59:28 +09003466 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003467
Leo Kim45102f82015-10-28 15:59:28 +09003468 wid.id = (u16)WID_START_SCAN_REQ;
3469 wid.type = WID_CHAR;
3470 wid.val = (s8 *)pu8ScanSource;
3471 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003472
Leo Kimb68d820b2015-10-12 16:55:37 +09003473 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003474}
3475
Tony Choa4ab1ad2015-10-12 16:56:05 +09003476s32 host_int_set_join_req(struct host_if_drv *hif_drv, u8 *pu8bssid,
3477 const u8 *pu8ssid, size_t ssidLen,
3478 const u8 *pu8IEs, size_t IEsLen,
3479 wilc_connect_result pfConnectResult, void *pvUserArg,
3480 u8 u8security, enum AUTHTYPE tenuAuth_type,
3481 u8 u8channel, void *pJoinParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003482{
Leo Kim31390ee2015-10-19 18:26:08 +09003483 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003484 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003485
Leo Kim91109e12015-10-19 18:26:13 +09003486 if (!hif_drv || !pfConnectResult) {
Leo Kim24db7132015-09-16 18:36:01 +09003487 PRINT_ER("Driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003488 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003489 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003490
Leo Kim91109e12015-10-19 18:26:13 +09003491 if (!pJoinParams) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003492 PRINT_ER("Unable to Join - JoinParams is NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003493 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003494 }
Leo Kim24db7132015-09-16 18:36:01 +09003495
Tony Cho143eb952015-09-21 12:16:32 +09003496 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003497
Tony Choa9f812a2015-09-21 12:16:33 +09003498 msg.id = HOST_IF_MSG_CONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003499
Leo Kima64fd672015-10-13 19:49:54 +09003500 msg.body.con_info.security = u8security;
Leo Kim61b4fd02015-10-13 19:49:57 +09003501 msg.body.con_info.auth_type = tenuAuth_type;
Leo Kim0d1527e2015-10-13 19:49:58 +09003502 msg.body.con_info.ch = u8channel;
Leo Kim6abcc112015-10-13 19:49:55 +09003503 msg.body.con_info.result = pfConnectResult;
Leo Kim8f38db82015-10-13 19:49:56 +09003504 msg.body.con_info.arg = pvUserArg;
Leo Kimf2bed2c2015-10-13 19:49:59 +09003505 msg.body.con_info.params = pJoinParams;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003506 msg.drv = hif_drv ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003507
Leo Kim91109e12015-10-19 18:26:13 +09003508 if (pu8bssid) {
Leo Kim9254db02015-10-13 19:49:49 +09003509 msg.body.con_info.bssid = kmalloc(6, GFP_KERNEL);
3510 memcpy(msg.body.con_info.bssid, pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003511 }
3512
Leo Kim91109e12015-10-19 18:26:13 +09003513 if (pu8ssid) {
Leo Kim8b3c9fa2015-10-13 19:49:51 +09003514 msg.body.con_info.ssid_len = ssidLen;
Leo Kimf7bbd9c2015-10-13 19:49:50 +09003515 msg.body.con_info.ssid = kmalloc(ssidLen, GFP_KERNEL);
3516 memcpy(msg.body.con_info.ssid, pu8ssid, ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003517 }
3518
Leo Kim91109e12015-10-19 18:26:13 +09003519 if (pu8IEs) {
Leo Kimb59d5c52015-10-13 19:49:53 +09003520 msg.body.con_info.ies_len = IEsLen;
Leo Kim2ea158c2015-10-13 19:49:52 +09003521 msg.body.con_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3522 memcpy(msg.body.con_info.ies, pu8IEs, IEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003523 }
Leo Kimb60005a2015-10-29 11:58:24 +09003524 if (hif_drv->hif_state < HOST_IF_CONNECTING)
3525 hif_drv->hif_state = HOST_IF_CONNECTING;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05303526 else
Leo Kimb60005a2015-10-29 11:58:24 +09003527 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' : %d\n",
3528 hif_drv->hif_state);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003529
Leo Kim31390ee2015-10-19 18:26:08 +09003530 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3531 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003532 PRINT_ER("Failed to send message queue: Set join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09003533 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003534 }
3535
Leo Kim81a59502015-10-29 11:58:35 +09003536 hif_drv->connect_timer.data = (unsigned long)hif_drv;
3537 mod_timer(&hif_drv->connect_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003538 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003539
Leo Kim31390ee2015-10-19 18:26:08 +09003540 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003541}
3542
Tony Choa4ab1ad2015-10-12 16:56:05 +09003543s32 host_int_flush_join_req(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003544{
Leo Kim31390ee2015-10-19 18:26:08 +09003545 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003546 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003547
Leo Kim7717880782015-10-19 18:26:11 +09003548 if (!join_req)
3549 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003550
Tony Choa4ab1ad2015-10-12 16:56:05 +09003551 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003552 PRINT_ER("Driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003553 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003554 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003555
Tony Choa9f812a2015-09-21 12:16:33 +09003556 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003557 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003558
Leo Kim31390ee2015-10-19 18:26:08 +09003559 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3560 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003561 PRINT_ER("Failed to send message queue: Flush join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09003562 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003563 }
3564
Leo Kim31390ee2015-10-19 18:26:08 +09003565 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003566}
3567
Tony Choa4ab1ad2015-10-12 16:56:05 +09003568s32 host_int_disconnect(struct host_if_drv *hif_drv, u16 u16ReasonCode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003569{
Leo Kim31390ee2015-10-19 18:26:08 +09003570 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003571 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003572
Tony Choa4ab1ad2015-10-12 16:56:05 +09003573 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003574 PRINT_ER("Driver is null\n");
3575 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003576 }
3577
Tony Cho143eb952015-09-21 12:16:32 +09003578 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003579
Tony Choa9f812a2015-09-21 12:16:33 +09003580 msg.id = HOST_IF_MSG_DISCONNECT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003581 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003582
Leo Kim31390ee2015-10-19 18:26:08 +09003583 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3584 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003585 PRINT_ER("Failed to send message queue: disconnect\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09003586
Leo Kime55e4962015-10-29 11:58:29 +09003587 down(&hif_drv->sem_test_disconn_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003588
Leo Kim31390ee2015-10-19 18:26:08 +09003589 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003590}
3591
Tony Choa4ab1ad2015-10-12 16:56:05 +09003592s32 host_int_disconnect_station(struct host_if_drv *hif_drv, u8 assoc_id)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003593{
Leo Kim45102f82015-10-28 15:59:28 +09003594 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003595
Leo Kim45102f82015-10-28 15:59:28 +09003596 wid.id = (u16)WID_DISCONNECT;
3597 wid.type = WID_CHAR;
3598 wid.val = (s8 *)&assoc_id;
3599 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003600
Leo Kimb68d820b2015-10-12 16:55:37 +09003601 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003602}
3603
Leo Kim8c8360b2015-10-19 18:26:12 +09003604s32 host_int_get_assoc_req_info(struct host_if_drv *hif_drv,
3605 u8 *pu8AssocReqInfo,
3606 u32 u32AssocReqInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003607{
Leo Kim45102f82015-10-28 15:59:28 +09003608 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003609
Leo Kim45102f82015-10-28 15:59:28 +09003610 wid.id = (u16)WID_ASSOC_REQ_INFO;
3611 wid.type = WID_STR;
3612 wid.val = pu8AssocReqInfo;
3613 wid.size = u32AssocReqInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003614
Leo Kimb68d820b2015-10-12 16:55:37 +09003615 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003616}
3617
Leo Kim8c8360b2015-10-19 18:26:12 +09003618s32 host_int_get_assoc_res_info(struct host_if_drv *hif_drv,
3619 u8 *pu8AssocRespInfo,
3620 u32 u32MaxAssocRespInfoLen,
3621 u32 *pu32RcvdAssocRespInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003622{
Leo Kim31390ee2015-10-19 18:26:08 +09003623 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09003624 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003625
Tony Choa4ab1ad2015-10-12 16:56:05 +09003626 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003627 PRINT_ER("Driver is null\n");
3628 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003629 }
3630
Leo Kim45102f82015-10-28 15:59:28 +09003631 wid.id = (u16)WID_ASSOC_RES_INFO;
3632 wid.type = WID_STR;
3633 wid.val = pu8AssocRespInfo;
3634 wid.size = u32MaxAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003635
Leo Kim45102f82015-10-28 15:59:28 +09003636 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09003637 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09003638 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003639 *pu32RcvdAssocRespInfoLen = 0;
Leo Kim24db7132015-09-16 18:36:01 +09003640 PRINT_ER("Failed to send association response config packet\n");
3641 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003642 } else {
Leo Kim45102f82015-10-28 15:59:28 +09003643 *pu32RcvdAssocRespInfoLen = wid.size;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003644 }
3645
Leo Kim31390ee2015-10-19 18:26:08 +09003646 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003647}
3648
Leo Kim8c8360b2015-10-19 18:26:12 +09003649s32 host_int_get_rx_power_level(struct host_if_drv *hif_drv,
3650 u8 *pu8RxPowerLevel,
3651 u32 u32RxPowerLevelLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003652{
Leo Kim45102f82015-10-28 15:59:28 +09003653 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003654
Leo Kim45102f82015-10-28 15:59:28 +09003655 wid.id = (u16)WID_RX_POWER_LEVEL;
3656 wid.type = WID_STR;
3657 wid.val = pu8RxPowerLevel;
3658 wid.size = u32RxPowerLevelLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003659
Leo Kimb68d820b2015-10-12 16:55:37 +09003660 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003661}
3662
Tony Choa4ab1ad2015-10-12 16:56:05 +09003663int host_int_set_mac_chnl_num(struct host_if_drv *hif_drv, u8 channel)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003664{
Chaehyun Lim792fb252015-10-05 11:07:22 +09003665 int result;
Tony Cho143eb952015-09-21 12:16:32 +09003666 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003667
Tony Choa4ab1ad2015-10-12 16:56:05 +09003668 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003669 PRINT_ER("driver is null\n");
3670 return -EFAULT;
3671 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003672
Tony Cho143eb952015-09-21 12:16:32 +09003673 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003674 msg.id = HOST_IF_MSG_SET_CHANNEL;
Leo Kim730ee052015-10-13 19:50:02 +09003675 msg.body.channel_info.set_ch = channel;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003676 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003677
Leo Kimcb067dc2015-10-15 13:24:53 +09003678 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lim1ef58e42015-10-02 21:44:49 +09003679 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003680 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim792fb252015-10-05 11:07:22 +09003681 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003682 }
3683
Chaehyun Lim792fb252015-10-05 11:07:22 +09003684 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003685}
3686
Chaehyun Lim244efb12015-10-02 21:44:53 +09003687int host_int_wait_msg_queue_idle(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003688{
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003689 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003690 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003691
Tony Cho143eb952015-09-21 12:16:32 +09003692 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003693 msg.id = HOST_IF_MSG_Q_IDLE;
Leo Kimcb067dc2015-10-15 13:24:53 +09003694 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003695 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003696 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003697 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003698 }
3699
Leo Kim2d25af82015-10-15 13:24:56 +09003700 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003701
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003702 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003703}
3704
Tony Choa4ab1ad2015-10-12 16:56:05 +09003705int host_int_set_wfi_drv_handler(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003706{
Chaehyun Lima0941012015-10-05 19:34:47 +09003707 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003708 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003709
Tony Cho143eb952015-09-21 12:16:32 +09003710 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003711 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
Leo Kima7f3b122015-10-28 15:59:29 +09003712 msg.body.drv.handler = get_id_from_handler(hif_drv);
Tony Choa4ab1ad2015-10-12 16:56:05 +09003713 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003714
Leo Kimcb067dc2015-10-15 13:24:53 +09003715 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lima0941012015-10-05 19:34:47 +09003716 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003717 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0941012015-10-05 19:34:47 +09003718 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003719 }
3720
Chaehyun Lima0941012015-10-05 19:34:47 +09003721 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003722}
3723
Tony Choa4ab1ad2015-10-12 16:56:05 +09003724int host_int_set_operation_mode(struct host_if_drv *hif_drv, u32 mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003725{
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003726 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003727 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003728
Tony Cho143eb952015-09-21 12:16:32 +09003729 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003730 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
Leo Kimc96debf2015-10-28 15:59:30 +09003731 msg.body.mode.mode = mode;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003732 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003733
Leo Kimcb067dc2015-10-15 13:24:53 +09003734 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003735 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003736 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003737 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003738 }
3739
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003740 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003741}
3742
Tony Choa4ab1ad2015-10-12 16:56:05 +09003743s32 host_int_get_host_chnl_num(struct host_if_drv *hif_drv, u8 *pu8ChNo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003744{
Leo Kim31390ee2015-10-19 18:26:08 +09003745 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003746 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003747
Tony Choa4ab1ad2015-10-12 16:56:05 +09003748 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003749 PRINT_ER("driver is null\n");
3750 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003751 }
3752
Tony Cho143eb952015-09-21 12:16:32 +09003753 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003754
Tony Choa9f812a2015-09-21 12:16:33 +09003755 msg.id = HOST_IF_MSG_GET_CHNL;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003756 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003757
Leo Kim31390ee2015-10-19 18:26:08 +09003758 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3759 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09003760 PRINT_ER("wilc mq send fail\n");
Leo Kim4ea90002015-10-29 11:58:32 +09003761 down(&hif_drv->sem_get_chnl);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003762
Leo Kim95ebb0f2015-10-15 13:25:03 +09003763 *pu8ChNo = ch_no;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003764
Leo Kim31390ee2015-10-19 18:26:08 +09003765 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003766}
3767
Tony Choa4ab1ad2015-10-12 16:56:05 +09003768s32 host_int_get_inactive_time(struct host_if_drv *hif_drv,
3769 const u8 *mac, u32 *pu32InactiveTime)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003770{
Leo Kim31390ee2015-10-19 18:26:08 +09003771 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003772 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003773
Tony Choa4ab1ad2015-10-12 16:56:05 +09003774 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003775 PRINT_ER("driver is null\n");
3776 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003777 }
3778
Tony Cho143eb952015-09-21 12:16:32 +09003779 memset(&msg, 0, sizeof(struct host_if_msg));
Leo Kim8c8360b2015-10-19 18:26:12 +09003780 memcpy(msg.body.mac_info.mac, mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003781
Tony Choa9f812a2015-09-21 12:16:33 +09003782 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003783 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003784
Leo Kim31390ee2015-10-19 18:26:08 +09003785 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3786 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003787 PRINT_ER("Failed to send get host channel param's message queue ");
3788
Leo Kim569a3c62015-10-29 11:58:33 +09003789 down(&hif_drv->sem_inactive_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003790
Leo Kimad269062015-10-15 13:25:06 +09003791 *pu32InactiveTime = inactive_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003792
Leo Kim31390ee2015-10-19 18:26:08 +09003793 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003794}
Glen Lee108b3432015-09-16 18:53:20 +09003795
Tony Choa4ab1ad2015-10-12 16:56:05 +09003796s32 host_int_test_get_int_wid(struct host_if_drv *hif_drv, u32 *pu32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003797{
Leo Kim31390ee2015-10-19 18:26:08 +09003798 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09003799 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003800
Tony Choa4ab1ad2015-10-12 16:56:05 +09003801 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003802 PRINT_ER("driver is null\n");
3803 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003804 }
3805
Leo Kim45102f82015-10-28 15:59:28 +09003806 wid.id = (u16)WID_MEMORY_ADDRESS;
3807 wid.type = WID_INT;
3808 wid.val = (s8 *)pu32TestMemAddr;
3809 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003810
Leo Kim45102f82015-10-28 15:59:28 +09003811 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09003812 get_id_from_handler(hif_drv));
Leo Kimae4dfa52015-10-13 19:49:26 +09003813
Leo Kim31390ee2015-10-19 18:26:08 +09003814 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003815 PRINT_ER("Failed to get wid value\n");
3816 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003817 } else {
3818 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003819 }
3820
Leo Kim31390ee2015-10-19 18:26:08 +09003821 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003822}
3823
Tony Choa4ab1ad2015-10-12 16:56:05 +09003824s32 host_int_get_rssi(struct host_if_drv *hif_drv, s8 *ps8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003825{
Leo Kim31390ee2015-10-19 18:26:08 +09003826 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003827 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003828
Leo Kimc09389a2015-10-28 15:59:24 +09003829 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003830 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003831 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003832
Leo Kim31390ee2015-10-19 18:26:08 +09003833 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3834 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003835 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003836 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003837 }
3838
Leo Kim7e111f92015-10-29 11:58:30 +09003839 down(&hif_drv->sem_get_rssi);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003840
Leo Kim91109e12015-10-19 18:26:13 +09003841 if (!ps8Rssi) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003842 PRINT_ER("RSS pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09003843 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003844 }
3845
Leo Kim144b7b22015-10-15 13:25:01 +09003846 *ps8Rssi = rssi;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003847
Leo Kim31390ee2015-10-19 18:26:08 +09003848 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003849}
3850
Tony Choa4ab1ad2015-10-12 16:56:05 +09003851s32 host_int_get_link_speed(struct host_if_drv *hif_drv, s8 *ps8lnkspd)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003852{
Tony Cho143eb952015-09-21 12:16:32 +09003853 struct host_if_msg msg;
Leo Kim31390ee2015-10-19 18:26:08 +09003854 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003855
Leo Kimc09389a2015-10-28 15:59:24 +09003856 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003857 msg.id = HOST_IF_MSG_GET_LINKSPEED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003858 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003859
Leo Kim31390ee2015-10-19 18:26:08 +09003860 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3861 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003862 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003863 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003864 }
3865
Leo Kimbc34da62015-10-29 11:58:31 +09003866 down(&hif_drv->sem_get_link_speed);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003867
Leo Kim91109e12015-10-19 18:26:13 +09003868 if (!ps8lnkspd) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003869 PRINT_ER("LINKSPEED pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09003870 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003871 }
3872
Leo Kim75327a02015-10-15 13:25:02 +09003873 *ps8lnkspd = link_speed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003874
Leo Kim31390ee2015-10-19 18:26:08 +09003875 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003876}
3877
Tony Choa4ab1ad2015-10-12 16:56:05 +09003878s32 host_int_get_statistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003879{
Leo Kim31390ee2015-10-19 18:26:08 +09003880 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003881 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003882
Leo Kimc09389a2015-10-28 15:59:24 +09003883 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003884 msg.id = HOST_IF_MSG_GET_STATISTICS;
Tony Choe60831e2015-10-05 13:50:45 +09003885 msg.body.data = (char *)pstrStatistics;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003886 msg.drv = hif_drv;
Leo Kimae4dfa52015-10-13 19:49:26 +09003887
Leo Kim31390ee2015-10-19 18:26:08 +09003888 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3889 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003890 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003891 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003892 }
3893
Leo Kim2d25af82015-10-15 13:24:56 +09003894 down(&hif_sema_wait_response);
Leo Kim31390ee2015-10-19 18:26:08 +09003895 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003896}
3897
Tony Choa4ab1ad2015-10-12 16:56:05 +09003898s32 host_int_scan(struct host_if_drv *hif_drv, u8 u8ScanSource,
3899 u8 u8ScanType, u8 *pu8ChnlFreqList,
3900 u8 u8ChnlListLen, const u8 *pu8IEs,
3901 size_t IEsLen, wilc_scan_result ScanResult,
3902 void *pvUserArg, struct hidden_network *pstrHiddenNetwork)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003903{
Leo Kim31390ee2015-10-19 18:26:08 +09003904 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003905 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003906
Leo Kim91109e12015-10-19 18:26:13 +09003907 if (!hif_drv || !ScanResult) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09003908 PRINT_ER("hif_drv or ScanResult = NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003909 return -EFAULT;
3910 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003911
Tony Cho143eb952015-09-21 12:16:32 +09003912 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003913
Tony Choa9f812a2015-09-21 12:16:33 +09003914 msg.id = HOST_IF_MSG_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003915
Leo Kim91109e12015-10-19 18:26:13 +09003916 if (pstrHiddenNetwork) {
Leo Kim629b9ca2015-10-13 19:49:46 +09003917 msg.body.scan_info.hidden_network.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
3918 msg.body.scan_info.hidden_network.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003919
3920 } else
3921 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
3922
Tony Choa4ab1ad2015-10-12 16:56:05 +09003923 msg.drv = hif_drv;
Leo Kim42568892015-10-13 19:49:37 +09003924 msg.body.scan_info.src = u8ScanSource;
Leo Kim1e276c82015-10-13 19:49:38 +09003925 msg.body.scan_info.type = u8ScanType;
Leo Kimc17c6da2015-10-13 19:49:44 +09003926 msg.body.scan_info.result = ScanResult;
Leo Kim5f2b50c2015-10-13 19:49:45 +09003927 msg.body.scan_info.arg = pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003928
Leo Kimf97bd9c2015-10-13 19:49:41 +09003929 msg.body.scan_info.ch_list_len = u8ChnlListLen;
Leo Kim82eeb0a2015-10-13 19:49:40 +09003930 msg.body.scan_info.ch_freq_list = kmalloc(u8ChnlListLen, GFP_KERNEL);
3931 memcpy(msg.body.scan_info.ch_freq_list, pu8ChnlFreqList, u8ChnlListLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003932
Leo Kim7b1f76c2015-10-13 19:49:43 +09003933 msg.body.scan_info.ies_len = IEsLen;
Leo Kimd6f19aa2015-10-13 19:49:42 +09003934 msg.body.scan_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3935 memcpy(msg.body.scan_info.ies, pu8IEs, IEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003936
Leo Kim31390ee2015-10-19 18:26:08 +09003937 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3938 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003939 PRINT_ER("Error in sending message queue\n");
3940 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003941 }
3942
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003943 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
Leo Kim13b313e2015-10-29 11:58:34 +09003944 hif_drv->scan_timer.data = (unsigned long)hif_drv;
3945 mod_timer(&hif_drv->scan_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003946 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003947
Leo Kim31390ee2015-10-19 18:26:08 +09003948 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003949}
Leo Kimae4dfa52015-10-13 19:49:26 +09003950
Tony Choa4ab1ad2015-10-12 16:56:05 +09003951s32 hif_set_cfg(struct host_if_drv *hif_drv,
3952 struct cfg_param_val *pstrCfgParamVal)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003953{
Leo Kim31390ee2015-10-19 18:26:08 +09003954 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003955 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003956
Tony Choa4ab1ad2015-10-12 16:56:05 +09003957 if (!hif_drv) {
3958 PRINT_ER("hif_drv NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003959 return -EFAULT;
3960 }
Leo Kimae4dfa52015-10-13 19:49:26 +09003961
Tony Cho143eb952015-09-21 12:16:32 +09003962 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003963 msg.id = HOST_IF_MSG_CFG_PARAMS;
Tony Cho221371e2015-10-12 16:56:06 +09003964 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003965 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003966
Leo Kim31390ee2015-10-19 18:26:08 +09003967 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003968
Leo Kim31390ee2015-10-19 18:26:08 +09003969 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003970}
3971
Tony Choa4ab1ad2015-10-12 16:56:05 +09003972s32 hif_get_cfg(struct host_if_drv *hif_drv, u16 u16WID, u16 *pu16WID_Value)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003973{
Leo Kim31390ee2015-10-19 18:26:08 +09003974 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003975
Leo Kim33110ad2015-10-29 11:58:27 +09003976 down(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003977
Tony Choa4ab1ad2015-10-12 16:56:05 +09003978 if (!hif_drv) {
3979 PRINT_ER("hif_drv NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003980 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003981 }
3982 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
3983 switch (u16WID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003984 case WID_BSS_TYPE:
Leo Kimace303f2015-10-29 11:58:26 +09003985 *pu16WID_Value = (u16)hif_drv->cfg_values.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003986 break;
3987
3988 case WID_AUTH_TYPE:
Leo Kimace303f2015-10-29 11:58:26 +09003989 *pu16WID_Value = (u16)hif_drv->cfg_values.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003990 break;
3991
3992 case WID_AUTH_TIMEOUT:
Leo Kimace303f2015-10-29 11:58:26 +09003993 *pu16WID_Value = hif_drv->cfg_values.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003994 break;
3995
3996 case WID_POWER_MANAGEMENT:
Leo Kimace303f2015-10-29 11:58:26 +09003997 *pu16WID_Value = (u16)hif_drv->cfg_values.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003998 break;
3999
4000 case WID_SHORT_RETRY_LIMIT:
Leo Kimace303f2015-10-29 11:58:26 +09004001 *pu16WID_Value = hif_drv->cfg_values.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004002 break;
4003
4004 case WID_LONG_RETRY_LIMIT:
Leo Kimace303f2015-10-29 11:58:26 +09004005 *pu16WID_Value = hif_drv->cfg_values.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004006 break;
4007
4008 case WID_FRAG_THRESHOLD:
Leo Kimace303f2015-10-29 11:58:26 +09004009 *pu16WID_Value = hif_drv->cfg_values.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004010 break;
4011
4012 case WID_RTS_THRESHOLD:
Leo Kimace303f2015-10-29 11:58:26 +09004013 *pu16WID_Value = hif_drv->cfg_values.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004014 break;
4015
4016 case WID_PREAMBLE:
Leo Kimace303f2015-10-29 11:58:26 +09004017 *pu16WID_Value = (u16)hif_drv->cfg_values.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004018 break;
4019
4020 case WID_SHORT_SLOT_ALLOWED:
Leo Kimace303f2015-10-29 11:58:26 +09004021 *pu16WID_Value = (u16)hif_drv->cfg_values.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004022 break;
4023
4024 case WID_11N_TXOP_PROT_DISABLE:
Leo Kimace303f2015-10-29 11:58:26 +09004025 *pu16WID_Value = (u16)hif_drv->cfg_values.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004026 break;
4027
4028 case WID_BEACON_INTERVAL:
Leo Kimace303f2015-10-29 11:58:26 +09004029 *pu16WID_Value = hif_drv->cfg_values.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004030 break;
4031
4032 case WID_DTIM_PERIOD:
Leo Kimace303f2015-10-29 11:58:26 +09004033 *pu16WID_Value = (u16)hif_drv->cfg_values.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004034 break;
4035
4036 case WID_SITE_SURVEY:
Leo Kimace303f2015-10-29 11:58:26 +09004037 *pu16WID_Value = (u16)hif_drv->cfg_values.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004038 break;
4039
4040 case WID_SITE_SURVEY_SCAN_TIME:
Leo Kimace303f2015-10-29 11:58:26 +09004041 *pu16WID_Value = hif_drv->cfg_values.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004042 break;
4043
4044 case WID_ACTIVE_SCAN_TIME:
Leo Kimace303f2015-10-29 11:58:26 +09004045 *pu16WID_Value = hif_drv->cfg_values.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004046 break;
4047
4048 case WID_PASSIVE_SCAN_TIME:
Leo Kimace303f2015-10-29 11:58:26 +09004049 *pu16WID_Value = hif_drv->cfg_values.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004050 break;
4051
4052 case WID_CURRENT_TX_RATE:
Leo Kimace303f2015-10-29 11:58:26 +09004053 *pu16WID_Value = hif_drv->cfg_values.curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004054 break;
4055
4056 default:
4057 break;
4058 }
4059
Leo Kim33110ad2015-10-29 11:58:27 +09004060 up(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004061
Leo Kim31390ee2015-10-19 18:26:08 +09004062 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004063}
4064
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004065static void GetPeriodicRSSI(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004066{
Tony Choa4ab1ad2015-10-12 16:56:05 +09004067 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004068
Tony Choa4ab1ad2015-10-12 16:56:05 +09004069 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004070 PRINT_ER("Driver handler is NULL\n");
4071 return;
4072 }
4073
Leo Kimb60005a2015-10-29 11:58:24 +09004074 if (hif_drv->hif_state == HOST_IF_CONNECTED) {
Leo Kim31390ee2015-10-19 18:26:08 +09004075 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004076 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004077
Tony Cho143eb952015-09-21 12:16:32 +09004078 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004079
Tony Choa9f812a2015-09-21 12:16:33 +09004080 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004081 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004082
Leo Kim31390ee2015-10-19 18:26:08 +09004083 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4084 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004085 PRINT_ER("Failed to send get host channel param's message queue ");
4086 return;
4087 }
4088 }
Leo Kim262f55e2015-10-15 13:24:58 +09004089 periodic_rssi.data = (unsigned long)hif_drv;
4090 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004091}
4092
Glen Leed53822192015-10-27 18:27:49 +09004093s32 host_int_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004094{
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004095 s32 result = 0;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004096 struct host_if_drv *hif_drv;
Johnny Kimd42ab082015-08-20 16:32:52 +09004097 int err;
Glen Leed53822192015-10-27 18:27:49 +09004098 perInterface_wlan_t *nic;
4099 struct wilc *wilc;
4100
4101 nic = netdev_priv(dev);
4102 wilc = nic->wilc;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004103
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004104 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
4105
Leo Kimca8540e42015-10-15 13:25:00 +09004106 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004107
Leo Kim2d25af82015-10-15 13:24:56 +09004108 sema_init(&hif_sema_wait_response, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004109
Tony Choa4ab1ad2015-10-12 16:56:05 +09004110 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
4111 if (!hif_drv) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004112 result = -ENOMEM;
Vincent Stehlé17db84e2015-10-07 07:08:25 +02004113 goto _fail_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004114 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09004115 *hif_drv_handler = hif_drv;
4116 err = add_handler_in_list(hif_drv);
Johnny Kimd42ab082015-08-20 16:32:52 +09004117 if (err) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004118 result = -EFAULT;
Johnny Kimd42ab082015-08-20 16:32:52 +09004119 goto _fail_timer_2;
4120 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004121
Dean Lee72ed4dc2015-06-12 14:11:44 +09004122 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004123
Tony Choa4ab1ad2015-10-12 16:56:05 +09004124 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004125 if (clients_count == 0) {
Leo Kim834e0cb2015-10-15 13:24:54 +09004126 sema_init(&hif_sema_thread, 0);
Leo Kim27ff2162015-10-15 13:24:55 +09004127 sema_init(&hif_sema_driver, 0);
Leo Kim440e89932015-10-15 13:24:57 +09004128 sema_init(&hif_sema_deinit, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004129 }
4130
Leo Kim9ea47132015-10-29 11:58:28 +09004131 sema_init(&hif_drv->sem_test_key_block, 0);
Leo Kime55e4962015-10-29 11:58:29 +09004132 sema_init(&hif_drv->sem_test_disconn_block, 0);
Leo Kim7e111f92015-10-29 11:58:30 +09004133 sema_init(&hif_drv->sem_get_rssi, 0);
Leo Kimbc34da62015-10-29 11:58:31 +09004134 sema_init(&hif_drv->sem_get_link_speed, 0);
Leo Kim4ea90002015-10-29 11:58:32 +09004135 sema_init(&hif_drv->sem_get_chnl, 0);
Leo Kim569a3c62015-10-29 11:58:33 +09004136 sema_init(&hif_drv->sem_inactive_time, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004137
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004138 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
4139
4140 if (clients_count == 0) {
Leo Kimcb067dc2015-10-15 13:24:53 +09004141 result = wilc_mq_create(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004142
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004143 if (result < 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004144 PRINT_ER("Failed to creat MQ\n");
4145 goto _fail_;
4146 }
Leo Kimc2115d82015-10-15 13:24:52 +09004147
Glen Leed53822192015-10-27 18:27:49 +09004148 hif_thread_handler = kthread_run(hostIFthread, wilc,
4149 "WILC_kthread");
Leo Kimc2115d82015-10-15 13:24:52 +09004150
4151 if (IS_ERR(hif_thread_handler)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004152 PRINT_ER("Failed to creat Thread\n");
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004153 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004154 goto _fail_mq_;
4155 }
Leo Kim262f55e2015-10-15 13:24:58 +09004156 setup_timer(&periodic_rssi, GetPeriodicRSSI,
Tony Choa4ab1ad2015-10-12 16:56:05 +09004157 (unsigned long)hif_drv);
Leo Kim262f55e2015-10-15 13:24:58 +09004158 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004159 }
4160
Leo Kim13b313e2015-10-29 11:58:34 +09004161 setup_timer(&hif_drv->scan_timer, TimerCB_Scan, 0);
Leo Kim81a59502015-10-29 11:58:35 +09004162 setup_timer(&hif_drv->connect_timer, TimerCB_Connect, 0);
Leo Kimcc2d7e92015-10-29 11:58:36 +09004163 setup_timer(&hif_drv->remain_on_ch_timer, ListenTimerCB, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004164
Leo Kim33110ad2015-10-29 11:58:27 +09004165 sema_init(&hif_drv->sem_cfg_values, 1);
4166 down(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004167
Leo Kimb60005a2015-10-29 11:58:24 +09004168 hif_drv->hif_state = HOST_IF_IDLE;
Leo Kimace303f2015-10-29 11:58:26 +09004169 hif_drv->cfg_values.site_survey_enabled = SITE_SURVEY_OFF;
4170 hif_drv->cfg_values.scan_source = DEFAULT_SCAN;
4171 hif_drv->cfg_values.active_scan_time = ACTIVE_SCAN_TIME;
4172 hif_drv->cfg_values.passive_scan_time = PASSIVE_SCAN_TIME;
4173 hif_drv->cfg_values.curr_tx_rate = AUTORATE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004174
Leo Kim1229b1a2015-10-29 12:05:39 +09004175 hif_drv->p2p_timeout = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004176
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004177 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 +09004178 hif_drv->cfg_values.site_survey_enabled,
4179 hif_drv->cfg_values.scan_source,
4180 hif_drv->cfg_values.active_scan_time,
4181 hif_drv->cfg_values.passive_scan_time,
4182 hif_drv->cfg_values.curr_tx_rate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004183
Leo Kim33110ad2015-10-29 11:58:27 +09004184 up(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004185
Leo Kimae4dfa52015-10-13 19:49:26 +09004186 clients_count++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004187
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004188 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004189
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004190_fail_timer_2:
Leo Kim33110ad2015-10-29 11:58:27 +09004191 up(&hif_drv->sem_cfg_values);
Leo Kim81a59502015-10-29 11:58:35 +09004192 del_timer_sync(&hif_drv->connect_timer);
Leo Kim13b313e2015-10-29 11:58:34 +09004193 del_timer_sync(&hif_drv->scan_timer);
Leo Kimc2115d82015-10-15 13:24:52 +09004194 kthread_stop(hif_thread_handler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004195_fail_mq_:
Leo Kimcb067dc2015-10-15 13:24:53 +09004196 wilc_mq_destroy(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004197_fail_:
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004198 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004199}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004200
Tony Choa4ab1ad2015-10-12 16:56:05 +09004201s32 host_int_deinit(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004202{
Leo Kim31390ee2015-10-19 18:26:08 +09004203 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004204 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004205 int ret;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004206
Tony Choa4ab1ad2015-10-12 16:56:05 +09004207 if (!hif_drv) {
4208 PRINT_ER("hif_drv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004209 return 0;
4210 }
4211
Leo Kim440e89932015-10-15 13:24:57 +09004212 down(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004213
Tony Choa4ab1ad2015-10-12 16:56:05 +09004214 terminated_handle = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004215 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
4216
Leo Kim13b313e2015-10-29 11:58:34 +09004217 if (del_timer_sync(&hif_drv->scan_timer))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004218 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004219
Leo Kim81a59502015-10-29 11:58:35 +09004220 if (del_timer_sync(&hif_drv->connect_timer))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004221 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004222
Leo Kim262f55e2015-10-15 13:24:58 +09004223 if (del_timer_sync(&periodic_rssi))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004224 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004225
Leo Kimcc2d7e92015-10-29 11:58:36 +09004226 del_timer_sync(&hif_drv->remain_on_ch_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004227
Johnny Kim218dc402015-08-13 13:41:19 +09004228 host_int_set_wfi_drv_handler(NULL);
Leo Kim27ff2162015-10-15 13:24:55 +09004229 down(&hif_sema_driver);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004230
Leo Kimbc801852015-10-29 11:58:50 +09004231 if (hif_drv->usr_scan_req.scan_result) {
4232 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL,
Leo Kim66eaea32015-10-29 11:58:51 +09004233 hif_drv->usr_scan_req.arg, NULL);
Leo Kimbc801852015-10-29 11:58:50 +09004234 hif_drv->usr_scan_req.scan_result = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004235 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004236
Leo Kimb60005a2015-10-29 11:58:24 +09004237 hif_drv->hif_state = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004238
Leo Kimca8540e42015-10-15 13:25:00 +09004239 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004240
Tony Cho143eb952015-09-21 12:16:32 +09004241 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004242
4243 if (clients_count == 1) {
Leo Kim262f55e2015-10-15 13:24:58 +09004244 if (del_timer_sync(&periodic_rssi))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004245 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Leo Kim262f55e2015-10-15 13:24:58 +09004246
Tony Choa9f812a2015-09-21 12:16:33 +09004247 msg.id = HOST_IF_MSG_EXIT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004248 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004249
Leo Kim31390ee2015-10-19 18:26:08 +09004250 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4251 if (result != 0)
4252 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004253
Leo Kim834e0cb2015-10-15 13:24:54 +09004254 down(&hif_sema_thread);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004255
Leo Kimcb067dc2015-10-15 13:24:53 +09004256 wilc_mq_destroy(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004257 }
4258
Leo Kim33110ad2015-10-29 11:58:27 +09004259 down(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004260
Tony Choa4ab1ad2015-10-12 16:56:05 +09004261 ret = remove_handler_in_list(hif_drv);
Johnny Kimd42ab082015-08-20 16:32:52 +09004262 if (ret)
Leo Kim31390ee2015-10-19 18:26:08 +09004263 result = -ENOENT;
Johnny Kimd42ab082015-08-20 16:32:52 +09004264
Tony Choa4ab1ad2015-10-12 16:56:05 +09004265 kfree(hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004266
Leo Kimae4dfa52015-10-13 19:49:26 +09004267 clients_count--;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09004268 terminated_handle = NULL;
Leo Kim440e89932015-10-15 13:24:57 +09004269 up(&hif_sema_deinit);
Leo Kim31390ee2015-10-19 18:26:08 +09004270 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004271}
4272
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004273void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004274{
Leo Kim31390ee2015-10-19 18:26:08 +09004275 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004276 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004277 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004278 struct host_if_drv *hif_drv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004279
Johnny Kimd42ab082015-08-20 16:32:52 +09004280 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09004281 hif_drv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004282
Tony Choa4ab1ad2015-10-12 16:56:05 +09004283 if (!hif_drv || hif_drv == terminated_handle) {
4284 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004285 return;
4286 }
4287
Tony Cho143eb952015-09-21 12:16:32 +09004288 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004289
Tony Choa9f812a2015-09-21 12:16:33 +09004290 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004291 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004292
Leo Kim3bffac62015-10-13 20:02:11 +09004293 msg.body.net_info.len = u32Length;
Leo Kimb021b802015-10-13 20:02:10 +09004294 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4295 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004296
Leo Kim31390ee2015-10-19 18:26:08 +09004297 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4298 if (result)
4299 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004300}
4301
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004302void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004303{
Leo Kim31390ee2015-10-19 18:26:08 +09004304 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004305 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004306 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004307 struct host_if_drv *hif_drv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004308
Leo Kim440e89932015-10-15 13:24:57 +09004309 down(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004310
Johnny Kimd42ab082015-08-20 16:32:52 +09004311 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09004312 hif_drv = get_handler_from_id(id);
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004313 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004314
Tony Choa4ab1ad2015-10-12 16:56:05 +09004315 if (!hif_drv || hif_drv == terminated_handle) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004316 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
Leo Kim440e89932015-10-15 13:24:57 +09004317 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004318 return;
4319 }
4320
Leo Kim33bfb192015-10-29 11:58:56 +09004321 if (!hif_drv->usr_conn_req.conn_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004322 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
Leo Kim440e89932015-10-15 13:24:57 +09004323 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004324 return;
4325 }
4326
Tony Cho143eb952015-09-21 12:16:32 +09004327 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004328
Tony Choa9f812a2015-09-21 12:16:33 +09004329 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004330 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004331
Leo Kimf94f4882015-10-13 19:50:01 +09004332 msg.body.async_info.len = u32Length;
Leo Kim33722ac72015-10-13 19:50:00 +09004333 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4334 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004335
Leo Kim31390ee2015-10-19 18:26:08 +09004336 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4337 if (result)
4338 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004339
Leo Kim440e89932015-10-15 13:24:57 +09004340 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004341}
4342
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004343void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004344{
Leo Kim31390ee2015-10-19 18:26:08 +09004345 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004346 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004347 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004348 struct host_if_drv *hif_drv = NULL;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004349
Johnny Kimd42ab082015-08-20 16:32:52 +09004350 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09004351 hif_drv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004352
Tony Choa4ab1ad2015-10-12 16:56:05 +09004353 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004354
Tony Choa4ab1ad2015-10-12 16:56:05 +09004355 if (!hif_drv || hif_drv == terminated_handle)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004356 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004357
Leo Kimbc801852015-10-29 11:58:50 +09004358 if (hif_drv->usr_scan_req.scan_result) {
Tony Cho143eb952015-09-21 12:16:32 +09004359 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004360
Tony Choa9f812a2015-09-21 12:16:33 +09004361 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004362 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004363
Leo Kim31390ee2015-10-19 18:26:08 +09004364 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4365 if (result)
4366 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004367 }
4368
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004369 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004370}
4371
Tony Choa4ab1ad2015-10-12 16:56:05 +09004372s32 host_int_remain_on_channel(struct host_if_drv *hif_drv, u32 u32SessionID,
4373 u32 u32duration, u16 chan,
4374 wilc_remain_on_chan_expired RemainOnChanExpired,
4375 wilc_remain_on_chan_ready RemainOnChanReady,
4376 void *pvUserArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004377{
Leo Kim31390ee2015-10-19 18:26:08 +09004378 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004379 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004380
Tony Choa4ab1ad2015-10-12 16:56:05 +09004381 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004382 PRINT_ER("driver is null\n");
4383 return -EFAULT;
4384 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004385
Tony Cho143eb952015-09-21 12:16:32 +09004386 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004387
Tony Choa9f812a2015-09-21 12:16:33 +09004388 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
Leo Kim839ab702015-10-29 11:58:41 +09004389 msg.body.remain_on_ch.ch = chan;
Leo Kimbfb62ab2015-10-29 11:58:42 +09004390 msg.body.remain_on_ch.expired = RemainOnChanExpired;
Leo Kim5e5f7912015-10-29 11:58:43 +09004391 msg.body.remain_on_ch.ready = RemainOnChanReady;
Leo Kimc5cc4b12015-10-29 11:58:44 +09004392 msg.body.remain_on_ch.arg = pvUserArg;
Tony Cho070d3652015-09-30 18:55:10 +09004393 msg.body.remain_on_ch.u32duration = u32duration;
Leo Kim9d764e32015-10-29 12:05:38 +09004394 msg.body.remain_on_ch.id = u32SessionID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004395 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004396
Leo Kim31390ee2015-10-19 18:26:08 +09004397 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4398 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004399 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004400
Leo Kim31390ee2015-10-19 18:26:08 +09004401 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004402}
4403
Tony Choa4ab1ad2015-10-12 16:56:05 +09004404s32 host_int_ListenStateExpired(struct host_if_drv *hif_drv, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004405{
Leo Kim31390ee2015-10-19 18:26:08 +09004406 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004407 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004408
Tony Choa4ab1ad2015-10-12 16:56:05 +09004409 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004410 PRINT_ER("driver is null\n");
4411 return -EFAULT;
4412 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004413
Leo Kimcc2d7e92015-10-29 11:58:36 +09004414 del_timer(&hif_drv->remain_on_ch_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004415
Tony Cho143eb952015-09-21 12:16:32 +09004416 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09004417 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004418 msg.drv = hif_drv;
Leo Kim9d764e32015-10-29 12:05:38 +09004419 msg.body.remain_on_ch.id = u32SessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004420
Leo Kim31390ee2015-10-19 18:26:08 +09004421 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4422 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004423 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004424
Leo Kim31390ee2015-10-19 18:26:08 +09004425 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004426}
4427
Tony Choa4ab1ad2015-10-12 16:56:05 +09004428s32 host_int_frame_register(struct host_if_drv *hif_drv, u16 u16FrameType, bool bReg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004429{
Leo Kim31390ee2015-10-19 18:26:08 +09004430 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004431 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004432
Tony Choa4ab1ad2015-10-12 16:56:05 +09004433 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004434 PRINT_ER("driver is null\n");
4435 return -EFAULT;
4436 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004437
Tony Cho143eb952015-09-21 12:16:32 +09004438 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004439
Tony Choa9f812a2015-09-21 12:16:33 +09004440 msg.id = HOST_IF_MSG_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004441 switch (u16FrameType) {
4442 case ACTION:
4443 PRINT_D(HOSTINF_DBG, "ACTION\n");
Leo Kimbcb410b2015-10-29 11:58:40 +09004444 msg.body.reg_frame.reg_id = ACTION_FRM_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004445 break;
4446
4447 case PROBE_REQ:
4448 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
Leo Kimbcb410b2015-10-29 11:58:40 +09004449 msg.body.reg_frame.reg_id = PROBE_REQ_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004450 break;
4451
4452 default:
4453 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
4454 break;
4455 }
Leo Kimd5f654c2015-10-29 11:58:39 +09004456 msg.body.reg_frame.frame_type = u16FrameType;
Leo Kim6abf8682015-10-29 11:58:38 +09004457 msg.body.reg_frame.reg = bReg;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004458 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004459
Leo Kim31390ee2015-10-19 18:26:08 +09004460 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4461 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004462 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004463
Leo Kim31390ee2015-10-19 18:26:08 +09004464 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004465}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004466
Tony Choa4ab1ad2015-10-12 16:56:05 +09004467s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
4468 u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head,
4469 u32 u32TailLen, u8 *pu8Tail)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004470{
Leo Kim31390ee2015-10-19 18:26:08 +09004471 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004472 struct host_if_msg msg;
Tony Choa98491e2015-09-30 18:44:31 +09004473 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004474
Tony Choa4ab1ad2015-10-12 16:56:05 +09004475 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004476 PRINT_ER("driver is null\n");
4477 return -EFAULT;
4478 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004479
Tony Cho143eb952015-09-21 12:16:32 +09004480 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004481
4482 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
4483
Tony Choa9f812a2015-09-21 12:16:33 +09004484 msg.id = HOST_IF_MSG_ADD_BEACON;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004485 msg.drv = hif_drv;
Leo Kim12262dd2015-10-13 19:50:03 +09004486 pstrSetBeaconParam->interval = u32Interval;
Leo Kime76ab772015-10-13 19:50:04 +09004487 pstrSetBeaconParam->dtim_period = u32DTIMPeriod;
Leo Kim51c66182015-10-13 19:50:05 +09004488 pstrSetBeaconParam->head_len = u32HeadLen;
Shraddha Barke543f5b12015-10-16 10:47:11 +05304489 pstrSetBeaconParam->head = kmemdup(pu8Head, u32HeadLen, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09004490 if (!pstrSetBeaconParam->head) {
Leo Kim31390ee2015-10-19 18:26:08 +09004491 result = -ENOMEM;
Leo Kim24db7132015-09-16 18:36:01 +09004492 goto ERRORHANDLER;
4493 }
Leo Kim030c57e2015-10-13 19:50:07 +09004494 pstrSetBeaconParam->tail_len = u32TailLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004495
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004496 if (u32TailLen > 0) {
Shraddha Barke543f5b12015-10-16 10:47:11 +05304497 pstrSetBeaconParam->tail = kmemdup(pu8Tail, u32TailLen,
4498 GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09004499 if (!pstrSetBeaconParam->tail) {
Leo Kim31390ee2015-10-19 18:26:08 +09004500 result = -ENOMEM;
Leo Kim24db7132015-09-16 18:36:01 +09004501 goto ERRORHANDLER;
4502 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004503 } else {
Leo Kim7dbcb6d32015-10-13 19:50:08 +09004504 pstrSetBeaconParam->tail = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004505 }
4506
Leo Kim31390ee2015-10-19 18:26:08 +09004507 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4508 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004509 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004510
Leo Kim24db7132015-09-16 18:36:01 +09004511ERRORHANDLER:
Leo Kim31390ee2015-10-19 18:26:08 +09004512 if (result) {
Shraddha Barke95f840f2015-10-14 07:29:19 +05304513 kfree(pstrSetBeaconParam->head);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004514
Shraddha Barke95f840f2015-10-14 07:29:19 +05304515 kfree(pstrSetBeaconParam->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004516 }
4517
Leo Kim31390ee2015-10-19 18:26:08 +09004518 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004519}
4520
Chaehyun Lim0a5298c2015-11-06 19:11:10 +09004521int host_int_del_beacon(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004522{
Chaehyun Lim0a5298c2015-11-06 19:11:10 +09004523 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004524 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004525
Tony Choa4ab1ad2015-10-12 16:56:05 +09004526 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004527 PRINT_ER("driver is null\n");
4528 return -EFAULT;
4529 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004530
Tony Choa9f812a2015-09-21 12:16:33 +09004531 msg.id = HOST_IF_MSG_DEL_BEACON;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004532 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004533 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
4534
Leo Kim31390ee2015-10-19 18:26:08 +09004535 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4536 if (result)
Leo Kim7dc1d0c2015-09-16 18:36:00 +09004537 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004538
Leo Kim31390ee2015-10-19 18:26:08 +09004539 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004540}
4541
Chaehyun Lim18cfbd32015-11-06 19:11:16 +09004542int host_int_add_station(struct host_if_drv *hif_drv,
Chaehyun Lime3378542015-11-06 19:11:18 +09004543 struct add_sta_param *sta_param)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004544{
Chaehyun Lim18cfbd32015-11-06 19:11:16 +09004545 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004546 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09004547 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004548
Tony Choa4ab1ad2015-10-12 16:56:05 +09004549 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004550 PRINT_ER("driver is null\n");
4551 return -EFAULT;
4552 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004553
Tony Cho143eb952015-09-21 12:16:32 +09004554 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004555
4556 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
4557
Tony Choa9f812a2015-09-21 12:16:33 +09004558 msg.id = HOST_IF_MSG_ADD_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004559 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004560
Chaehyun Lime3378542015-11-06 19:11:18 +09004561 memcpy(pstrAddStationMsg, sta_param, sizeof(struct add_sta_param));
Leo Kime7342232015-10-29 12:05:43 +09004562 if (pstrAddStationMsg->rates_len > 0) {
4563 u8 *rates = kmalloc(pstrAddStationMsg->rates_len, GFP_KERNEL);
Leo Kimc09389a2015-10-28 15:59:24 +09004564
Leo Kim7ae43362015-09-16 18:35:59 +09004565 if (!rates)
4566 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004567
Chaehyun Lime3378542015-11-06 19:11:18 +09004568 memcpy(rates, sta_param->rates,
Leo Kime7342232015-10-29 12:05:43 +09004569 pstrAddStationMsg->rates_len);
Leo Kima622e012015-10-29 12:05:44 +09004570 pstrAddStationMsg->rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004571 }
4572
Leo Kim31390ee2015-10-19 18:26:08 +09004573 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4574 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004575 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004576 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004577}
4578
Chaehyun Limc9c4eb42015-11-06 19:11:14 +09004579int host_int_del_station(struct host_if_drv *hif_drv, const u8 *mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004580{
Chaehyun Lim79a0c0a2015-11-06 19:11:12 +09004581 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004582 struct host_if_msg msg;
Chaehyun Limc87fbed2015-11-06 19:11:15 +09004583 struct del_sta *del_sta_info = &msg.body.del_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004584
Tony Choa4ab1ad2015-10-12 16:56:05 +09004585 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004586 PRINT_ER("driver is null\n");
4587 return -EFAULT;
4588 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004589
Tony Cho143eb952015-09-21 12:16:32 +09004590 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004591
4592 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
4593
Tony Choa9f812a2015-09-21 12:16:33 +09004594 msg.id = HOST_IF_MSG_DEL_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004595 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004596
Chaehyun Limc9c4eb42015-11-06 19:11:14 +09004597 if (!mac_addr)
Chaehyun Limc87fbed2015-11-06 19:11:15 +09004598 eth_broadcast_addr(del_sta_info->mac_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004599 else
Chaehyun Limc87fbed2015-11-06 19:11:15 +09004600 memcpy(del_sta_info->mac_addr, mac_addr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004601
Leo Kim31390ee2015-10-19 18:26:08 +09004602 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4603 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004604 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004605 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004606}
Leo Kimae4dfa52015-10-13 19:49:26 +09004607
Tony Choa4ab1ad2015-10-12 16:56:05 +09004608s32 host_int_del_allstation(struct host_if_drv *hif_drv,
Leo Kim441dc602015-10-12 16:55:35 +09004609 u8 pu8MacAddr[][ETH_ALEN])
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004610{
Leo Kim31390ee2015-10-19 18:26:08 +09004611 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004612 struct host_if_msg msg;
Tony Chob0c1e802015-10-05 13:50:46 +09004613 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004614 u8 au8Zero_Buff[ETH_ALEN] = {0};
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004615 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004616 u8 u8AssocNumb = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004617
Tony Choa4ab1ad2015-10-12 16:56:05 +09004618 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004619 PRINT_ER("driver is null\n");
4620 return -EFAULT;
4621 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004622
Tony Cho143eb952015-09-21 12:16:32 +09004623 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004624
4625 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
4626
Tony Choa9f812a2015-09-21 12:16:33 +09004627 msg.id = HOST_IF_MSG_DEL_ALL_STA;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004628 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004629
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004630 for (i = 0; i < MAX_NUM_STA; i++) {
4631 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
Leo Kime51b9212015-10-13 19:50:09 +09004632 memcpy(pstrDelAllStationMsg->del_all_sta[i], pu8MacAddr[i], ETH_ALEN);
4633 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
4634 pstrDelAllStationMsg->del_all_sta[i][0],
4635 pstrDelAllStationMsg->del_all_sta[i][1],
4636 pstrDelAllStationMsg->del_all_sta[i][2],
4637 pstrDelAllStationMsg->del_all_sta[i][3],
4638 pstrDelAllStationMsg->del_all_sta[i][4],
4639 pstrDelAllStationMsg->del_all_sta[i][5]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004640 u8AssocNumb++;
4641 }
4642 }
4643 if (!u8AssocNumb) {
4644 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004645 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004646 }
4647
Leo Kim8ba18032015-10-13 19:50:10 +09004648 pstrDelAllStationMsg->assoc_sta = u8AssocNumb;
Leo Kim31390ee2015-10-19 18:26:08 +09004649 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004650
Leo Kim31390ee2015-10-19 18:26:08 +09004651 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004652 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004653
Leo Kim2d25af82015-10-15 13:24:56 +09004654 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004655
Leo Kim31390ee2015-10-19 18:26:08 +09004656 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004657}
4658
Tony Choa4ab1ad2015-10-12 16:56:05 +09004659s32 host_int_edit_station(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09004660 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004661{
Leo Kim31390ee2015-10-19 18:26:08 +09004662 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004663 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09004664 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004665
Tony Choa4ab1ad2015-10-12 16:56:05 +09004666 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004667 PRINT_ER("driver is null\n");
4668 return -EFAULT;
4669 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004670
4671 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
4672
Tony Cho143eb952015-09-21 12:16:32 +09004673 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004674
Tony Choa9f812a2015-09-21 12:16:33 +09004675 msg.id = HOST_IF_MSG_EDIT_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004676 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004677
Tony Cho6a89ba92015-09-21 12:16:46 +09004678 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Leo Kime7342232015-10-29 12:05:43 +09004679 if (pstrAddStationMsg->rates_len > 0) {
4680 u8 *rates = kmalloc(pstrAddStationMsg->rates_len, GFP_KERNEL);
Leo Kimc09389a2015-10-28 15:59:24 +09004681
Leo Kim7ae43362015-09-16 18:35:59 +09004682 if (!rates)
4683 return -ENOMEM;
4684
Leo Kima622e012015-10-29 12:05:44 +09004685 memcpy(rates, pstrStaParams->rates,
Leo Kime7342232015-10-29 12:05:43 +09004686 pstrAddStationMsg->rates_len);
Leo Kima622e012015-10-29 12:05:44 +09004687 pstrAddStationMsg->rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004688 }
4689
Leo Kim31390ee2015-10-19 18:26:08 +09004690 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4691 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004692 PRINT_ER("wilc_mq_send fail\n");
4693
Leo Kim31390ee2015-10-19 18:26:08 +09004694 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004695}
Glen Lee108b3432015-09-16 18:53:20 +09004696
Tony Choa4ab1ad2015-10-12 16:56:05 +09004697s32 host_int_set_power_mgmt(struct host_if_drv *hif_drv,
4698 bool bIsEnabled,
4699 u32 u32Timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004700{
Leo Kim31390ee2015-10-19 18:26:08 +09004701 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004702 struct host_if_msg msg;
Tony Cho49e1f812015-09-30 18:44:36 +09004703 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004704
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004705 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004706
Tony Choa4ab1ad2015-10-12 16:56:05 +09004707 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004708 PRINT_ER("driver is null\n");
4709 return -EFAULT;
4710 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004711
4712 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
4713
Tony Cho143eb952015-09-21 12:16:32 +09004714 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004715
Tony Choa9f812a2015-09-21 12:16:33 +09004716 msg.id = HOST_IF_MSG_POWER_MGMT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004717 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004718
Leo Kim33c70c12015-10-13 20:02:07 +09004719 pstrPowerMgmtParam->enabled = bIsEnabled;
Leo Kim937918f2015-10-13 20:02:08 +09004720 pstrPowerMgmtParam->timeout = u32Timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004721
Leo Kim31390ee2015-10-19 18:26:08 +09004722 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4723 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004724 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004725 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004726}
4727
Tony Choa4ab1ad2015-10-12 16:56:05 +09004728s32 host_int_setup_multicast_filter(struct host_if_drv *hif_drv,
4729 bool bIsEnabled,
4730 u32 u32count)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004731{
Leo Kim31390ee2015-10-19 18:26:08 +09004732 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004733 struct host_if_msg msg;
Tony Choa079cf4d2015-09-30 18:55:05 +09004734 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004735
Tony Choa4ab1ad2015-10-12 16:56:05 +09004736 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004737 PRINT_ER("driver is null\n");
4738 return -EFAULT;
4739 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004740
4741 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
4742
Tony Cho143eb952015-09-21 12:16:32 +09004743 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004744
Tony Choa9f812a2015-09-21 12:16:33 +09004745 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004746 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004747
Leo Kimbae636eb2015-10-13 20:02:04 +09004748 pstrMulticastFilterParam->enabled = bIsEnabled;
Leo Kimadab2f72015-10-13 20:02:05 +09004749 pstrMulticastFilterParam->cnt = u32count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004750
Leo Kim31390ee2015-10-19 18:26:08 +09004751 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4752 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004753 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004754 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004755}
4756
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004757static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
4758{
Leo Kime0a12212015-10-12 16:55:49 +09004759 struct join_bss_param *pNewJoinBssParam = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004760 u8 *pu8IEs;
Chaehyun Limd85f5322015-06-11 14:35:54 +09004761 u16 u16IEsLen;
4762 u16 index = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004763 u8 suppRatesNo = 0;
4764 u8 extSuppRatesNo;
Chaehyun Limd85f5322015-06-11 14:35:54 +09004765 u16 jumpOffset;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004766 u8 pcipherCount;
4767 u8 authCount;
4768 u8 pcipherTotalCount = 0;
4769 u8 authTotalCount = 0;
4770 u8 i, j;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004771
4772 pu8IEs = ptstrNetworkInfo->pu8IEs;
4773 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4774
Shraddha Barkeb156f1e2015-10-13 23:07:00 +05304775 pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09004776 if (pNewJoinBssParam) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004777 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4778 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
4779 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004780 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004781 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
Leo Kim619d27b2015-10-15 13:24:42 +09004782 pNewJoinBssParam->ssid_len = ptstrNetworkInfo->u8SsidLen;
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004783 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4784 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004785
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004786 while (index < u16IEsLen) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004787 if (pu8IEs[index] == SUPP_RATES_IE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004788 suppRatesNo = pu8IEs[index + 1];
4789 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
Leo Kimae4dfa52015-10-13 19:49:26 +09004790 index += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004791
Leo Kimd1666e22015-10-28 15:59:22 +09004792 for (i = 0; i < suppRatesNo; i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004793 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
Leo Kimd1666e22015-10-28 15:59:22 +09004794
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004795 index += suppRatesNo;
4796 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004797 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004798 extSuppRatesNo = pu8IEs[index + 1];
4799 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4800 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4801 else
4802 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4803 index += 2;
Leo Kimd1666e22015-10-28 15:59:22 +09004804 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004805 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
Leo Kimd1666e22015-10-28 15:59:22 +09004806
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004807 index += extSuppRatesNo;
4808 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004809 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004810 pNewJoinBssParam->ht_capable = true;
Leo Kimae4dfa52015-10-13 19:49:26 +09004811 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004812 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004813 } else if ((pu8IEs[index] == WMM_IE) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004814 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
Leo Kimae4dfa52015-10-13 19:49:26 +09004815 (pu8IEs[index + 4] == 0xF2) &&
4816 (pu8IEs[index + 5] == 0x02) &&
4817 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004818 (pu8IEs[index + 7] == 0x01)) {
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004819 pNewJoinBssParam->wmm_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004820
Anish Bhattffda2032015-09-29 12:15:49 -07004821 if (pu8IEs[index + 8] & BIT(7))
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004822 pNewJoinBssParam->uapsd_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004823 index += pu8IEs[index + 1] + 2;
4824 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004825 } else if ((pu8IEs[index] == P2P_IE) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004826 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
Leo Kimae4dfa52015-10-13 19:49:26 +09004827 (pu8IEs[index + 4] == 0x9a) &&
4828 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09004829 u16 u16P2P_count;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004830
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004831 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
Leo Kim7a8d51d2015-10-15 13:24:43 +09004832 pNewJoinBssParam->noa_enabled = 1;
Leo Kimcc179002015-10-15 13:24:47 +09004833 pNewJoinBssParam->idx = pu8IEs[index + 9];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004834
Anish Bhattffda2032015-09-29 12:15:49 -07004835 if (pu8IEs[index + 10] & BIT(7)) {
Leo Kimd72b33c2015-10-15 13:24:44 +09004836 pNewJoinBssParam->opp_enabled = 1;
Leo Kim99b66942015-10-15 13:24:45 +09004837 pNewJoinBssParam->ct_window = pu8IEs[index + 10];
Leo Kimd72b33c2015-10-15 13:24:44 +09004838 } else {
4839 pNewJoinBssParam->opp_enabled = 0;
4840 }
Leo Kimae4dfa52015-10-13 19:49:26 +09004841
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004842 PRINT_D(GENERIC_DBG, "P2P Dump\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004843 for (i = 0; i < pu8IEs[index + 7]; i++)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004844 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004845
Leo Kimc21047e2015-10-15 13:24:46 +09004846 pNewJoinBssParam->cnt = pu8IEs[index + 11];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004847 u16P2P_count = index + 12;
4848
Leo Kim109e6ca2015-10-15 13:24:48 +09004849 memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004850 u16P2P_count += 4;
4851
Leo Kim1d8b76b2015-10-15 13:24:49 +09004852 memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004853 u16P2P_count += 4;
4854
Leo Kim4be55e22015-10-28 15:59:27 +09004855 memcpy(pNewJoinBssParam->start_time, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004856
4857 index += pu8IEs[index + 1] + 2;
4858 continue;
4859
Leo Kimae4dfa52015-10-13 19:49:26 +09004860 } else if ((pu8IEs[index] == RSN_IE) ||
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004861 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
4862 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
4863 (pu8IEs[index + 5] == 0x01))) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09004864 u16 rsnIndex = index;
Leo Kimae4dfa52015-10-13 19:49:26 +09004865
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004866 if (pu8IEs[rsnIndex] == RSN_IE) {
4867 pNewJoinBssParam->mode_802_11i = 2;
Leo Kimae4dfa52015-10-13 19:49:26 +09004868 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004869 if (pNewJoinBssParam->mode_802_11i == 0)
4870 pNewJoinBssParam->mode_802_11i = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004871 rsnIndex += 4;
4872 }
Leo Kimae4dfa52015-10-13 19:49:26 +09004873
4874 rsnIndex += 7;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004875 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
4876 rsnIndex++;
Leo Kimae4dfa52015-10-13 19:49:26 +09004877 jumpOffset = pu8IEs[rsnIndex] * 4;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004878 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
Leo Kimae4dfa52015-10-13 19:49:26 +09004879 rsnIndex += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004880
Leo Kimd1666e22015-10-28 15:59:22 +09004881 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004882 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
Leo Kimd1666e22015-10-28 15:59:22 +09004883
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004884 pcipherTotalCount += pcipherCount;
4885 rsnIndex += jumpOffset;
4886
4887 jumpOffset = pu8IEs[rsnIndex] * 4;
4888
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004889 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
Leo Kimae4dfa52015-10-13 19:49:26 +09004890 rsnIndex += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004891
Leo Kimd1666e22015-10-28 15:59:22 +09004892 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004893 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
Leo Kimd1666e22015-10-28 15:59:22 +09004894
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004895 authTotalCount += authCount;
4896 rsnIndex += jumpOffset;
Leo Kimae4dfa52015-10-13 19:49:26 +09004897
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004898 if (pu8IEs[index] == RSN_IE) {
4899 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
4900 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
4901 rsnIndex += 2;
4902 }
Abdul Hussainf717c0eb2015-06-16 09:49:49 +00004903 pNewJoinBssParam->rsn_found = true;
Leo Kimae4dfa52015-10-13 19:49:26 +09004904 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004905 continue;
4906 } else
Leo Kimae4dfa52015-10-13 19:49:26 +09004907 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004908 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004909 }
4910
4911 return (void *)pNewJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004912}
4913
4914void host_int_freeJoinParams(void *pJoinParams)
4915{
Leo Kim91109e12015-10-19 18:26:13 +09004916 if ((struct bss_param *)pJoinParams)
Leo Kime0a12212015-10-12 16:55:49 +09004917 kfree((struct bss_param *)pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004918 else
4919 PRINT_ER("Unable to FREE null pointer\n");
4920}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004921
Tony Choa4ab1ad2015-10-12 16:56:05 +09004922s32 host_int_delBASession(struct host_if_drv *hif_drv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004923{
Leo Kim31390ee2015-10-19 18:26:08 +09004924 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004925 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09004926 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004927
Tony Choa4ab1ad2015-10-12 16:56:05 +09004928 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004929 PRINT_ER("driver is null\n");
4930 return -EFAULT;
4931 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004932
Tony Cho143eb952015-09-21 12:16:32 +09004933 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004934
Tony Choa9f812a2015-09-21 12:16:33 +09004935 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004936
Leo Kim3fc49992015-10-29 11:58:45 +09004937 memcpy(pBASessionInfo->bssid, pBSSID, ETH_ALEN);
Leo Kim16c9b392015-10-29 11:58:46 +09004938 pBASessionInfo->tid = TID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004939 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004940
Leo Kim31390ee2015-10-19 18:26:08 +09004941 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4942 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004943 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004944
Leo Kim2d25af82015-10-15 13:24:56 +09004945 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004946
Leo Kim31390ee2015-10-19 18:26:08 +09004947 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004948}
4949
Tony Choa4ab1ad2015-10-12 16:56:05 +09004950s32 host_int_del_All_Rx_BASession(struct host_if_drv *hif_drv,
4951 char *pBSSID,
4952 char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004953{
Leo Kim31390ee2015-10-19 18:26:08 +09004954 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004955 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09004956 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004957
Tony Choa4ab1ad2015-10-12 16:56:05 +09004958 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004959 PRINT_ER("driver is null\n");
4960 return -EFAULT;
4961 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004962
Tony Cho143eb952015-09-21 12:16:32 +09004963 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004964
Tony Choa9f812a2015-09-21 12:16:33 +09004965 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004966
Leo Kim3fc49992015-10-29 11:58:45 +09004967 memcpy(pBASessionInfo->bssid, pBSSID, ETH_ALEN);
Leo Kim16c9b392015-10-29 11:58:46 +09004968 pBASessionInfo->tid = TID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004969 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004970
Leo Kim31390ee2015-10-19 18:26:08 +09004971 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4972 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004973 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004974
Leo Kim2d25af82015-10-15 13:24:56 +09004975 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004976
Leo Kim31390ee2015-10-19 18:26:08 +09004977 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004978}
4979
Tony Choa4ab1ad2015-10-12 16:56:05 +09004980s32 host_int_setup_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004981{
Leo Kim31390ee2015-10-19 18:26:08 +09004982 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004983 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004984
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004985 return 0;
4986
Tony Choa4ab1ad2015-10-12 16:56:05 +09004987 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004988 PRINT_ER("driver is null\n");
4989 return -EFAULT;
4990 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004991
Tony Cho143eb952015-09-21 12:16:32 +09004992 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004993
Tony Choa9f812a2015-09-21 12:16:33 +09004994 msg.id = HOST_IF_MSG_SET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004995
Leo Kim78675be2015-10-13 20:02:09 +09004996 msg.body.ip_info.ip_addr = u16ipadd;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004997 msg.drv = hif_drv;
Tony Chofb2d65e2015-09-30 18:44:39 +09004998 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004999
Leo Kim31390ee2015-10-19 18:26:08 +09005000 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5001 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09005002 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005003
Leo Kim31390ee2015-10-19 18:26:08 +09005004 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005005}
5006
Tony Choa4ab1ad2015-10-12 16:56:05 +09005007s32 host_int_get_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005008{
Leo Kim31390ee2015-10-19 18:26:08 +09005009 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005010 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005011
Tony Choa4ab1ad2015-10-12 16:56:05 +09005012 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005013 PRINT_ER("driver is null\n");
5014 return -EFAULT;
5015 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005016
Tony Cho143eb952015-09-21 12:16:32 +09005017 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005018
Tony Choa9f812a2015-09-21 12:16:33 +09005019 msg.id = HOST_IF_MSG_GET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005020
Leo Kim78675be2015-10-13 20:02:09 +09005021 msg.body.ip_info.ip_addr = u16ipadd;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005022 msg.drv = hif_drv;
Tony Chofb2d65e2015-09-30 18:44:39 +09005023 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005024
Leo Kim31390ee2015-10-19 18:26:08 +09005025 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5026 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09005027 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005028
Leo Kim31390ee2015-10-19 18:26:08 +09005029 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005030}