blob: 96c6d4a96024a4eabb575bd23da725749460a438 [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
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900246u8 gau8MulticastMacAddrList[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
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900274extern void chip_sleep_manually(u32 u32SleepTime);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900275extern int linux_wlan_get_num_conn_ifcs(void);
276
Leo Kim441dc602015-10-12 16:55:35 +0900277static int add_handler_in_list(struct host_if_drv *handler)
Johnny Kimd42ab082015-08-20 16:32:52 +0900278{
279 int i;
280
281 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
282 if (!wfidrv_list[i]) {
283 wfidrv_list[i] = handler;
284 return 0;
285 }
286 }
287
288 return -ENOBUFS;
289}
290
Leo Kim441dc602015-10-12 16:55:35 +0900291static int remove_handler_in_list(struct host_if_drv *handler)
Johnny Kimd42ab082015-08-20 16:32:52 +0900292{
293 int i;
294
295 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
296 if (wfidrv_list[i] == handler) {
297 wfidrv_list[i] = NULL;
298 return 0;
299 }
300 }
301
302 return -EINVAL;
303}
304
Leo Kim441dc602015-10-12 16:55:35 +0900305static int get_id_from_handler(struct host_if_drv *handler)
Johnny Kimd42ab082015-08-20 16:32:52 +0900306{
307 int i;
308
309 if (!handler)
310 return 0;
311
312 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
313 if (wfidrv_list[i] == handler)
314 return i;
315 }
316
317 return 0;
318}
319
Leo Kim441dc602015-10-12 16:55:35 +0900320static struct host_if_drv *get_handler_from_id(int id)
Johnny Kimd42ab082015-08-20 16:32:52 +0900321{
Dan Carpenter6ae9ac02015-09-15 09:54:33 +0300322 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
Johnny Kimd42ab082015-08-20 16:32:52 +0900323 return NULL;
324 return wfidrv_list[id];
325}
326
Tony Choa4ab1ad2015-10-12 16:56:05 +0900327static s32 Handle_SetChannel(struct host_if_drv *hif_drv,
Leo Kim9cf78782015-10-29 12:05:54 +0900328 struct channel_attr *hif_set_ch)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900329{
Leo Kim31390ee2015-10-19 18:26:08 +0900330 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900331 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900332
Leo Kim45102f82015-10-28 15:59:28 +0900333 wid.id = (u16)WID_CURRENT_CHANNEL;
334 wid.type = WID_CHAR;
Leo Kim9cf78782015-10-29 12:05:54 +0900335 wid.val = (char *)&hif_set_ch->set_ch;
Leo Kim45102f82015-10-28 15:59:28 +0900336 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900337
338 PRINT_D(HOSTINF_DBG, "Setting channel\n");
Leo Kimae4dfa52015-10-13 19:49:26 +0900339
Leo Kim45102f82015-10-28 15:59:28 +0900340 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +0900341 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +0900342
343 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900344 PRINT_ER("Failed to set channel\n");
Leo Kim24db7132015-09-16 18:36:01 +0900345 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900346 }
347
Leo Kim31390ee2015-10-19 18:26:08 +0900348 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900349}
Leo Kimae4dfa52015-10-13 19:49:26 +0900350
Tony Choa4ab1ad2015-10-12 16:56:05 +0900351static s32 Handle_SetWfiDrvHandler(struct host_if_drv *hif_drv,
Leo Kim6b73c742015-10-29 12:05:55 +0900352 struct drv_handler *hif_drv_handler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900353{
Leo Kim31390ee2015-10-19 18:26:08 +0900354 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900355 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900356
Leo Kim45102f82015-10-28 15:59:28 +0900357 wid.id = (u16)WID_SET_DRV_HANDLER;
358 wid.type = WID_INT;
Leo Kim6b73c742015-10-29 12:05:55 +0900359 wid.val = (s8 *)&hif_drv_handler->handler;
Leo Kim45102f82015-10-28 15:59:28 +0900360 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900361
Leo Kim6b73c742015-10-29 12:05:55 +0900362 result = send_config_pkt(SET_CFG, &wid, 1, hif_drv_handler->handler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900363
Tony Choa4ab1ad2015-10-12 16:56:05 +0900364 if (!hif_drv)
Leo Kim27ff2162015-10-15 13:24:55 +0900365 up(&hif_sema_driver);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900366
Leo Kim31390ee2015-10-19 18:26:08 +0900367 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900368 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900369 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900370 }
371
Leo Kim31390ee2015-10-19 18:26:08 +0900372 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900373}
374
Tony Choa4ab1ad2015-10-12 16:56:05 +0900375static s32 Handle_SetOperationMode(struct host_if_drv *hif_drv,
Tony Cho801bee52015-09-21 12:16:53 +0900376 struct op_mode *pstrHostIfSetOperationMode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900377{
Leo Kim31390ee2015-10-19 18:26:08 +0900378 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900379 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900380
Leo Kim45102f82015-10-28 15:59:28 +0900381 wid.id = (u16)WID_SET_OPERATION_MODE;
382 wid.type = WID_INT;
Leo Kimc96debf2015-10-28 15:59:30 +0900383 wid.val = (s8 *)&pstrHostIfSetOperationMode->mode;
Leo Kim45102f82015-10-28 15:59:28 +0900384 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900385
Leo Kim45102f82015-10-28 15:59:28 +0900386 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +0900387 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900388
Leo Kimc96debf2015-10-28 15:59:30 +0900389 if ((pstrHostIfSetOperationMode->mode) == IDLE_MODE)
Leo Kim27ff2162015-10-15 13:24:55 +0900390 up(&hif_sema_driver);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900391
Leo Kim31390ee2015-10-19 18:26:08 +0900392 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900393 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900394 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900395 }
396
Leo Kim31390ee2015-10-19 18:26:08 +0900397 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900398}
399
Tony Choa4ab1ad2015-10-12 16:56:05 +0900400s32 Handle_set_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900401{
Leo Kim31390ee2015-10-19 18:26:08 +0900402 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900403 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900404 char firmwareIPAddress[4] = {0};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900405
406 if (pu8IPAddr[0] < 192)
407 pu8IPAddr[0] = 0;
408
Luis de Bethencourtb3a02832015-06-26 17:40:25 +0200409 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n", idx, pu8IPAddr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900410
Leo Kim078b1e92015-10-15 13:25:04 +0900411 memcpy(set_ip[idx], pu8IPAddr, 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;
415 wid.val = (u8 *)pu8IPAddr;
416 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
Tony Choa4ab1ad2015-10-12 16:56:05 +0900421 host_int_get_ipaddress(hif_drv, firmwareIPAddress, 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
Tony Choa4ab1ad2015-10-12 16:56:05 +0900433s32 Handle_get_IPAddress(struct host_if_drv *hif_drv, u8 *pu8IPAddr, 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
Tony Choa4ab1ad2015-10-12 16:56:05 +0900467static s32 Handle_SetMacAddress(struct host_if_drv *hif_drv,
Tony Chob7611a82015-09-21 12:16:54 +0900468 struct set_mac_addr *pstrHostIfSetMacAddress)
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 Kimae5e4522015-10-28 15:59:31 +0900478 memcpy(mac_buf, pstrHostIfSetMacAddress->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
Tony Choa4ab1ad2015-10-12 16:56:05 +0900497static s32 Handle_GetMacAddress(struct host_if_drv *hif_drv,
Tony Chofcd27c52015-09-21 12:16:55 +0900498 struct get_mac_addr *pstrHostIfGetMacAddress)
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 Kim6ceba0a2015-10-28 15:59:32 +0900505 wid.val = pstrHostIfGetMacAddress->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
Tony Choa4ab1ad2015-10-12 16:56:05 +0900520static s32 Handle_CfgParam(struct host_if_drv *hif_drv,
Tony Cho361ff842015-09-21 12:16:41 +0900521 struct cfg_param_attr *strHostIFCfgParamAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900522{
Leo Kim31390ee2015-10-19 18:26:08 +0900523 s32 result = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900524 struct wid strWIDList[32];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900525 u8 u8WidCnt = 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
Tony Cho87c05b22015-10-12 16:56:07 +0900531 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BSS_TYPE) {
Tony Cho221371e2015-10-12 16:56:06 +0900532 if (strHostIFCfgParamAttr->cfg_attr_info.bss_type < 6) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900533 strWIDList[u8WidCnt].id = WID_BSS_TYPE;
Tony Cho221371e2015-10-12 16:56:06 +0900534 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.bss_type;
Leo Kim416d8322015-10-12 16:55:43 +0900535 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900536 strWIDList[u8WidCnt].size = sizeof(char);
Leo Kimace303f2015-10-29 11:58:26 +0900537 hif_drv->cfg_values.bss_type = (u8)strHostIFCfgParamAttr->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 }
543 u8WidCnt++;
544 }
Tony Cho87c05b22015-10-12 16:56:07 +0900545 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTH_TYPE) {
Tony Cho221371e2015-10-12 16:56:06 +0900546 if ((strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 1 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 2 || (strHostIFCfgParamAttr->cfg_attr_info.auth_type) == 5) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900547 strWIDList[u8WidCnt].id = WID_AUTH_TYPE;
Tony Cho221371e2015-10-12 16:56:06 +0900548 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_type;
Leo Kim416d8322015-10-12 16:55:43 +0900549 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900550 strWIDList[u8WidCnt].size = sizeof(char);
Leo Kimace303f2015-10-29 11:58:26 +0900551 hif_drv->cfg_values.auth_type = (u8)strHostIFCfgParamAttr->cfg_attr_info.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900552 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900553 PRINT_ER("Impossible value \n");
Leo Kim31390ee2015-10-19 18:26:08 +0900554 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900555 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900556 }
557 u8WidCnt++;
558 }
Tony Cho87c05b22015-10-12 16:56:07 +0900559 if (strHostIFCfgParamAttr->cfg_attr_info.flag & AUTHEN_TIMEOUT) {
Tony Cho221371e2015-10-12 16:56:06 +0900560 if (strHostIFCfgParamAttr->cfg_attr_info.auth_timeout > 0 && strHostIFCfgParamAttr->cfg_attr_info.auth_timeout < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900561 strWIDList[u8WidCnt].id = WID_AUTH_TIMEOUT;
Tony Cho221371e2015-10-12 16:56:06 +0900562 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
Leo Kim416d8322015-10-12 16:55:43 +0900563 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900564 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kimace303f2015-10-29 11:58:26 +0900565 hif_drv->cfg_values.auth_timeout = strHostIFCfgParamAttr->cfg_attr_info.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900566 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900567 PRINT_ER("Range(1 ~ 65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900568 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900569 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900570 }
571 u8WidCnt++;
572 }
Tony Cho87c05b22015-10-12 16:56:07 +0900573 if (strHostIFCfgParamAttr->cfg_attr_info.flag & POWER_MANAGEMENT) {
Tony Cho221371e2015-10-12 16:56:06 +0900574 if (strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode < 5) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900575 strWIDList[u8WidCnt].id = WID_POWER_MANAGEMENT;
Tony Cho221371e2015-10-12 16:56:06 +0900576 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
Leo Kim416d8322015-10-12 16:55:43 +0900577 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900578 strWIDList[u8WidCnt].size = sizeof(char);
Leo Kimace303f2015-10-29 11:58:26 +0900579 hif_drv->cfg_values.power_mgmt_mode = (u8)strHostIFCfgParamAttr->cfg_attr_info.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900580 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900581 PRINT_ER("Invalide power mode\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900582 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900583 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900584 }
585 u8WidCnt++;
586 }
Tony Cho87c05b22015-10-12 16:56:07 +0900587 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_SHORT) {
Tony Cho221371e2015-10-12 16:56:06 +0900588 if ((strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit < 256)) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900589 strWIDList[u8WidCnt].id = WID_SHORT_RETRY_LIMIT;
Tony Cho221371e2015-10-12 16:56:06 +0900590 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
Leo Kim416d8322015-10-12 16:55:43 +0900591 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900592 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kimace303f2015-10-29 11:58:26 +0900593 hif_drv->cfg_values.short_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900594 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900595 PRINT_ER("Range(1~256) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900596 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900597 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900598 }
599 u8WidCnt++;
600 }
Tony Cho87c05b22015-10-12 16:56:07 +0900601 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RETRY_LONG) {
Tony Cho221371e2015-10-12 16:56:06 +0900602 if ((strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit > 0) && (strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit < 256)) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900603 strWIDList[u8WidCnt].id = WID_LONG_RETRY_LIMIT;
Tony Cho221371e2015-10-12 16:56:06 +0900604 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900605
Leo Kim416d8322015-10-12 16:55:43 +0900606 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900607 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kimace303f2015-10-29 11:58:26 +0900608 hif_drv->cfg_values.long_retry_limit = strHostIFCfgParamAttr->cfg_attr_info.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900609 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900610 PRINT_ER("Range(1~256) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900611 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900612 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900613 }
614 u8WidCnt++;
615 }
Tony Cho87c05b22015-10-12 16:56:07 +0900616 if (strHostIFCfgParamAttr->cfg_attr_info.flag & FRAG_THRESHOLD) {
Tony Cho221371e2015-10-12 16:56:06 +0900617 if (strHostIFCfgParamAttr->cfg_attr_info.frag_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.frag_threshold < 7937) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900618 strWIDList[u8WidCnt].id = WID_FRAG_THRESHOLD;
Tony Cho221371e2015-10-12 16:56:06 +0900619 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
Leo Kim416d8322015-10-12 16:55:43 +0900620 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900621 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kimace303f2015-10-29 11:58:26 +0900622 hif_drv->cfg_values.frag_threshold = strHostIFCfgParamAttr->cfg_attr_info.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900623 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900624 PRINT_ER("Threshold Range fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900625 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900626 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900627 }
628 u8WidCnt++;
629 }
Tony Cho87c05b22015-10-12 16:56:07 +0900630 if (strHostIFCfgParamAttr->cfg_attr_info.flag & RTS_THRESHOLD) {
Tony Cho221371e2015-10-12 16:56:06 +0900631 if (strHostIFCfgParamAttr->cfg_attr_info.rts_threshold > 255 && strHostIFCfgParamAttr->cfg_attr_info.rts_threshold < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900632 strWIDList[u8WidCnt].id = WID_RTS_THRESHOLD;
Tony Cho221371e2015-10-12 16:56:06 +0900633 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
Leo Kim416d8322015-10-12 16:55:43 +0900634 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900635 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kimace303f2015-10-29 11:58:26 +0900636 hif_drv->cfg_values.rts_threshold = strHostIFCfgParamAttr->cfg_attr_info.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900637 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900638 PRINT_ER("Threshold Range fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900639 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900640 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900641 }
642 u8WidCnt++;
643 }
Tony Cho87c05b22015-10-12 16:56:07 +0900644 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PREAMBLE) {
Tony Cho221371e2015-10-12 16:56:06 +0900645 if (strHostIFCfgParamAttr->cfg_attr_info.preamble_type < 3) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900646 strWIDList[u8WidCnt].id = WID_PREAMBLE;
Tony Cho221371e2015-10-12 16:56:06 +0900647 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
Leo Kim416d8322015-10-12 16:55:43 +0900648 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900649 strWIDList[u8WidCnt].size = sizeof(char);
Leo Kimace303f2015-10-29 11:58:26 +0900650 hif_drv->cfg_values.preamble_type = strHostIFCfgParamAttr->cfg_attr_info.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900651 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900652 PRINT_ER("Preamle Range(0~2) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900653 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900654 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900655 }
656 u8WidCnt++;
657 }
Tony Cho87c05b22015-10-12 16:56:07 +0900658 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SHORT_SLOT_ALLOWED) {
Tony Cho221371e2015-10-12 16:56:06 +0900659 if (strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed < 2) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900660 strWIDList[u8WidCnt].id = WID_SHORT_SLOT_ALLOWED;
Tony Cho221371e2015-10-12 16:56:06 +0900661 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
Leo Kim416d8322015-10-12 16:55:43 +0900662 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900663 strWIDList[u8WidCnt].size = sizeof(char);
Leo Kimace303f2015-10-29 11:58:26 +0900664 hif_drv->cfg_values.short_slot_allowed = (u8)strHostIFCfgParamAttr->cfg_attr_info.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900665 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900666 PRINT_ER("Short slot(2) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900667 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900668 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900669 }
670 u8WidCnt++;
671 }
Tony Cho87c05b22015-10-12 16:56:07 +0900672 if (strHostIFCfgParamAttr->cfg_attr_info.flag & TXOP_PROT_DISABLE) {
Tony Cho221371e2015-10-12 16:56:06 +0900673 if (strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled < 2) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900674 strWIDList[u8WidCnt].id = WID_11N_TXOP_PROT_DISABLE;
Tony Cho221371e2015-10-12 16:56:06 +0900675 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
Leo Kim416d8322015-10-12 16:55:43 +0900676 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900677 strWIDList[u8WidCnt].size = sizeof(char);
Leo Kimace303f2015-10-29 11:58:26 +0900678 hif_drv->cfg_values.txop_prot_disabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900679 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900680 PRINT_ER("TXOP prot disable\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900681 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900682 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900683 }
684 u8WidCnt++;
685 }
Tony Cho87c05b22015-10-12 16:56:07 +0900686 if (strHostIFCfgParamAttr->cfg_attr_info.flag & BEACON_INTERVAL) {
Tony Cho221371e2015-10-12 16:56:06 +0900687 if (strHostIFCfgParamAttr->cfg_attr_info.beacon_interval > 0 && strHostIFCfgParamAttr->cfg_attr_info.beacon_interval < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900688 strWIDList[u8WidCnt].id = WID_BEACON_INTERVAL;
Tony Cho221371e2015-10-12 16:56:06 +0900689 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
Leo Kim416d8322015-10-12 16:55:43 +0900690 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900691 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kimace303f2015-10-29 11:58:26 +0900692 hif_drv->cfg_values.beacon_interval = strHostIFCfgParamAttr->cfg_attr_info.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900693 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900694 PRINT_ER("Beacon interval(1~65535) fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900695 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900696 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900697 }
698 u8WidCnt++;
699 }
Tony Cho87c05b22015-10-12 16:56:07 +0900700 if (strHostIFCfgParamAttr->cfg_attr_info.flag & DTIM_PERIOD) {
Tony Cho221371e2015-10-12 16:56:06 +0900701 if (strHostIFCfgParamAttr->cfg_attr_info.dtim_period > 0 && strHostIFCfgParamAttr->cfg_attr_info.dtim_period < 256) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900702 strWIDList[u8WidCnt].id = WID_DTIM_PERIOD;
Tony Cho221371e2015-10-12 16:56:06 +0900703 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
Leo Kim416d8322015-10-12 16:55:43 +0900704 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900705 strWIDList[u8WidCnt].size = sizeof(char);
Leo Kimace303f2015-10-29 11:58:26 +0900706 hif_drv->cfg_values.dtim_period = strHostIFCfgParamAttr->cfg_attr_info.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900707 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900708 PRINT_ER("DTIM range(1~255) fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900709 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900710 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900711 }
712 u8WidCnt++;
713 }
Tony Cho87c05b22015-10-12 16:56:07 +0900714 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY) {
Tony Cho221371e2015-10-12 16:56:06 +0900715 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled < 3) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900716 strWIDList[u8WidCnt].id = WID_SITE_SURVEY;
Tony Cho221371e2015-10-12 16:56:06 +0900717 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
Leo Kim416d8322015-10-12 16:55:43 +0900718 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900719 strWIDList[u8WidCnt].size = sizeof(char);
Leo Kimace303f2015-10-29 11:58:26 +0900720 hif_drv->cfg_values.site_survey_enabled = (u8)strHostIFCfgParamAttr->cfg_attr_info.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900721 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900722 PRINT_ER("Site survey disable\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900723 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900724 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900725 }
726 u8WidCnt++;
727 }
Tony Cho87c05b22015-10-12 16:56:07 +0900728 if (strHostIFCfgParamAttr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) {
Tony Cho221371e2015-10-12 16:56:06 +0900729 if (strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900730 strWIDList[u8WidCnt].id = WID_SITE_SURVEY_SCAN_TIME;
Tony Cho221371e2015-10-12 16:56:06 +0900731 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
Leo Kim416d8322015-10-12 16:55:43 +0900732 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900733 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kimace303f2015-10-29 11:58:26 +0900734 hif_drv->cfg_values.site_survey_scan_time = strHostIFCfgParamAttr->cfg_attr_info.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900735 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900736 PRINT_ER("Site survey scan time(1~65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900737 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900738 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900739 }
740 u8WidCnt++;
741 }
Tony Cho87c05b22015-10-12 16:56:07 +0900742 if (strHostIFCfgParamAttr->cfg_attr_info.flag & ACTIVE_SCANTIME) {
Tony Cho221371e2015-10-12 16:56:06 +0900743 if (strHostIFCfgParamAttr->cfg_attr_info.active_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.active_scan_time < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900744 strWIDList[u8WidCnt].id = WID_ACTIVE_SCAN_TIME;
Tony Cho221371e2015-10-12 16:56:06 +0900745 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
Leo Kim416d8322015-10-12 16:55:43 +0900746 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900747 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kimace303f2015-10-29 11:58:26 +0900748 hif_drv->cfg_values.active_scan_time = strHostIFCfgParamAttr->cfg_attr_info.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900749 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900750 PRINT_ER("Active scan time(1~65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900751 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900752 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900753 }
754 u8WidCnt++;
755 }
Tony Cho87c05b22015-10-12 16:56:07 +0900756 if (strHostIFCfgParamAttr->cfg_attr_info.flag & PASSIVE_SCANTIME) {
Tony Cho221371e2015-10-12 16:56:06 +0900757 if (strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time > 0 && strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900758 strWIDList[u8WidCnt].id = WID_PASSIVE_SCAN_TIME;
Tony Cho221371e2015-10-12 16:56:06 +0900759 strWIDList[u8WidCnt].val = (s8 *)&strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
Leo Kim416d8322015-10-12 16:55:43 +0900760 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900761 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kimace303f2015-10-29 11:58:26 +0900762 hif_drv->cfg_values.passive_scan_time = strHostIFCfgParamAttr->cfg_attr_info.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900763 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900764 PRINT_ER("Passive scan time(1~65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900765 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900766 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900767 }
768 u8WidCnt++;
769 }
Tony Cho87c05b22015-10-12 16:56:07 +0900770 if (strHostIFCfgParamAttr->cfg_attr_info.flag & CURRENT_TX_RATE) {
Tony Cho221371e2015-10-12 16:56:06 +0900771 enum CURRENT_TXRATE curr_tx_rate = strHostIFCfgParamAttr->cfg_attr_info.curr_tx_rate;
Leo Kimc09389a2015-10-28 15:59:24 +0900772
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900773 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
774 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
775 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
776 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
777 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
778 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900779 strWIDList[u8WidCnt].id = WID_CURRENT_TX_RATE;
Leo Kim900bb4a2015-10-12 16:55:46 +0900780 strWIDList[u8WidCnt].val = (s8 *)&curr_tx_rate;
Leo Kim416d8322015-10-12 16:55:43 +0900781 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900782 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kimace303f2015-10-29 11:58:26 +0900783 hif_drv->cfg_values.curr_tx_rate = (u8)curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900784 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900785 PRINT_ER("out of TX rate\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900786 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900787 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900788 }
789 u8WidCnt++;
790 }
Leo Kim31390ee2015-10-19 18:26:08 +0900791
792 result = send_config_pkt(SET_CFG, strWIDList, u8WidCnt,
Leo Kim8c8360b2015-10-19 18:26:12 +0900793 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900794
Leo Kim31390ee2015-10-19 18:26:08 +0900795 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900796 PRINT_ER("Error in setting CFG params\n");
797
Leo Kim24db7132015-09-16 18:36:01 +0900798ERRORHANDLER:
Leo Kim33110ad2015-10-29 11:58:27 +0900799 up(&hif_drv->sem_cfg_values);
Leo Kim31390ee2015-10-19 18:26:08 +0900800 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900801}
802
Chaehyun Limfb4ec9c2015-06-11 14:35:59 +0900803static s32 Handle_wait_msg_q_empty(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900804{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900805 g_wilc_initialized = 0;
Leo Kim2d25af82015-10-15 13:24:56 +0900806 up(&hif_sema_wait_response);
Leo Kimb68d820b2015-10-12 16:55:37 +0900807 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900808}
809
Tony Choa4ab1ad2015-10-12 16:56:05 +0900810static s32 Handle_Scan(struct host_if_drv *hif_drv,
Tony Choc476feb2015-09-21 12:16:36 +0900811 struct scan_attr *pstrHostIFscanAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900812{
Leo Kim31390ee2015-10-19 18:26:08 +0900813 s32 result = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900814 struct wid strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900815 u32 u32WidsCount = 0;
816 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900817 u8 *pu8Buffer;
818 u8 valuesize = 0;
819 u8 *pu8HdnNtwrksWidVal = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900820
821 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
Leo Kimb60005a2015-10-29 11:58:24 +0900822 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", hif_drv->hif_state);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900823
Leo Kimbc801852015-10-29 11:58:50 +0900824 hif_drv->usr_scan_req.scan_result = pstrHostIFscanAttr->result;
Leo Kim66eaea32015-10-29 11:58:51 +0900825 hif_drv->usr_scan_req.arg = pstrHostIFscanAttr->arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900826
Leo Kimb60005a2015-10-29 11:58:24 +0900827 if ((hif_drv->hif_state >= HOST_IF_SCANNING) &&
828 (hif_drv->hif_state < HOST_IF_CONNECTED)) {
829 PRINT_D(GENERIC_DBG, "Don't scan already in [%d] state\n",
830 hif_drv->hif_state);
Leo Kim24db7132015-09-16 18:36:01 +0900831 PRINT_ER("Already scan\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900832 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +0900833 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900834 }
835
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900836 if (g_obtainingIP || connecting) {
837 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +0900838 PRINT_ER("Don't do obss scan\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900839 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +0900840 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900841 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900842
843 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
844
Leo Kimf79756e2015-10-29 12:05:36 +0900845 hif_drv->usr_scan_req.rcvd_ch_cnt = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900846
Leo Kimdaaf16b2015-10-12 16:55:44 +0900847 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
Leo Kim416d8322015-10-12 16:55:43 +0900848 strWIDList[u32WidsCount].type = WID_STR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900849
Leo Kim629b9ca2015-10-13 19:49:46 +0900850 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++)
851 valuesize += ((pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
Glen Leef3052582015-09-10 12:03:04 +0900852 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
Leo Kim900bb4a2015-10-12 16:55:46 +0900853 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
Leo Kim91109e12015-10-19 18:26:13 +0900854 if (strWIDList[u32WidsCount].val) {
Leo Kim900bb4a2015-10-12 16:55:46 +0900855 pu8Buffer = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900856
Leo Kim629b9ca2015-10-13 19:49:46 +0900857 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900858
Leo Kim629b9ca2015-10-13 19:49:46 +0900859 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->hidden_network.u8ssidnum);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900860
Leo Kim629b9ca2015-10-13 19:49:46 +0900861 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++) {
862 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
863 memcpy(pu8Buffer, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen);
864 pu8Buffer += pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900865 }
866
Leo Kim2fd3e442015-10-12 16:55:45 +0900867 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900868 u32WidsCount++;
869 }
870
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900871 {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900872 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
Leo Kim416d8322015-10-12 16:55:43 +0900873 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kimd6f19aa2015-10-13 19:49:42 +0900874 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ies;
Leo Kim7b1f76c2015-10-13 19:49:43 +0900875 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ies_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900876 u32WidsCount++;
877 }
878
Leo Kimdaaf16b2015-10-12 16:55:44 +0900879 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +0900880 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900881 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +0900882 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900883 u32WidsCount++;
884
Leo Kimdaaf16b2015-10-12 16:55:44 +0900885 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
Leo Kim416d8322015-10-12 16:55:43 +0900886 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900887
Leo Kim91109e12015-10-19 18:26:13 +0900888 if (pstrHostIFscanAttr->ch_freq_list &&
889 pstrHostIFscanAttr->ch_list_len > 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900890 int i;
891
Leo Kimf97bd9c2015-10-13 19:49:41 +0900892 for (i = 0; i < pstrHostIFscanAttr->ch_list_len; i++) {
Leo Kim82eeb0a2015-10-13 19:49:40 +0900893 if (pstrHostIFscanAttr->ch_freq_list[i] > 0)
894 pstrHostIFscanAttr->ch_freq_list[i] = pstrHostIFscanAttr->ch_freq_list[i] - 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900895 }
896 }
897
Leo Kim82eeb0a2015-10-13 19:49:40 +0900898 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
Leo Kimf97bd9c2015-10-13 19:49:41 +0900899 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900900 u32WidsCount++;
901
Leo Kimdaaf16b2015-10-12 16:55:44 +0900902 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
Leo Kim416d8322015-10-12 16:55:43 +0900903 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900904 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +0900905 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->src;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900906 u32WidsCount++;
907
Leo Kimb60005a2015-10-29 11:58:24 +0900908 if (hif_drv->hif_state == HOST_IF_CONNECTED)
Leo Kimca8540e42015-10-15 13:25:00 +0900909 scan_while_connected = true;
Leo Kimb60005a2015-10-29 11:58:24 +0900910 else if (hif_drv->hif_state == HOST_IF_IDLE)
Leo Kimca8540e42015-10-15 13:25:00 +0900911 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900912
Leo Kim31390ee2015-10-19 18:26:08 +0900913 result = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
Leo Kim8c8360b2015-10-19 18:26:12 +0900914 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900915
Leo Kim31390ee2015-10-19 18:26:08 +0900916 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900917 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +0900918 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900919 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900920
Leo Kim24db7132015-09-16 18:36:01 +0900921ERRORHANDLER:
Leo Kim31390ee2015-10-19 18:26:08 +0900922 if (result) {
Leo Kim13b313e2015-10-29 11:58:34 +0900923 del_timer(&hif_drv->scan_timer);
Tony Choa4ab1ad2015-10-12 16:56:05 +0900924 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900925 }
926
Shraddha Barke95f840f2015-10-14 07:29:19 +0530927 kfree(pstrHostIFscanAttr->ch_freq_list);
928 pstrHostIFscanAttr->ch_freq_list = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900929
Shraddha Barke95f840f2015-10-14 07:29:19 +0530930 kfree(pstrHostIFscanAttr->ies);
931 pstrHostIFscanAttr->ies = NULL;
932 kfree(pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo);
933 pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900934
Shraddha Barke95f840f2015-10-14 07:29:19 +0530935 kfree(pu8HdnNtwrksWidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900936
Leo Kim31390ee2015-10-19 18:26:08 +0900937 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900938}
939
Tony Choa4ab1ad2015-10-12 16:56:05 +0900940static s32 Handle_ScanDone(struct host_if_drv *hif_drv,
941 enum scan_event enuEvent)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900942{
Leo Kim31390ee2015-10-19 18:26:08 +0900943 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900944 u8 u8abort_running_scan;
Leo Kim45102f82015-10-28 15:59:28 +0900945 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900946
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900947 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
948
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900949 if (enuEvent == SCAN_EVENT_ABORTED) {
950 PRINT_D(GENERIC_DBG, "Abort running scan\n");
951 u8abort_running_scan = 1;
Leo Kim45102f82015-10-28 15:59:28 +0900952 wid.id = (u16)WID_ABORT_RUNNING_SCAN;
953 wid.type = WID_CHAR;
954 wid.val = (s8 *)&u8abort_running_scan;
955 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900956
Leo Kim45102f82015-10-28 15:59:28 +0900957 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +0900958 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +0900959
960 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900961 PRINT_ER("Failed to set abort running scan\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900962 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900963 }
964 }
965
Tony Choa4ab1ad2015-10-12 16:56:05 +0900966 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900967 PRINT_ER("Driver handler is NULL\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900968 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900969 }
970
Leo Kimbc801852015-10-29 11:58:50 +0900971 if (hif_drv->usr_scan_req.scan_result) {
972 hif_drv->usr_scan_req.scan_result(enuEvent, NULL,
Leo Kim66eaea32015-10-29 11:58:51 +0900973 hif_drv->usr_scan_req.arg, NULL);
Leo Kimbc801852015-10-29 11:58:50 +0900974 hif_drv->usr_scan_req.scan_result = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900975 }
976
Leo Kim31390ee2015-10-19 18:26:08 +0900977 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900978}
979
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900980u8 u8ConnectedSSID[6] = {0};
Tony Choa4ab1ad2015-10-12 16:56:05 +0900981static s32 Handle_Connect(struct host_if_drv *hif_drv,
Tony Cho120ae592015-09-21 12:16:37 +0900982 struct connect_attr *pstrHostIFconnectAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900983{
Leo Kim31390ee2015-10-19 18:26:08 +0900984 s32 result = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900985 struct wid strWIDList[8];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900986 u32 u32WidsCount = 0, dummyval = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900987 u8 *pu8CurrByte = NULL;
Leo Kime0a12212015-10-12 16:55:49 +0900988 struct join_bss_param *ptstrJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900989
990 PRINT_D(GENERIC_DBG, "Handling connect request\n");
991
Leo Kim9254db02015-10-13 19:49:49 +0900992 if (memcmp(pstrHostIFconnectAttr->bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
Leo Kim31390ee2015-10-19 18:26:08 +0900993 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900994 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900995 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900996 }
997
998 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
999
Leo Kimf2bed2c2015-10-13 19:49:59 +09001000 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->params;
Leo Kim91109e12015-10-19 18:26:13 +09001001 if (!ptstrJoinBssParam) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001002 PRINT_ER("Required BSSID not found\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001003 result = -ENOENT;
Leo Kim24db7132015-09-16 18:36:01 +09001004 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001005 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001006
Leo Kim91109e12015-10-19 18:26:13 +09001007 if (pstrHostIFconnectAttr->bssid) {
Leo Kimf8b17132015-10-28 15:59:34 +09001008 hif_drv->usr_conn_req.pu8bssid = kmalloc(6, GFP_KERNEL);
1009 memcpy(hif_drv->usr_conn_req.pu8bssid, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001010 }
1011
Leo Kim74ab5e42015-10-29 11:58:53 +09001012 hif_drv->usr_conn_req.ssid_len = pstrHostIFconnectAttr->ssid_len;
Leo Kim91109e12015-10-19 18:26:13 +09001013 if (pstrHostIFconnectAttr->ssid) {
Leo Kimf8b17132015-10-28 15:59:34 +09001014 hif_drv->usr_conn_req.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
1015 memcpy(hif_drv->usr_conn_req.pu8ssid,
Leo Kim8c8360b2015-10-19 18:26:12 +09001016 pstrHostIFconnectAttr->ssid,
1017 pstrHostIFconnectAttr->ssid_len);
Leo Kimf8b17132015-10-28 15:59:34 +09001018 hif_drv->usr_conn_req.pu8ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001019 }
1020
Leo Kim331ed082015-10-29 11:58:55 +09001021 hif_drv->usr_conn_req.ies_len = pstrHostIFconnectAttr->ies_len;
Leo Kim91109e12015-10-19 18:26:13 +09001022 if (pstrHostIFconnectAttr->ies) {
Leo Kima3b2f4b2015-10-29 11:58:54 +09001023 hif_drv->usr_conn_req.ies = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1024 memcpy(hif_drv->usr_conn_req.ies,
Leo Kim8c8360b2015-10-19 18:26:12 +09001025 pstrHostIFconnectAttr->ies,
1026 pstrHostIFconnectAttr->ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001027 }
1028
Leo Kimf8b17132015-10-28 15:59:34 +09001029 hif_drv->usr_conn_req.u8security = pstrHostIFconnectAttr->security;
Leo Kim7d069722015-10-29 12:05:37 +09001030 hif_drv->usr_conn_req.auth_type = pstrHostIFconnectAttr->auth_type;
Leo Kim33bfb192015-10-29 11:58:56 +09001031 hif_drv->usr_conn_req.conn_result = pstrHostIFconnectAttr->result;
Leo Kim73abaa42015-10-29 12:05:27 +09001032 hif_drv->usr_conn_req.arg = pstrHostIFconnectAttr->arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001033
Leo Kimdaaf16b2015-10-12 16:55:44 +09001034 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001035 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001036 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001037 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001038 u32WidsCount++;
1039
Leo Kimdaaf16b2015-10-12 16:55:44 +09001040 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001041 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001042 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001043 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001044 u32WidsCount++;
1045
Leo Kimdaaf16b2015-10-12 16:55:44 +09001046 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001047 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001048 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001049 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001050 u32WidsCount++;
1051
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001052 {
Leo Kimdaaf16b2015-10-12 16:55:44 +09001053 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
Leo Kim416d8322015-10-12 16:55:43 +09001054 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001055 strWIDList[u32WidsCount].val = hif_drv->usr_conn_req.ies;
Leo Kim331ed082015-10-29 11:58:55 +09001056 strWIDList[u32WidsCount].size = hif_drv->usr_conn_req.ies_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001057 u32WidsCount++;
1058
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001059 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Leo Kim331ed082015-10-29 11:58:55 +09001060 info_element_size = hif_drv->usr_conn_req.ies_len;
Leo Kimdfef7b82015-10-15 13:25:14 +09001061 info_element = kmalloc(info_element_size, GFP_KERNEL);
Leo Kima3b2f4b2015-10-29 11:58:54 +09001062 memcpy(info_element, hif_drv->usr_conn_req.ies,
Leo Kimdfef7b82015-10-15 13:25:14 +09001063 info_element_size);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001064 }
1065 }
Leo Kimdaaf16b2015-10-12 16:55:44 +09001066 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001067 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001068 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimf8b17132015-10-28 15:59:34 +09001069 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001070 u32WidsCount++;
1071
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001072 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
Leo Kimf8b17132015-10-28 15:59:34 +09001073 mode_11i = hif_drv->usr_conn_req.u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001074
Leo Kimf8b17132015-10-28 15:59:34 +09001075 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", hif_drv->usr_conn_req.u8security);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001076
Leo Kimdaaf16b2015-10-12 16:55:44 +09001077 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001078 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001079 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim7d069722015-10-29 12:05:37 +09001080 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001081 u32WidsCount++;
1082
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001083 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
Leo Kim7d069722015-10-29 12:05:37 +09001084 auth_type = (u8)hif_drv->usr_conn_req.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001085
Leo Kim7d069722015-10-29 12:05:37 +09001086 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n",
1087 hif_drv->usr_conn_req.auth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001088 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
Leo Kimf8b17132015-10-28 15:59:34 +09001089 hif_drv->usr_conn_req.pu8ssid, pstrHostIFconnectAttr->ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001090
Leo Kimdaaf16b2015-10-12 16:55:44 +09001091 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
Leo Kim416d8322015-10-12 16:55:43 +09001092 strWIDList[u32WidsCount].type = WID_STR;
Leo Kimae4dfa52015-10-13 19:49:26 +09001093 strWIDList[u32WidsCount].size = 112;
Leo Kim900bb4a2015-10-12 16:55:46 +09001094 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001095
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001096 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Leo Kim0626baa2015-10-15 13:25:13 +09001097 join_req_size = strWIDList[u32WidsCount].size;
1098 join_req = kmalloc(join_req_size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001099 }
Leo Kim91109e12015-10-19 18:26:13 +09001100 if (!strWIDList[u32WidsCount].val) {
Leo Kim31390ee2015-10-19 18:26:08 +09001101 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09001102 goto ERRORHANDLER;
1103 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001104
Leo Kim900bb4a2015-10-12 16:55:46 +09001105 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001106
Leo Kim91109e12015-10-19 18:26:13 +09001107 if (pstrHostIFconnectAttr->ssid) {
Leo Kim8b3c9fa2015-10-13 19:49:51 +09001108 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1109 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001110 }
1111 pu8CurrByte += MAX_SSID_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001112 *(pu8CurrByte++) = INFRASTRUCTURE;
Leo Kimae4dfa52015-10-13 19:49:26 +09001113
Leo Kim0d1527e2015-10-13 19:49:58 +09001114 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1115 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001116 } else {
1117 PRINT_ER("Channel out of range\n");
1118 *(pu8CurrByte++) = 0xFF;
1119 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001120 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1121 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1122 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1123
Leo Kim91109e12015-10-19 18:26:13 +09001124 if (pstrHostIFconnectAttr->bssid)
Leo Kim9254db02015-10-13 19:49:49 +09001125 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001126 pu8CurrByte += 6;
1127
Tony Choc0f52fb2015-10-20 17:10:46 +09001128 if (pstrHostIFconnectAttr->bssid)
1129 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1130 pu8CurrByte += 6;
1131
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001132 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1133 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1134 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001135 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1136 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
Leo Kimae4dfa52015-10-13 19:49:26 +09001137
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001138 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001139 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1140
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001141 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1142 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001143 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1144
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001145 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
Leo Kimff069822015-10-29 12:05:26 +09001146 hif_drv->usr_conn_req.ht_capable = ptstrJoinBssParam->ht_capable;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001147
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001148 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1149 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001150 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1151 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001152 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1153 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
Leo Kimae4dfa52015-10-13 19:49:26 +09001154
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001155 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001156 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1157
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001158 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001159 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1160
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001161 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001162 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1163
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001164 *(pu8CurrByte++) = REAL_JOIN_REQ;
Leo Kim7a8d51d2015-10-15 13:24:43 +09001165 *(pu8CurrByte++) = ptstrJoinBssParam->noa_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001166
Leo Kim7a8d51d2015-10-15 13:24:43 +09001167 if (ptstrJoinBssParam->noa_enabled) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001168 PRINT_D(HOSTINF_DBG, "NOA present\n");
1169
1170 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1171 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1172 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1173 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1174
Leo Kimd72b33c2015-10-15 13:24:44 +09001175 *(pu8CurrByte++) = ptstrJoinBssParam->opp_enabled;
Leo Kimcc179002015-10-15 13:24:47 +09001176 *(pu8CurrByte++) = ptstrJoinBssParam->idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001177
Leo Kimd72b33c2015-10-15 13:24:44 +09001178 if (ptstrJoinBssParam->opp_enabled)
Leo Kim99b66942015-10-15 13:24:45 +09001179 *(pu8CurrByte++) = ptstrJoinBssParam->ct_window;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001180
Leo Kimc21047e2015-10-15 13:24:46 +09001181 *(pu8CurrByte++) = ptstrJoinBssParam->cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001182
Leo Kim109e6ca2015-10-15 13:24:48 +09001183 memcpy(pu8CurrByte, ptstrJoinBssParam->duration, sizeof(ptstrJoinBssParam->duration));
1184 pu8CurrByte += sizeof(ptstrJoinBssParam->duration);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001185
Leo Kim1d8b76b2015-10-15 13:24:49 +09001186 memcpy(pu8CurrByte, ptstrJoinBssParam->interval, sizeof(ptstrJoinBssParam->interval));
1187 pu8CurrByte += sizeof(ptstrJoinBssParam->interval);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001188
Leo Kim4be55e22015-10-28 15:59:27 +09001189 memcpy(pu8CurrByte, ptstrJoinBssParam->start_time, sizeof(ptstrJoinBssParam->start_time));
1190 pu8CurrByte += sizeof(ptstrJoinBssParam->start_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001191 } else
1192 PRINT_D(HOSTINF_DBG, "NOA not present\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001193
Leo Kim900bb4a2015-10-12 16:55:46 +09001194 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001195 u32WidsCount++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001196
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001197 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Leo Kim0626baa2015-10-15 13:25:13 +09001198 memcpy(join_req, pu8CurrByte, join_req_size);
Leo Kim870515c2015-10-15 13:25:15 +09001199 join_req_drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001200 }
1201
1202 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1203
Leo Kim91109e12015-10-19 18:26:13 +09001204 if (pstrHostIFconnectAttr->bssid) {
Leo Kim9254db02015-10-13 19:49:49 +09001205 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001206
Leo Kim9254db02015-10-13 19:49:49 +09001207 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->bssid);
Alexander Kuleshov310a28f2015-09-04 00:48:14 +06001208 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001209 }
1210
Leo Kim31390ee2015-10-19 18:26:08 +09001211 result = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
Leo Kim8c8360b2015-10-19 18:26:12 +09001212 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09001213 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09001214 PRINT_ER("failed to send config packet\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001215 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09001216 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001217 } else {
1218 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
Leo Kimb60005a2015-10-29 11:58:24 +09001219 hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001220 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001221
Leo Kim24db7132015-09-16 18:36:01 +09001222ERRORHANDLER:
Leo Kim31390ee2015-10-19 18:26:08 +09001223 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001224 tstrConnectInfo strConnectInfo;
1225
Leo Kim81a59502015-10-29 11:58:35 +09001226 del_timer(&hif_drv->connect_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001227
1228 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1229
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001230 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001231
Leo Kim91109e12015-10-19 18:26:13 +09001232 if (pstrHostIFconnectAttr->result) {
1233 if (pstrHostIFconnectAttr->bssid)
Leo Kim9254db02015-10-13 19:49:49 +09001234 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001235
Leo Kim91109e12015-10-19 18:26:13 +09001236 if (pstrHostIFconnectAttr->ies) {
Leo Kimb59d5c52015-10-13 19:49:53 +09001237 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->ies_len;
1238 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001239 memcpy(strConnectInfo.pu8ReqIEs,
Leo Kim8c8360b2015-10-19 18:26:12 +09001240 pstrHostIFconnectAttr->ies,
1241 pstrHostIFconnectAttr->ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001242 }
1243
Leo Kim6abcc112015-10-13 19:49:55 +09001244 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001245 &strConnectInfo,
1246 MAC_DISCONNECTED,
1247 NULL,
Leo Kim8f38db82015-10-13 19:49:56 +09001248 pstrHostIFconnectAttr->arg);
Leo Kimb60005a2015-10-29 11:58:24 +09001249 hif_drv->hif_state = HOST_IF_IDLE;
Shraddha Barke95f840f2015-10-14 07:29:19 +05301250 kfree(strConnectInfo.pu8ReqIEs);
1251 strConnectInfo.pu8ReqIEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001252
1253 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001254 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001255 }
1256 }
1257
1258 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
Shraddha Barke95f840f2015-10-14 07:29:19 +05301259 kfree(pstrHostIFconnectAttr->bssid);
1260 pstrHostIFconnectAttr->bssid = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001261
Shraddha Barke95f840f2015-10-14 07:29:19 +05301262 kfree(pstrHostIFconnectAttr->ssid);
1263 pstrHostIFconnectAttr->ssid = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001264
Shraddha Barke95f840f2015-10-14 07:29:19 +05301265 kfree(pstrHostIFconnectAttr->ies);
1266 pstrHostIFconnectAttr->ies = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001267
Shraddha Barke95f840f2015-10-14 07:29:19 +05301268 kfree(pu8CurrByte);
Leo Kim31390ee2015-10-19 18:26:08 +09001269 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001270}
1271
Tony Choa4ab1ad2015-10-12 16:56:05 +09001272static s32 Handle_FlushConnect(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001273{
Leo Kim31390ee2015-10-19 18:26:08 +09001274 s32 result = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09001275 struct wid strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001276 u32 u32WidsCount = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001277 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001278
Leo Kimdaaf16b2015-10-12 16:55:44 +09001279 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
Leo Kim416d8322015-10-12 16:55:43 +09001280 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kim48ce2462015-10-15 13:25:10 +09001281 strWIDList[u32WidsCount].val = info_element;
Leo Kimdfef7b82015-10-15 13:25:14 +09001282 strWIDList[u32WidsCount].size = info_element_size;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001283 u32WidsCount++;
1284
Leo Kimdaaf16b2015-10-12 16:55:44 +09001285 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001286 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001287 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim1bd9d442015-10-15 13:25:11 +09001288 strWIDList[u32WidsCount].val = (s8 *)(&(mode_11i));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001289 u32WidsCount++;
1290
Leo Kimdaaf16b2015-10-12 16:55:44 +09001291 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001292 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001293 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimfba49892015-10-15 13:25:12 +09001294 strWIDList[u32WidsCount].val = (s8 *)(&auth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001295 u32WidsCount++;
1296
Leo Kimdaaf16b2015-10-12 16:55:44 +09001297 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
Leo Kim416d8322015-10-12 16:55:43 +09001298 strWIDList[u32WidsCount].type = WID_STR;
Leo Kim0626baa2015-10-15 13:25:13 +09001299 strWIDList[u32WidsCount].size = join_req_size;
Leo Kim044a64102015-10-15 13:25:09 +09001300 strWIDList[u32WidsCount].val = (s8 *)join_req;
Leo Kim900bb4a2015-10-12 16:55:46 +09001301 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001302
1303 pu8CurrByte += FLUSHED_BYTE_POS;
1304 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1305
1306 u32WidsCount++;
1307
Leo Kim31390ee2015-10-19 18:26:08 +09001308 result = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
Leo Kim8c8360b2015-10-19 18:26:12 +09001309 get_id_from_handler(join_req_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09001310 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09001311 PRINT_ER("failed to send config packet\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001312 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001313 }
1314
Leo Kim31390ee2015-10-19 18:26:08 +09001315 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001316}
1317
Tony Choa4ab1ad2015-10-12 16:56:05 +09001318static s32 Handle_ConnectTimeout(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001319{
Leo Kim31390ee2015-10-19 18:26:08 +09001320 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001321 tstrConnectInfo strConnectInfo;
Leo Kim45102f82015-10-28 15:59:28 +09001322 struct wid wid;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001323 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001324
Tony Choa4ab1ad2015-10-12 16:56:05 +09001325 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001326 PRINT_ER("Driver handler is NULL\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001327 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001328 }
1329
Leo Kimb60005a2015-10-29 11:58:24 +09001330 hif_drv->hif_state = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001331
Leo Kimca8540e42015-10-15 13:25:00 +09001332 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001333
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001334 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001335
Leo Kim33bfb192015-10-29 11:58:56 +09001336 if (hif_drv->usr_conn_req.conn_result) {
Leo Kimf8b17132015-10-28 15:59:34 +09001337 if (hif_drv->usr_conn_req.pu8bssid) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001338 memcpy(strConnectInfo.au8bssid,
Leo Kimf8b17132015-10-28 15:59:34 +09001339 hif_drv->usr_conn_req.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001340 }
1341
Leo Kima3b2f4b2015-10-29 11:58:54 +09001342 if (hif_drv->usr_conn_req.ies) {
Leo Kim331ed082015-10-29 11:58:55 +09001343 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len;
1344 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001345 memcpy(strConnectInfo.pu8ReqIEs,
Leo Kima3b2f4b2015-10-29 11:58:54 +09001346 hif_drv->usr_conn_req.ies,
Leo Kim331ed082015-10-29 11:58:55 +09001347 hif_drv->usr_conn_req.ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001348 }
1349
Leo Kim33bfb192015-10-29 11:58:56 +09001350 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1351 &strConnectInfo,
1352 MAC_DISCONNECTED,
1353 NULL,
Leo Kim73abaa42015-10-29 12:05:27 +09001354 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001355
Shraddha Barke95f840f2015-10-14 07:29:19 +05301356 kfree(strConnectInfo.pu8ReqIEs);
1357 strConnectInfo.pu8ReqIEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001358 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001359 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001360 }
1361
Leo Kim45102f82015-10-28 15:59:28 +09001362 wid.id = (u16)WID_DISCONNECT;
1363 wid.type = WID_CHAR;
1364 wid.val = (s8 *)&u16DummyReasonCode;
1365 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001366
1367 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1368
Leo Kim45102f82015-10-28 15:59:28 +09001369 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001370 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09001371 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001372 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001373
Leo Kim74ab5e42015-10-29 11:58:53 +09001374 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09001375 kfree(hif_drv->usr_conn_req.pu8ssid);
1376 kfree(hif_drv->usr_conn_req.pu8bssid);
Leo Kim331ed082015-10-29 11:58:55 +09001377 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001378 kfree(hif_drv->usr_conn_req.ies);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001379
Shraddha Barke281dd5a2015-10-05 17:00:33 +05301380 eth_zero_addr(u8ConnectedSSID);
Leo Kimae4dfa52015-10-13 19:49:26 +09001381
Leo Kim91109e12015-10-19 18:26:13 +09001382 if (join_req && join_req_drv == hif_drv) {
Leo Kim044a64102015-10-15 13:25:09 +09001383 kfree(join_req);
1384 join_req = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001385 }
Leo Kim48ce2462015-10-15 13:25:10 +09001386
Leo Kim91109e12015-10-19 18:26:13 +09001387 if (info_element && join_req_drv == hif_drv) {
Leo Kim48ce2462015-10-15 13:25:10 +09001388 kfree(info_element);
1389 info_element = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001390 }
1391
Leo Kim31390ee2015-10-19 18:26:08 +09001392 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001393}
1394
Tony Choa4ab1ad2015-10-12 16:56:05 +09001395static s32 Handle_RcvdNtwrkInfo(struct host_if_drv *hif_drv,
Tony Cho3bbd59f2015-09-21 12:16:38 +09001396 struct rcvd_net_info *pstrRcvdNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001397{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001398 u32 i;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001399 bool bNewNtwrkFound;
Leo Kim31390ee2015-10-19 18:26:08 +09001400 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001401 tstrNetworkInfo *pstrNetworkInfo = NULL;
1402 void *pJoinParams = NULL;
1403
Dean Lee72ed4dc2015-06-12 14:11:44 +09001404 bNewNtwrkFound = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001405 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1406
Leo Kimbc801852015-10-29 11:58:50 +09001407 if (hif_drv->usr_scan_req.scan_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001408 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
Leo Kimb021b802015-10-13 20:02:10 +09001409 parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo);
Leo Kim91109e12015-10-19 18:26:13 +09001410 if ((!pstrNetworkInfo) ||
Leo Kimbc801852015-10-29 11:58:50 +09001411 (!hif_drv->usr_scan_req.scan_result)) {
Leo Kim24db7132015-09-16 18:36:01 +09001412 PRINT_ER("driver is null\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001413 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +09001414 goto done;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001415 }
1416
Leo Kimf79756e2015-10-29 12:05:36 +09001417 for (i = 0; i < hif_drv->usr_scan_req.rcvd_ch_cnt; i++) {
Leo Kimaf973f32015-10-29 11:58:52 +09001418 if ((hif_drv->usr_scan_req.net_info[i].au8bssid) &&
Leo Kim91109e12015-10-19 18:26:13 +09001419 (pstrNetworkInfo->au8bssid)) {
Leo Kimaf973f32015-10-29 11:58:52 +09001420 if (memcmp(hif_drv->usr_scan_req.net_info[i].au8bssid,
Leo Kim8c8360b2015-10-19 18:26:12 +09001421 pstrNetworkInfo->au8bssid, 6) == 0) {
Leo Kimaf973f32015-10-29 11:58:52 +09001422 if (pstrNetworkInfo->s8rssi <= hif_drv->usr_scan_req.net_info[i].s8rssi) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001423 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
1424 goto done;
1425 } else {
Leo Kimaf973f32015-10-29 11:58:52 +09001426 hif_drv->usr_scan_req.net_info[i].s8rssi = pstrNetworkInfo->s8rssi;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001427 bNewNtwrkFound = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001428 break;
1429 }
1430 }
1431 }
1432 }
1433
Punit Vara047e6642015-10-25 04:01:25 +05301434 if (bNewNtwrkFound) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001435 PRINT_D(HOSTINF_DBG, "New network found\n");
1436
Leo Kimf79756e2015-10-29 12:05:36 +09001437 if (hif_drv->usr_scan_req.rcvd_ch_cnt < MAX_NUM_SCANNED_NETWORKS) {
1438 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 +09001439
Leo Kimf79756e2015-10-29 12:05:36 +09001440 if (hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].au8bssid &&
Leo Kim91109e12015-10-19 18:26:13 +09001441 pstrNetworkInfo->au8bssid) {
Leo Kimf79756e2015-10-29 12:05:36 +09001442 memcpy(hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].au8bssid,
Leo Kim8c8360b2015-10-19 18:26:12 +09001443 pstrNetworkInfo->au8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001444
Leo Kimf79756e2015-10-29 12:05:36 +09001445 hif_drv->usr_scan_req.rcvd_ch_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001446
Dean Lee72ed4dc2015-06-12 14:11:44 +09001447 pstrNetworkInfo->bNewNetwork = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001448 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001449
Leo Kimbc801852015-10-29 11:58:50 +09001450 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
Leo Kim66eaea32015-10-29 11:58:51 +09001451 hif_drv->usr_scan_req.arg,
Leo Kimbc801852015-10-29 11:58:50 +09001452 pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001453 }
1454 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001455 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001456 }
1457 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001458 pstrNetworkInfo->bNewNetwork = false;
Leo Kimbc801852015-10-29 11:58:50 +09001459 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
Leo Kim66eaea32015-10-29 11:58:51 +09001460 hif_drv->usr_scan_req.arg, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001461 }
1462 }
1463
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001464done:
Shraddha Barke95f840f2015-10-14 07:29:19 +05301465 kfree(pstrRcvdNetworkInfo->buffer);
1466 pstrRcvdNetworkInfo->buffer = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001467
Leo Kim91109e12015-10-19 18:26:13 +09001468 if (pstrNetworkInfo) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001469 DeallocateNetworkInfo(pstrNetworkInfo);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001470 pstrNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001471 }
1472
Leo Kim31390ee2015-10-19 18:26:08 +09001473 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001474}
1475
Tony Choa4ab1ad2015-10-12 16:56:05 +09001476static s32 Handle_RcvdGnrlAsyncInfo(struct host_if_drv *hif_drv,
Tony Chof23a9ea2015-09-21 12:16:39 +09001477 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001478{
Leo Kim31390ee2015-10-19 18:26:08 +09001479 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001480 u8 u8MsgType = 0;
1481 u8 u8MsgID = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001482 u16 u16MsgLen = 0;
1483 u16 u16WidID = (u16)WID_NIL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001484 u8 u8WidLen = 0;
1485 u8 u8MacStatus;
1486 u8 u8MacStatusReasonCode;
1487 u8 u8MacStatusAdditionalInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001488 tstrConnectInfo strConnectInfo;
1489 tstrDisconnectNotifInfo strDisconnectNotifInfo;
Leo Kime6e12662015-09-16 18:36:03 +09001490 s32 s32Err = 0;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02001491
Tony Choa4ab1ad2015-10-12 16:56:05 +09001492 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001493 PRINT_ER("Driver handler is NULL\n");
Leo Kim234837d2015-09-22 14:34:43 +09001494 return -ENODEV;
1495 }
Leo Kimb60005a2015-10-29 11:58:24 +09001496 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n",
1497 hif_drv->hif_state, pstrRcvdGnrlAsyncInfo->buffer[7]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001498
Leo Kimb60005a2015-10-29 11:58:24 +09001499 if ((hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
1500 (hif_drv->hif_state == HOST_IF_CONNECTED) ||
Leo Kimbc801852015-10-29 11:58:50 +09001501 hif_drv->usr_scan_req.scan_result) {
Leo Kim91109e12015-10-19 18:26:13 +09001502 if (!pstrRcvdGnrlAsyncInfo->buffer ||
Leo Kim33bfb192015-10-29 11:58:56 +09001503 !hif_drv->usr_conn_req.conn_result) {
Leo Kim24db7132015-09-16 18:36:01 +09001504 PRINT_ER("driver is null\n");
1505 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001506 }
1507
Leo Kim33722ac72015-10-13 19:50:00 +09001508 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001509
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001510 if ('I' != u8MsgType) {
1511 PRINT_ER("Received Message format incorrect.\n");
Leo Kim24db7132015-09-16 18:36:01 +09001512 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001513 }
1514
Leo Kim33722ac72015-10-13 19:50:00 +09001515 u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1];
1516 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]);
1517 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]);
1518 u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6];
1519 u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7];
1520 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8];
1521 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001522 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
Leo Kimb60005a2015-10-29 11:58:24 +09001523 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001524 u32 u32RcvdAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001525 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
1526
1527 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1528
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001529 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001530
1531 if (u8MacStatus == MAC_CONNECTED) {
Leo Kima633c0b2015-10-15 13:24:59 +09001532 memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001533
Tony Choa4ab1ad2015-10-12 16:56:05 +09001534 host_int_get_assoc_res_info(hif_drv,
Leo Kima633c0b2015-10-15 13:24:59 +09001535 rcv_assoc_resp,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001536 MAX_ASSOC_RESP_FRAME_SIZE,
1537 &u32RcvdAssocRespInfoLen);
1538
1539 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
1540
1541 if (u32RcvdAssocRespInfoLen != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001542 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
Leo Kima633c0b2015-10-15 13:24:59 +09001543 s32Err = ParseAssocRespInfo(rcv_assoc_resp, u32RcvdAssocRespInfoLen,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001544 &pstrConnectRespInfo);
1545 if (s32Err) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001546 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001547 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001548 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
1549
1550 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
1551 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
Leo Kim91109e12015-10-19 18:26:13 +09001552 if (pstrConnectRespInfo->pu8RespIEs) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001553 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001554 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001555 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001556 pstrConnectRespInfo->u16RespIEsLen);
1557 }
1558 }
1559
Leo Kim91109e12015-10-19 18:26:13 +09001560 if (pstrConnectRespInfo) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001561 DeallocateAssocRespInfo(pstrConnectRespInfo);
1562 pstrConnectRespInfo = NULL;
1563 }
1564 }
1565 }
1566 }
1567
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001568 if ((u8MacStatus == MAC_CONNECTED) &&
1569 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001570 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 +05301571 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001572
1573 } else if (u8MacStatus == MAC_DISCONNECTED) {
1574 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
Shraddha Barke281dd5a2015-10-05 17:00:33 +05301575 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001576 }
1577
Leo Kimf8b17132015-10-28 15:59:34 +09001578 if (hif_drv->usr_conn_req.pu8bssid) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001579 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
Leo Kimf8b17132015-10-28 15:59:34 +09001580 memcpy(strConnectInfo.au8bssid, hif_drv->usr_conn_req.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001581
1582 if ((u8MacStatus == MAC_CONNECTED) &&
1583 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Leo Kim2a4eded2015-10-29 11:58:25 +09001584 memcpy(hif_drv->assoc_bssid,
Leo Kimf8b17132015-10-28 15:59:34 +09001585 hif_drv->usr_conn_req.pu8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001586 }
1587 }
1588
Leo Kima3b2f4b2015-10-29 11:58:54 +09001589 if (hif_drv->usr_conn_req.ies) {
Leo Kim331ed082015-10-29 11:58:55 +09001590 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len;
1591 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001592 memcpy(strConnectInfo.pu8ReqIEs,
Leo Kima3b2f4b2015-10-29 11:58:54 +09001593 hif_drv->usr_conn_req.ies,
Leo Kim331ed082015-10-29 11:58:55 +09001594 hif_drv->usr_conn_req.ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001595 }
1596
Leo Kim81a59502015-10-29 11:58:35 +09001597 del_timer(&hif_drv->connect_timer);
Leo Kim33bfb192015-10-29 11:58:56 +09001598 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1599 &strConnectInfo,
1600 u8MacStatus,
1601 NULL,
Leo Kim73abaa42015-10-29 12:05:27 +09001602 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001603
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001604 if ((u8MacStatus == MAC_CONNECTED) &&
1605 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09001606 host_int_set_power_mgmt(hif_drv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001607
1608 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
Leo Kimb60005a2015-10-29 11:58:24 +09001609 hif_drv->hif_state = HOST_IF_CONNECTED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001610
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001611 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +09001612 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07001613 mod_timer(&hDuringIpTimer,
1614 jiffies + msecs_to_jiffies(10000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001615 } else {
1616 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
Leo Kimb60005a2015-10-29 11:58:24 +09001617 hif_drv->hif_state = HOST_IF_IDLE;
Leo Kimca8540e42015-10-15 13:25:00 +09001618 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001619 }
1620
Shraddha Barke95f840f2015-10-14 07:29:19 +05301621 kfree(strConnectInfo.pu8RespIEs);
1622 strConnectInfo.pu8RespIEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001623
Shraddha Barke95f840f2015-10-14 07:29:19 +05301624 kfree(strConnectInfo.pu8ReqIEs);
1625 strConnectInfo.pu8ReqIEs = NULL;
Leo Kim74ab5e42015-10-29 11:58:53 +09001626 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09001627 kfree(hif_drv->usr_conn_req.pu8ssid);
1628 kfree(hif_drv->usr_conn_req.pu8bssid);
Leo Kim331ed082015-10-29 11:58:55 +09001629 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001630 kfree(hif_drv->usr_conn_req.ies);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001631 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
Leo Kimb60005a2015-10-29 11:58:24 +09001632 (hif_drv->hif_state == HOST_IF_CONNECTED)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001633 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
1634
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001635 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001636
Leo Kimbc801852015-10-29 11:58:50 +09001637 if (hif_drv->usr_scan_req.scan_result) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001638 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
Leo Kim13b313e2015-10-29 11:58:34 +09001639 del_timer(&hif_drv->scan_timer);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001640 Handle_ScanDone((void *)hif_drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001641 }
1642
1643 strDisconnectNotifInfo.u16reason = 0;
1644 strDisconnectNotifInfo.ie = NULL;
1645 strDisconnectNotifInfo.ie_len = 0;
1646
Leo Kim33bfb192015-10-29 11:58:56 +09001647 if (hif_drv->usr_conn_req.conn_result) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001648 g_obtainingIP = false;
Tony Choa4ab1ad2015-10-12 16:56:05 +09001649 host_int_set_power_mgmt(hif_drv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001650
Leo Kim33bfb192015-10-29 11:58:56 +09001651 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1652 NULL,
1653 0,
1654 &strDisconnectNotifInfo,
Leo Kim73abaa42015-10-29 12:05:27 +09001655 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001656 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001657 PRINT_ER("Connect result callback function is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001658 }
1659
Leo Kim2a4eded2015-10-29 11:58:25 +09001660 eth_zero_addr(hif_drv->assoc_bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001661
Leo Kim74ab5e42015-10-29 11:58:53 +09001662 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09001663 kfree(hif_drv->usr_conn_req.pu8ssid);
1664 kfree(hif_drv->usr_conn_req.pu8bssid);
Leo Kim331ed082015-10-29 11:58:55 +09001665 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001666 kfree(hif_drv->usr_conn_req.ies);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001667
Leo Kim91109e12015-10-19 18:26:13 +09001668 if (join_req && join_req_drv == hif_drv) {
Leo Kim044a64102015-10-15 13:25:09 +09001669 kfree(join_req);
1670 join_req = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001671 }
Leo Kim48ce2462015-10-15 13:25:10 +09001672
Leo Kim91109e12015-10-19 18:26:13 +09001673 if (info_element && join_req_drv == hif_drv) {
Leo Kim48ce2462015-10-15 13:25:10 +09001674 kfree(info_element);
1675 info_element = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001676 }
1677
Leo Kimb60005a2015-10-29 11:58:24 +09001678 hif_drv->hif_state = HOST_IF_IDLE;
Leo Kimca8540e42015-10-15 13:25:00 +09001679 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001680
1681 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
Leo Kimbc801852015-10-29 11:58:50 +09001682 (hif_drv->usr_scan_req.scan_result)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001683 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001684 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09001685
Leo Kim13b313e2015-10-29 11:58:34 +09001686 del_timer(&hif_drv->scan_timer);
Leo Kimbc801852015-10-29 11:58:50 +09001687 if (hif_drv->usr_scan_req.scan_result)
Tony Choa4ab1ad2015-10-12 16:56:05 +09001688 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001689 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001690 }
1691
Shraddha Barke95f840f2015-10-14 07:29:19 +05301692 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1693 pstrRcvdGnrlAsyncInfo->buffer = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001694
Leo Kim31390ee2015-10-19 18:26:08 +09001695 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001696}
1697
Tony Choa4ab1ad2015-10-12 16:56:05 +09001698static int Handle_Key(struct host_if_drv *hif_drv,
Tony Choc98387a2015-09-21 12:16:40 +09001699 struct key_attr *pstrHostIFkeyAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001700{
Leo Kim31390ee2015-10-19 18:26:08 +09001701 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09001702 struct wid wid;
Leo Kime9e0c262015-10-12 16:55:41 +09001703 struct wid strWIDList[5];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001704 u8 i;
1705 u8 *pu8keybuf;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001706 s8 s8idxarray[1];
1707 s8 ret = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001708
Leo Kim8e9f4272015-10-13 19:49:27 +09001709 switch (pstrHostIFkeyAttr->type) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001710 case WEP:
1711
Leo Kim0d17e382015-10-13 19:49:28 +09001712 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001713 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Leo Kimbafaa692015-10-28 15:59:21 +09001714 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", pstrHostIFkeyAttr->attr.wep.index);
Leo Kimdaaf16b2015-10-12 16:55:44 +09001715 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001716 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001717 strWIDList[0].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001718 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001719
Leo Kimdaaf16b2015-10-12 16:55:44 +09001720 strWIDList[1].id = WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001721 strWIDList[1].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001722 strWIDList[1].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001723 strWIDList[1].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001724
Leo Kimdaaf16b2015-10-12 16:55:44 +09001725 strWIDList[2].id = (u16)WID_KEY_ID;
Leo Kim416d8322015-10-12 16:55:43 +09001726 strWIDList[2].type = WID_CHAR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001727
Leo Kimbafaa692015-10-28 15:59:21 +09001728 strWIDList[2].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
Leo Kim2fd3e442015-10-12 16:55:45 +09001729 strWIDList[2].size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001730
Shraddha Barke543f5b12015-10-16 10:47:11 +05301731 pu8keybuf = kmemdup(pstrHostIFkeyAttr->attr.wep.key,
1732 pstrHostIFkeyAttr->attr.wep.key_len,
1733 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001734
1735 if (pu8keybuf == NULL) {
1736 PRINT_ER("No buffer to send Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001737 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001738 }
1739
Leo Kim73b2e382015-10-13 19:49:29 +09001740 kfree(pstrHostIFkeyAttr->attr.wep.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001741
Leo Kimdaaf16b2015-10-12 16:55:44 +09001742 strWIDList[3].id = (u16)WID_WEP_KEY_VALUE;
Leo Kim416d8322015-10-12 16:55:43 +09001743 strWIDList[3].type = WID_STR;
Leo Kim73b2e382015-10-13 19:49:29 +09001744 strWIDList[3].size = pstrHostIFkeyAttr->attr.wep.key_len;
Leo Kim900bb4a2015-10-12 16:55:46 +09001745 strWIDList[3].val = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001746
Leo Kim31390ee2015-10-19 18:26:08 +09001747 result = send_config_pkt(SET_CFG, strWIDList, 4,
Leo Kim8c8360b2015-10-19 18:26:12 +09001748 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001749 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001750 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001751
Leo Kim0d17e382015-10-13 19:49:28 +09001752 if (pstrHostIFkeyAttr->action & ADDKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001753 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Leo Kim73b2e382015-10-13 19:49:29 +09001754 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001755 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001756 PRINT_ER("No buffer to send Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001757 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001758 }
Leo Kim73b2e382015-10-13 19:49:29 +09001759 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1760 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1761 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001762 pstrHostIFkeyAttr->attr.wep.key_len);
Leo Kim73b2e382015-10-13 19:49:29 +09001763 kfree(pstrHostIFkeyAttr->attr.wep.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001764
Leo Kim45102f82015-10-28 15:59:28 +09001765 wid.id = (u16)WID_ADD_WEP_KEY;
1766 wid.type = WID_STR;
1767 wid.val = (s8 *)pu8keybuf;
1768 wid.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001769
Leo Kim45102f82015-10-28 15:59:28 +09001770 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001771 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001772 kfree(pu8keybuf);
Leo Kim0d17e382015-10-13 19:49:28 +09001773 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001774 PRINT_D(HOSTINF_DBG, "Removing key\n");
Leo Kim45102f82015-10-28 15:59:28 +09001775 wid.id = (u16)WID_REMOVE_WEP_KEY;
1776 wid.type = WID_STR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001777
Leo Kim73b2e382015-10-13 19:49:29 +09001778 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
Leo Kim45102f82015-10-28 15:59:28 +09001779 wid.val = s8idxarray;
1780 wid.size = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001781
Leo Kim45102f82015-10-28 15:59:28 +09001782 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001783 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001784 } else {
Leo Kim45102f82015-10-28 15:59:28 +09001785 wid.id = (u16)WID_KEY_ID;
1786 wid.type = WID_CHAR;
1787 wid.val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
1788 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001789
1790 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
1791
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 }
Leo Kim9ea47132015-10-29 11:58:28 +09001795 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001796 break;
1797
Leo Kim5cd8f7a2015-10-29 12:05:34 +09001798 case WPA_RX_GTK:
Leo Kim0d17e382015-10-13 19:49:28 +09001799 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Shraddha Barkeb156f1e2015-10-13 23:07:00 +05301800 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001801 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001802 PRINT_ER("No buffer to send RxGTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001803 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001804 goto _WPARxGtk_end_case_;
1805 }
1806
Leo Kim91109e12015-10-19 18:26:13 +09001807 if (pstrHostIFkeyAttr->attr.wpa.seq)
Leo Kim0e74c002015-10-13 19:49:32 +09001808 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001809
Leo Kime2dfbac2015-10-13 19:49:34 +09001810 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
Leo Kim6acf2912015-10-13 19:49:35 +09001811 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001812 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001813 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001814
Leo Kimdaaf16b2015-10-12 16:55:44 +09001815 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001816 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001817 strWIDList[0].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001818 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001819
Leo Kimdaaf16b2015-10-12 16:55:44 +09001820 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
Leo Kim416d8322015-10-12 16:55:43 +09001821 strWIDList[1].type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09001822 strWIDList[1].val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09001823 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001824
Leo Kim31390ee2015-10-19 18:26:08 +09001825 result = send_config_pkt(SET_CFG, strWIDList, 2,
Leo Kim8c8360b2015-10-19 18:26:12 +09001826 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001827
Chaehyun Lim49188af2015-08-11 10:32:41 +09001828 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001829 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001830 }
1831
Leo Kim0d17e382015-10-13 19:49:28 +09001832 if (pstrHostIFkeyAttr->action & ADDKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001833 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
1834
Shraddha Barkeb156f1e2015-10-13 23:07:00 +05301835 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001836 if (pu8keybuf == NULL) {
1837 PRINT_ER("No buffer to send RxGTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001838 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001839 goto _WPARxGtk_end_case_;
1840 }
1841
Leo Kimb60005a2015-10-29 11:58:24 +09001842 if (hif_drv->hif_state == HOST_IF_CONNECTED)
Leo Kim2a4eded2015-10-29 11:58:25 +09001843 memcpy(pu8keybuf, hif_drv->assoc_bssid, ETH_ALEN);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301844 else
Leo Kimb60005a2015-10-29 11:58:24 +09001845 PRINT_ER("Couldn't handle WPARxGtk while state is not HOST_IF_CONNECTED\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001846
Leo Kim0e74c002015-10-13 19:49:32 +09001847 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
Leo Kime2dfbac2015-10-13 19:49:34 +09001848 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
Leo Kim6acf2912015-10-13 19:49:35 +09001849 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001850 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001851 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001852
Leo Kim45102f82015-10-28 15:59:28 +09001853 wid.id = (u16)WID_ADD_RX_GTK;
1854 wid.type = WID_STR;
1855 wid.val = (s8 *)pu8keybuf;
1856 wid.size = RX_MIC_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001857
Leo Kim45102f82015-10-28 15:59:28 +09001858 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001859 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001860
Chaehyun Lim49188af2015-08-11 10:32:41 +09001861 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001862 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001863 }
1864_WPARxGtk_end_case_:
Leo Kim124968fc2015-10-13 19:49:30 +09001865 kfree(pstrHostIFkeyAttr->attr.wpa.key);
Leo Kim0e74c002015-10-13 19:49:32 +09001866 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
Luis de Bethencourt90819872015-10-26 05:52:50 +00001867 if (ret)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001868 return ret;
1869
1870 break;
1871
Leo Kim2141fe32015-10-29 12:05:35 +09001872 case WPA_PTK:
Leo Kim0d17e382015-10-13 19:49:28 +09001873 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Glen Leef3052582015-09-10 12:03:04 +09001874 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001875 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001876 PRINT_ER("No buffer to send PTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001877 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001878 goto _WPAPtk_end_case_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001879 }
1880
Leo Kim248080a2015-10-13 19:49:31 +09001881 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
Leo Kime2dfbac2015-10-13 19:49:34 +09001882 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
Leo Kim6acf2912015-10-13 19:49:35 +09001883 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001884 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001885 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001886
Leo Kimdaaf16b2015-10-12 16:55:44 +09001887 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001888 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001889 strWIDList[0].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001890 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001891
Leo Kimdaaf16b2015-10-12 16:55:44 +09001892 strWIDList[1].id = (u16)WID_ADD_PTK;
Leo Kim416d8322015-10-12 16:55:43 +09001893 strWIDList[1].type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09001894 strWIDList[1].val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09001895 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001896
Leo Kim31390ee2015-10-19 18:26:08 +09001897 result = send_config_pkt(SET_CFG, strWIDList, 2,
Leo Kim8c8360b2015-10-19 18:26:12 +09001898 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001899 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001900 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001901 }
Leo Kim0d17e382015-10-13 19:49:28 +09001902 if (pstrHostIFkeyAttr->action & ADDKEY) {
Glen Leef3052582015-09-10 12:03:04 +09001903 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001904 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001905 PRINT_ER("No buffer to send PTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001906 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001907 goto _WPAPtk_end_case_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001908 }
1909
Leo Kim248080a2015-10-13 19:49:31 +09001910 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
Leo Kim6acf2912015-10-13 19:49:35 +09001911 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001912 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001913 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001914
Leo Kim45102f82015-10-28 15:59:28 +09001915 wid.id = (u16)WID_ADD_PTK;
1916 wid.type = WID_STR;
1917 wid.val = (s8 *)pu8keybuf;
1918 wid.size = PTK_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001919
Leo Kim45102f82015-10-28 15:59:28 +09001920 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001921 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001922 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001923 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001924 }
1925
1926_WPAPtk_end_case_:
Leo Kim124968fc2015-10-13 19:49:30 +09001927 kfree(pstrHostIFkeyAttr->attr.wpa.key);
Luis de Bethencourt90819872015-10-26 05:52:50 +00001928 if (ret)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001929 return ret;
1930
1931 break;
1932
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001933 case PMKSA:
1934
1935 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
1936
Leo Kim73b2e382015-10-13 19:49:29 +09001937 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001938 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001939 PRINT_ER("No buffer to send PMKSA Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001940 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001941 }
1942
Leo Kim73b2e382015-10-13 19:49:29 +09001943 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001944
Leo Kim73b2e382015-10-13 19:49:29 +09001945 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
1946 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
1947 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001948 }
1949
Leo Kim45102f82015-10-28 15:59:28 +09001950 wid.id = (u16)WID_PMKID_INFO;
1951 wid.type = WID_STR;
1952 wid.val = (s8 *)pu8keybuf;
1953 wid.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001954
Leo Kim45102f82015-10-28 15:59:28 +09001955 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001956 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001957
Chaehyun Lim49188af2015-08-11 10:32:41 +09001958 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001959 break;
1960 }
1961
Leo Kim31390ee2015-10-19 18:26:08 +09001962 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001963 PRINT_ER("Failed to send key config packet\n");
1964
Leo Kim31390ee2015-10-19 18:26:08 +09001965 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001966}
1967
Tony Choa4ab1ad2015-10-12 16:56:05 +09001968static void Handle_Disconnect(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001969{
Leo Kim45102f82015-10-28 15:59:28 +09001970 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001971
Leo Kim31390ee2015-10-19 18:26:08 +09001972 s32 result = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001973 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001974
Leo Kim45102f82015-10-28 15:59:28 +09001975 wid.id = (u16)WID_DISCONNECT;
1976 wid.type = WID_CHAR;
1977 wid.val = (s8 *)&u16DummyReasonCode;
1978 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001979
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001980 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1981
Dean Lee72ed4dc2015-06-12 14:11:44 +09001982 g_obtainingIP = false;
Tony Choa4ab1ad2015-10-12 16:56:05 +09001983 host_int_set_power_mgmt(hif_drv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001984
Shraddha Barke281dd5a2015-10-05 17:00:33 +05301985 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001986
Leo Kim45102f82015-10-28 15:59:28 +09001987 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001988 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001989
Leo Kim31390ee2015-10-19 18:26:08 +09001990 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001991 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001992 } else {
1993 tstrDisconnectNotifInfo strDisconnectNotifInfo;
1994
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001995 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001996
1997 strDisconnectNotifInfo.u16reason = 0;
1998 strDisconnectNotifInfo.ie = NULL;
1999 strDisconnectNotifInfo.ie_len = 0;
2000
Leo Kimbc801852015-10-29 11:58:50 +09002001 if (hif_drv->usr_scan_req.scan_result) {
Leo Kim13b313e2015-10-29 11:58:34 +09002002 del_timer(&hif_drv->scan_timer);
Leo Kim33bfb192015-10-29 11:58:56 +09002003 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED,
2004 NULL,
2005 hif_drv->usr_scan_req.arg,
2006 NULL);
Leo Kimbc801852015-10-29 11:58:50 +09002007 hif_drv->usr_scan_req.scan_result = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002008 }
2009
Leo Kim33bfb192015-10-29 11:58:56 +09002010 if (hif_drv->usr_conn_req.conn_result) {
Leo Kimb60005a2015-10-29 11:58:24 +09002011 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002012 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
Leo Kim81a59502015-10-29 11:58:35 +09002013 del_timer(&hif_drv->connect_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002014 }
2015
Leo Kim33bfb192015-10-29 11:58:56 +09002016 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2017 NULL,
2018 0,
2019 &strDisconnectNotifInfo,
Leo Kim73abaa42015-10-29 12:05:27 +09002020 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002021 } else {
Leo Kim33bfb192015-10-29 11:58:56 +09002022 PRINT_ER("usr_conn_req.conn_result = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002023 }
2024
Leo Kimca8540e42015-10-15 13:25:00 +09002025 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002026
Leo Kimb60005a2015-10-29 11:58:24 +09002027 hif_drv->hif_state = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002028
Leo Kim2a4eded2015-10-29 11:58:25 +09002029 eth_zero_addr(hif_drv->assoc_bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002030
Leo Kim74ab5e42015-10-29 11:58:53 +09002031 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09002032 kfree(hif_drv->usr_conn_req.pu8ssid);
2033 kfree(hif_drv->usr_conn_req.pu8bssid);
Leo Kim331ed082015-10-29 11:58:55 +09002034 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09002035 kfree(hif_drv->usr_conn_req.ies);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002036
Leo Kim91109e12015-10-19 18:26:13 +09002037 if (join_req && join_req_drv == hif_drv) {
Leo Kim044a64102015-10-15 13:25:09 +09002038 kfree(join_req);
2039 join_req = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002040 }
Leo Kim48ce2462015-10-15 13:25:10 +09002041
Leo Kim91109e12015-10-19 18:26:13 +09002042 if (info_element && join_req_drv == hif_drv) {
Leo Kim48ce2462015-10-15 13:25:10 +09002043 kfree(info_element);
2044 info_element = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002045 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002046 }
2047
Leo Kime55e4962015-10-29 11:58:29 +09002048 up(&hif_drv->sem_test_disconn_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002049}
2050
Tony Choa4ab1ad2015-10-12 16:56:05 +09002051void resolve_disconnect_aberration(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002052{
Tony Choa4ab1ad2015-10-12 16:56:05 +09002053 if (!hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002054 return;
Leo Kimb60005a2015-10-29 11:58:24 +09002055 if ((hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
2056 (hif_drv->hif_state == HOST_IF_CONNECTING)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002057 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09002058 host_int_disconnect(hif_drv, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002059 }
2060}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002061
Tony Choa4ab1ad2015-10-12 16:56:05 +09002062static s32 Handle_GetChnl(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002063{
Leo Kim31390ee2015-10-19 18:26:08 +09002064 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002065 struct wid wid;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002066
Leo Kim45102f82015-10-28 15:59:28 +09002067 wid.id = (u16)WID_CURRENT_CHANNEL;
2068 wid.type = WID_CHAR;
2069 wid.val = (s8 *)&ch_no;
2070 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002071
2072 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2073
Leo Kim45102f82015-10-28 15:59:28 +09002074 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002075 get_id_from_handler(hif_drv));
Leo Kimae4dfa52015-10-13 19:49:26 +09002076
Leo Kim31390ee2015-10-19 18:26:08 +09002077 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002078 PRINT_ER("Failed to get channel number\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002079 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002080 }
2081
Leo Kim4ea90002015-10-29 11:58:32 +09002082 up(&hif_drv->sem_get_chnl);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002083
Leo Kim31390ee2015-10-19 18:26:08 +09002084 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002085}
2086
Tony Choa4ab1ad2015-10-12 16:56:05 +09002087static void Handle_GetRssi(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002088{
Leo Kim31390ee2015-10-19 18:26:08 +09002089 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002090 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002091
Leo Kim45102f82015-10-28 15:59:28 +09002092 wid.id = (u16)WID_RSSI;
2093 wid.type = WID_CHAR;
2094 wid.val = &rssi;
2095 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002096
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002097 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2098
Leo Kim45102f82015-10-28 15:59:28 +09002099 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002100 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002101 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002102 PRINT_ER("Failed to get RSSI value\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002103 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002104 }
2105
Leo Kim7e111f92015-10-29 11:58:30 +09002106 up(&hif_drv->sem_get_rssi);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002107}
2108
Tony Choa4ab1ad2015-10-12 16:56:05 +09002109static void Handle_GetLinkspeed(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002110{
Leo Kim31390ee2015-10-19 18:26:08 +09002111 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002112 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002113
Leo Kim75327a02015-10-15 13:25:02 +09002114 link_speed = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002115
Leo Kim45102f82015-10-28 15:59:28 +09002116 wid.id = (u16)WID_LINKSPEED;
2117 wid.type = WID_CHAR;
2118 wid.val = &link_speed;
2119 wid.size = sizeof(char);
Leo Kimae4dfa52015-10-13 19:49:26 +09002120
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002121 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2122
Leo Kim45102f82015-10-28 15:59:28 +09002123 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002124 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002125 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002126 PRINT_ER("Failed to get LINKSPEED value\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002127 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002128 }
2129
Leo Kimbc34da62015-10-29 11:58:31 +09002130 up(&hif_drv->sem_get_link_speed);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002131}
2132
Tony Choa4ab1ad2015-10-12 16:56:05 +09002133s32 Handle_GetStatistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002134{
Leo Kime9e0c262015-10-12 16:55:41 +09002135 struct wid strWIDList[5];
Leo Kim31390ee2015-10-19 18:26:08 +09002136 u32 u32WidsCount = 0, result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002137
Leo Kimdaaf16b2015-10-12 16:55:44 +09002138 strWIDList[u32WidsCount].id = WID_LINKSPEED;
Leo Kim416d8322015-10-12 16:55:43 +09002139 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002140 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim5babeec2015-10-29 12:05:29 +09002141 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->link_speed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002142 u32WidsCount++;
2143
Leo Kimdaaf16b2015-10-12 16:55:44 +09002144 strWIDList[u32WidsCount].id = WID_RSSI;
Leo Kim416d8322015-10-12 16:55:43 +09002145 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002146 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim00c8dfc2015-10-29 12:05:30 +09002147 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rssi;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002148 u32WidsCount++;
2149
Leo Kimdaaf16b2015-10-12 16:55:44 +09002150 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002151 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002152 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim7e84ff42015-10-29 12:05:31 +09002153 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002154 u32WidsCount++;
2155
Leo Kimdaaf16b2015-10-12 16:55:44 +09002156 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002157 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002158 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim9b992742015-10-29 12:05:32 +09002159 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rx_cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002160 u32WidsCount++;
2161
Leo Kimdaaf16b2015-10-12 16:55:44 +09002162 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002163 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002164 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim54160372015-10-29 12:05:33 +09002165 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_fail_cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002166 u32WidsCount++;
2167
Leo Kim31390ee2015-10-19 18:26:08 +09002168 result = send_config_pkt(GET_CFG, strWIDList, u32WidsCount,
Leo Kim8c8360b2015-10-19 18:26:12 +09002169 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002170
Leo Kim31390ee2015-10-19 18:26:08 +09002171 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002172 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09002173
Leo Kim2d25af82015-10-15 13:24:56 +09002174 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002175 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002176}
2177
Tony Choa4ab1ad2015-10-12 16:56:05 +09002178static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,
Tony Cho3d1eac02015-09-21 12:16:49 +09002179 struct sta_inactive_t *strHostIfStaInactiveT)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002180{
Leo Kim31390ee2015-10-19 18:26:08 +09002181 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002182 u8 *stamac;
Leo Kim45102f82015-10-28 15:59:28 +09002183 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002184
Leo Kim45102f82015-10-28 15:59:28 +09002185 wid.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2186 wid.type = WID_STR;
2187 wid.size = ETH_ALEN;
2188 wid.val = kmalloc(wid.size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002189
Leo Kim45102f82015-10-28 15:59:28 +09002190 stamac = wid.val;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002191 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002192
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002193 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2194
Leo Kim45102f82015-10-28 15:59:28 +09002195 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002196 get_id_from_handler(hif_drv));
Leo Kimae4dfa52015-10-13 19:49:26 +09002197
Leo Kim31390ee2015-10-19 18:26:08 +09002198 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002199 PRINT_ER("Failed to SET incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09002200 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002201 }
2202
Leo Kim45102f82015-10-28 15:59:28 +09002203 wid.id = (u16)WID_GET_INACTIVE_TIME;
2204 wid.type = WID_INT;
2205 wid.val = (s8 *)&inactive_time;
2206 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002207
Leo Kim45102f82015-10-28 15:59:28 +09002208 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002209 get_id_from_handler(hif_drv));
Leo Kimae4dfa52015-10-13 19:49:26 +09002210
Leo Kim31390ee2015-10-19 18:26:08 +09002211 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002212 PRINT_ER("Failed to get incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09002213 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002214 }
2215
Leo Kimad269062015-10-15 13:25:06 +09002216 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", inactive_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002217
Leo Kim569a3c62015-10-29 11:58:33 +09002218 up(&hif_drv->sem_inactive_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002219
Leo Kim31390ee2015-10-19 18:26:08 +09002220 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002221}
2222
Tony Choa4ab1ad2015-10-12 16:56:05 +09002223static void Handle_AddBeacon(struct host_if_drv *hif_drv,
Tony Cho7f33fec2015-09-30 18:44:30 +09002224 struct beacon_attr *pstrSetBeaconParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002225{
Leo Kim31390ee2015-10-19 18:26:08 +09002226 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002227 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002228 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002229
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002230 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
2231
Leo Kim45102f82015-10-28 15:59:28 +09002232 wid.id = (u16)WID_ADD_BEACON;
2233 wid.type = WID_BIN;
2234 wid.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
2235 wid.val = kmalloc(wid.size, GFP_KERNEL);
2236 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002237 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002238
Leo Kim45102f82015-10-28 15:59:28 +09002239 pu8CurrByte = wid.val;
Leo Kim12262dd2015-10-13 19:50:03 +09002240 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2241 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2242 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2243 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002244
Leo Kime76ab772015-10-13 19:50:04 +09002245 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2246 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2247 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2248 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002249
Leo Kim51c66182015-10-13 19:50:05 +09002250 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2251 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2252 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2253 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002254
Leo Kim8ce528b2015-10-13 19:50:06 +09002255 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
Leo Kim51c66182015-10-13 19:50:05 +09002256 pu8CurrByte += pstrSetBeaconParam->head_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002257
Leo Kim030c57e2015-10-13 19:50:07 +09002258 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2259 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2260 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2261 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002262
Leo Kim7dbcb6d32015-10-13 19:50:08 +09002263 if (pstrSetBeaconParam->tail > 0)
2264 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
Leo Kim030c57e2015-10-13 19:50:07 +09002265 pu8CurrByte += pstrSetBeaconParam->tail_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002266
Leo Kim45102f82015-10-28 15:59:28 +09002267 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002268 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002269 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002270 PRINT_ER("Failed to send add beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002271
Leo Kim24db7132015-09-16 18:36:01 +09002272ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002273 kfree(wid.val);
Leo Kim8ce528b2015-10-13 19:50:06 +09002274 kfree(pstrSetBeaconParam->head);
Leo Kim7dbcb6d32015-10-13 19:50:08 +09002275 kfree(pstrSetBeaconParam->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002276}
2277
Tony Choa4ab1ad2015-10-12 16:56:05 +09002278static void Handle_DelBeacon(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002279{
Leo Kim31390ee2015-10-19 18:26:08 +09002280 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002281 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002282 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002283
Leo Kim45102f82015-10-28 15:59:28 +09002284 wid.id = (u16)WID_DEL_BEACON;
2285 wid.type = WID_CHAR;
2286 wid.size = sizeof(char);
2287 wid.val = &del_beacon;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002288
Leo Kim45102f82015-10-28 15:59:28 +09002289 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002290 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002291
Leo Kim45102f82015-10-28 15:59:28 +09002292 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002293
2294 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002295
Leo Kim45102f82015-10-28 15:59:28 +09002296 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002297 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002298 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002299 PRINT_ER("Failed to send delete beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002300}
2301
Tony Cho6a89ba92015-09-21 12:16:46 +09002302static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2303 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002304{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002305 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002306
2307 pu8CurrByte = pu8Buffer;
2308
2309 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
Leo Kim2353c382015-10-29 12:05:41 +09002310 memcpy(pu8CurrByte, pstrStationParam->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002311 pu8CurrByte += ETH_ALEN;
2312
Leo Kim4101eb82015-10-29 12:05:42 +09002313 *pu8CurrByte++ = pstrStationParam->aid & 0xFF;
2314 *pu8CurrByte++ = (pstrStationParam->aid >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002315
Leo Kime7342232015-10-29 12:05:43 +09002316 *pu8CurrByte++ = pstrStationParam->rates_len;
2317 if (pstrStationParam->rates_len > 0)
Leo Kima622e012015-10-29 12:05:44 +09002318 memcpy(pu8CurrByte, pstrStationParam->rates,
Leo Kime7342232015-10-29 12:05:43 +09002319 pstrStationParam->rates_len);
2320 pu8CurrByte += pstrStationParam->rates_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002321
Leo Kim22520122015-10-29 12:05:45 +09002322 *pu8CurrByte++ = pstrStationParam->ht_supported;
Leo Kim0d073f62015-10-29 12:05:46 +09002323 *pu8CurrByte++ = pstrStationParam->ht_capa_info & 0xFF;
2324 *pu8CurrByte++ = (pstrStationParam->ht_capa_info >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002325
Leo Kimfba1f2d2015-10-29 12:05:47 +09002326 *pu8CurrByte++ = pstrStationParam->ht_ampdu_params;
Leo Kim5ebbf4f2015-10-29 12:05:48 +09002327 memcpy(pu8CurrByte, pstrStationParam->ht_supp_mcs_set,
2328 WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002329 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2330
Leo Kim223741d2015-10-29 12:05:49 +09002331 *pu8CurrByte++ = pstrStationParam->ht_ext_params & 0xFF;
2332 *pu8CurrByte++ = (pstrStationParam->ht_ext_params >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002333
Leo Kim74fe73c2015-10-29 12:05:50 +09002334 *pu8CurrByte++ = pstrStationParam->ht_tx_bf_cap & 0xFF;
2335 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 8) & 0xFF;
2336 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 16) & 0xFF;
2337 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 24) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002338
Leo Kima486baf2015-10-29 12:05:51 +09002339 *pu8CurrByte++ = pstrStationParam->ht_ante_sel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002340
Leo Kimf676e172015-10-29 12:05:52 +09002341 *pu8CurrByte++ = pstrStationParam->flags_mask & 0xFF;
2342 *pu8CurrByte++ = (pstrStationParam->flags_mask >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002343
Leo Kim67ab64e2015-10-29 12:05:53 +09002344 *pu8CurrByte++ = pstrStationParam->flags_set & 0xFF;
2345 *pu8CurrByte++ = (pstrStationParam->flags_set >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002346
2347 return pu8CurrByte - pu8Buffer;
2348}
2349
Tony Choa4ab1ad2015-10-12 16:56:05 +09002350static void Handle_AddStation(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09002351 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002352{
Leo Kim31390ee2015-10-19 18:26:08 +09002353 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002354 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002355 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002356
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002357 PRINT_D(HOSTINF_DBG, "Handling add station\n");
Leo Kim45102f82015-10-28 15:59:28 +09002358 wid.id = (u16)WID_ADD_STA;
2359 wid.type = WID_BIN;
Leo Kime7342232015-10-29 12:05:43 +09002360 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002361
Leo Kim45102f82015-10-28 15:59:28 +09002362 wid.val = kmalloc(wid.size, GFP_KERNEL);
2363 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002364 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002365
Leo Kim45102f82015-10-28 15:59:28 +09002366 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002367 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2368
Leo Kim45102f82015-10-28 15:59:28 +09002369 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002370 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002371 if (result != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002372 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002373
Leo Kim24db7132015-09-16 18:36:01 +09002374ERRORHANDLER:
Leo Kima622e012015-10-29 12:05:44 +09002375 kfree(pstrStationParam->rates);
Leo Kim45102f82015-10-28 15:59:28 +09002376 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002377}
2378
Tony Choa4ab1ad2015-10-12 16:56:05 +09002379static void Handle_DelAllSta(struct host_if_drv *hif_drv,
Tony Chob4e644e2015-09-21 12:17:00 +09002380 struct del_all_sta *pstrDelAllStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002381{
Leo Kim31390ee2015-10-19 18:26:08 +09002382 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002383 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002384 u8 *pu8CurrByte;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002385 u8 i;
Chaehyun Lim37034802015-06-11 14:34:32 +09002386 u8 au8Zero_Buff[6] = {0};
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002387
Leo Kim45102f82015-10-28 15:59:28 +09002388 wid.id = (u16)WID_DEL_ALL_STA;
2389 wid.type = WID_STR;
2390 wid.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002391
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002392 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002393
Leo Kim45102f82015-10-28 15:59:28 +09002394 wid.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2395 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002396 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002397
Leo Kim45102f82015-10-28 15:59:28 +09002398 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002399
Leo Kim8ba18032015-10-13 19:50:10 +09002400 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002401
2402 for (i = 0; i < MAX_NUM_STA; i++) {
Leo Kime51b9212015-10-13 19:50:09 +09002403 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2404 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002405 else
2406 continue;
2407
2408 pu8CurrByte += ETH_ALEN;
2409 }
2410
Leo Kim45102f82015-10-28 15:59:28 +09002411 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002412 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002413 if (result)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02002414 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002415
Leo Kim24db7132015-09-16 18:36:01 +09002416ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002417 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002418
Leo Kim2d25af82015-10-15 13:24:56 +09002419 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002420}
2421
Tony Choa4ab1ad2015-10-12 16:56:05 +09002422static void Handle_DelStation(struct host_if_drv *hif_drv,
Tony Chofb93a1e2015-09-21 12:16:57 +09002423 struct del_sta *pstrDelStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002424{
Leo Kim31390ee2015-10-19 18:26:08 +09002425 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002426 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002427 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002428
Leo Kim45102f82015-10-28 15:59:28 +09002429 wid.id = (u16)WID_REMOVE_STA;
2430 wid.type = WID_BIN;
2431 wid.size = ETH_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002432
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002433 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002434
Leo Kim45102f82015-10-28 15:59:28 +09002435 wid.val = kmalloc(wid.size, GFP_KERNEL);
2436 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002437 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002438
Leo Kim45102f82015-10-28 15:59:28 +09002439 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002440
Leo Kime4839d32015-10-13 20:02:06 +09002441 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002442
Leo Kim45102f82015-10-28 15:59:28 +09002443 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002444 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002445 if (result)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02002446 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002447
Leo Kim24db7132015-09-16 18:36:01 +09002448ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002449 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002450}
2451
Tony Choa4ab1ad2015-10-12 16:56:05 +09002452static void Handle_EditStation(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09002453 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002454{
Leo Kim31390ee2015-10-19 18:26:08 +09002455 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002456 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002457 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002458
Leo Kim45102f82015-10-28 15:59:28 +09002459 wid.id = (u16)WID_EDIT_STA;
2460 wid.type = WID_BIN;
Leo Kime7342232015-10-29 12:05:43 +09002461 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002462
2463 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
Leo Kim45102f82015-10-28 15:59:28 +09002464 wid.val = kmalloc(wid.size, GFP_KERNEL);
2465 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002466 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002467
Leo Kim45102f82015-10-28 15:59:28 +09002468 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002469 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2470
Leo Kim45102f82015-10-28 15:59:28 +09002471 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002472 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002473 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002474 PRINT_ER("Failed to send edit station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002475
Leo Kim24db7132015-09-16 18:36:01 +09002476ERRORHANDLER:
Leo Kima622e012015-10-29 12:05:44 +09002477 kfree(pstrStationParam->rates);
Leo Kim45102f82015-10-28 15:59:28 +09002478 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002479}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002480
Tony Choa4ab1ad2015-10-12 16:56:05 +09002481static int Handle_RemainOnChan(struct host_if_drv *hif_drv,
Tony Cho2f9c03f2015-09-21 12:16:58 +09002482 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002483{
Leo Kim31390ee2015-10-19 18:26:08 +09002484 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002485 u8 u8remain_on_chan_flag;
Leo Kim45102f82015-10-28 15:59:28 +09002486 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002487
Leo Kim5beef2c2015-10-28 15:59:36 +09002488 if (!hif_drv->remain_on_ch_pending) {
Leo Kimc5cc4b12015-10-29 11:58:44 +09002489 hif_drv->remain_on_ch.arg = pstrHostIfRemainOnChan->arg;
Leo Kimbfb62ab2015-10-29 11:58:42 +09002490 hif_drv->remain_on_ch.expired = pstrHostIfRemainOnChan->expired;
Leo Kim5e5f7912015-10-29 11:58:43 +09002491 hif_drv->remain_on_ch.ready = pstrHostIfRemainOnChan->ready;
Leo Kim839ab702015-10-29 11:58:41 +09002492 hif_drv->remain_on_ch.ch = pstrHostIfRemainOnChan->ch;
Leo Kim9d764e32015-10-29 12:05:38 +09002493 hif_drv->remain_on_ch.id = pstrHostIfRemainOnChan->id;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002494 } else {
Leo Kim839ab702015-10-29 11:58:41 +09002495 pstrHostIfRemainOnChan->ch = hif_drv->remain_on_ch.ch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002496 }
2497
Leo Kimbc801852015-10-29 11:58:50 +09002498 if (hif_drv->usr_scan_req.scan_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002499 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
Leo Kim5beef2c2015-10-28 15:59:36 +09002500 hif_drv->remain_on_ch_pending = 1;
Leo Kim31390ee2015-10-19 18:26:08 +09002501 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +09002502 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002503 }
Leo Kimb60005a2015-10-29 11:58:24 +09002504 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002505 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002506 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +09002507 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002508 }
2509
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002510 if (g_obtainingIP || connecting) {
2511 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002512 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +09002513 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002514 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002515
Leo Kim839ab702015-10-29 11:58:41 +09002516 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n",
2517 pstrHostIfRemainOnChan->ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002518
Dean Lee72ed4dc2015-06-12 14:11:44 +09002519 u8remain_on_chan_flag = true;
Leo Kim45102f82015-10-28 15:59:28 +09002520 wid.id = (u16)WID_REMAIN_ON_CHAN;
2521 wid.type = WID_STR;
2522 wid.size = 2;
2523 wid.val = kmalloc(wid.size, GFP_KERNEL);
2524 if (!wid.val) {
Leo Kim31390ee2015-10-19 18:26:08 +09002525 result = -ENOMEM;
Leo Kim24db7132015-09-16 18:36:01 +09002526 goto ERRORHANDLER;
2527 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002528
Leo Kim45102f82015-10-28 15:59:28 +09002529 wid.val[0] = u8remain_on_chan_flag;
Leo Kim839ab702015-10-29 11:58:41 +09002530 wid.val[1] = (s8)pstrHostIfRemainOnChan->ch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002531
Leo Kim45102f82015-10-28 15:59:28 +09002532 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002533 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002534 if (result != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002535 PRINT_ER("Failed to set remain on channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002536
Leo Kim24db7132015-09-16 18:36:01 +09002537ERRORHANDLER:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002538 {
2539 P2P_LISTEN_STATE = 1;
Leo Kimcc2d7e92015-10-29 11:58:36 +09002540 hif_drv->remain_on_ch_timer.data = (unsigned long)hif_drv;
2541 mod_timer(&hif_drv->remain_on_ch_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002542 jiffies +
2543 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002544
Leo Kim5e5f7912015-10-29 11:58:43 +09002545 if (hif_drv->remain_on_ch.ready)
Leo Kimc5cc4b12015-10-29 11:58:44 +09002546 hif_drv->remain_on_ch.ready(hif_drv->remain_on_ch.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002547
Leo Kim5beef2c2015-10-28 15:59:36 +09002548 if (hif_drv->remain_on_ch_pending)
2549 hif_drv->remain_on_ch_pending = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002550 }
Leo Kim31390ee2015-10-19 18:26:08 +09002551
2552 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002553}
2554
Tony Choa4ab1ad2015-10-12 16:56:05 +09002555static int Handle_RegisterFrame(struct host_if_drv *hif_drv,
Tony Chobc37c5d2015-09-21 12:16:59 +09002556 struct reg_frame *pstrHostIfRegisterFrame)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002557{
Leo Kim31390ee2015-10-19 18:26:08 +09002558 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002559 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002560 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002561
Leo Kim6abf8682015-10-29 11:58:38 +09002562 PRINT_D(HOSTINF_DBG, "Handling frame register : %d FrameType: %d\n",
2563 pstrHostIfRegisterFrame->reg,
Leo Kimd5f654c2015-10-29 11:58:39 +09002564 pstrHostIfRegisterFrame->frame_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002565
Leo Kim45102f82015-10-28 15:59:28 +09002566 wid.id = (u16)WID_REGISTER_FRAME;
2567 wid.type = WID_STR;
2568 wid.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2569 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002570 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002571
Leo Kim45102f82015-10-28 15:59:28 +09002572 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002573
Leo Kim6abf8682015-10-29 11:58:38 +09002574 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg;
Leo Kimbcb410b2015-10-29 11:58:40 +09002575 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg_id;
Leo Kimd5f654c2015-10-29 11:58:39 +09002576 memcpy(pu8CurrByte, &pstrHostIfRegisterFrame->frame_type, sizeof(u16));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002577
Leo Kim45102f82015-10-28 15:59:28 +09002578 wid.size = sizeof(u16) + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002579
Leo Kim45102f82015-10-28 15:59:28 +09002580 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002581 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002582 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002583 PRINT_ER("Failed to frame register config packet\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002584 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002585 }
2586
Leo Kim31390ee2015-10-19 18:26:08 +09002587 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002588}
2589
Tony Choa4ab1ad2015-10-12 16:56:05 +09002590static u32 Handle_ListenStateExpired(struct host_if_drv *hif_drv,
Tony Cho2f9c03f2015-09-21 12:16:58 +09002591 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002592{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002593 u8 u8remain_on_chan_flag;
Leo Kim45102f82015-10-28 15:59:28 +09002594 struct wid wid;
Leo Kim31390ee2015-10-19 18:26:08 +09002595 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002596
2597 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
2598
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002599 if (P2P_LISTEN_STATE) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002600 u8remain_on_chan_flag = false;
Leo Kim45102f82015-10-28 15:59:28 +09002601 wid.id = (u16)WID_REMAIN_ON_CHAN;
2602 wid.type = WID_STR;
2603 wid.size = 2;
2604 wid.val = kmalloc(wid.size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002605
Leo Kim45102f82015-10-28 15:59:28 +09002606 if (!wid.val)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002607 PRINT_ER("Failed to allocate memory\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002608
Leo Kim45102f82015-10-28 15:59:28 +09002609 wid.val[0] = u8remain_on_chan_flag;
2610 wid.val[1] = FALSE_FRMWR_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002611
Leo Kim45102f82015-10-28 15:59:28 +09002612 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002613 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002614 if (result != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002615 PRINT_ER("Failed to set remain on channel\n");
2616 goto _done_;
2617 }
2618
Leo Kimbfb62ab2015-10-29 11:58:42 +09002619 if (hif_drv->remain_on_ch.expired) {
Leo Kimc5cc4b12015-10-29 11:58:44 +09002620 hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg,
Leo Kim9d764e32015-10-29 12:05:38 +09002621 pstrHostIfRemainOnChan->id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002622 }
2623 P2P_LISTEN_STATE = 0;
2624 } else {
2625 PRINT_D(GENERIC_DBG, "Not in listen state\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002626 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002627 }
2628
2629_done_:
Leo Kim31390ee2015-10-19 18:26:08 +09002630 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002631}
2632
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07002633static void ListenTimerCB(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002634{
Leo Kim31390ee2015-10-19 18:26:08 +09002635 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09002636 struct host_if_msg msg;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002637 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
Leo Kimae4dfa52015-10-13 19:49:26 +09002638
Leo Kimcc2d7e92015-10-29 11:58:36 +09002639 del_timer(&hif_drv->remain_on_ch_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002640
Tony Cho143eb952015-09-21 12:16:32 +09002641 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09002642 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002643 msg.drv = hif_drv;
Leo Kim9d764e32015-10-29 12:05:38 +09002644 msg.body.remain_on_ch.id = hif_drv->remain_on_ch.id;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002645
Leo Kim31390ee2015-10-19 18:26:08 +09002646 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2647 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09002648 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002649}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002650
Tony Choa4ab1ad2015-10-12 16:56:05 +09002651static void Handle_PowerManagement(struct host_if_drv *hif_drv,
Tony Cho5a008f12015-09-21 12:16:48 +09002652 struct power_mgmt_param *strPowerMgmtParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002653{
Leo Kim31390ee2015-10-19 18:26:08 +09002654 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002655 struct wid wid;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002656 s8 s8PowerMode;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002657
Leo Kim45102f82015-10-28 15:59:28 +09002658 wid.id = (u16)WID_POWER_MANAGEMENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002659
Punit Vara047e6642015-10-25 04:01:25 +05302660 if (strPowerMgmtParam->enabled)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002661 s8PowerMode = MIN_FAST_PS;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302662 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002663 s8PowerMode = NO_POWERSAVE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002664 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
Leo Kim45102f82015-10-28 15:59:28 +09002665 wid.val = &s8PowerMode;
2666 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002667
2668 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
2669
Leo Kim45102f82015-10-28 15:59:28 +09002670 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002671 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002672 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002673 PRINT_ER("Failed to send power management config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002674}
2675
Tony Choa4ab1ad2015-10-12 16:56:05 +09002676static void Handle_SetMulticastFilter(struct host_if_drv *hif_drv,
Tony Cho641210a2015-09-21 12:16:52 +09002677 struct set_multicast *strHostIfSetMulti)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002678{
Leo Kim31390ee2015-10-19 18:26:08 +09002679 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002680 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002681 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002682
2683 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
2684
Leo Kim45102f82015-10-28 15:59:28 +09002685 wid.id = (u16)WID_SETUP_MULTICAST_FILTER;
2686 wid.type = WID_BIN;
2687 wid.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2688 wid.val = kmalloc(wid.size, GFP_KERNEL);
2689 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002690 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002691
Leo Kim45102f82015-10-28 15:59:28 +09002692 pu8CurrByte = wid.val;
Leo Kimbae636eb2015-10-13 20:02:04 +09002693 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
2694 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 8) & 0xFF);
2695 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 16) & 0xFF);
2696 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002697
Leo Kimadab2f72015-10-13 20:02:05 +09002698 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2699 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2700 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2701 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002702
Leo Kimadab2f72015-10-13 20:02:05 +09002703 if ((strHostIfSetMulti->cnt) > 0)
2704 memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->cnt) * ETH_ALEN));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002705
Leo Kim45102f82015-10-28 15:59:28 +09002706 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002707 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002708 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002709 PRINT_ER("Failed to send setup multicast config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002710
Leo Kim24db7132015-09-16 18:36:01 +09002711ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002712 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002713}
2714
Tony Choa4ab1ad2015-10-12 16:56:05 +09002715static s32 Handle_AddBASession(struct host_if_drv *hif_drv,
Tony Cho54265472015-09-21 12:16:56 +09002716 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002717{
Leo Kim31390ee2015-10-19 18:26:08 +09002718 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002719 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002720 int AddbaTimeout = 100;
2721 char *ptr = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002722
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002723 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 +09002724 strHostIfBASessionInfo->bssid[0],
2725 strHostIfBASessionInfo->bssid[1],
2726 strHostIfBASessionInfo->bssid[2],
Leo Kim277c2132015-10-29 11:58:47 +09002727 strHostIfBASessionInfo->buf_size,
Leo Kim23d0bfa2015-10-29 11:58:48 +09002728 strHostIfBASessionInfo->time_out,
Leo Kim16c9b392015-10-29 11:58:46 +09002729 strHostIfBASessionInfo->tid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002730
Leo Kim45102f82015-10-28 15:59:28 +09002731 wid.id = (u16)WID_11E_P_ACTION_REQ;
2732 wid.type = WID_STR;
2733 wid.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2734 wid.size = BLOCK_ACK_REQ_SIZE;
2735 ptr = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002736 *ptr++ = 0x14;
2737 *ptr++ = 0x3;
2738 *ptr++ = 0x0;
Leo Kim3fc49992015-10-29 11:58:45 +09002739 memcpy(ptr, strHostIfBASessionInfo->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002740 ptr += ETH_ALEN;
Leo Kim16c9b392015-10-29 11:58:46 +09002741 *ptr++ = strHostIfBASessionInfo->tid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002742 *ptr++ = 1;
Leo Kim277c2132015-10-29 11:58:47 +09002743 *ptr++ = (strHostIfBASessionInfo->buf_size & 0xFF);
2744 *ptr++ = ((strHostIfBASessionInfo->buf_size >> 16) & 0xFF);
Leo Kim23d0bfa2015-10-29 11:58:48 +09002745 *ptr++ = (strHostIfBASessionInfo->time_out & 0xFF);
2746 *ptr++ = ((strHostIfBASessionInfo->time_out >> 16) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002747 *ptr++ = (AddbaTimeout & 0xFF);
2748 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002749 *ptr++ = 8;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002750 *ptr++ = 0;
2751
Leo Kim45102f82015-10-28 15:59:28 +09002752 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002753 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002754 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002755 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
2756
Leo Kim45102f82015-10-28 15:59:28 +09002757 wid.id = (u16)WID_11E_P_ACTION_REQ;
2758 wid.type = WID_STR;
2759 wid.size = 15;
2760 ptr = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002761 *ptr++ = 15;
2762 *ptr++ = 7;
2763 *ptr++ = 0x2;
Leo Kim3fc49992015-10-29 11:58:45 +09002764 memcpy(ptr, strHostIfBASessionInfo->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002765 ptr += ETH_ALEN;
Leo Kim16c9b392015-10-29 11:58:46 +09002766 *ptr++ = strHostIfBASessionInfo->tid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002767 *ptr++ = 8;
Leo Kim277c2132015-10-29 11:58:47 +09002768 *ptr++ = (strHostIfBASessionInfo->buf_size & 0xFF);
Leo Kim23d0bfa2015-10-29 11:58:48 +09002769 *ptr++ = ((strHostIfBASessionInfo->time_out >> 16) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002770 *ptr++ = 3;
Leo Kim45102f82015-10-28 15:59:28 +09002771 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002772 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002773
Leo Kim45102f82015-10-28 15:59:28 +09002774 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002775
Leo Kim31390ee2015-10-19 18:26:08 +09002776 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002777}
2778
Tony Choa4ab1ad2015-10-12 16:56:05 +09002779static s32 Handle_DelAllRxBASessions(struct host_if_drv *hif_drv,
Tony Cho54265472015-09-21 12:16:56 +09002780 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002781{
Leo Kim31390ee2015-10-19 18:26:08 +09002782 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002783 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002784 char *ptr = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002785
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002786 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Leo Kim3fc49992015-10-29 11:58:45 +09002787 strHostIfBASessionInfo->bssid[0],
2788 strHostIfBASessionInfo->bssid[1],
2789 strHostIfBASessionInfo->bssid[2],
Leo Kim16c9b392015-10-29 11:58:46 +09002790 strHostIfBASessionInfo->tid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002791
Leo Kim45102f82015-10-28 15:59:28 +09002792 wid.id = (u16)WID_DEL_ALL_RX_BA;
2793 wid.type = WID_STR;
2794 wid.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2795 wid.size = BLOCK_ACK_REQ_SIZE;
2796 ptr = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002797 *ptr++ = 0x14;
2798 *ptr++ = 0x3;
2799 *ptr++ = 0x2;
Leo Kim3fc49992015-10-29 11:58:45 +09002800 memcpy(ptr, strHostIfBASessionInfo->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002801 ptr += ETH_ALEN;
Leo Kim16c9b392015-10-29 11:58:46 +09002802 *ptr++ = strHostIfBASessionInfo->tid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002803 *ptr++ = 0;
Leo Kimae4dfa52015-10-13 19:49:26 +09002804 *ptr++ = 32;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002805
Leo Kim45102f82015-10-28 15:59:28 +09002806 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002807 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002808 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002809 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
2810
Leo Kim45102f82015-10-28 15:59:28 +09002811 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002812
Leo Kim2d25af82015-10-15 13:24:56 +09002813 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002814
Leo Kim31390ee2015-10-19 18:26:08 +09002815 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002816}
2817
Arnd Bergmann1999bd52015-05-29 22:52:14 +02002818static int hostIFthread(void *pvArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002819{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002820 u32 u32Ret;
Tony Cho143eb952015-09-21 12:16:32 +09002821 struct host_if_msg msg;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002822 struct host_if_drv *hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002823
Tony Cho143eb952015-09-21 12:16:32 +09002824 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002825
2826 while (1) {
Leo Kimcb067dc2015-10-15 13:24:53 +09002827 wilc_mq_recv(&hif_msg_q, &msg, sizeof(struct host_if_msg), &u32Ret);
Tony Choa4ab1ad2015-10-12 16:56:05 +09002828 hif_drv = (struct host_if_drv *)msg.drv;
Tony Choa9f812a2015-09-21 12:16:33 +09002829 if (msg.id == HOST_IF_MSG_EXIT) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002830 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
2831 break;
2832 }
2833
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002834 if ((!g_wilc_initialized)) {
2835 PRINT_D(GENERIC_DBG, "--WAIT--");
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07002836 usleep_range(200 * 1000, 200 * 1000);
Leo Kimcb067dc2015-10-15 13:24:53 +09002837 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002838 continue;
2839 }
2840
Leo Kim91109e12015-10-19 18:26:13 +09002841 if (msg.id == HOST_IF_MSG_CONNECT &&
Leo Kimbc801852015-10-29 11:58:50 +09002842 hif_drv->usr_scan_req.scan_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002843 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
Leo Kimcb067dc2015-10-15 13:24:53 +09002844 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07002845 usleep_range(2 * 1000, 2 * 1000);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002846 continue;
2847 }
2848
Tony Choa9f812a2015-09-21 12:16:33 +09002849 switch (msg.id) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002850 case HOST_IF_MSG_Q_IDLE:
2851 Handle_wait_msg_q_empty();
2852 break;
2853
2854 case HOST_IF_MSG_SCAN:
Leo Kim2482a792015-10-12 16:55:36 +09002855 Handle_Scan(msg.drv, &msg.body.scan_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002856 break;
2857
2858 case HOST_IF_MSG_CONNECT:
Leo Kim2482a792015-10-12 16:55:36 +09002859 Handle_Connect(msg.drv, &msg.body.con_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002860 break;
2861
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002862 case HOST_IF_MSG_FLUSH_CONNECT:
Leo Kim2482a792015-10-12 16:55:36 +09002863 Handle_FlushConnect(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002864 break;
2865
2866 case HOST_IF_MSG_RCVD_NTWRK_INFO:
Leo Kim2482a792015-10-12 16:55:36 +09002867 Handle_RcvdNtwrkInfo(msg.drv, &msg.body.net_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002868 break;
2869
2870 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
Leo Kim2482a792015-10-12 16:55:36 +09002871 Handle_RcvdGnrlAsyncInfo(msg.drv, &msg.body.async_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002872 break;
2873
2874 case HOST_IF_MSG_KEY:
Leo Kim2482a792015-10-12 16:55:36 +09002875 Handle_Key(msg.drv, &msg.body.key_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002876 break;
2877
2878 case HOST_IF_MSG_CFG_PARAMS:
2879
Leo Kim2482a792015-10-12 16:55:36 +09002880 Handle_CfgParam(msg.drv, &msg.body.cfg_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002881 break;
2882
2883 case HOST_IF_MSG_SET_CHANNEL:
Leo Kim2482a792015-10-12 16:55:36 +09002884 Handle_SetChannel(msg.drv, &msg.body.channel_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002885 break;
2886
2887 case HOST_IF_MSG_DISCONNECT:
Leo Kim2482a792015-10-12 16:55:36 +09002888 Handle_Disconnect(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002889 break;
2890
2891 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
Leo Kim13b313e2015-10-29 11:58:34 +09002892 del_timer(&hif_drv->scan_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002893 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
2894
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002895 if (!linux_wlan_get_num_conn_ifcs())
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002896 chip_sleep_manually(INFINITE_SLEEP_TIME);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002897
Leo Kim2482a792015-10-12 16:55:36 +09002898 Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002899
Leo Kim5beef2c2015-10-28 15:59:36 +09002900 if (hif_drv->remain_on_ch_pending)
Leo Kim2482a792015-10-12 16:55:36 +09002901 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002902
2903 break;
2904
2905 case HOST_IF_MSG_GET_RSSI:
Leo Kim2482a792015-10-12 16:55:36 +09002906 Handle_GetRssi(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002907 break;
2908
2909 case HOST_IF_MSG_GET_LINKSPEED:
Leo Kim2482a792015-10-12 16:55:36 +09002910 Handle_GetLinkspeed(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002911 break;
2912
2913 case HOST_IF_MSG_GET_STATISTICS:
Leo Kim03e7b9c2015-10-12 16:55:58 +09002914 Handle_GetStatistics(msg.drv, (struct rf_info *)msg.body.data);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002915 break;
2916
2917 case HOST_IF_MSG_GET_CHNL:
Leo Kim2482a792015-10-12 16:55:36 +09002918 Handle_GetChnl(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002919 break;
2920
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002921 case HOST_IF_MSG_ADD_BEACON:
Leo Kim2482a792015-10-12 16:55:36 +09002922 Handle_AddBeacon(msg.drv, &msg.body.beacon_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002923 break;
2924
2925 case HOST_IF_MSG_DEL_BEACON:
Leo Kim2482a792015-10-12 16:55:36 +09002926 Handle_DelBeacon(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002927 break;
2928
2929 case HOST_IF_MSG_ADD_STATION:
Leo Kim2482a792015-10-12 16:55:36 +09002930 Handle_AddStation(msg.drv, &msg.body.add_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002931 break;
2932
2933 case HOST_IF_MSG_DEL_STATION:
Leo Kim2482a792015-10-12 16:55:36 +09002934 Handle_DelStation(msg.drv, &msg.body.del_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002935 break;
2936
2937 case HOST_IF_MSG_EDIT_STATION:
Leo Kim2482a792015-10-12 16:55:36 +09002938 Handle_EditStation(msg.drv, &msg.body.edit_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002939 break;
2940
2941 case HOST_IF_MSG_GET_INACTIVETIME:
Leo Kim2482a792015-10-12 16:55:36 +09002942 Handle_Get_InActiveTime(msg.drv, &msg.body.mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002943 break;
2944
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002945 case HOST_IF_MSG_SCAN_TIMER_FIRED:
2946 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
2947
Leo Kim2482a792015-10-12 16:55:36 +09002948 Handle_ScanDone(msg.drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002949 break;
2950
2951 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002952 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
Leo Kim2482a792015-10-12 16:55:36 +09002953 Handle_ConnectTimeout(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002954 break;
2955
2956 case HOST_IF_MSG_POWER_MGMT:
Leo Kim2482a792015-10-12 16:55:36 +09002957 Handle_PowerManagement(msg.drv, &msg.body.pwr_mgmt_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002958 break;
2959
2960 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
Leo Kim2482a792015-10-12 16:55:36 +09002961 Handle_SetWfiDrvHandler(msg.drv,
Tony Cho5e4377e2015-09-30 18:44:38 +09002962 &msg.body.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002963 break;
2964
2965 case HOST_IF_MSG_SET_OPERATION_MODE:
Leo Kim2482a792015-10-12 16:55:36 +09002966 Handle_SetOperationMode(msg.drv, &msg.body.mode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002967 break;
2968
2969 case HOST_IF_MSG_SET_IPADDRESS:
2970 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Leo Kim78675be2015-10-13 20:02:09 +09002971 Handle_set_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002972 break;
2973
2974 case HOST_IF_MSG_GET_IPADDRESS:
2975 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Leo Kim78675be2015-10-13 20:02:09 +09002976 Handle_get_IPAddress(msg.drv, msg.body.ip_info.ip_addr, msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002977 break;
2978
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002979 case HOST_IF_MSG_SET_MAC_ADDRESS:
Leo Kim2482a792015-10-12 16:55:36 +09002980 Handle_SetMacAddress(msg.drv, &msg.body.set_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002981 break;
2982
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002983 case HOST_IF_MSG_GET_MAC_ADDRESS:
Leo Kim2482a792015-10-12 16:55:36 +09002984 Handle_GetMacAddress(msg.drv, &msg.body.get_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002985 break;
2986
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002987 case HOST_IF_MSG_REMAIN_ON_CHAN:
2988 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
Leo Kim2482a792015-10-12 16:55:36 +09002989 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002990 break;
2991
2992 case HOST_IF_MSG_REGISTER_FRAME:
2993 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
Leo Kim2482a792015-10-12 16:55:36 +09002994 Handle_RegisterFrame(msg.drv, &msg.body.reg_frame);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002995 break;
2996
2997 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
Leo Kim2482a792015-10-12 16:55:36 +09002998 Handle_ListenStateExpired(msg.drv, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002999 break;
3000
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003001 case HOST_IF_MSG_SET_MULTICAST_FILTER:
3002 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
Leo Kim2482a792015-10-12 16:55:36 +09003003 Handle_SetMulticastFilter(msg.drv, &msg.body.multicast_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003004 break;
3005
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003006 case HOST_IF_MSG_ADD_BA_SESSION:
Leo Kim2482a792015-10-12 16:55:36 +09003007 Handle_AddBASession(msg.drv, &msg.body.session_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003008 break;
3009
3010 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
Leo Kim2482a792015-10-12 16:55:36 +09003011 Handle_DelAllRxBASessions(msg.drv, &msg.body.session_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003012 break;
3013
3014 case HOST_IF_MSG_DEL_ALL_STA:
Leo Kim2482a792015-10-12 16:55:36 +09003015 Handle_DelAllSta(msg.drv, &msg.body.del_all_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003016 break;
3017
3018 default:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003019 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003020 break;
3021 }
3022 }
3023
3024 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
Leo Kim834e0cb2015-10-15 13:24:54 +09003025 up(&hif_sema_thread);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02003026 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003027}
3028
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003029static void TimerCB_Scan(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003030{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003031 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09003032 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003033
Tony Cho143eb952015-09-21 12:16:32 +09003034 memset(&msg, 0, sizeof(struct host_if_msg));
Leo Kim2482a792015-10-12 16:55:36 +09003035 msg.drv = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09003036 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003037
Leo Kimcb067dc2015-10-15 13:24:53 +09003038 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003039}
3040
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003041static void TimerCB_Connect(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003042{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003043 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09003044 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003045
Tony Cho143eb952015-09-21 12:16:32 +09003046 memset(&msg, 0, sizeof(struct host_if_msg));
Leo Kim2482a792015-10-12 16:55:36 +09003047 msg.drv = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09003048 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003049
Leo Kimcb067dc2015-10-15 13:24:53 +09003050 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003051}
3052
Tony Choa4ab1ad2015-10-12 16:56:05 +09003053s32 host_int_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003054{
Leo Kim45102f82015-10-28 15:59:28 +09003055 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003056
Leo Kim45102f82015-10-28 15:59:28 +09003057 wid.id = (u16)WID_REMOVE_KEY;
3058 wid.type = WID_STR;
3059 wid.val = (s8 *)pu8StaAddress;
3060 wid.size = 6;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003061
Leo Kimb68d820b2015-10-12 16:55:37 +09003062 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003063}
3064
Tony Choa4ab1ad2015-10-12 16:56:05 +09003065int host_int_remove_wep_key(struct host_if_drv *hif_drv, u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003066{
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003067 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003068 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003069
Tony Choa4ab1ad2015-10-12 16:56:05 +09003070 if (!hif_drv) {
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003071 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003072 PRINT_ER("Failed to send setup multicast config packet\n");
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003073 return result;
Leo Kim24db7132015-09-16 18:36:01 +09003074 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003075
Tony Cho143eb952015-09-21 12:16:32 +09003076 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003077
Tony Choa9f812a2015-09-21 12:16:33 +09003078 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003079 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003080 msg.body.key_info.action = REMOVEKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003081 msg.drv = hif_drv;
Leo Kim73b2e382015-10-13 19:49:29 +09003082 msg.body.key_info.attr.wep.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003083
Leo Kimcb067dc2015-10-15 13:24:53 +09003084 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003085 if (result)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003086 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003087 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003088
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003089 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003090}
3091
Chaehyun Limdf8b4832015-10-26 09:44:45 +09003092int host_int_set_wep_default_key(struct host_if_drv *hif_drv, u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003093{
Chaehyun Lim5b41c7c2015-10-26 09:44:42 +09003094 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003095 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003096
Tony Choa4ab1ad2015-10-12 16:56:05 +09003097 if (!hif_drv) {
Leo Kim31390ee2015-10-19 18:26:08 +09003098 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003099 PRINT_ER("driver is null\n");
Leo Kim31390ee2015-10-19 18:26:08 +09003100 return result;
Leo Kim24db7132015-09-16 18:36:01 +09003101 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003102
Tony Cho143eb952015-09-21 12:16:32 +09003103 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003104
Tony Choa9f812a2015-09-21 12:16:33 +09003105 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003106 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003107 msg.body.key_info.action = DEFAULTKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003108 msg.drv = hif_drv;
Chaehyun Lime91d0342015-10-26 09:44:44 +09003109 msg.body.key_info.attr.wep.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003110
Leo Kim31390ee2015-10-19 18:26:08 +09003111 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3112 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003113 PRINT_ER("Error in sending message queue : Default key index\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003114 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003115
Leo Kim31390ee2015-10-19 18:26:08 +09003116 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003117}
3118
Chaehyun Lim66b8cb82015-10-27 20:40:32 +09003119int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
Chaehyun Limfba778b2015-10-27 20:40:34 +09003120 const u8 *key,
Chaehyun Limdbc53192015-10-27 20:40:35 +09003121 u8 len,
Chaehyun Lim0b2cc3e2015-10-27 20:40:36 +09003122 u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003123{
Chaehyun Lim66b8cb82015-10-27 20:40:32 +09003124 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003125 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003126
Tony Choa4ab1ad2015-10-12 16:56:05 +09003127 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003128 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003129 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003130 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003131
Tony Cho143eb952015-09-21 12:16:32 +09003132 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003133
Tony Choa9f812a2015-09-21 12:16:33 +09003134 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003135 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003136 msg.body.key_info.action = ADDKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003137 msg.drv = hif_drv;
Chaehyun Lim1cc0c322015-10-27 20:40:37 +09003138 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3139 if (!msg.body.key_info.attr.wep.key)
3140 return -ENOMEM;
3141
Chaehyun Limdbc53192015-10-27 20:40:35 +09003142 msg.body.key_info.attr.wep.key_len = len;
Chaehyun Lim0b2cc3e2015-10-27 20:40:36 +09003143 msg.body.key_info.attr.wep.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003144
Leo Kim31390ee2015-10-19 18:26:08 +09003145 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3146 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003147 PRINT_ER("Error in sending message queue :WEP Key\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003148 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003149
Leo Kim31390ee2015-10-19 18:26:08 +09003150 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003151}
3152
Chaehyun Lim641c20a2015-10-28 08:19:19 +09003153int host_int_add_wep_key_bss_ap(struct host_if_drv *hif_drv,
Chaehyun Lim81117252015-10-28 08:19:22 +09003154 const u8 *key,
Chaehyun Lima5389b02015-10-28 08:19:23 +09003155 u8 len,
Chaehyun Lima76dc952015-10-28 08:19:24 +09003156 u8 index,
Chaehyun Lim730a28d2015-10-28 08:19:25 +09003157 u8 mode,
Chaehyun Limff3bce22015-10-28 08:19:26 +09003158 enum AUTHTYPE auth_type)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003159{
Chaehyun Lim641c20a2015-10-28 08:19:19 +09003160 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003161 struct host_if_msg msg;
Chaehyun Limfd741462015-10-28 08:19:21 +09003162 int i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003163
Tony Choa4ab1ad2015-10-12 16:56:05 +09003164 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003165 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003166 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003167 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003168
Tony Cho143eb952015-09-21 12:16:32 +09003169 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003170
3171 if (INFO) {
Chaehyun Lima5389b02015-10-28 08:19:23 +09003172 for (i = 0; i < len; i++)
Chaehyun Lim81117252015-10-28 08:19:22 +09003173 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", key[i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003174 }
Tony Choa9f812a2015-09-21 12:16:33 +09003175 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003176 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003177 msg.body.key_info.action = ADDKEY_AP;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003178 msg.drv = hif_drv;
Chaehyun Lim58eabd62015-10-28 08:19:27 +09003179 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3180 if (!msg.body.key_info.attr.wep.key)
3181 return -ENOMEM;
3182
Chaehyun Lima5389b02015-10-28 08:19:23 +09003183 msg.body.key_info.attr.wep.key_len = len;
Chaehyun Lima76dc952015-10-28 08:19:24 +09003184 msg.body.key_info.attr.wep.index = index;
Chaehyun Lim730a28d2015-10-28 08:19:25 +09003185 msg.body.key_info.attr.wep.mode = mode;
Chaehyun Limff3bce22015-10-28 08:19:26 +09003186 msg.body.key_info.attr.wep.auth_type = auth_type;
Leo Kimae4dfa52015-10-13 19:49:26 +09003187
Leo Kim31390ee2015-10-19 18:26:08 +09003188 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003189
Leo Kim31390ee2015-10-19 18:26:08 +09003190 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003191 PRINT_ER("Error in sending message queue :WEP Key\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003192 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003193
Leo Kim31390ee2015-10-19 18:26:08 +09003194 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003195}
Glen Lee108b3432015-09-16 18:53:20 +09003196
Tony Choa4ab1ad2015-10-12 16:56:05 +09003197s32 host_int_add_ptk(struct host_if_drv *hif_drv, const u8 *pu8Ptk,
3198 u8 u8PtkKeylen, const u8 *mac_addr,
3199 const u8 *pu8RxMic, const u8 *pu8TxMic,
3200 u8 mode, u8 u8Ciphermode, u8 u8Idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003201{
Leo Kim31390ee2015-10-19 18:26:08 +09003202 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003203 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003204 u8 u8KeyLen = u8PtkKeylen;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003205 u32 i;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003206
Tony Choa4ab1ad2015-10-12 16:56:05 +09003207 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003208 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003209 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003210 }
Leo Kim91109e12015-10-19 18:26:13 +09003211
3212 if (pu8RxMic)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003213 u8KeyLen += RX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003214
3215 if (pu8TxMic)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003216 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003217
Tony Cho143eb952015-09-21 12:16:32 +09003218 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003219
Tony Choa9f812a2015-09-21 12:16:33 +09003220 msg.id = HOST_IF_MSG_KEY;
Leo Kim2141fe32015-10-29 12:05:35 +09003221 msg.body.key_info.type = WPA_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003222 if (mode == AP_MODE) {
Leo Kim0d17e382015-10-13 19:49:28 +09003223 msg.body.key_info.action = ADDKEY_AP;
Leo Kime2dfbac2015-10-13 19:49:34 +09003224 msg.body.key_info.attr.wpa.index = u8Idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003225 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003226 if (mode == STATION_MODE)
Leo Kim0d17e382015-10-13 19:49:28 +09003227 msg.body.key_info.action = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003228
Leo Kim124968fc2015-10-13 19:49:30 +09003229 msg.body.key_info.attr.wpa.key = kmalloc(u8PtkKeylen, GFP_KERNEL);
3230 memcpy(msg.body.key_info.attr.wpa.key, pu8Ptk, u8PtkKeylen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003231
Leo Kim91109e12015-10-19 18:26:13 +09003232 if (pu8RxMic) {
Leo Kim124968fc2015-10-13 19:49:30 +09003233 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003234 if (INFO) {
3235 for (i = 0; i < RX_MIC_KEY_LEN; i++)
3236 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
3237 }
3238 }
Leo Kim91109e12015-10-19 18:26:13 +09003239 if (pu8TxMic) {
Leo Kim124968fc2015-10-13 19:49:30 +09003240 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003241 if (INFO) {
3242 for (i = 0; i < TX_MIC_KEY_LEN; i++)
3243 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
3244 }
3245 }
3246
Leo Kim6acf2912015-10-13 19:49:35 +09003247 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
Leo Kim248080a2015-10-13 19:49:31 +09003248 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
Leo Kim7b2ebb22015-10-13 19:49:36 +09003249 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003250 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003251
Leo Kim31390ee2015-10-19 18:26:08 +09003252 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003253
Leo Kim31390ee2015-10-19 18:26:08 +09003254 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003255 PRINT_ER("Error in sending message queue: PTK Key\n");
3256
Leo Kim9ea47132015-10-29 11:58:28 +09003257 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003258
Leo Kim31390ee2015-10-19 18:26:08 +09003259 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003260}
3261
Tony Choa4ab1ad2015-10-12 16:56:05 +09003262s32 host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *pu8RxGtk,
3263 u8 u8GtkKeylen, u8 u8KeyIdx,
3264 u32 u32KeyRSClen, const u8 *KeyRSC,
3265 const u8 *pu8RxMic, const u8 *pu8TxMic,
3266 u8 mode, u8 u8Ciphermode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003267{
Leo Kim31390ee2015-10-19 18:26:08 +09003268 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003269 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003270 u8 u8KeyLen = u8GtkKeylen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003271
Tony Choa4ab1ad2015-10-12 16:56:05 +09003272 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003273 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003274 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003275 }
Tony Cho143eb952015-09-21 12:16:32 +09003276 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003277
Leo Kim91109e12015-10-19 18:26:13 +09003278 if (pu8RxMic)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003279 u8KeyLen += RX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003280
3281 if (pu8TxMic)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003282 u8KeyLen += TX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003283
3284 if (KeyRSC) {
Leo Kim0e74c002015-10-13 19:49:32 +09003285 msg.body.key_info.attr.wpa.seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
3286 memcpy(msg.body.key_info.attr.wpa.seq, KeyRSC, u32KeyRSClen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003287 }
3288
Tony Choa9f812a2015-09-21 12:16:33 +09003289 msg.id = HOST_IF_MSG_KEY;
Leo Kim5cd8f7a2015-10-29 12:05:34 +09003290 msg.body.key_info.type = WPA_RX_GTK;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003291 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003292
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003293 if (mode == AP_MODE) {
Leo Kim0d17e382015-10-13 19:49:28 +09003294 msg.body.key_info.action = ADDKEY_AP;
Leo Kim7b2ebb22015-10-13 19:49:36 +09003295 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003296 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003297 if (mode == STATION_MODE)
Leo Kim0d17e382015-10-13 19:49:28 +09003298 msg.body.key_info.action = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003299
Leo Kim124968fc2015-10-13 19:49:30 +09003300 msg.body.key_info.attr.wpa.key = kmalloc(u8KeyLen, GFP_KERNEL);
3301 memcpy(msg.body.key_info.attr.wpa.key, pu8RxGtk, u8GtkKeylen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003302
Leo Kimd1666e22015-10-28 15:59:22 +09003303 if (pu8RxMic)
3304 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic,
3305 RX_MIC_KEY_LEN);
Leo Kim91109e12015-10-19 18:26:13 +09003306
Leo Kimd1666e22015-10-28 15:59:22 +09003307 if (pu8TxMic)
3308 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic,
3309 TX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003310
Leo Kime2dfbac2015-10-13 19:49:34 +09003311 msg.body.key_info.attr.wpa.index = u8KeyIdx;
Leo Kim6acf2912015-10-13 19:49:35 +09003312 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
Leo Kimdacc5942015-10-13 19:49:33 +09003313 msg.body.key_info.attr.wpa.seq_len = u32KeyRSClen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003314
Leo Kim31390ee2015-10-19 18:26:08 +09003315 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3316 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003317 PRINT_ER("Error in sending message queue: RX GTK\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09003318
Leo Kim9ea47132015-10-29 11:58:28 +09003319 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003320
Leo Kim31390ee2015-10-19 18:26:08 +09003321 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003322}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003323
Tony Choa4ab1ad2015-10-12 16:56:05 +09003324s32 host_int_set_pmkid_info(struct host_if_drv *hif_drv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003325{
Leo Kim31390ee2015-10-19 18:26:08 +09003326 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003327 struct host_if_msg msg;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003328 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003329
Tony Choa4ab1ad2015-10-12 16:56:05 +09003330 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003331 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003332 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003333 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003334
Tony Cho143eb952015-09-21 12:16:32 +09003335 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003336
Tony Choa9f812a2015-09-21 12:16:33 +09003337 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003338 msg.body.key_info.type = PMKSA;
Leo Kim0d17e382015-10-13 19:49:28 +09003339 msg.body.key_info.action = ADDKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003340 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003341
3342 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
Leo Kim8c8360b2015-10-19 18:26:12 +09003343 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid,
3344 &pu8PmkidInfoArray->pmkidlist[i].bssid, ETH_ALEN);
3345 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid,
3346 &pu8PmkidInfoArray->pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003347 }
3348
Leo Kim31390ee2015-10-19 18:26:08 +09003349 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3350 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003351 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3352
Leo Kim31390ee2015-10-19 18:26:08 +09003353 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003354}
3355
Tony Choa4ab1ad2015-10-12 16:56:05 +09003356s32 host_int_get_pmkid_info(struct host_if_drv *hif_drv,
3357 u8 *pu8PmkidInfoArray,
3358 u32 u32PmkidInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003359{
Leo Kim45102f82015-10-28 15:59:28 +09003360 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003361
Leo Kim45102f82015-10-28 15:59:28 +09003362 wid.id = (u16)WID_PMKID_INFO;
3363 wid.type = WID_STR;
3364 wid.size = u32PmkidInfoLen;
3365 wid.val = pu8PmkidInfoArray;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003366
Leo Kimb68d820b2015-10-12 16:55:37 +09003367 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003368}
3369
Tony Choa4ab1ad2015-10-12 16:56:05 +09003370s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3371 u8 *pu8PassPhrase,
3372 u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003373{
Leo Kim45102f82015-10-28 15:59:28 +09003374 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003375
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003376 if ((u8Psklength > 7) && (u8Psklength < 65)) {
Leo Kim45102f82015-10-28 15:59:28 +09003377 wid.id = (u16)WID_11I_PSK;
3378 wid.type = WID_STR;
3379 wid.val = pu8PassPhrase;
3380 wid.size = u8Psklength;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003381 }
3382
Leo Kimb68d820b2015-10-12 16:55:37 +09003383 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003384}
Leo Kimae4dfa52015-10-13 19:49:26 +09003385
Tony Choa4ab1ad2015-10-12 16:56:05 +09003386s32 host_int_get_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003387{
Leo Kim31390ee2015-10-19 18:26:08 +09003388 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003389 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003390
Tony Cho143eb952015-09-21 12:16:32 +09003391 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003392
Tony Choa9f812a2015-09-21 12:16:33 +09003393 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
Leo Kim6ceba0a2015-10-28 15:59:32 +09003394 msg.body.get_mac_info.mac_addr = pu8MacAddress;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003395 msg.drv = hif_drv;
Leo Kimae4dfa52015-10-13 19:49:26 +09003396
Leo Kim31390ee2015-10-19 18:26:08 +09003397 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3398 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003399 PRINT_ER("Failed to send get mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +09003400 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003401 }
3402
Leo Kim2d25af82015-10-15 13:24:56 +09003403 down(&hif_sema_wait_response);
Leo Kim31390ee2015-10-19 18:26:08 +09003404 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003405}
3406
Tony Choa4ab1ad2015-10-12 16:56:05 +09003407s32 host_int_set_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003408{
Leo Kim31390ee2015-10-19 18:26:08 +09003409 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003410 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003411
3412 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
3413
Tony Cho143eb952015-09-21 12:16:32 +09003414 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003415 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
Leo Kimae5e4522015-10-28 15:59:31 +09003416 memcpy(msg.body.set_mac_info.mac_addr, pu8MacAddress, ETH_ALEN);
Tony Choa4ab1ad2015-10-12 16:56:05 +09003417 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003418
Leo Kim31390ee2015-10-19 18:26:08 +09003419 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3420 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003421 PRINT_ER("Failed to send message queue: Set mac address\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003422
Leo Kim31390ee2015-10-19 18:26:08 +09003423 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003424}
3425
Tony Choa4ab1ad2015-10-12 16:56:05 +09003426s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3427 u8 *pu8PassPhrase, u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003428{
Leo Kim45102f82015-10-28 15:59:28 +09003429 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003430
Leo Kim45102f82015-10-28 15:59:28 +09003431 wid.id = (u16)WID_11I_PSK;
3432 wid.type = WID_STR;
3433 wid.size = u8Psklength;
3434 wid.val = pu8PassPhrase;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003435
Leo Kimb68d820b2015-10-12 16:55:37 +09003436 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003437}
3438
Tony Choa4ab1ad2015-10-12 16:56:05 +09003439s32 host_int_set_start_scan_req(struct host_if_drv *hif_drv, u8 scanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003440{
Leo Kim45102f82015-10-28 15:59:28 +09003441 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003442
Leo Kim45102f82015-10-28 15:59:28 +09003443 wid.id = (u16)WID_START_SCAN_REQ;
3444 wid.type = WID_CHAR;
3445 wid.val = (s8 *)&scanSource;
3446 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003447
Leo Kimb68d820b2015-10-12 16:55:37 +09003448 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003449}
3450
Tony Choa4ab1ad2015-10-12 16:56:05 +09003451s32 host_int_get_start_scan_req(struct host_if_drv *hif_drv, u8 *pu8ScanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003452{
Leo Kim45102f82015-10-28 15:59:28 +09003453 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003454
Leo Kim45102f82015-10-28 15:59:28 +09003455 wid.id = (u16)WID_START_SCAN_REQ;
3456 wid.type = WID_CHAR;
3457 wid.val = (s8 *)pu8ScanSource;
3458 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003459
Leo Kimb68d820b2015-10-12 16:55:37 +09003460 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003461}
3462
Tony Choa4ab1ad2015-10-12 16:56:05 +09003463s32 host_int_set_join_req(struct host_if_drv *hif_drv, u8 *pu8bssid,
3464 const u8 *pu8ssid, size_t ssidLen,
3465 const u8 *pu8IEs, size_t IEsLen,
3466 wilc_connect_result pfConnectResult, void *pvUserArg,
3467 u8 u8security, enum AUTHTYPE tenuAuth_type,
3468 u8 u8channel, void *pJoinParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003469{
Leo Kim31390ee2015-10-19 18:26:08 +09003470 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003471 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003472
Leo Kim91109e12015-10-19 18:26:13 +09003473 if (!hif_drv || !pfConnectResult) {
Leo Kim24db7132015-09-16 18:36:01 +09003474 PRINT_ER("Driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003475 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003476 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003477
Leo Kim91109e12015-10-19 18:26:13 +09003478 if (!pJoinParams) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003479 PRINT_ER("Unable to Join - JoinParams is NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003480 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003481 }
Leo Kim24db7132015-09-16 18:36:01 +09003482
Tony Cho143eb952015-09-21 12:16:32 +09003483 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003484
Tony Choa9f812a2015-09-21 12:16:33 +09003485 msg.id = HOST_IF_MSG_CONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003486
Leo Kima64fd672015-10-13 19:49:54 +09003487 msg.body.con_info.security = u8security;
Leo Kim61b4fd02015-10-13 19:49:57 +09003488 msg.body.con_info.auth_type = tenuAuth_type;
Leo Kim0d1527e2015-10-13 19:49:58 +09003489 msg.body.con_info.ch = u8channel;
Leo Kim6abcc112015-10-13 19:49:55 +09003490 msg.body.con_info.result = pfConnectResult;
Leo Kim8f38db82015-10-13 19:49:56 +09003491 msg.body.con_info.arg = pvUserArg;
Leo Kimf2bed2c2015-10-13 19:49:59 +09003492 msg.body.con_info.params = pJoinParams;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003493 msg.drv = hif_drv ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003494
Leo Kim91109e12015-10-19 18:26:13 +09003495 if (pu8bssid) {
Leo Kim9254db02015-10-13 19:49:49 +09003496 msg.body.con_info.bssid = kmalloc(6, GFP_KERNEL);
3497 memcpy(msg.body.con_info.bssid, pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003498 }
3499
Leo Kim91109e12015-10-19 18:26:13 +09003500 if (pu8ssid) {
Leo Kim8b3c9fa2015-10-13 19:49:51 +09003501 msg.body.con_info.ssid_len = ssidLen;
Leo Kimf7bbd9c2015-10-13 19:49:50 +09003502 msg.body.con_info.ssid = kmalloc(ssidLen, GFP_KERNEL);
3503 memcpy(msg.body.con_info.ssid, pu8ssid, ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003504 }
3505
Leo Kim91109e12015-10-19 18:26:13 +09003506 if (pu8IEs) {
Leo Kimb59d5c52015-10-13 19:49:53 +09003507 msg.body.con_info.ies_len = IEsLen;
Leo Kim2ea158c2015-10-13 19:49:52 +09003508 msg.body.con_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3509 memcpy(msg.body.con_info.ies, pu8IEs, IEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003510 }
Leo Kimb60005a2015-10-29 11:58:24 +09003511 if (hif_drv->hif_state < HOST_IF_CONNECTING)
3512 hif_drv->hif_state = HOST_IF_CONNECTING;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05303513 else
Leo Kimb60005a2015-10-29 11:58:24 +09003514 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' : %d\n",
3515 hif_drv->hif_state);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003516
Leo Kim31390ee2015-10-19 18:26:08 +09003517 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3518 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003519 PRINT_ER("Failed to send message queue: Set join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09003520 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003521 }
3522
Leo Kim81a59502015-10-29 11:58:35 +09003523 hif_drv->connect_timer.data = (unsigned long)hif_drv;
3524 mod_timer(&hif_drv->connect_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003525 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003526
Leo Kim31390ee2015-10-19 18:26:08 +09003527 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003528}
3529
Tony Choa4ab1ad2015-10-12 16:56:05 +09003530s32 host_int_flush_join_req(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003531{
Leo Kim31390ee2015-10-19 18:26:08 +09003532 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003533 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003534
Leo Kim7717880782015-10-19 18:26:11 +09003535 if (!join_req)
3536 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003537
Tony Choa4ab1ad2015-10-12 16:56:05 +09003538 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003539 PRINT_ER("Driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003540 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003541 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003542
Tony Choa9f812a2015-09-21 12:16:33 +09003543 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003544 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003545
Leo Kim31390ee2015-10-19 18:26:08 +09003546 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3547 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003548 PRINT_ER("Failed to send message queue: Flush join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09003549 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003550 }
3551
Leo Kim31390ee2015-10-19 18:26:08 +09003552 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003553}
3554
Tony Choa4ab1ad2015-10-12 16:56:05 +09003555s32 host_int_disconnect(struct host_if_drv *hif_drv, u16 u16ReasonCode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003556{
Leo Kim31390ee2015-10-19 18:26:08 +09003557 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003558 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003559
Tony Choa4ab1ad2015-10-12 16:56:05 +09003560 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003561 PRINT_ER("Driver is null\n");
3562 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003563 }
3564
Tony Cho143eb952015-09-21 12:16:32 +09003565 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003566
Tony Choa9f812a2015-09-21 12:16:33 +09003567 msg.id = HOST_IF_MSG_DISCONNECT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003568 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003569
Leo Kim31390ee2015-10-19 18:26:08 +09003570 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3571 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003572 PRINT_ER("Failed to send message queue: disconnect\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09003573
Leo Kime55e4962015-10-29 11:58:29 +09003574 down(&hif_drv->sem_test_disconn_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003575
Leo Kim31390ee2015-10-19 18:26:08 +09003576 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003577}
3578
Tony Choa4ab1ad2015-10-12 16:56:05 +09003579s32 host_int_disconnect_station(struct host_if_drv *hif_drv, u8 assoc_id)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003580{
Leo Kim45102f82015-10-28 15:59:28 +09003581 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003582
Leo Kim45102f82015-10-28 15:59:28 +09003583 wid.id = (u16)WID_DISCONNECT;
3584 wid.type = WID_CHAR;
3585 wid.val = (s8 *)&assoc_id;
3586 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003587
Leo Kimb68d820b2015-10-12 16:55:37 +09003588 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003589}
3590
Leo Kim8c8360b2015-10-19 18:26:12 +09003591s32 host_int_get_assoc_req_info(struct host_if_drv *hif_drv,
3592 u8 *pu8AssocReqInfo,
3593 u32 u32AssocReqInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003594{
Leo Kim45102f82015-10-28 15:59:28 +09003595 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003596
Leo Kim45102f82015-10-28 15:59:28 +09003597 wid.id = (u16)WID_ASSOC_REQ_INFO;
3598 wid.type = WID_STR;
3599 wid.val = pu8AssocReqInfo;
3600 wid.size = u32AssocReqInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003601
Leo Kimb68d820b2015-10-12 16:55:37 +09003602 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003603}
3604
Leo Kim8c8360b2015-10-19 18:26:12 +09003605s32 host_int_get_assoc_res_info(struct host_if_drv *hif_drv,
3606 u8 *pu8AssocRespInfo,
3607 u32 u32MaxAssocRespInfoLen,
3608 u32 *pu32RcvdAssocRespInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003609{
Leo Kim31390ee2015-10-19 18:26:08 +09003610 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09003611 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003612
Tony Choa4ab1ad2015-10-12 16:56:05 +09003613 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003614 PRINT_ER("Driver is null\n");
3615 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003616 }
3617
Leo Kim45102f82015-10-28 15:59:28 +09003618 wid.id = (u16)WID_ASSOC_RES_INFO;
3619 wid.type = WID_STR;
3620 wid.val = pu8AssocRespInfo;
3621 wid.size = u32MaxAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003622
Leo Kim45102f82015-10-28 15:59:28 +09003623 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09003624 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09003625 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003626 *pu32RcvdAssocRespInfoLen = 0;
Leo Kim24db7132015-09-16 18:36:01 +09003627 PRINT_ER("Failed to send association response config packet\n");
3628 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003629 } else {
Leo Kim45102f82015-10-28 15:59:28 +09003630 *pu32RcvdAssocRespInfoLen = wid.size;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003631 }
3632
Leo Kim31390ee2015-10-19 18:26:08 +09003633 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003634}
3635
Leo Kim8c8360b2015-10-19 18:26:12 +09003636s32 host_int_get_rx_power_level(struct host_if_drv *hif_drv,
3637 u8 *pu8RxPowerLevel,
3638 u32 u32RxPowerLevelLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003639{
Leo Kim45102f82015-10-28 15:59:28 +09003640 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003641
Leo Kim45102f82015-10-28 15:59:28 +09003642 wid.id = (u16)WID_RX_POWER_LEVEL;
3643 wid.type = WID_STR;
3644 wid.val = pu8RxPowerLevel;
3645 wid.size = u32RxPowerLevelLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003646
Leo Kimb68d820b2015-10-12 16:55:37 +09003647 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003648}
3649
Tony Choa4ab1ad2015-10-12 16:56:05 +09003650int host_int_set_mac_chnl_num(struct host_if_drv *hif_drv, u8 channel)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003651{
Chaehyun Lim792fb252015-10-05 11:07:22 +09003652 int result;
Tony Cho143eb952015-09-21 12:16:32 +09003653 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003654
Tony Choa4ab1ad2015-10-12 16:56:05 +09003655 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003656 PRINT_ER("driver is null\n");
3657 return -EFAULT;
3658 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003659
Tony Cho143eb952015-09-21 12:16:32 +09003660 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003661 msg.id = HOST_IF_MSG_SET_CHANNEL;
Leo Kim730ee052015-10-13 19:50:02 +09003662 msg.body.channel_info.set_ch = channel;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003663 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003664
Leo Kimcb067dc2015-10-15 13:24:53 +09003665 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lim1ef58e42015-10-02 21:44:49 +09003666 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003667 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim792fb252015-10-05 11:07:22 +09003668 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003669 }
3670
Chaehyun Lim792fb252015-10-05 11:07:22 +09003671 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003672}
3673
Chaehyun Lim244efb12015-10-02 21:44:53 +09003674int host_int_wait_msg_queue_idle(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003675{
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003676 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003677 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003678
Tony Cho143eb952015-09-21 12:16:32 +09003679 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003680 msg.id = HOST_IF_MSG_Q_IDLE;
Leo Kimcb067dc2015-10-15 13:24:53 +09003681 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003682 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003683 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003684 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003685 }
3686
Leo Kim2d25af82015-10-15 13:24:56 +09003687 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003688
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003689 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003690}
3691
Tony Choa4ab1ad2015-10-12 16:56:05 +09003692int host_int_set_wfi_drv_handler(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003693{
Chaehyun Lima0941012015-10-05 19:34:47 +09003694 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003695 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003696
Tony Cho143eb952015-09-21 12:16:32 +09003697 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003698 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
Leo Kima7f3b122015-10-28 15:59:29 +09003699 msg.body.drv.handler = get_id_from_handler(hif_drv);
Tony Choa4ab1ad2015-10-12 16:56:05 +09003700 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003701
Leo Kimcb067dc2015-10-15 13:24:53 +09003702 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lima0941012015-10-05 19:34:47 +09003703 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003704 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0941012015-10-05 19:34:47 +09003705 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003706 }
3707
Chaehyun Lima0941012015-10-05 19:34:47 +09003708 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003709}
3710
Tony Choa4ab1ad2015-10-12 16:56:05 +09003711int host_int_set_operation_mode(struct host_if_drv *hif_drv, u32 mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003712{
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003713 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003714 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003715
Tony Cho143eb952015-09-21 12:16:32 +09003716 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003717 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
Leo Kimc96debf2015-10-28 15:59:30 +09003718 msg.body.mode.mode = mode;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003719 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003720
Leo Kimcb067dc2015-10-15 13:24:53 +09003721 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003722 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003723 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003724 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003725 }
3726
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003727 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003728}
3729
Tony Choa4ab1ad2015-10-12 16:56:05 +09003730s32 host_int_get_host_chnl_num(struct host_if_drv *hif_drv, u8 *pu8ChNo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003731{
Leo Kim31390ee2015-10-19 18:26:08 +09003732 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003733 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003734
Tony Choa4ab1ad2015-10-12 16:56:05 +09003735 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003736 PRINT_ER("driver is null\n");
3737 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003738 }
3739
Tony Cho143eb952015-09-21 12:16:32 +09003740 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003741
Tony Choa9f812a2015-09-21 12:16:33 +09003742 msg.id = HOST_IF_MSG_GET_CHNL;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003743 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003744
Leo Kim31390ee2015-10-19 18:26:08 +09003745 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3746 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09003747 PRINT_ER("wilc mq send fail\n");
Leo Kim4ea90002015-10-29 11:58:32 +09003748 down(&hif_drv->sem_get_chnl);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003749
Leo Kim95ebb0f2015-10-15 13:25:03 +09003750 *pu8ChNo = ch_no;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003751
Leo Kim31390ee2015-10-19 18:26:08 +09003752 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003753}
3754
Tony Choa4ab1ad2015-10-12 16:56:05 +09003755s32 host_int_get_inactive_time(struct host_if_drv *hif_drv,
3756 const u8 *mac, u32 *pu32InactiveTime)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003757{
Leo Kim31390ee2015-10-19 18:26:08 +09003758 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003759 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003760
Tony Choa4ab1ad2015-10-12 16:56:05 +09003761 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003762 PRINT_ER("driver is null\n");
3763 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003764 }
3765
Tony Cho143eb952015-09-21 12:16:32 +09003766 memset(&msg, 0, sizeof(struct host_if_msg));
Leo Kim8c8360b2015-10-19 18:26:12 +09003767 memcpy(msg.body.mac_info.mac, mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003768
Tony Choa9f812a2015-09-21 12:16:33 +09003769 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003770 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003771
Leo Kim31390ee2015-10-19 18:26:08 +09003772 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3773 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003774 PRINT_ER("Failed to send get host channel param's message queue ");
3775
Leo Kim569a3c62015-10-29 11:58:33 +09003776 down(&hif_drv->sem_inactive_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003777
Leo Kimad269062015-10-15 13:25:06 +09003778 *pu32InactiveTime = inactive_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003779
Leo Kim31390ee2015-10-19 18:26:08 +09003780 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003781}
Glen Lee108b3432015-09-16 18:53:20 +09003782
Tony Choa4ab1ad2015-10-12 16:56:05 +09003783s32 host_int_test_get_int_wid(struct host_if_drv *hif_drv, u32 *pu32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003784{
Leo Kim31390ee2015-10-19 18:26:08 +09003785 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09003786 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003787
Tony Choa4ab1ad2015-10-12 16:56:05 +09003788 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003789 PRINT_ER("driver is null\n");
3790 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003791 }
3792
Leo Kim45102f82015-10-28 15:59:28 +09003793 wid.id = (u16)WID_MEMORY_ADDRESS;
3794 wid.type = WID_INT;
3795 wid.val = (s8 *)pu32TestMemAddr;
3796 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003797
Leo Kim45102f82015-10-28 15:59:28 +09003798 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09003799 get_id_from_handler(hif_drv));
Leo Kimae4dfa52015-10-13 19:49:26 +09003800
Leo Kim31390ee2015-10-19 18:26:08 +09003801 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003802 PRINT_ER("Failed to get wid value\n");
3803 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003804 } else {
3805 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003806 }
3807
Leo Kim31390ee2015-10-19 18:26:08 +09003808 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003809}
3810
Tony Choa4ab1ad2015-10-12 16:56:05 +09003811s32 host_int_get_rssi(struct host_if_drv *hif_drv, s8 *ps8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003812{
Leo Kim31390ee2015-10-19 18:26:08 +09003813 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003814 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003815
Leo Kimc09389a2015-10-28 15:59:24 +09003816 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003817 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003818 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003819
Leo Kim31390ee2015-10-19 18:26:08 +09003820 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3821 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003822 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003823 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003824 }
3825
Leo Kim7e111f92015-10-29 11:58:30 +09003826 down(&hif_drv->sem_get_rssi);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003827
Leo Kim91109e12015-10-19 18:26:13 +09003828 if (!ps8Rssi) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003829 PRINT_ER("RSS pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09003830 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003831 }
3832
Leo Kim144b7b22015-10-15 13:25:01 +09003833 *ps8Rssi = rssi;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003834
Leo Kim31390ee2015-10-19 18:26:08 +09003835 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003836}
3837
Tony Choa4ab1ad2015-10-12 16:56:05 +09003838s32 host_int_get_link_speed(struct host_if_drv *hif_drv, s8 *ps8lnkspd)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003839{
Tony Cho143eb952015-09-21 12:16:32 +09003840 struct host_if_msg msg;
Leo Kim31390ee2015-10-19 18:26:08 +09003841 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003842
Leo Kimc09389a2015-10-28 15:59:24 +09003843 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003844 msg.id = HOST_IF_MSG_GET_LINKSPEED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003845 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003846
Leo Kim31390ee2015-10-19 18:26:08 +09003847 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3848 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003849 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003850 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003851 }
3852
Leo Kimbc34da62015-10-29 11:58:31 +09003853 down(&hif_drv->sem_get_link_speed);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003854
Leo Kim91109e12015-10-19 18:26:13 +09003855 if (!ps8lnkspd) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003856 PRINT_ER("LINKSPEED pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09003857 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003858 }
3859
Leo Kim75327a02015-10-15 13:25:02 +09003860 *ps8lnkspd = link_speed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003861
Leo Kim31390ee2015-10-19 18:26:08 +09003862 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003863}
3864
Tony Choa4ab1ad2015-10-12 16:56:05 +09003865s32 host_int_get_statistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003866{
Leo Kim31390ee2015-10-19 18:26:08 +09003867 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003868 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003869
Leo Kimc09389a2015-10-28 15:59:24 +09003870 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003871 msg.id = HOST_IF_MSG_GET_STATISTICS;
Tony Choe60831e2015-10-05 13:50:45 +09003872 msg.body.data = (char *)pstrStatistics;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003873 msg.drv = hif_drv;
Leo Kimae4dfa52015-10-13 19:49:26 +09003874
Leo Kim31390ee2015-10-19 18:26:08 +09003875 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3876 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003877 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003878 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003879 }
3880
Leo Kim2d25af82015-10-15 13:24:56 +09003881 down(&hif_sema_wait_response);
Leo Kim31390ee2015-10-19 18:26:08 +09003882 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003883}
3884
Tony Choa4ab1ad2015-10-12 16:56:05 +09003885s32 host_int_scan(struct host_if_drv *hif_drv, u8 u8ScanSource,
3886 u8 u8ScanType, u8 *pu8ChnlFreqList,
3887 u8 u8ChnlListLen, const u8 *pu8IEs,
3888 size_t IEsLen, wilc_scan_result ScanResult,
3889 void *pvUserArg, struct hidden_network *pstrHiddenNetwork)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003890{
Leo Kim31390ee2015-10-19 18:26:08 +09003891 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003892 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003893
Leo Kim91109e12015-10-19 18:26:13 +09003894 if (!hif_drv || !ScanResult) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09003895 PRINT_ER("hif_drv or ScanResult = NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003896 return -EFAULT;
3897 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003898
Tony Cho143eb952015-09-21 12:16:32 +09003899 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003900
Tony Choa9f812a2015-09-21 12:16:33 +09003901 msg.id = HOST_IF_MSG_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003902
Leo Kim91109e12015-10-19 18:26:13 +09003903 if (pstrHiddenNetwork) {
Leo Kim629b9ca2015-10-13 19:49:46 +09003904 msg.body.scan_info.hidden_network.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
3905 msg.body.scan_info.hidden_network.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003906
3907 } else
3908 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
3909
Tony Choa4ab1ad2015-10-12 16:56:05 +09003910 msg.drv = hif_drv;
Leo Kim42568892015-10-13 19:49:37 +09003911 msg.body.scan_info.src = u8ScanSource;
Leo Kim1e276c82015-10-13 19:49:38 +09003912 msg.body.scan_info.type = u8ScanType;
Leo Kimc17c6da2015-10-13 19:49:44 +09003913 msg.body.scan_info.result = ScanResult;
Leo Kim5f2b50c2015-10-13 19:49:45 +09003914 msg.body.scan_info.arg = pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003915
Leo Kimf97bd9c2015-10-13 19:49:41 +09003916 msg.body.scan_info.ch_list_len = u8ChnlListLen;
Leo Kim82eeb0a2015-10-13 19:49:40 +09003917 msg.body.scan_info.ch_freq_list = kmalloc(u8ChnlListLen, GFP_KERNEL);
3918 memcpy(msg.body.scan_info.ch_freq_list, pu8ChnlFreqList, u8ChnlListLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003919
Leo Kim7b1f76c2015-10-13 19:49:43 +09003920 msg.body.scan_info.ies_len = IEsLen;
Leo Kimd6f19aa2015-10-13 19:49:42 +09003921 msg.body.scan_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3922 memcpy(msg.body.scan_info.ies, pu8IEs, IEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003923
Leo Kim31390ee2015-10-19 18:26:08 +09003924 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3925 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003926 PRINT_ER("Error in sending message queue\n");
3927 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003928 }
3929
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003930 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
Leo Kim13b313e2015-10-29 11:58:34 +09003931 hif_drv->scan_timer.data = (unsigned long)hif_drv;
3932 mod_timer(&hif_drv->scan_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003933 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003934
Leo Kim31390ee2015-10-19 18:26:08 +09003935 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003936}
Leo Kimae4dfa52015-10-13 19:49:26 +09003937
Tony Choa4ab1ad2015-10-12 16:56:05 +09003938s32 hif_set_cfg(struct host_if_drv *hif_drv,
3939 struct cfg_param_val *pstrCfgParamVal)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003940{
Leo Kim31390ee2015-10-19 18:26:08 +09003941 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003942 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003943
Tony Choa4ab1ad2015-10-12 16:56:05 +09003944 if (!hif_drv) {
3945 PRINT_ER("hif_drv NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003946 return -EFAULT;
3947 }
Leo Kimae4dfa52015-10-13 19:49:26 +09003948
Tony Cho143eb952015-09-21 12:16:32 +09003949 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003950 msg.id = HOST_IF_MSG_CFG_PARAMS;
Tony Cho221371e2015-10-12 16:56:06 +09003951 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003952 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003953
Leo Kim31390ee2015-10-19 18:26:08 +09003954 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003955
Leo Kim31390ee2015-10-19 18:26:08 +09003956 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003957}
3958
Tony Choa4ab1ad2015-10-12 16:56:05 +09003959s32 hif_get_cfg(struct host_if_drv *hif_drv, u16 u16WID, u16 *pu16WID_Value)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003960{
Leo Kim31390ee2015-10-19 18:26:08 +09003961 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003962
Leo Kim33110ad2015-10-29 11:58:27 +09003963 down(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003964
Tony Choa4ab1ad2015-10-12 16:56:05 +09003965 if (!hif_drv) {
3966 PRINT_ER("hif_drv NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003967 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003968 }
3969 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
3970 switch (u16WID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003971 case WID_BSS_TYPE:
Leo Kimace303f2015-10-29 11:58:26 +09003972 *pu16WID_Value = (u16)hif_drv->cfg_values.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003973 break;
3974
3975 case WID_AUTH_TYPE:
Leo Kimace303f2015-10-29 11:58:26 +09003976 *pu16WID_Value = (u16)hif_drv->cfg_values.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003977 break;
3978
3979 case WID_AUTH_TIMEOUT:
Leo Kimace303f2015-10-29 11:58:26 +09003980 *pu16WID_Value = hif_drv->cfg_values.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003981 break;
3982
3983 case WID_POWER_MANAGEMENT:
Leo Kimace303f2015-10-29 11:58:26 +09003984 *pu16WID_Value = (u16)hif_drv->cfg_values.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003985 break;
3986
3987 case WID_SHORT_RETRY_LIMIT:
Leo Kimace303f2015-10-29 11:58:26 +09003988 *pu16WID_Value = hif_drv->cfg_values.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003989 break;
3990
3991 case WID_LONG_RETRY_LIMIT:
Leo Kimace303f2015-10-29 11:58:26 +09003992 *pu16WID_Value = hif_drv->cfg_values.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003993 break;
3994
3995 case WID_FRAG_THRESHOLD:
Leo Kimace303f2015-10-29 11:58:26 +09003996 *pu16WID_Value = hif_drv->cfg_values.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003997 break;
3998
3999 case WID_RTS_THRESHOLD:
Leo Kimace303f2015-10-29 11:58:26 +09004000 *pu16WID_Value = hif_drv->cfg_values.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004001 break;
4002
4003 case WID_PREAMBLE:
Leo Kimace303f2015-10-29 11:58:26 +09004004 *pu16WID_Value = (u16)hif_drv->cfg_values.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004005 break;
4006
4007 case WID_SHORT_SLOT_ALLOWED:
Leo Kimace303f2015-10-29 11:58:26 +09004008 *pu16WID_Value = (u16)hif_drv->cfg_values.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004009 break;
4010
4011 case WID_11N_TXOP_PROT_DISABLE:
Leo Kimace303f2015-10-29 11:58:26 +09004012 *pu16WID_Value = (u16)hif_drv->cfg_values.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004013 break;
4014
4015 case WID_BEACON_INTERVAL:
Leo Kimace303f2015-10-29 11:58:26 +09004016 *pu16WID_Value = hif_drv->cfg_values.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004017 break;
4018
4019 case WID_DTIM_PERIOD:
Leo Kimace303f2015-10-29 11:58:26 +09004020 *pu16WID_Value = (u16)hif_drv->cfg_values.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004021 break;
4022
4023 case WID_SITE_SURVEY:
Leo Kimace303f2015-10-29 11:58:26 +09004024 *pu16WID_Value = (u16)hif_drv->cfg_values.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004025 break;
4026
4027 case WID_SITE_SURVEY_SCAN_TIME:
Leo Kimace303f2015-10-29 11:58:26 +09004028 *pu16WID_Value = hif_drv->cfg_values.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004029 break;
4030
4031 case WID_ACTIVE_SCAN_TIME:
Leo Kimace303f2015-10-29 11:58:26 +09004032 *pu16WID_Value = hif_drv->cfg_values.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004033 break;
4034
4035 case WID_PASSIVE_SCAN_TIME:
Leo Kimace303f2015-10-29 11:58:26 +09004036 *pu16WID_Value = hif_drv->cfg_values.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004037 break;
4038
4039 case WID_CURRENT_TX_RATE:
Leo Kimace303f2015-10-29 11:58:26 +09004040 *pu16WID_Value = hif_drv->cfg_values.curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004041 break;
4042
4043 default:
4044 break;
4045 }
4046
Leo Kim33110ad2015-10-29 11:58:27 +09004047 up(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004048
Leo Kim31390ee2015-10-19 18:26:08 +09004049 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004050}
4051
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004052static void GetPeriodicRSSI(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004053{
Tony Choa4ab1ad2015-10-12 16:56:05 +09004054 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004055
Tony Choa4ab1ad2015-10-12 16:56:05 +09004056 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004057 PRINT_ER("Driver handler is NULL\n");
4058 return;
4059 }
4060
Leo Kimb60005a2015-10-29 11:58:24 +09004061 if (hif_drv->hif_state == HOST_IF_CONNECTED) {
Leo Kim31390ee2015-10-19 18:26:08 +09004062 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004063 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004064
Tony Cho143eb952015-09-21 12:16:32 +09004065 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004066
Tony Choa9f812a2015-09-21 12:16:33 +09004067 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004068 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004069
Leo Kim31390ee2015-10-19 18:26:08 +09004070 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4071 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004072 PRINT_ER("Failed to send get host channel param's message queue ");
4073 return;
4074 }
4075 }
Leo Kim262f55e2015-10-15 13:24:58 +09004076 periodic_rssi.data = (unsigned long)hif_drv;
4077 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004078}
4079
Glen Leed53822192015-10-27 18:27:49 +09004080s32 host_int_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004081{
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004082 s32 result = 0;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004083 struct host_if_drv *hif_drv;
Johnny Kimd42ab082015-08-20 16:32:52 +09004084 int err;
Glen Leed53822192015-10-27 18:27:49 +09004085 perInterface_wlan_t *nic;
4086 struct wilc *wilc;
4087
4088 nic = netdev_priv(dev);
4089 wilc = nic->wilc;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004090
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004091 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
4092
Leo Kimca8540e42015-10-15 13:25:00 +09004093 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004094
Leo Kim2d25af82015-10-15 13:24:56 +09004095 sema_init(&hif_sema_wait_response, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004096
Tony Choa4ab1ad2015-10-12 16:56:05 +09004097 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
4098 if (!hif_drv) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004099 result = -ENOMEM;
Vincent Stehlé17db84e2015-10-07 07:08:25 +02004100 goto _fail_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004101 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09004102 *hif_drv_handler = hif_drv;
4103 err = add_handler_in_list(hif_drv);
Johnny Kimd42ab082015-08-20 16:32:52 +09004104 if (err) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004105 result = -EFAULT;
Johnny Kimd42ab082015-08-20 16:32:52 +09004106 goto _fail_timer_2;
4107 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004108
Dean Lee72ed4dc2015-06-12 14:11:44 +09004109 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004110
Tony Choa4ab1ad2015-10-12 16:56:05 +09004111 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004112 if (clients_count == 0) {
Leo Kim834e0cb2015-10-15 13:24:54 +09004113 sema_init(&hif_sema_thread, 0);
Leo Kim27ff2162015-10-15 13:24:55 +09004114 sema_init(&hif_sema_driver, 0);
Leo Kim440e89932015-10-15 13:24:57 +09004115 sema_init(&hif_sema_deinit, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004116 }
4117
Leo Kim9ea47132015-10-29 11:58:28 +09004118 sema_init(&hif_drv->sem_test_key_block, 0);
Leo Kime55e4962015-10-29 11:58:29 +09004119 sema_init(&hif_drv->sem_test_disconn_block, 0);
Leo Kim7e111f92015-10-29 11:58:30 +09004120 sema_init(&hif_drv->sem_get_rssi, 0);
Leo Kimbc34da62015-10-29 11:58:31 +09004121 sema_init(&hif_drv->sem_get_link_speed, 0);
Leo Kim4ea90002015-10-29 11:58:32 +09004122 sema_init(&hif_drv->sem_get_chnl, 0);
Leo Kim569a3c62015-10-29 11:58:33 +09004123 sema_init(&hif_drv->sem_inactive_time, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004124
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004125 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
4126
4127 if (clients_count == 0) {
Leo Kimcb067dc2015-10-15 13:24:53 +09004128 result = wilc_mq_create(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004129
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004130 if (result < 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004131 PRINT_ER("Failed to creat MQ\n");
4132 goto _fail_;
4133 }
Leo Kimc2115d82015-10-15 13:24:52 +09004134
Glen Leed53822192015-10-27 18:27:49 +09004135 hif_thread_handler = kthread_run(hostIFthread, wilc,
4136 "WILC_kthread");
Leo Kimc2115d82015-10-15 13:24:52 +09004137
4138 if (IS_ERR(hif_thread_handler)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004139 PRINT_ER("Failed to creat Thread\n");
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004140 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004141 goto _fail_mq_;
4142 }
Leo Kim262f55e2015-10-15 13:24:58 +09004143 setup_timer(&periodic_rssi, GetPeriodicRSSI,
Tony Choa4ab1ad2015-10-12 16:56:05 +09004144 (unsigned long)hif_drv);
Leo Kim262f55e2015-10-15 13:24:58 +09004145 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004146 }
4147
Leo Kim13b313e2015-10-29 11:58:34 +09004148 setup_timer(&hif_drv->scan_timer, TimerCB_Scan, 0);
Leo Kim81a59502015-10-29 11:58:35 +09004149 setup_timer(&hif_drv->connect_timer, TimerCB_Connect, 0);
Leo Kimcc2d7e92015-10-29 11:58:36 +09004150 setup_timer(&hif_drv->remain_on_ch_timer, ListenTimerCB, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004151
Leo Kim33110ad2015-10-29 11:58:27 +09004152 sema_init(&hif_drv->sem_cfg_values, 1);
4153 down(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004154
Leo Kimb60005a2015-10-29 11:58:24 +09004155 hif_drv->hif_state = HOST_IF_IDLE;
Leo Kimace303f2015-10-29 11:58:26 +09004156 hif_drv->cfg_values.site_survey_enabled = SITE_SURVEY_OFF;
4157 hif_drv->cfg_values.scan_source = DEFAULT_SCAN;
4158 hif_drv->cfg_values.active_scan_time = ACTIVE_SCAN_TIME;
4159 hif_drv->cfg_values.passive_scan_time = PASSIVE_SCAN_TIME;
4160 hif_drv->cfg_values.curr_tx_rate = AUTORATE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004161
Leo Kim1229b1a2015-10-29 12:05:39 +09004162 hif_drv->p2p_timeout = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004163
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004164 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 +09004165 hif_drv->cfg_values.site_survey_enabled,
4166 hif_drv->cfg_values.scan_source,
4167 hif_drv->cfg_values.active_scan_time,
4168 hif_drv->cfg_values.passive_scan_time,
4169 hif_drv->cfg_values.curr_tx_rate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004170
Leo Kim33110ad2015-10-29 11:58:27 +09004171 up(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004172
Leo Kimae4dfa52015-10-13 19:49:26 +09004173 clients_count++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004174
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004175 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004176
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004177_fail_timer_2:
Leo Kim33110ad2015-10-29 11:58:27 +09004178 up(&hif_drv->sem_cfg_values);
Leo Kim81a59502015-10-29 11:58:35 +09004179 del_timer_sync(&hif_drv->connect_timer);
Leo Kim13b313e2015-10-29 11:58:34 +09004180 del_timer_sync(&hif_drv->scan_timer);
Leo Kimc2115d82015-10-15 13:24:52 +09004181 kthread_stop(hif_thread_handler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004182_fail_mq_:
Leo Kimcb067dc2015-10-15 13:24:53 +09004183 wilc_mq_destroy(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004184_fail_:
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004185 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004186}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004187
Tony Choa4ab1ad2015-10-12 16:56:05 +09004188s32 host_int_deinit(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004189{
Leo Kim31390ee2015-10-19 18:26:08 +09004190 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004191 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004192 int ret;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004193
Tony Choa4ab1ad2015-10-12 16:56:05 +09004194 if (!hif_drv) {
4195 PRINT_ER("hif_drv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004196 return 0;
4197 }
4198
Leo Kim440e89932015-10-15 13:24:57 +09004199 down(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004200
Tony Choa4ab1ad2015-10-12 16:56:05 +09004201 terminated_handle = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004202 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
4203
Leo Kim13b313e2015-10-29 11:58:34 +09004204 if (del_timer_sync(&hif_drv->scan_timer))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004205 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004206
Leo Kim81a59502015-10-29 11:58:35 +09004207 if (del_timer_sync(&hif_drv->connect_timer))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004208 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004209
Leo Kim262f55e2015-10-15 13:24:58 +09004210 if (del_timer_sync(&periodic_rssi))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004211 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004212
Leo Kimcc2d7e92015-10-29 11:58:36 +09004213 del_timer_sync(&hif_drv->remain_on_ch_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004214
Johnny Kim218dc402015-08-13 13:41:19 +09004215 host_int_set_wfi_drv_handler(NULL);
Leo Kim27ff2162015-10-15 13:24:55 +09004216 down(&hif_sema_driver);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004217
Leo Kimbc801852015-10-29 11:58:50 +09004218 if (hif_drv->usr_scan_req.scan_result) {
4219 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL,
Leo Kim66eaea32015-10-29 11:58:51 +09004220 hif_drv->usr_scan_req.arg, NULL);
Leo Kimbc801852015-10-29 11:58:50 +09004221 hif_drv->usr_scan_req.scan_result = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004222 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004223
Leo Kimb60005a2015-10-29 11:58:24 +09004224 hif_drv->hif_state = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004225
Leo Kimca8540e42015-10-15 13:25:00 +09004226 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004227
Tony Cho143eb952015-09-21 12:16:32 +09004228 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004229
4230 if (clients_count == 1) {
Leo Kim262f55e2015-10-15 13:24:58 +09004231 if (del_timer_sync(&periodic_rssi))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004232 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Leo Kim262f55e2015-10-15 13:24:58 +09004233
Tony Choa9f812a2015-09-21 12:16:33 +09004234 msg.id = HOST_IF_MSG_EXIT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004235 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004236
Leo Kim31390ee2015-10-19 18:26:08 +09004237 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4238 if (result != 0)
4239 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004240
Leo Kim834e0cb2015-10-15 13:24:54 +09004241 down(&hif_sema_thread);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004242
Leo Kimcb067dc2015-10-15 13:24:53 +09004243 wilc_mq_destroy(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004244 }
4245
Leo Kim33110ad2015-10-29 11:58:27 +09004246 down(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004247
Tony Choa4ab1ad2015-10-12 16:56:05 +09004248 ret = remove_handler_in_list(hif_drv);
Johnny Kimd42ab082015-08-20 16:32:52 +09004249 if (ret)
Leo Kim31390ee2015-10-19 18:26:08 +09004250 result = -ENOENT;
Johnny Kimd42ab082015-08-20 16:32:52 +09004251
Tony Choa4ab1ad2015-10-12 16:56:05 +09004252 kfree(hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004253
Leo Kimae4dfa52015-10-13 19:49:26 +09004254 clients_count--;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09004255 terminated_handle = NULL;
Leo Kim440e89932015-10-15 13:24:57 +09004256 up(&hif_sema_deinit);
Leo Kim31390ee2015-10-19 18:26:08 +09004257 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004258}
4259
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004260void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004261{
Leo Kim31390ee2015-10-19 18:26:08 +09004262 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004263 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004264 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004265 struct host_if_drv *hif_drv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004266
Johnny Kimd42ab082015-08-20 16:32:52 +09004267 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09004268 hif_drv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004269
Tony Choa4ab1ad2015-10-12 16:56:05 +09004270 if (!hif_drv || hif_drv == terminated_handle) {
4271 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004272 return;
4273 }
4274
Tony Cho143eb952015-09-21 12:16:32 +09004275 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004276
Tony Choa9f812a2015-09-21 12:16:33 +09004277 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004278 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004279
Leo Kim3bffac62015-10-13 20:02:11 +09004280 msg.body.net_info.len = u32Length;
Leo Kimb021b802015-10-13 20:02:10 +09004281 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4282 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004283
Leo Kim31390ee2015-10-19 18:26:08 +09004284 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4285 if (result)
4286 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004287}
4288
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004289void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004290{
Leo Kim31390ee2015-10-19 18:26:08 +09004291 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004292 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004293 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004294 struct host_if_drv *hif_drv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004295
Leo Kim440e89932015-10-15 13:24:57 +09004296 down(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004297
Johnny Kimd42ab082015-08-20 16:32:52 +09004298 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09004299 hif_drv = get_handler_from_id(id);
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004300 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004301
Tony Choa4ab1ad2015-10-12 16:56:05 +09004302 if (!hif_drv || hif_drv == terminated_handle) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004303 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
Leo Kim440e89932015-10-15 13:24:57 +09004304 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004305 return;
4306 }
4307
Leo Kim33bfb192015-10-29 11:58:56 +09004308 if (!hif_drv->usr_conn_req.conn_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004309 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
Leo Kim440e89932015-10-15 13:24:57 +09004310 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004311 return;
4312 }
4313
Tony Cho143eb952015-09-21 12:16:32 +09004314 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004315
Tony Choa9f812a2015-09-21 12:16:33 +09004316 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004317 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004318
Leo Kimf94f4882015-10-13 19:50:01 +09004319 msg.body.async_info.len = u32Length;
Leo Kim33722ac72015-10-13 19:50:00 +09004320 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4321 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004322
Leo Kim31390ee2015-10-19 18:26:08 +09004323 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4324 if (result)
4325 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004326
Leo Kim440e89932015-10-15 13:24:57 +09004327 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004328}
4329
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004330void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004331{
Leo Kim31390ee2015-10-19 18:26:08 +09004332 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004333 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004334 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004335 struct host_if_drv *hif_drv = NULL;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004336
Johnny Kimd42ab082015-08-20 16:32:52 +09004337 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09004338 hif_drv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004339
Tony Choa4ab1ad2015-10-12 16:56:05 +09004340 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004341
Tony Choa4ab1ad2015-10-12 16:56:05 +09004342 if (!hif_drv || hif_drv == terminated_handle)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004343 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004344
Leo Kimbc801852015-10-29 11:58:50 +09004345 if (hif_drv->usr_scan_req.scan_result) {
Tony Cho143eb952015-09-21 12:16:32 +09004346 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004347
Tony Choa9f812a2015-09-21 12:16:33 +09004348 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004349 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004350
Leo Kim31390ee2015-10-19 18:26:08 +09004351 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4352 if (result)
4353 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004354 }
4355
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004356 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004357}
4358
Tony Choa4ab1ad2015-10-12 16:56:05 +09004359s32 host_int_remain_on_channel(struct host_if_drv *hif_drv, u32 u32SessionID,
4360 u32 u32duration, u16 chan,
4361 wilc_remain_on_chan_expired RemainOnChanExpired,
4362 wilc_remain_on_chan_ready RemainOnChanReady,
4363 void *pvUserArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004364{
Leo Kim31390ee2015-10-19 18:26:08 +09004365 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004366 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004367
Tony Choa4ab1ad2015-10-12 16:56:05 +09004368 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004369 PRINT_ER("driver is null\n");
4370 return -EFAULT;
4371 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004372
Tony Cho143eb952015-09-21 12:16:32 +09004373 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004374
Tony Choa9f812a2015-09-21 12:16:33 +09004375 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
Leo Kim839ab702015-10-29 11:58:41 +09004376 msg.body.remain_on_ch.ch = chan;
Leo Kimbfb62ab2015-10-29 11:58:42 +09004377 msg.body.remain_on_ch.expired = RemainOnChanExpired;
Leo Kim5e5f7912015-10-29 11:58:43 +09004378 msg.body.remain_on_ch.ready = RemainOnChanReady;
Leo Kimc5cc4b12015-10-29 11:58:44 +09004379 msg.body.remain_on_ch.arg = pvUserArg;
Tony Cho070d3652015-09-30 18:55:10 +09004380 msg.body.remain_on_ch.u32duration = u32duration;
Leo Kim9d764e32015-10-29 12:05:38 +09004381 msg.body.remain_on_ch.id = u32SessionID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004382 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004383
Leo Kim31390ee2015-10-19 18:26:08 +09004384 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4385 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004386 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004387
Leo Kim31390ee2015-10-19 18:26:08 +09004388 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004389}
4390
Tony Choa4ab1ad2015-10-12 16:56:05 +09004391s32 host_int_ListenStateExpired(struct host_if_drv *hif_drv, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004392{
Leo Kim31390ee2015-10-19 18:26:08 +09004393 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004394 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004395
Tony Choa4ab1ad2015-10-12 16:56:05 +09004396 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004397 PRINT_ER("driver is null\n");
4398 return -EFAULT;
4399 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004400
Leo Kimcc2d7e92015-10-29 11:58:36 +09004401 del_timer(&hif_drv->remain_on_ch_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004402
Tony Cho143eb952015-09-21 12:16:32 +09004403 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09004404 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004405 msg.drv = hif_drv;
Leo Kim9d764e32015-10-29 12:05:38 +09004406 msg.body.remain_on_ch.id = u32SessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004407
Leo Kim31390ee2015-10-19 18:26:08 +09004408 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4409 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004410 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004411
Leo Kim31390ee2015-10-19 18:26:08 +09004412 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004413}
4414
Tony Choa4ab1ad2015-10-12 16:56:05 +09004415s32 host_int_frame_register(struct host_if_drv *hif_drv, u16 u16FrameType, bool bReg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004416{
Leo Kim31390ee2015-10-19 18:26:08 +09004417 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004418 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004419
Tony Choa4ab1ad2015-10-12 16:56:05 +09004420 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004421 PRINT_ER("driver is null\n");
4422 return -EFAULT;
4423 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004424
Tony Cho143eb952015-09-21 12:16:32 +09004425 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004426
Tony Choa9f812a2015-09-21 12:16:33 +09004427 msg.id = HOST_IF_MSG_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004428 switch (u16FrameType) {
4429 case ACTION:
4430 PRINT_D(HOSTINF_DBG, "ACTION\n");
Leo Kimbcb410b2015-10-29 11:58:40 +09004431 msg.body.reg_frame.reg_id = ACTION_FRM_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004432 break;
4433
4434 case PROBE_REQ:
4435 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
Leo Kimbcb410b2015-10-29 11:58:40 +09004436 msg.body.reg_frame.reg_id = PROBE_REQ_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004437 break;
4438
4439 default:
4440 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
4441 break;
4442 }
Leo Kimd5f654c2015-10-29 11:58:39 +09004443 msg.body.reg_frame.frame_type = u16FrameType;
Leo Kim6abf8682015-10-29 11:58:38 +09004444 msg.body.reg_frame.reg = bReg;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004445 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004446
Leo Kim31390ee2015-10-19 18:26:08 +09004447 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4448 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004449 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004450
Leo Kim31390ee2015-10-19 18:26:08 +09004451 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004452}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004453
Tony Choa4ab1ad2015-10-12 16:56:05 +09004454s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
4455 u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head,
4456 u32 u32TailLen, u8 *pu8Tail)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004457{
Leo Kim31390ee2015-10-19 18:26:08 +09004458 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004459 struct host_if_msg msg;
Tony Choa98491e2015-09-30 18:44:31 +09004460 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004461
Tony Choa4ab1ad2015-10-12 16:56:05 +09004462 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004463 PRINT_ER("driver is null\n");
4464 return -EFAULT;
4465 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004466
Tony Cho143eb952015-09-21 12:16:32 +09004467 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004468
4469 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
4470
Tony Choa9f812a2015-09-21 12:16:33 +09004471 msg.id = HOST_IF_MSG_ADD_BEACON;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004472 msg.drv = hif_drv;
Leo Kim12262dd2015-10-13 19:50:03 +09004473 pstrSetBeaconParam->interval = u32Interval;
Leo Kime76ab772015-10-13 19:50:04 +09004474 pstrSetBeaconParam->dtim_period = u32DTIMPeriod;
Leo Kim51c66182015-10-13 19:50:05 +09004475 pstrSetBeaconParam->head_len = u32HeadLen;
Shraddha Barke543f5b12015-10-16 10:47:11 +05304476 pstrSetBeaconParam->head = kmemdup(pu8Head, u32HeadLen, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09004477 if (!pstrSetBeaconParam->head) {
Leo Kim31390ee2015-10-19 18:26:08 +09004478 result = -ENOMEM;
Leo Kim24db7132015-09-16 18:36:01 +09004479 goto ERRORHANDLER;
4480 }
Leo Kim030c57e2015-10-13 19:50:07 +09004481 pstrSetBeaconParam->tail_len = u32TailLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004482
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004483 if (u32TailLen > 0) {
Shraddha Barke543f5b12015-10-16 10:47:11 +05304484 pstrSetBeaconParam->tail = kmemdup(pu8Tail, u32TailLen,
4485 GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09004486 if (!pstrSetBeaconParam->tail) {
Leo Kim31390ee2015-10-19 18:26:08 +09004487 result = -ENOMEM;
Leo Kim24db7132015-09-16 18:36:01 +09004488 goto ERRORHANDLER;
4489 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004490 } else {
Leo Kim7dbcb6d32015-10-13 19:50:08 +09004491 pstrSetBeaconParam->tail = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004492 }
4493
Leo Kim31390ee2015-10-19 18:26:08 +09004494 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4495 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004496 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004497
Leo Kim24db7132015-09-16 18:36:01 +09004498ERRORHANDLER:
Leo Kim31390ee2015-10-19 18:26:08 +09004499 if (result) {
Shraddha Barke95f840f2015-10-14 07:29:19 +05304500 kfree(pstrSetBeaconParam->head);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004501
Shraddha Barke95f840f2015-10-14 07:29:19 +05304502 kfree(pstrSetBeaconParam->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004503 }
4504
Leo Kim31390ee2015-10-19 18:26:08 +09004505 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004506}
4507
Tony Choa4ab1ad2015-10-12 16:56:05 +09004508s32 host_int_del_beacon(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004509{
Leo Kim31390ee2015-10-19 18:26:08 +09004510 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004511 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004512
Tony Choa4ab1ad2015-10-12 16:56:05 +09004513 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004514 PRINT_ER("driver is null\n");
4515 return -EFAULT;
4516 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004517
Tony Choa9f812a2015-09-21 12:16:33 +09004518 msg.id = HOST_IF_MSG_DEL_BEACON;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004519 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004520 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
4521
Leo Kim31390ee2015-10-19 18:26:08 +09004522 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4523 if (result)
Leo Kim7dc1d0c2015-09-16 18:36:00 +09004524 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004525
Leo Kim31390ee2015-10-19 18:26:08 +09004526 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004527}
4528
Tony Choa4ab1ad2015-10-12 16:56:05 +09004529s32 host_int_add_station(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09004530 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004531{
Leo Kim31390ee2015-10-19 18:26:08 +09004532 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004533 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09004534 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004535
Tony Choa4ab1ad2015-10-12 16:56:05 +09004536 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004537 PRINT_ER("driver is null\n");
4538 return -EFAULT;
4539 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004540
Tony Cho143eb952015-09-21 12:16:32 +09004541 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004542
4543 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
4544
Tony Choa9f812a2015-09-21 12:16:33 +09004545 msg.id = HOST_IF_MSG_ADD_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004546 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004547
Tony Cho6a89ba92015-09-21 12:16:46 +09004548 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Leo Kime7342232015-10-29 12:05:43 +09004549 if (pstrAddStationMsg->rates_len > 0) {
4550 u8 *rates = kmalloc(pstrAddStationMsg->rates_len, GFP_KERNEL);
Leo Kimc09389a2015-10-28 15:59:24 +09004551
Leo Kim7ae43362015-09-16 18:35:59 +09004552 if (!rates)
4553 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004554
Leo Kima622e012015-10-29 12:05:44 +09004555 memcpy(rates, pstrStaParams->rates,
Leo Kime7342232015-10-29 12:05:43 +09004556 pstrAddStationMsg->rates_len);
Leo Kima622e012015-10-29 12:05:44 +09004557 pstrAddStationMsg->rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004558 }
4559
Leo Kim31390ee2015-10-19 18:26:08 +09004560 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4561 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004562 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004563 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004564}
4565
Tony Choa4ab1ad2015-10-12 16:56:05 +09004566s32 host_int_del_station(struct host_if_drv *hif_drv, const u8 *pu8MacAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004567{
Leo Kim31390ee2015-10-19 18:26:08 +09004568 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004569 struct host_if_msg msg;
Tony Cho889c25b2015-09-30 18:44:33 +09004570 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004571
Tony Choa4ab1ad2015-10-12 16:56:05 +09004572 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004573 PRINT_ER("driver is null\n");
4574 return -EFAULT;
4575 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004576
Tony Cho143eb952015-09-21 12:16:32 +09004577 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004578
4579 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
4580
Tony Choa9f812a2015-09-21 12:16:33 +09004581 msg.id = HOST_IF_MSG_DEL_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004582 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004583
Leo Kim91109e12015-10-19 18:26:13 +09004584 if (!pu8MacAddr)
Punit Vara0bc85242015-10-29 01:53:30 +05304585 eth_broadcast_addr(pstrDelStationMsg->mac_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004586 else
Leo Kime4839d32015-10-13 20:02:06 +09004587 memcpy(pstrDelStationMsg->mac_addr, pu8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004588
Leo Kim31390ee2015-10-19 18:26:08 +09004589 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4590 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004591 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004592 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004593}
Leo Kimae4dfa52015-10-13 19:49:26 +09004594
Tony Choa4ab1ad2015-10-12 16:56:05 +09004595s32 host_int_del_allstation(struct host_if_drv *hif_drv,
Leo Kim441dc602015-10-12 16:55:35 +09004596 u8 pu8MacAddr[][ETH_ALEN])
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004597{
Leo Kim31390ee2015-10-19 18:26:08 +09004598 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004599 struct host_if_msg msg;
Tony Chob0c1e802015-10-05 13:50:46 +09004600 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004601 u8 au8Zero_Buff[ETH_ALEN] = {0};
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004602 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004603 u8 u8AssocNumb = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004604
Tony Choa4ab1ad2015-10-12 16:56:05 +09004605 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004606 PRINT_ER("driver is null\n");
4607 return -EFAULT;
4608 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004609
Tony Cho143eb952015-09-21 12:16:32 +09004610 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004611
4612 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
4613
Tony Choa9f812a2015-09-21 12:16:33 +09004614 msg.id = HOST_IF_MSG_DEL_ALL_STA;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004615 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004616
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004617 for (i = 0; i < MAX_NUM_STA; i++) {
4618 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
Leo Kime51b9212015-10-13 19:50:09 +09004619 memcpy(pstrDelAllStationMsg->del_all_sta[i], pu8MacAddr[i], ETH_ALEN);
4620 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
4621 pstrDelAllStationMsg->del_all_sta[i][0],
4622 pstrDelAllStationMsg->del_all_sta[i][1],
4623 pstrDelAllStationMsg->del_all_sta[i][2],
4624 pstrDelAllStationMsg->del_all_sta[i][3],
4625 pstrDelAllStationMsg->del_all_sta[i][4],
4626 pstrDelAllStationMsg->del_all_sta[i][5]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004627 u8AssocNumb++;
4628 }
4629 }
4630 if (!u8AssocNumb) {
4631 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004632 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004633 }
4634
Leo Kim8ba18032015-10-13 19:50:10 +09004635 pstrDelAllStationMsg->assoc_sta = u8AssocNumb;
Leo Kim31390ee2015-10-19 18:26:08 +09004636 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004637
Leo Kim31390ee2015-10-19 18:26:08 +09004638 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004639 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004640
Leo Kim2d25af82015-10-15 13:24:56 +09004641 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004642
Leo Kim31390ee2015-10-19 18:26:08 +09004643 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004644}
4645
Tony Choa4ab1ad2015-10-12 16:56:05 +09004646s32 host_int_edit_station(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09004647 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004648{
Leo Kim31390ee2015-10-19 18:26:08 +09004649 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004650 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09004651 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004652
Tony Choa4ab1ad2015-10-12 16:56:05 +09004653 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004654 PRINT_ER("driver is null\n");
4655 return -EFAULT;
4656 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004657
4658 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
4659
Tony Cho143eb952015-09-21 12:16:32 +09004660 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004661
Tony Choa9f812a2015-09-21 12:16:33 +09004662 msg.id = HOST_IF_MSG_EDIT_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004663 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004664
Tony Cho6a89ba92015-09-21 12:16:46 +09004665 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Leo Kime7342232015-10-29 12:05:43 +09004666 if (pstrAddStationMsg->rates_len > 0) {
4667 u8 *rates = kmalloc(pstrAddStationMsg->rates_len, GFP_KERNEL);
Leo Kimc09389a2015-10-28 15:59:24 +09004668
Leo Kim7ae43362015-09-16 18:35:59 +09004669 if (!rates)
4670 return -ENOMEM;
4671
Leo Kima622e012015-10-29 12:05:44 +09004672 memcpy(rates, pstrStaParams->rates,
Leo Kime7342232015-10-29 12:05:43 +09004673 pstrAddStationMsg->rates_len);
Leo Kima622e012015-10-29 12:05:44 +09004674 pstrAddStationMsg->rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004675 }
4676
Leo Kim31390ee2015-10-19 18:26:08 +09004677 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4678 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004679 PRINT_ER("wilc_mq_send fail\n");
4680
Leo Kim31390ee2015-10-19 18:26:08 +09004681 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004682}
Glen Lee108b3432015-09-16 18:53:20 +09004683
Tony Choa4ab1ad2015-10-12 16:56:05 +09004684s32 host_int_set_power_mgmt(struct host_if_drv *hif_drv,
4685 bool bIsEnabled,
4686 u32 u32Timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004687{
Leo Kim31390ee2015-10-19 18:26:08 +09004688 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004689 struct host_if_msg msg;
Tony Cho49e1f812015-09-30 18:44:36 +09004690 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004691
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004692 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004693
Tony Choa4ab1ad2015-10-12 16:56:05 +09004694 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004695 PRINT_ER("driver is null\n");
4696 return -EFAULT;
4697 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004698
4699 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
4700
Tony Cho143eb952015-09-21 12:16:32 +09004701 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004702
Tony Choa9f812a2015-09-21 12:16:33 +09004703 msg.id = HOST_IF_MSG_POWER_MGMT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004704 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004705
Leo Kim33c70c12015-10-13 20:02:07 +09004706 pstrPowerMgmtParam->enabled = bIsEnabled;
Leo Kim937918f2015-10-13 20:02:08 +09004707 pstrPowerMgmtParam->timeout = u32Timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004708
Leo Kim31390ee2015-10-19 18:26:08 +09004709 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4710 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004711 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004712 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004713}
4714
Tony Choa4ab1ad2015-10-12 16:56:05 +09004715s32 host_int_setup_multicast_filter(struct host_if_drv *hif_drv,
4716 bool bIsEnabled,
4717 u32 u32count)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004718{
Leo Kim31390ee2015-10-19 18:26:08 +09004719 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004720 struct host_if_msg msg;
Tony Choa079cf4d2015-09-30 18:55:05 +09004721 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004722
Tony Choa4ab1ad2015-10-12 16:56:05 +09004723 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004724 PRINT_ER("driver is null\n");
4725 return -EFAULT;
4726 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004727
4728 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
4729
Tony Cho143eb952015-09-21 12:16:32 +09004730 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004731
Tony Choa9f812a2015-09-21 12:16:33 +09004732 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004733 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004734
Leo Kimbae636eb2015-10-13 20:02:04 +09004735 pstrMulticastFilterParam->enabled = bIsEnabled;
Leo Kimadab2f72015-10-13 20:02:05 +09004736 pstrMulticastFilterParam->cnt = u32count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004737
Leo Kim31390ee2015-10-19 18:26:08 +09004738 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4739 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004740 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004741 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004742}
4743
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004744static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
4745{
Leo Kime0a12212015-10-12 16:55:49 +09004746 struct join_bss_param *pNewJoinBssParam = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004747 u8 *pu8IEs;
Chaehyun Limd85f5322015-06-11 14:35:54 +09004748 u16 u16IEsLen;
4749 u16 index = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004750 u8 suppRatesNo = 0;
4751 u8 extSuppRatesNo;
Chaehyun Limd85f5322015-06-11 14:35:54 +09004752 u16 jumpOffset;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004753 u8 pcipherCount;
4754 u8 authCount;
4755 u8 pcipherTotalCount = 0;
4756 u8 authTotalCount = 0;
4757 u8 i, j;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004758
4759 pu8IEs = ptstrNetworkInfo->pu8IEs;
4760 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4761
Shraddha Barkeb156f1e2015-10-13 23:07:00 +05304762 pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09004763 if (pNewJoinBssParam) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004764 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4765 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
4766 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004767 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004768 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
Leo Kim619d27b2015-10-15 13:24:42 +09004769 pNewJoinBssParam->ssid_len = ptstrNetworkInfo->u8SsidLen;
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004770 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4771 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004772
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004773 while (index < u16IEsLen) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004774 if (pu8IEs[index] == SUPP_RATES_IE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004775 suppRatesNo = pu8IEs[index + 1];
4776 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
Leo Kimae4dfa52015-10-13 19:49:26 +09004777 index += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004778
Leo Kimd1666e22015-10-28 15:59:22 +09004779 for (i = 0; i < suppRatesNo; i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004780 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
Leo Kimd1666e22015-10-28 15:59:22 +09004781
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004782 index += suppRatesNo;
4783 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004784 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004785 extSuppRatesNo = pu8IEs[index + 1];
4786 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4787 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4788 else
4789 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4790 index += 2;
Leo Kimd1666e22015-10-28 15:59:22 +09004791 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004792 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
Leo Kimd1666e22015-10-28 15:59:22 +09004793
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004794 index += extSuppRatesNo;
4795 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004796 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004797 pNewJoinBssParam->ht_capable = true;
Leo Kimae4dfa52015-10-13 19:49:26 +09004798 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004799 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004800 } else if ((pu8IEs[index] == WMM_IE) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004801 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
Leo Kimae4dfa52015-10-13 19:49:26 +09004802 (pu8IEs[index + 4] == 0xF2) &&
4803 (pu8IEs[index + 5] == 0x02) &&
4804 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004805 (pu8IEs[index + 7] == 0x01)) {
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004806 pNewJoinBssParam->wmm_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004807
Anish Bhattffda2032015-09-29 12:15:49 -07004808 if (pu8IEs[index + 8] & BIT(7))
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004809 pNewJoinBssParam->uapsd_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004810 index += pu8IEs[index + 1] + 2;
4811 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004812 } else if ((pu8IEs[index] == P2P_IE) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004813 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
Leo Kimae4dfa52015-10-13 19:49:26 +09004814 (pu8IEs[index + 4] == 0x9a) &&
4815 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09004816 u16 u16P2P_count;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004817
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004818 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
Leo Kim7a8d51d2015-10-15 13:24:43 +09004819 pNewJoinBssParam->noa_enabled = 1;
Leo Kimcc179002015-10-15 13:24:47 +09004820 pNewJoinBssParam->idx = pu8IEs[index + 9];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004821
Anish Bhattffda2032015-09-29 12:15:49 -07004822 if (pu8IEs[index + 10] & BIT(7)) {
Leo Kimd72b33c2015-10-15 13:24:44 +09004823 pNewJoinBssParam->opp_enabled = 1;
Leo Kim99b66942015-10-15 13:24:45 +09004824 pNewJoinBssParam->ct_window = pu8IEs[index + 10];
Leo Kimd72b33c2015-10-15 13:24:44 +09004825 } else {
4826 pNewJoinBssParam->opp_enabled = 0;
4827 }
Leo Kimae4dfa52015-10-13 19:49:26 +09004828
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004829 PRINT_D(GENERIC_DBG, "P2P Dump\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004830 for (i = 0; i < pu8IEs[index + 7]; i++)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004831 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004832
Leo Kimc21047e2015-10-15 13:24:46 +09004833 pNewJoinBssParam->cnt = pu8IEs[index + 11];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004834 u16P2P_count = index + 12;
4835
Leo Kim109e6ca2015-10-15 13:24:48 +09004836 memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004837 u16P2P_count += 4;
4838
Leo Kim1d8b76b2015-10-15 13:24:49 +09004839 memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004840 u16P2P_count += 4;
4841
Leo Kim4be55e22015-10-28 15:59:27 +09004842 memcpy(pNewJoinBssParam->start_time, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004843
4844 index += pu8IEs[index + 1] + 2;
4845 continue;
4846
Leo Kimae4dfa52015-10-13 19:49:26 +09004847 } else if ((pu8IEs[index] == RSN_IE) ||
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004848 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
4849 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
4850 (pu8IEs[index + 5] == 0x01))) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09004851 u16 rsnIndex = index;
Leo Kimae4dfa52015-10-13 19:49:26 +09004852
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004853 if (pu8IEs[rsnIndex] == RSN_IE) {
4854 pNewJoinBssParam->mode_802_11i = 2;
Leo Kimae4dfa52015-10-13 19:49:26 +09004855 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004856 if (pNewJoinBssParam->mode_802_11i == 0)
4857 pNewJoinBssParam->mode_802_11i = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004858 rsnIndex += 4;
4859 }
Leo Kimae4dfa52015-10-13 19:49:26 +09004860
4861 rsnIndex += 7;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004862 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
4863 rsnIndex++;
Leo Kimae4dfa52015-10-13 19:49:26 +09004864 jumpOffset = pu8IEs[rsnIndex] * 4;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004865 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
Leo Kimae4dfa52015-10-13 19:49:26 +09004866 rsnIndex += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004867
Leo Kimd1666e22015-10-28 15:59:22 +09004868 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004869 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
Leo Kimd1666e22015-10-28 15:59:22 +09004870
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004871 pcipherTotalCount += pcipherCount;
4872 rsnIndex += jumpOffset;
4873
4874 jumpOffset = pu8IEs[rsnIndex] * 4;
4875
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004876 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
Leo Kimae4dfa52015-10-13 19:49:26 +09004877 rsnIndex += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004878
Leo Kimd1666e22015-10-28 15:59:22 +09004879 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004880 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
Leo Kimd1666e22015-10-28 15:59:22 +09004881
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004882 authTotalCount += authCount;
4883 rsnIndex += jumpOffset;
Leo Kimae4dfa52015-10-13 19:49:26 +09004884
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004885 if (pu8IEs[index] == RSN_IE) {
4886 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
4887 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
4888 rsnIndex += 2;
4889 }
Abdul Hussainf717c0eb2015-06-16 09:49:49 +00004890 pNewJoinBssParam->rsn_found = true;
Leo Kimae4dfa52015-10-13 19:49:26 +09004891 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004892 continue;
4893 } else
Leo Kimae4dfa52015-10-13 19:49:26 +09004894 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004895 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004896 }
4897
4898 return (void *)pNewJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004899}
4900
4901void host_int_freeJoinParams(void *pJoinParams)
4902{
Leo Kim91109e12015-10-19 18:26:13 +09004903 if ((struct bss_param *)pJoinParams)
Leo Kime0a12212015-10-12 16:55:49 +09004904 kfree((struct bss_param *)pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004905 else
4906 PRINT_ER("Unable to FREE null pointer\n");
4907}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004908
Tony Choa4ab1ad2015-10-12 16:56:05 +09004909s32 host_int_delBASession(struct host_if_drv *hif_drv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004910{
Leo Kim31390ee2015-10-19 18:26:08 +09004911 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004912 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09004913 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004914
Tony Choa4ab1ad2015-10-12 16:56:05 +09004915 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004916 PRINT_ER("driver is null\n");
4917 return -EFAULT;
4918 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004919
Tony Cho143eb952015-09-21 12:16:32 +09004920 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004921
Tony Choa9f812a2015-09-21 12:16:33 +09004922 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004923
Leo Kim3fc49992015-10-29 11:58:45 +09004924 memcpy(pBASessionInfo->bssid, pBSSID, ETH_ALEN);
Leo Kim16c9b392015-10-29 11:58:46 +09004925 pBASessionInfo->tid = TID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004926 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004927
Leo Kim31390ee2015-10-19 18:26:08 +09004928 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4929 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004930 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004931
Leo Kim2d25af82015-10-15 13:24:56 +09004932 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004933
Leo Kim31390ee2015-10-19 18:26:08 +09004934 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004935}
4936
Tony Choa4ab1ad2015-10-12 16:56:05 +09004937s32 host_int_del_All_Rx_BASession(struct host_if_drv *hif_drv,
4938 char *pBSSID,
4939 char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004940{
Leo Kim31390ee2015-10-19 18:26:08 +09004941 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004942 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09004943 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004944
Tony Choa4ab1ad2015-10-12 16:56:05 +09004945 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004946 PRINT_ER("driver is null\n");
4947 return -EFAULT;
4948 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004949
Tony Cho143eb952015-09-21 12:16:32 +09004950 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004951
Tony Choa9f812a2015-09-21 12:16:33 +09004952 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004953
Leo Kim3fc49992015-10-29 11:58:45 +09004954 memcpy(pBASessionInfo->bssid, pBSSID, ETH_ALEN);
Leo Kim16c9b392015-10-29 11:58:46 +09004955 pBASessionInfo->tid = TID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004956 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004957
Leo Kim31390ee2015-10-19 18:26:08 +09004958 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4959 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004960 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004961
Leo Kim2d25af82015-10-15 13:24:56 +09004962 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004963
Leo Kim31390ee2015-10-19 18:26:08 +09004964 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004965}
4966
Tony Choa4ab1ad2015-10-12 16:56:05 +09004967s32 host_int_setup_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004968{
Leo Kim31390ee2015-10-19 18:26:08 +09004969 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004970 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004971
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004972 return 0;
4973
Tony Choa4ab1ad2015-10-12 16:56:05 +09004974 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004975 PRINT_ER("driver is null\n");
4976 return -EFAULT;
4977 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004978
Tony Cho143eb952015-09-21 12:16:32 +09004979 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004980
Tony Choa9f812a2015-09-21 12:16:33 +09004981 msg.id = HOST_IF_MSG_SET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004982
Leo Kim78675be2015-10-13 20:02:09 +09004983 msg.body.ip_info.ip_addr = u16ipadd;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004984 msg.drv = hif_drv;
Tony Chofb2d65e2015-09-30 18:44:39 +09004985 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004986
Leo Kim31390ee2015-10-19 18:26:08 +09004987 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4988 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004989 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004990
Leo Kim31390ee2015-10-19 18:26:08 +09004991 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004992}
4993
Tony Choa4ab1ad2015-10-12 16:56:05 +09004994s32 host_int_get_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004995{
Leo Kim31390ee2015-10-19 18:26:08 +09004996 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004997 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004998
Tony Choa4ab1ad2015-10-12 16:56:05 +09004999 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005000 PRINT_ER("driver is null\n");
5001 return -EFAULT;
5002 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005003
Tony Cho143eb952015-09-21 12:16:32 +09005004 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005005
Tony Choa9f812a2015-09-21 12:16:33 +09005006 msg.id = HOST_IF_MSG_GET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005007
Leo Kim78675be2015-10-13 20:02:09 +09005008 msg.body.ip_info.ip_addr = u16ipadd;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005009 msg.drv = hif_drv;
Tony Chofb2d65e2015-09-30 18:44:39 +09005010 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005011
Leo Kim31390ee2015-10-19 18:26:08 +09005012 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5013 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09005014 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005015
Leo Kim31390ee2015-10-19 18:26:08 +09005016 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005017}