blob: 4c91ae26fa745267c8cf88fbbd347fe0516e569d [file] [log] [blame]
Chaehyun Lime215a872015-09-30 08:15:41 +09001#include <linux/slab.h>
2#include <linux/time.h>
3#include <linux/kthread.h>
4#include <linux/delay.h>
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005#include "host_interface.h"
Johnny Kimc5c77ba2015-05-11 14:30:56 +09006#include "coreconfigurator.h"
Chaehyun Lim53660122015-09-17 16:48:49 +09007#include "wilc_wlan_if.h"
Chaehyun Limf23eb982015-09-23 18:03:47 +09008#include "wilc_msgqueue.h"
Shraddha Barke281dd5a2015-10-05 17:00:33 +05309#include <linux/etherdevice.h>
Glen Leed53822192015-10-27 18:27:49 +090010#include "wilc_wfi_netdevice.h"
Johnny Kimc5c77ba2015-05-11 14:30:56 +090011
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090012extern u8 connecting;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090013
Greg Kroah-Hartmanda711eb2015-08-14 19:46:06 -070014extern struct timer_list hDuringIpTimer;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090015
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +090016extern u8 g_wilc_initialized;
Johnny Kimc5c77ba2015-05-11 14:30:56 +090017
Chaehyun Lim9eac3a12015-06-18 22:08:51 +090018#define HOST_IF_MSG_SCAN 0
19#define HOST_IF_MSG_CONNECT 1
20#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2
21#define HOST_IF_MSG_KEY 3
22#define HOST_IF_MSG_RCVD_NTWRK_INFO 4
23#define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5
24#define HOST_IF_MSG_CFG_PARAMS 6
25#define HOST_IF_MSG_SET_CHANNEL 7
26#define HOST_IF_MSG_DISCONNECT 8
27#define HOST_IF_MSG_GET_RSSI 9
28#define HOST_IF_MSG_GET_CHNL 10
29#define HOST_IF_MSG_ADD_BEACON 11
30#define HOST_IF_MSG_DEL_BEACON 12
31#define HOST_IF_MSG_ADD_STATION 13
32#define HOST_IF_MSG_DEL_STATION 14
33#define HOST_IF_MSG_EDIT_STATION 15
34#define HOST_IF_MSG_SCAN_TIMER_FIRED 16
35#define HOST_IF_MSG_CONNECT_TIMER_FIRED 17
36#define HOST_IF_MSG_POWER_MGMT 18
37#define HOST_IF_MSG_GET_INACTIVETIME 19
38#define HOST_IF_MSG_REMAIN_ON_CHAN 20
39#define HOST_IF_MSG_REGISTER_FRAME 21
40#define HOST_IF_MSG_LISTEN_TIMER_FIRED 22
41#define HOST_IF_MSG_GET_LINKSPEED 23
42#define HOST_IF_MSG_SET_WFIDRV_HANDLER 24
43#define HOST_IF_MSG_SET_MAC_ADDRESS 25
44#define HOST_IF_MSG_GET_MAC_ADDRESS 26
45#define HOST_IF_MSG_SET_OPERATION_MODE 27
46#define HOST_IF_MSG_SET_IPADDRESS 28
47#define HOST_IF_MSG_GET_IPADDRESS 29
48#define HOST_IF_MSG_FLUSH_CONNECT 30
49#define HOST_IF_MSG_GET_STATISTICS 31
50#define HOST_IF_MSG_SET_MULTICAST_FILTER 32
51#define HOST_IF_MSG_ADD_BA_SESSION 33
52#define HOST_IF_MSG_DEL_BA_SESSION 34
53#define HOST_IF_MSG_Q_IDLE 35
54#define HOST_IF_MSG_DEL_ALL_STA 36
55#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS 34
56#define HOST_IF_MSG_EXIT 100
Johnny Kimc5c77ba2015-05-11 14:30:56 +090057
Chaehyun Lime54d5b72015-06-18 22:08:50 +090058#define HOST_IF_SCAN_TIMEOUT 4000
59#define HOST_IF_CONNECT_TIMEOUT 9500
Johnny Kimc5c77ba2015-05-11 14:30:56 +090060
Chaehyun Lime54d5b72015-06-18 22:08:50 +090061#define BA_SESSION_DEFAULT_BUFFER_SIZE 16
62#define BA_SESSION_DEFAULT_TIMEOUT 1000
63#define BLOCK_ACK_REQ_SIZE 0x14
Leo Kim9f3295a2015-10-19 18:26:10 +090064#define FALSE_FRMWR_CHANNEL 100
Johnny Kimc5c77ba2015-05-11 14:30:56 +090065
Tony Cho361ff842015-09-21 12:16:41 +090066struct cfg_param_attr {
Tony Cho221371e2015-10-12 16:56:06 +090067 struct cfg_param_val cfg_attr_info;
Tony Cho361ff842015-09-21 12:16:41 +090068};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090069
Leo Kim4372d3d2015-10-05 15:25:43 +090070struct host_if_wpa_attr {
Leo Kim124968fc2015-10-13 19:49:30 +090071 u8 *key;
Leo Kim248080a2015-10-13 19:49:31 +090072 const u8 *mac_addr;
Leo Kim0e74c002015-10-13 19:49:32 +090073 u8 *seq;
Leo Kimdacc5942015-10-13 19:49:33 +090074 u8 seq_len;
Leo Kime2dfbac2015-10-13 19:49:34 +090075 u8 index;
Leo Kim6acf2912015-10-13 19:49:35 +090076 u8 key_len;
Leo Kim7b2ebb22015-10-13 19:49:36 +090077 u8 mode;
Leo Kim4372d3d2015-10-05 15:25:43 +090078};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090079
Leo Kimc276c442015-10-05 15:25:42 +090080struct host_if_wep_attr {
Tony Choe5538d32015-10-12 16:56:11 +090081 u8 *key;
Tony Chod520e352015-10-12 16:56:12 +090082 u8 key_len;
Tony Cho259b3aa2015-10-12 16:56:13 +090083 u8 index;
Tony Chob5eaff12015-10-12 16:56:14 +090084 u8 mode;
Tony Cho7fa252e2015-10-12 16:56:15 +090085 enum AUTHTYPE auth_type;
Leo Kimc276c442015-10-05 15:25:42 +090086};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090087
Leo Kim40cc2c92015-10-05 15:25:41 +090088union host_if_key_attr {
Tony Cho2ed7a2f2015-10-12 16:56:08 +090089 struct host_if_wep_attr wep;
Tony Choe3501a42015-10-12 16:56:09 +090090 struct host_if_wpa_attr wpa;
Tony Cho610e3862015-10-12 16:56:10 +090091 struct host_if_pmkid_attr pmkid;
Leo Kim40cc2c92015-10-05 15:25:41 +090092};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090093
Tony Choc98387a2015-09-21 12:16:40 +090094struct key_attr {
Leo Kim8e9f4272015-10-13 19:49:27 +090095 enum KEY_TYPE type;
Leo Kim0d17e382015-10-13 19:49:28 +090096 u8 action;
Leo Kim73b2e382015-10-13 19:49:29 +090097 union host_if_key_attr attr;
Tony Choc98387a2015-09-21 12:16:40 +090098};
Johnny Kimc5c77ba2015-05-11 14:30:56 +090099
Tony Choc476feb2015-09-21 12:16:36 +0900100struct scan_attr {
Leo Kim42568892015-10-13 19:49:37 +0900101 u8 src;
Leo Kim1e276c82015-10-13 19:49:38 +0900102 u8 type;
Leo Kim82eeb0a2015-10-13 19:49:40 +0900103 u8 *ch_freq_list;
Leo Kimf97bd9c2015-10-13 19:49:41 +0900104 u8 ch_list_len;
Leo Kimd6f19aa2015-10-13 19:49:42 +0900105 u8 *ies;
Leo Kim7b1f76c2015-10-13 19:49:43 +0900106 size_t ies_len;
Leo Kimc17c6da2015-10-13 19:49:44 +0900107 wilc_scan_result result;
Leo Kim5f2b50c2015-10-13 19:49:45 +0900108 void *arg;
Leo Kim629b9ca2015-10-13 19:49:46 +0900109 struct hidden_network hidden_network;
Tony Choc476feb2015-09-21 12:16:36 +0900110};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900111
Tony Cho120ae592015-09-21 12:16:37 +0900112struct connect_attr {
Leo Kim9254db02015-10-13 19:49:49 +0900113 u8 *bssid;
Leo Kimf7bbd9c2015-10-13 19:49:50 +0900114 u8 *ssid;
Leo Kim8b3c9fa2015-10-13 19:49:51 +0900115 size_t ssid_len;
Leo Kim2ea158c2015-10-13 19:49:52 +0900116 u8 *ies;
Leo Kimb59d5c52015-10-13 19:49:53 +0900117 size_t ies_len;
Leo Kima64fd672015-10-13 19:49:54 +0900118 u8 security;
Leo Kim6abcc112015-10-13 19:49:55 +0900119 wilc_connect_result result;
Leo Kim8f38db82015-10-13 19:49:56 +0900120 void *arg;
Leo Kim61b4fd02015-10-13 19:49:57 +0900121 enum AUTHTYPE auth_type;
Leo Kim0d1527e2015-10-13 19:49:58 +0900122 u8 ch;
Leo Kimf2bed2c2015-10-13 19:49:59 +0900123 void *params;
Tony Cho120ae592015-09-21 12:16:37 +0900124};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900125
Tony Chof23a9ea2015-09-21 12:16:39 +0900126struct rcvd_async_info {
Leo Kim33722ac72015-10-13 19:50:00 +0900127 u8 *buffer;
Leo Kimf94f4882015-10-13 19:50:01 +0900128 u32 len;
Tony Chof23a9ea2015-09-21 12:16:39 +0900129};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900130
Tony Cho94bdfe42015-09-30 18:44:27 +0900131struct channel_attr {
Leo Kim730ee052015-10-13 19:50:02 +0900132 u8 set_ch;
Tony Cho326b3232015-09-21 12:16:42 +0900133};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900134
Tony Cho7f33fec2015-09-30 18:44:30 +0900135struct beacon_attr {
Leo Kim12262dd2015-10-13 19:50:03 +0900136 u32 interval;
Leo Kime76ab772015-10-13 19:50:04 +0900137 u32 dtim_period;
Leo Kim51c66182015-10-13 19:50:05 +0900138 u32 head_len;
Leo Kim8ce528b2015-10-13 19:50:06 +0900139 u8 *head;
Leo Kim030c57e2015-10-13 19:50:07 +0900140 u32 tail_len;
Leo Kim7dbcb6d32015-10-13 19:50:08 +0900141 u8 *tail;
Tony Cho902362b2015-09-21 12:16:44 +0900142};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900143
Tony Cho641210a2015-09-21 12:16:52 +0900144struct set_multicast {
Leo Kimbae636eb2015-10-13 20:02:04 +0900145 bool enabled;
Leo Kimadab2f72015-10-13 20:02:05 +0900146 u32 cnt;
Tony Cho641210a2015-09-21 12:16:52 +0900147};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900148
Tony Chob4e644e2015-09-21 12:17:00 +0900149struct del_all_sta {
Leo Kime51b9212015-10-13 19:50:09 +0900150 u8 del_all_sta[MAX_NUM_STA][ETH_ALEN];
Leo Kim8ba18032015-10-13 19:50:10 +0900151 u8 assoc_sta;
Tony Chob4e644e2015-09-21 12:17:00 +0900152};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900153
Tony Chofb93a1e2015-09-21 12:16:57 +0900154struct del_sta {
Leo Kime4839d32015-10-13 20:02:06 +0900155 u8 mac_addr[ETH_ALEN];
Tony Chofb93a1e2015-09-21 12:16:57 +0900156};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900157
Tony Cho5a008f12015-09-21 12:16:48 +0900158struct power_mgmt_param {
Leo Kim33c70c12015-10-13 20:02:07 +0900159 bool enabled;
Leo Kim937918f2015-10-13 20:02:08 +0900160 u32 timeout;
Tony Cho5a008f12015-09-21 12:16:48 +0900161};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900162
Tony Cho15191ea2015-09-21 12:16:50 +0900163struct set_ip_addr {
Leo Kim78675be2015-10-13 20:02:09 +0900164 u8 *ip_addr;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900165 u8 idx;
Tony Cho15191ea2015-09-21 12:16:50 +0900166};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900167
Tony Cho3d1eac02015-09-21 12:16:49 +0900168struct sta_inactive_t {
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900169 u8 mac[6];
Tony Cho3d1eac02015-09-21 12:16:49 +0900170};
Leo Kimae4dfa52015-10-13 19:49:26 +0900171
Tony Chodfc76632015-09-21 12:16:34 +0900172union message_body {
Tony Cho4528bdb2015-09-30 18:44:20 +0900173 struct scan_attr scan_info;
Tony Cho3f501972015-09-30 18:44:21 +0900174 struct connect_attr con_info;
Tony Cho02d19462015-09-30 18:44:22 +0900175 struct rcvd_net_info net_info;
Tony Cho66add622015-09-30 18:44:23 +0900176 struct rcvd_async_info async_info;
Tony Cho18990bf2015-09-30 18:44:24 +0900177 struct key_attr key_info;
Tony Choa2340c32015-09-30 18:44:25 +0900178 struct cfg_param_attr cfg_info;
Tony Choffd6dbc2015-09-30 18:44:28 +0900179 struct channel_attr channel_info;
Tony Choa98491e2015-09-30 18:44:31 +0900180 struct beacon_attr beacon_info;
Tony Choca8f47f2015-09-30 18:44:32 +0900181 struct add_sta_param add_sta_info;
Tony Cho889c25b2015-09-30 18:44:33 +0900182 struct del_sta del_sta_info;
Tony Cho4a930962015-09-30 18:44:34 +0900183 struct add_sta_param edit_sta_info;
Tony Cho49e1f812015-09-30 18:44:36 +0900184 struct power_mgmt_param pwr_mgmt_info;
Tony Cho66bac7f2015-09-30 18:44:37 +0900185 struct sta_inactive_t mac_info;
Tony Chofb2d65e2015-09-30 18:44:39 +0900186 struct set_ip_addr ip_info;
Tony Cho5e4377e2015-09-30 18:44:38 +0900187 struct drv_handler drv;
Tony Choa079cf4d2015-09-30 18:55:05 +0900188 struct set_multicast multicast_info;
Tony Cho00c46302015-09-30 18:55:06 +0900189 struct op_mode mode;
Tony Cho15326e22015-09-30 18:55:07 +0900190 struct set_mac_addr set_mac_info;
Tony Choa5848692015-09-30 18:55:08 +0900191 struct get_mac_addr get_mac_info;
Tony Choc833b472015-09-30 18:55:09 +0900192 struct ba_session_info session_info;
Tony Cho070d3652015-09-30 18:55:10 +0900193 struct remain_ch remain_on_ch;
Tony Cho5c4008d2015-10-05 13:50:44 +0900194 struct reg_frame reg_frame;
Tony Choe60831e2015-10-05 13:50:45 +0900195 char *data;
Tony Chob0c1e802015-10-05 13:50:46 +0900196 struct del_all_sta del_all_sta_info;
Tony Chodfc76632015-09-21 12:16:34 +0900197};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900198
Tony Cho3a8c41b2015-09-18 18:11:04 +0900199struct host_if_msg {
Leo Kimae4dfa52015-10-13 19:49:26 +0900200 u16 id;
201 union message_body body;
Leo Kim2482a792015-10-12 16:55:36 +0900202 struct host_if_drv *drv;
Tony Cho3a8c41b2015-09-18 18:11:04 +0900203};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900204
Leo Kime0a12212015-10-12 16:55:49 +0900205struct join_bss_param {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900206 BSSTYPE_T bss_type;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900207 u8 dtim_period;
Chaehyun Limd85f5322015-06-11 14:35:54 +0900208 u16 beacon_period;
209 u16 cap_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900210 u8 au8bssid[6];
Dean Lee576917a2015-06-15 11:58:57 +0900211 char ssid[MAX_SSID_LEN];
Leo Kim619d27b2015-10-15 13:24:42 +0900212 u8 ssid_len;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900213 u8 supp_rates[MAX_RATES_SUPPORTED + 1];
214 u8 ht_capable;
215 u8 wmm_cap;
216 u8 uapsd_cap;
Dean Lee72ed4dc2015-06-12 14:11:44 +0900217 bool rsn_found;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900218 u8 rsn_grp_policy;
219 u8 mode_802_11i;
220 u8 rsn_pcip_policy[3];
221 u8 rsn_auth_policy[3];
222 u8 rsn_cap[2];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900223 u32 tsf;
Leo Kim7a8d51d2015-10-15 13:24:43 +0900224 u8 noa_enabled;
Leo Kimd72b33c2015-10-15 13:24:44 +0900225 u8 opp_enabled;
Leo Kim99b66942015-10-15 13:24:45 +0900226 u8 ct_window;
Leo Kimc21047e2015-10-15 13:24:46 +0900227 u8 cnt;
Leo Kimcc179002015-10-15 13:24:47 +0900228 u8 idx;
Leo Kim109e6ca2015-10-15 13:24:48 +0900229 u8 duration[4];
Leo Kim1d8b76b2015-10-15 13:24:49 +0900230 u8 interval[4];
Leo Kim4be55e22015-10-28 15:59:27 +0900231 u8 start_time[4];
Leo Kime0a12212015-10-12 16:55:49 +0900232};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900233
Leo Kim441dc602015-10-12 16:55:35 +0900234static struct host_if_drv *wfidrv_list[NUM_CONCURRENT_IFC + 1];
235struct host_if_drv *terminated_handle;
Leo Kimf2fc9f62015-10-13 19:49:47 +0900236bool g_obtainingIP;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900237u8 P2P_LISTEN_STATE;
Leo Kimc2115d82015-10-15 13:24:52 +0900238static struct task_struct *hif_thread_handler;
Leo Kimcb067dc2015-10-15 13:24:53 +0900239static WILC_MsgQueueHandle hif_msg_q;
Leo Kim834e0cb2015-10-15 13:24:54 +0900240static struct semaphore hif_sema_thread;
kbuild test robot413f9302015-10-15 14:07:41 +0800241static struct semaphore hif_sema_driver;
Leo Kim2d25af82015-10-15 13:24:56 +0900242static struct semaphore hif_sema_wait_response;
kbuild test robot17225002015-10-15 14:21:32 +0800243static struct semaphore hif_sema_deinit;
kbuild test robot24aadb82015-10-15 14:32:40 +0800244static struct timer_list periodic_rssi;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900245
Leo Kimfb70e9f2015-11-05 14:36:09 +0900246u8 multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900247
Leo Kima633c0b2015-10-15 13:24:59 +0900248static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE];
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900249
kbuild test robotf64321c2015-10-15 14:46:26 +0800250static bool scan_while_connected;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900251
Leo Kim144b7b22015-10-15 13:25:01 +0900252static s8 rssi;
Leo Kim75327a02015-10-15 13:25:02 +0900253static s8 link_speed;
Leo Kim95ebb0f2015-10-15 13:25:03 +0900254static u8 ch_no;
Leo Kim078b1e92015-10-15 13:25:04 +0900255static u8 set_ip[2][4];
Leo Kim1e75d012015-10-15 13:25:05 +0900256static u8 get_ip[2][4];
Leo Kimad269062015-10-15 13:25:06 +0900257static u32 inactive_time;
Leo Kima74c7bf2015-10-15 13:25:07 +0900258static u8 del_beacon;
Leo Kim7178aed2015-10-19 18:26:09 +0900259static u32 clients_count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900260
kbuild test robotef599192015-10-15 15:04:15 +0800261static u8 *join_req;
Leo Kim48ce2462015-10-15 13:25:10 +0900262u8 *info_element;
kbuild test robot23047d52015-10-15 15:18:34 +0800263static u8 mode_11i;
Leo Kimfba49892015-10-15 13:25:12 +0900264u8 auth_type;
Leo Kim0626baa2015-10-15 13:25:13 +0900265u32 join_req_size;
kbuild test robot5e0e7c22015-10-15 15:47:44 +0800266static u32 info_element_size;
kbuild test robot23fba592015-10-15 15:59:53 +0800267static struct host_if_drv *join_req_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900268#define REAL_JOIN_REQ 0
269#define FLUSHED_JOIN_REQ 1
Leo Kimae4dfa52015-10-13 19:49:26 +0900270#define FLUSHED_BYTE_POS 79
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900271
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900272static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900273
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900274extern int linux_wlan_get_num_conn_ifcs(void);
275
Leo Kim441dc602015-10-12 16:55:35 +0900276static int add_handler_in_list(struct host_if_drv *handler)
Johnny Kimd42ab082015-08-20 16:32:52 +0900277{
278 int i;
279
280 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
281 if (!wfidrv_list[i]) {
282 wfidrv_list[i] = handler;
283 return 0;
284 }
285 }
286
287 return -ENOBUFS;
288}
289
Leo Kim441dc602015-10-12 16:55:35 +0900290static int remove_handler_in_list(struct host_if_drv *handler)
Johnny Kimd42ab082015-08-20 16:32:52 +0900291{
292 int i;
293
294 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
295 if (wfidrv_list[i] == handler) {
296 wfidrv_list[i] = NULL;
297 return 0;
298 }
299 }
300
301 return -EINVAL;
302}
303
Leo Kim441dc602015-10-12 16:55:35 +0900304static int get_id_from_handler(struct host_if_drv *handler)
Johnny Kimd42ab082015-08-20 16:32:52 +0900305{
306 int i;
307
308 if (!handler)
309 return 0;
310
311 for (i = 1; i < ARRAY_SIZE(wfidrv_list); i++) {
312 if (wfidrv_list[i] == handler)
313 return i;
314 }
315
316 return 0;
317}
318
Leo Kim441dc602015-10-12 16:55:35 +0900319static struct host_if_drv *get_handler_from_id(int id)
Johnny Kimd42ab082015-08-20 16:32:52 +0900320{
Dan Carpenter6ae9ac02015-09-15 09:54:33 +0300321 if (id <= 0 || id >= ARRAY_SIZE(wfidrv_list))
Johnny Kimd42ab082015-08-20 16:32:52 +0900322 return NULL;
323 return wfidrv_list[id];
324}
325
Leo Kim3eec50c2015-11-06 11:20:03 +0900326static s32 handle_set_channel(struct host_if_drv *hif_drv,
Leo Kim9cf78782015-10-29 12:05:54 +0900327 struct channel_attr *hif_set_ch)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900328{
Leo Kim31390ee2015-10-19 18:26:08 +0900329 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900330 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900331
Leo Kim45102f82015-10-28 15:59:28 +0900332 wid.id = (u16)WID_CURRENT_CHANNEL;
333 wid.type = WID_CHAR;
Leo Kim9cf78782015-10-29 12:05:54 +0900334 wid.val = (char *)&hif_set_ch->set_ch;
Leo Kim45102f82015-10-28 15:59:28 +0900335 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900336
337 PRINT_D(HOSTINF_DBG, "Setting channel\n");
Leo Kimae4dfa52015-10-13 19:49:26 +0900338
Leo Kim45102f82015-10-28 15:59:28 +0900339 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +0900340 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +0900341
342 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900343 PRINT_ER("Failed to set channel\n");
Leo Kim24db7132015-09-16 18:36:01 +0900344 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900345 }
346
Leo Kim31390ee2015-10-19 18:26:08 +0900347 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900348}
Leo Kimae4dfa52015-10-13 19:49:26 +0900349
Leo Kim23f2bad2015-11-06 11:20:04 +0900350static s32 handle_set_wfi_drv_handler(struct host_if_drv *hif_drv,
351 struct drv_handler *hif_drv_handler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900352{
Leo Kim31390ee2015-10-19 18:26:08 +0900353 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900354 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900355
Leo Kim45102f82015-10-28 15:59:28 +0900356 wid.id = (u16)WID_SET_DRV_HANDLER;
357 wid.type = WID_INT;
Leo Kim6b73c742015-10-29 12:05:55 +0900358 wid.val = (s8 *)&hif_drv_handler->handler;
Leo Kim45102f82015-10-28 15:59:28 +0900359 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900360
Leo Kim6b73c742015-10-29 12:05:55 +0900361 result = send_config_pkt(SET_CFG, &wid, 1, hif_drv_handler->handler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900362
Tony Choa4ab1ad2015-10-12 16:56:05 +0900363 if (!hif_drv)
Leo Kim27ff2162015-10-15 13:24:55 +0900364 up(&hif_sema_driver);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900365
Leo Kim31390ee2015-10-19 18:26:08 +0900366 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900367 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900368 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900369 }
370
Leo Kim31390ee2015-10-19 18:26:08 +0900371 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900372}
373
Leo Kim97b5c592015-11-06 11:20:05 +0900374static s32 handle_set_operation_mode(struct host_if_drv *hif_drv,
375 struct op_mode *hif_op_mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900376{
Leo Kim31390ee2015-10-19 18:26:08 +0900377 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900378 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900379
Leo Kim45102f82015-10-28 15:59:28 +0900380 wid.id = (u16)WID_SET_OPERATION_MODE;
381 wid.type = WID_INT;
Leo Kimacff1d72015-10-29 12:05:56 +0900382 wid.val = (s8 *)&hif_op_mode->mode;
Leo Kim45102f82015-10-28 15:59:28 +0900383 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900384
Leo Kim45102f82015-10-28 15:59:28 +0900385 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +0900386 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900387
Leo Kimacff1d72015-10-29 12:05:56 +0900388 if ((hif_op_mode->mode) == IDLE_MODE)
Leo Kim27ff2162015-10-15 13:24:55 +0900389 up(&hif_sema_driver);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900390
Leo Kim31390ee2015-10-19 18:26:08 +0900391 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900392 PRINT_ER("Failed to set driver handler\n");
Leo Kim24db7132015-09-16 18:36:01 +0900393 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900394 }
395
Leo Kim31390ee2015-10-19 18:26:08 +0900396 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900397}
398
Leo Kima6e6d482015-11-06 11:20:06 +0900399s32 handle_set_ip_address(struct host_if_drv *hif_drv, u8 *ip_addr, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900400{
Leo Kim31390ee2015-10-19 18:26:08 +0900401 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900402 struct wid wid;
Leo Kimebc57d12015-11-05 14:36:03 +0900403 char firmware_ip_addr[4] = {0};
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900404
Leo Kima6527c32015-11-05 14:36:02 +0900405 if (ip_addr[0] < 192)
406 ip_addr[0] = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900407
Leo Kima6527c32015-11-05 14:36:02 +0900408 PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %pI4\n",
409 idx, ip_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900410
Leo Kima6527c32015-11-05 14:36:02 +0900411 memcpy(set_ip[idx], ip_addr, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900412
Leo Kim45102f82015-10-28 15:59:28 +0900413 wid.id = (u16)WID_IP_ADDRESS;
414 wid.type = WID_STR;
Leo Kima6527c32015-11-05 14:36:02 +0900415 wid.val = (u8 *)ip_addr;
Leo Kim45102f82015-10-28 15:59:28 +0900416 wid.size = IP_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900417
Leo Kim45102f82015-10-28 15:59:28 +0900418 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +0900419 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900420
Leo Kimebc57d12015-11-05 14:36:03 +0900421 host_int_get_ipaddress(hif_drv, firmware_ip_addr, idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900422
Leo Kim31390ee2015-10-19 18:26:08 +0900423 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +0900424 PRINT_ER("Failed to set IP address\n");
425 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900426 }
427
Leo Kim24db7132015-09-16 18:36:01 +0900428 PRINT_INFO(HOSTINF_DBG, "IP address set\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900429
Leo Kim31390ee2015-10-19 18:26:08 +0900430 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900431}
432
Leo Kimd4516952015-11-06 11:20:07 +0900433s32 handle_get_ip_address(struct host_if_drv *hif_drv, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900434{
Leo Kim31390ee2015-10-19 18:26:08 +0900435 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900436 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900437
Leo Kim45102f82015-10-28 15:59:28 +0900438 wid.id = (u16)WID_IP_ADDRESS;
439 wid.type = WID_STR;
440 wid.val = kmalloc(IP_ALEN, GFP_KERNEL);
441 wid.size = IP_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900442
Leo Kim45102f82015-10-28 15:59:28 +0900443 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +0900444 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900445
Leo Kim45102f82015-10-28 15:59:28 +0900446 PRINT_INFO(HOSTINF_DBG, "%pI4\n", wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900447
Leo Kim45102f82015-10-28 15:59:28 +0900448 memcpy(get_ip[idx], wid.val, IP_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900449
Leo Kim45102f82015-10-28 15:59:28 +0900450 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900451
Leo Kim1e75d012015-10-15 13:25:05 +0900452 if (memcmp(get_ip[idx], set_ip[idx], IP_ALEN) != 0)
Leo Kim078b1e92015-10-15 13:25:04 +0900453 host_int_setup_ipaddress(hif_drv, set_ip[idx], idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900454
Leo Kim31390ee2015-10-19 18:26:08 +0900455 if (result != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900456 PRINT_ER("Failed to get IP address\n");
Leo Kim24db7132015-09-16 18:36:01 +0900457 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900458 }
459
Leo Kim24db7132015-09-16 18:36:01 +0900460 PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d\n", idx);
Leo Kim1e75d012015-10-15 13:25:05 +0900461 PRINT_INFO(HOSTINF_DBG, "%pI4\n", get_ip[idx]);
Leo Kim24db7132015-09-16 18:36:01 +0900462 PRINT_INFO(HOSTINF_DBG, "\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900463
Leo Kim31390ee2015-10-19 18:26:08 +0900464 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900465}
466
Leo Kima8267422015-11-06 11:20:08 +0900467static s32 handle_set_mac_address(struct host_if_drv *hif_drv,
468 struct set_mac_addr *set_mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900469{
Leo Kim31390ee2015-10-19 18:26:08 +0900470 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900471 struct wid wid;
Glen Leef3052582015-09-10 12:03:04 +0900472 u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
Leo Kimc09389a2015-10-28 15:59:24 +0900473
Leo Kim91109e12015-10-19 18:26:13 +0900474 if (!mac_buf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900475 PRINT_ER("No buffer to send mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +0900476 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900477 }
Leo Kim090dbb12015-11-05 14:36:05 +0900478 memcpy(mac_buf, set_mac_addr->mac_addr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900479
Leo Kim45102f82015-10-28 15:59:28 +0900480 wid.id = (u16)WID_MAC_ADDR;
481 wid.type = WID_STR;
482 wid.val = mac_buf;
483 wid.size = ETH_ALEN;
484 PRINT_D(GENERIC_DBG, "mac addr = :%pM\n", wid.val);
Leo Kimae4dfa52015-10-13 19:49:26 +0900485
Leo Kim45102f82015-10-28 15:59:28 +0900486 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +0900487 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +0900488 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900489 PRINT_ER("Failed to set mac address\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900490 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900491 }
492
Chaehyun Lim49188af2015-08-11 10:32:41 +0900493 kfree(mac_buf);
Leo Kim31390ee2015-10-19 18:26:08 +0900494 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900495}
496
Leo Kimb3bf8fd2015-11-06 11:20:09 +0900497static s32 handle_get_mac_address(struct host_if_drv *hif_drv,
498 struct get_mac_addr *get_mac_addr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900499{
Leo Kim31390ee2015-10-19 18:26:08 +0900500 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +0900501 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900502
Leo Kim45102f82015-10-28 15:59:28 +0900503 wid.id = (u16)WID_MAC_ADDR;
504 wid.type = WID_STR;
Leo Kim7f0ee9a2015-11-05 14:36:06 +0900505 wid.val = get_mac_addr->mac_addr;
Leo Kim45102f82015-10-28 15:59:28 +0900506 wid.size = ETH_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900507
Leo Kim45102f82015-10-28 15:59:28 +0900508 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +0900509 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +0900510
511 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900512 PRINT_ER("Failed to get mac address\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900513 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900514 }
Leo Kim2d25af82015-10-15 13:24:56 +0900515 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900516
Leo Kim31390ee2015-10-19 18:26:08 +0900517 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900518}
519
Leo Kimdc276662015-11-06 11:20:10 +0900520static s32 handle_cfg_param(struct host_if_drv *hif_drv,
521 struct cfg_param_attr *cfg_param_attr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900522{
Leo Kim31390ee2015-10-19 18:26:08 +0900523 s32 result = 0;
Leo 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
Leo Kim02ae2bd2015-11-05 14:36:07 +0900531 if (cfg_param_attr->cfg_attr_info.flag & BSS_TYPE) {
532 if (cfg_param_attr->cfg_attr_info.bss_type < 6) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900533 strWIDList[u8WidCnt].id = WID_BSS_TYPE;
Leo Kim02ae2bd2015-11-05 14:36:07 +0900534 strWIDList[u8WidCnt].val = (s8 *)&cfg_param_attr->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 Kim02ae2bd2015-11-05 14:36:07 +0900537 hif_drv->cfg_values.bss_type = (u8)cfg_param_attr->cfg_attr_info.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900538 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900539 PRINT_ER("check value 6 over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900540 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900541 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900542 }
543 u8WidCnt++;
544 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900545 if (cfg_param_attr->cfg_attr_info.flag & AUTH_TYPE) {
546 if (cfg_param_attr->cfg_attr_info.auth_type == 1 ||
547 cfg_param_attr->cfg_attr_info.auth_type == 2 ||
548 cfg_param_attr->cfg_attr_info.auth_type == 5) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900549 strWIDList[u8WidCnt].id = WID_AUTH_TYPE;
Leo Kim02ae2bd2015-11-05 14:36:07 +0900550 strWIDList[u8WidCnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.auth_type;
Leo Kim416d8322015-10-12 16:55:43 +0900551 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900552 strWIDList[u8WidCnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900553 hif_drv->cfg_values.auth_type = (u8)cfg_param_attr->cfg_attr_info.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900554 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900555 PRINT_ER("Impossible value \n");
Leo Kim31390ee2015-10-19 18:26:08 +0900556 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900557 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900558 }
559 u8WidCnt++;
560 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900561 if (cfg_param_attr->cfg_attr_info.flag & AUTHEN_TIMEOUT) {
562 if (cfg_param_attr->cfg_attr_info.auth_timeout > 0 &&
563 cfg_param_attr->cfg_attr_info.auth_timeout < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900564 strWIDList[u8WidCnt].id = WID_AUTH_TIMEOUT;
Leo Kim02ae2bd2015-11-05 14:36:07 +0900565 strWIDList[u8WidCnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.auth_timeout;
Leo Kim416d8322015-10-12 16:55:43 +0900566 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900567 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900568 hif_drv->cfg_values.auth_timeout = cfg_param_attr->cfg_attr_info.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900569 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900570 PRINT_ER("Range(1 ~ 65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900571 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900572 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900573 }
574 u8WidCnt++;
575 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900576 if (cfg_param_attr->cfg_attr_info.flag & POWER_MANAGEMENT) {
577 if (cfg_param_attr->cfg_attr_info.power_mgmt_mode < 5) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900578 strWIDList[u8WidCnt].id = WID_POWER_MANAGEMENT;
Leo Kim02ae2bd2015-11-05 14:36:07 +0900579 strWIDList[u8WidCnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.power_mgmt_mode;
Leo Kim416d8322015-10-12 16:55:43 +0900580 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900581 strWIDList[u8WidCnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900582 hif_drv->cfg_values.power_mgmt_mode = (u8)cfg_param_attr->cfg_attr_info.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900583 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900584 PRINT_ER("Invalide power mode\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900585 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900586 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900587 }
588 u8WidCnt++;
589 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900590 if (cfg_param_attr->cfg_attr_info.flag & RETRY_SHORT) {
591 if (cfg_param_attr->cfg_attr_info.short_retry_limit > 0 &&
592 cfg_param_attr->cfg_attr_info.short_retry_limit < 256) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900593 strWIDList[u8WidCnt].id = WID_SHORT_RETRY_LIMIT;
Leo Kim02ae2bd2015-11-05 14:36:07 +0900594 strWIDList[u8WidCnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.short_retry_limit;
Leo Kim416d8322015-10-12 16:55:43 +0900595 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900596 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900597 hif_drv->cfg_values.short_retry_limit = cfg_param_attr->cfg_attr_info.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900598 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900599 PRINT_ER("Range(1~256) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900600 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900601 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900602 }
603 u8WidCnt++;
604 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900605 if (cfg_param_attr->cfg_attr_info.flag & RETRY_LONG) {
606 if (cfg_param_attr->cfg_attr_info.long_retry_limit > 0 &&
607 cfg_param_attr->cfg_attr_info.long_retry_limit < 256) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900608 strWIDList[u8WidCnt].id = WID_LONG_RETRY_LIMIT;
Leo Kim02ae2bd2015-11-05 14:36:07 +0900609 strWIDList[u8WidCnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900610
Leo Kim416d8322015-10-12 16:55:43 +0900611 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900612 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900613 hif_drv->cfg_values.long_retry_limit = cfg_param_attr->cfg_attr_info.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900614 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900615 PRINT_ER("Range(1~256) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900616 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900617 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900618 }
619 u8WidCnt++;
620 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900621 if (cfg_param_attr->cfg_attr_info.flag & FRAG_THRESHOLD) {
622 if (cfg_param_attr->cfg_attr_info.frag_threshold > 255 &&
623 cfg_param_attr->cfg_attr_info.frag_threshold < 7937) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900624 strWIDList[u8WidCnt].id = WID_FRAG_THRESHOLD;
Leo Kim02ae2bd2015-11-05 14:36:07 +0900625 strWIDList[u8WidCnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.frag_threshold;
Leo Kim416d8322015-10-12 16:55:43 +0900626 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900627 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900628 hif_drv->cfg_values.frag_threshold = cfg_param_attr->cfg_attr_info.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900629 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900630 PRINT_ER("Threshold Range fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900631 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900632 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900633 }
634 u8WidCnt++;
635 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900636 if (cfg_param_attr->cfg_attr_info.flag & RTS_THRESHOLD) {
637 if (cfg_param_attr->cfg_attr_info.rts_threshold > 255 &&
638 cfg_param_attr->cfg_attr_info.rts_threshold < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900639 strWIDList[u8WidCnt].id = WID_RTS_THRESHOLD;
Leo Kim02ae2bd2015-11-05 14:36:07 +0900640 strWIDList[u8WidCnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.rts_threshold;
Leo Kim416d8322015-10-12 16:55:43 +0900641 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900642 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900643 hif_drv->cfg_values.rts_threshold = cfg_param_attr->cfg_attr_info.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900644 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900645 PRINT_ER("Threshold Range fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900646 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900647 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900648 }
649 u8WidCnt++;
650 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900651 if (cfg_param_attr->cfg_attr_info.flag & PREAMBLE) {
652 if (cfg_param_attr->cfg_attr_info.preamble_type < 3) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900653 strWIDList[u8WidCnt].id = WID_PREAMBLE;
Leo Kim02ae2bd2015-11-05 14:36:07 +0900654 strWIDList[u8WidCnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.preamble_type;
Leo Kim416d8322015-10-12 16:55:43 +0900655 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900656 strWIDList[u8WidCnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900657 hif_drv->cfg_values.preamble_type = cfg_param_attr->cfg_attr_info.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900658 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900659 PRINT_ER("Preamle Range(0~2) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900660 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900661 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900662 }
663 u8WidCnt++;
664 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900665 if (cfg_param_attr->cfg_attr_info.flag & SHORT_SLOT_ALLOWED) {
666 if (cfg_param_attr->cfg_attr_info.short_slot_allowed < 2) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900667 strWIDList[u8WidCnt].id = WID_SHORT_SLOT_ALLOWED;
Leo Kim02ae2bd2015-11-05 14:36:07 +0900668 strWIDList[u8WidCnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.short_slot_allowed;
Leo Kim416d8322015-10-12 16:55:43 +0900669 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900670 strWIDList[u8WidCnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900671 hif_drv->cfg_values.short_slot_allowed = (u8)cfg_param_attr->cfg_attr_info.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900672 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900673 PRINT_ER("Short slot(2) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900674 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900675 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900676 }
677 u8WidCnt++;
678 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900679 if (cfg_param_attr->cfg_attr_info.flag & TXOP_PROT_DISABLE) {
680 if (cfg_param_attr->cfg_attr_info.txop_prot_disabled < 2) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900681 strWIDList[u8WidCnt].id = WID_11N_TXOP_PROT_DISABLE;
Leo Kim02ae2bd2015-11-05 14:36:07 +0900682 strWIDList[u8WidCnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.txop_prot_disabled;
Leo Kim416d8322015-10-12 16:55:43 +0900683 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900684 strWIDList[u8WidCnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900685 hif_drv->cfg_values.txop_prot_disabled = (u8)cfg_param_attr->cfg_attr_info.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900686 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900687 PRINT_ER("TXOP prot disable\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900688 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900689 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900690 }
691 u8WidCnt++;
692 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900693 if (cfg_param_attr->cfg_attr_info.flag & BEACON_INTERVAL) {
694 if (cfg_param_attr->cfg_attr_info.beacon_interval > 0 &&
695 cfg_param_attr->cfg_attr_info.beacon_interval < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900696 strWIDList[u8WidCnt].id = WID_BEACON_INTERVAL;
Leo Kim02ae2bd2015-11-05 14:36:07 +0900697 strWIDList[u8WidCnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.beacon_interval;
Leo Kim416d8322015-10-12 16:55:43 +0900698 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900699 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900700 hif_drv->cfg_values.beacon_interval = cfg_param_attr->cfg_attr_info.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900701 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900702 PRINT_ER("Beacon interval(1~65535) fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900703 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900704 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900705 }
706 u8WidCnt++;
707 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900708 if (cfg_param_attr->cfg_attr_info.flag & DTIM_PERIOD) {
709 if (cfg_param_attr->cfg_attr_info.dtim_period > 0 &&
710 cfg_param_attr->cfg_attr_info.dtim_period < 256) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900711 strWIDList[u8WidCnt].id = WID_DTIM_PERIOD;
Leo Kim02ae2bd2015-11-05 14:36:07 +0900712 strWIDList[u8WidCnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.dtim_period;
Leo Kim416d8322015-10-12 16:55:43 +0900713 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900714 strWIDList[u8WidCnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900715 hif_drv->cfg_values.dtim_period = cfg_param_attr->cfg_attr_info.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900716 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900717 PRINT_ER("DTIM range(1~255) fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900718 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900719 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900720 }
721 u8WidCnt++;
722 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900723 if (cfg_param_attr->cfg_attr_info.flag & SITE_SURVEY) {
724 if (cfg_param_attr->cfg_attr_info.site_survey_enabled < 3) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900725 strWIDList[u8WidCnt].id = WID_SITE_SURVEY;
Leo Kim02ae2bd2015-11-05 14:36:07 +0900726 strWIDList[u8WidCnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.site_survey_enabled;
Leo Kim416d8322015-10-12 16:55:43 +0900727 strWIDList[u8WidCnt].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900728 strWIDList[u8WidCnt].size = sizeof(char);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900729 hif_drv->cfg_values.site_survey_enabled = (u8)cfg_param_attr->cfg_attr_info.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900730 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900731 PRINT_ER("Site survey disable\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900732 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900733 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900734 }
735 u8WidCnt++;
736 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900737 if (cfg_param_attr->cfg_attr_info.flag & SITE_SURVEY_SCAN_TIME) {
738 if (cfg_param_attr->cfg_attr_info.site_survey_scan_time > 0 &&
739 cfg_param_attr->cfg_attr_info.site_survey_scan_time < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900740 strWIDList[u8WidCnt].id = WID_SITE_SURVEY_SCAN_TIME;
Leo Kim02ae2bd2015-11-05 14:36:07 +0900741 strWIDList[u8WidCnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.site_survey_scan_time;
Leo Kim416d8322015-10-12 16:55:43 +0900742 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900743 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900744 hif_drv->cfg_values.site_survey_scan_time = cfg_param_attr->cfg_attr_info.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900745 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900746 PRINT_ER("Site survey scan time(1~65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900747 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900748 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900749 }
750 u8WidCnt++;
751 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900752 if (cfg_param_attr->cfg_attr_info.flag & ACTIVE_SCANTIME) {
753 if (cfg_param_attr->cfg_attr_info.active_scan_time > 0 &&
754 cfg_param_attr->cfg_attr_info.active_scan_time < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900755 strWIDList[u8WidCnt].id = WID_ACTIVE_SCAN_TIME;
Leo Kim02ae2bd2015-11-05 14:36:07 +0900756 strWIDList[u8WidCnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.active_scan_time;
Leo Kim416d8322015-10-12 16:55:43 +0900757 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900758 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900759 hif_drv->cfg_values.active_scan_time = cfg_param_attr->cfg_attr_info.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900760 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900761 PRINT_ER("Active scan time(1~65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900762 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900763 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900764 }
765 u8WidCnt++;
766 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900767 if (cfg_param_attr->cfg_attr_info.flag & PASSIVE_SCANTIME) {
768 if (cfg_param_attr->cfg_attr_info.passive_scan_time > 0 &&
769 cfg_param_attr->cfg_attr_info.passive_scan_time < 65536) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900770 strWIDList[u8WidCnt].id = WID_PASSIVE_SCAN_TIME;
Leo Kim02ae2bd2015-11-05 14:36:07 +0900771 strWIDList[u8WidCnt].val = (s8 *)&cfg_param_attr->cfg_attr_info.passive_scan_time;
Leo Kim416d8322015-10-12 16:55:43 +0900772 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900773 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kim02ae2bd2015-11-05 14:36:07 +0900774 hif_drv->cfg_values.passive_scan_time = cfg_param_attr->cfg_attr_info.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900775 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900776 PRINT_ER("Passive scan time(1~65535) over\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900777 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900778 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900779 }
780 u8WidCnt++;
781 }
Leo Kim02ae2bd2015-11-05 14:36:07 +0900782 if (cfg_param_attr->cfg_attr_info.flag & CURRENT_TX_RATE) {
783 enum CURRENT_TXRATE curr_tx_rate = cfg_param_attr->cfg_attr_info.curr_tx_rate;
Leo Kimc09389a2015-10-28 15:59:24 +0900784
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900785 if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
786 || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
787 || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
788 || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
789 || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
790 || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900791 strWIDList[u8WidCnt].id = WID_CURRENT_TX_RATE;
Leo Kim900bb4a2015-10-12 16:55:46 +0900792 strWIDList[u8WidCnt].val = (s8 *)&curr_tx_rate;
Leo Kim416d8322015-10-12 16:55:43 +0900793 strWIDList[u8WidCnt].type = WID_SHORT;
Leo Kim2fd3e442015-10-12 16:55:45 +0900794 strWIDList[u8WidCnt].size = sizeof(u16);
Leo Kimace303f2015-10-29 11:58:26 +0900795 hif_drv->cfg_values.curr_tx_rate = (u8)curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900796 } else {
Leo Kim24db7132015-09-16 18:36:01 +0900797 PRINT_ER("out of TX rate\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900798 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +0900799 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900800 }
801 u8WidCnt++;
802 }
Leo Kim31390ee2015-10-19 18:26:08 +0900803
804 result = send_config_pkt(SET_CFG, strWIDList, u8WidCnt,
Leo Kim8c8360b2015-10-19 18:26:12 +0900805 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900806
Leo Kim31390ee2015-10-19 18:26:08 +0900807 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900808 PRINT_ER("Error in setting CFG params\n");
809
Leo Kim24db7132015-09-16 18:36:01 +0900810ERRORHANDLER:
Leo Kim33110ad2015-10-29 11:58:27 +0900811 up(&hif_drv->sem_cfg_values);
Leo Kim31390ee2015-10-19 18:26:08 +0900812 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900813}
814
Leo Kim3b840e42015-11-05 14:36:08 +0900815static void Handle_wait_msg_q_empty(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900816{
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900817 g_wilc_initialized = 0;
Leo Kim2d25af82015-10-15 13:24:56 +0900818 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900819}
820
Tony Choa4ab1ad2015-10-12 16:56:05 +0900821static s32 Handle_Scan(struct host_if_drv *hif_drv,
Tony Choc476feb2015-09-21 12:16:36 +0900822 struct scan_attr *pstrHostIFscanAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900823{
Leo Kim31390ee2015-10-19 18:26:08 +0900824 s32 result = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900825 struct wid strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900826 u32 u32WidsCount = 0;
827 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900828 u8 *pu8Buffer;
829 u8 valuesize = 0;
830 u8 *pu8HdnNtwrksWidVal = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900831
832 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
Leo Kimb60005a2015-10-29 11:58:24 +0900833 PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state\n", hif_drv->hif_state);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900834
Leo Kimbc801852015-10-29 11:58:50 +0900835 hif_drv->usr_scan_req.scan_result = pstrHostIFscanAttr->result;
Leo Kim66eaea32015-10-29 11:58:51 +0900836 hif_drv->usr_scan_req.arg = pstrHostIFscanAttr->arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900837
Leo Kimb60005a2015-10-29 11:58:24 +0900838 if ((hif_drv->hif_state >= HOST_IF_SCANNING) &&
839 (hif_drv->hif_state < HOST_IF_CONNECTED)) {
840 PRINT_D(GENERIC_DBG, "Don't scan already in [%d] state\n",
841 hif_drv->hif_state);
Leo Kim24db7132015-09-16 18:36:01 +0900842 PRINT_ER("Already scan\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900843 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +0900844 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900845 }
846
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900847 if (g_obtainingIP || connecting) {
848 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim24db7132015-09-16 18:36:01 +0900849 PRINT_ER("Don't do obss scan\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900850 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +0900851 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900852 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900853
854 PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
855
Leo Kimf79756e2015-10-29 12:05:36 +0900856 hif_drv->usr_scan_req.rcvd_ch_cnt = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900857
Leo Kimdaaf16b2015-10-12 16:55:44 +0900858 strWIDList[u32WidsCount].id = (u16)WID_SSID_PROBE_REQ;
Leo Kim416d8322015-10-12 16:55:43 +0900859 strWIDList[u32WidsCount].type = WID_STR;
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 valuesize += ((pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
Glen Leef3052582015-09-10 12:03:04 +0900863 pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL);
Leo Kim900bb4a2015-10-12 16:55:46 +0900864 strWIDList[u32WidsCount].val = pu8HdnNtwrksWidVal;
Leo Kim91109e12015-10-19 18:26:13 +0900865 if (strWIDList[u32WidsCount].val) {
Leo Kim900bb4a2015-10-12 16:55:46 +0900866 pu8Buffer = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900867
Leo Kim629b9ca2015-10-13 19:49:46 +0900868 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900869
Leo Kim629b9ca2015-10-13 19:49:46 +0900870 PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->hidden_network.u8ssidnum);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900871
Leo Kim629b9ca2015-10-13 19:49:46 +0900872 for (i = 0; i < pstrHostIFscanAttr->hidden_network.u8ssidnum; i++) {
873 *pu8Buffer++ = pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
874 memcpy(pu8Buffer, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen);
875 pu8Buffer += pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo[i].u8ssidlen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900876 }
877
Leo Kim2fd3e442015-10-12 16:55:45 +0900878 strWIDList[u32WidsCount].size = (s32)(valuesize + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900879 u32WidsCount++;
880 }
881
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900882 {
Leo Kimdaaf16b2015-10-12 16:55:44 +0900883 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_PROBE;
Leo Kim416d8322015-10-12 16:55:43 +0900884 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kimd6f19aa2015-10-13 19:49:42 +0900885 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ies;
Leo Kim7b1f76c2015-10-13 19:49:43 +0900886 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ies_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900887 u32WidsCount++;
888 }
889
Leo Kimdaaf16b2015-10-12 16:55:44 +0900890 strWIDList[u32WidsCount].id = WID_SCAN_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +0900891 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900892 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +0900893 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900894 u32WidsCount++;
895
Leo Kimdaaf16b2015-10-12 16:55:44 +0900896 strWIDList[u32WidsCount].id = WID_SCAN_CHANNEL_LIST;
Leo Kim416d8322015-10-12 16:55:43 +0900897 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900898
Leo Kim91109e12015-10-19 18:26:13 +0900899 if (pstrHostIFscanAttr->ch_freq_list &&
900 pstrHostIFscanAttr->ch_list_len > 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900901 int i;
902
Leo Kimf97bd9c2015-10-13 19:49:41 +0900903 for (i = 0; i < pstrHostIFscanAttr->ch_list_len; i++) {
Leo Kim82eeb0a2015-10-13 19:49:40 +0900904 if (pstrHostIFscanAttr->ch_freq_list[i] > 0)
905 pstrHostIFscanAttr->ch_freq_list[i] = pstrHostIFscanAttr->ch_freq_list[i] - 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900906 }
907 }
908
Leo Kim82eeb0a2015-10-13 19:49:40 +0900909 strWIDList[u32WidsCount].val = pstrHostIFscanAttr->ch_freq_list;
Leo Kimf97bd9c2015-10-13 19:49:41 +0900910 strWIDList[u32WidsCount].size = pstrHostIFscanAttr->ch_list_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900911 u32WidsCount++;
912
Leo Kimdaaf16b2015-10-12 16:55:44 +0900913 strWIDList[u32WidsCount].id = WID_START_SCAN_REQ;
Leo Kim416d8322015-10-12 16:55:43 +0900914 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +0900915 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +0900916 strWIDList[u32WidsCount].val = (s8 *)&pstrHostIFscanAttr->src;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900917 u32WidsCount++;
918
Leo Kimb60005a2015-10-29 11:58:24 +0900919 if (hif_drv->hif_state == HOST_IF_CONNECTED)
Leo Kimca8540e42015-10-15 13:25:00 +0900920 scan_while_connected = true;
Leo Kimb60005a2015-10-29 11:58:24 +0900921 else if (hif_drv->hif_state == HOST_IF_IDLE)
Leo Kimca8540e42015-10-15 13:25:00 +0900922 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900923
Leo Kim31390ee2015-10-19 18:26:08 +0900924 result = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
Leo Kim8c8360b2015-10-19 18:26:12 +0900925 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900926
Leo Kim31390ee2015-10-19 18:26:08 +0900927 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900928 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +0900929 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900930 PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900931
Leo Kim24db7132015-09-16 18:36:01 +0900932ERRORHANDLER:
Leo Kim31390ee2015-10-19 18:26:08 +0900933 if (result) {
Leo Kim13b313e2015-10-29 11:58:34 +0900934 del_timer(&hif_drv->scan_timer);
Tony Choa4ab1ad2015-10-12 16:56:05 +0900935 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900936 }
937
Shraddha Barke95f840f2015-10-14 07:29:19 +0530938 kfree(pstrHostIFscanAttr->ch_freq_list);
939 pstrHostIFscanAttr->ch_freq_list = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900940
Shraddha Barke95f840f2015-10-14 07:29:19 +0530941 kfree(pstrHostIFscanAttr->ies);
942 pstrHostIFscanAttr->ies = NULL;
943 kfree(pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo);
944 pstrHostIFscanAttr->hidden_network.pstrHiddenNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900945
Shraddha Barke95f840f2015-10-14 07:29:19 +0530946 kfree(pu8HdnNtwrksWidVal);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900947
Leo Kim31390ee2015-10-19 18:26:08 +0900948 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900949}
950
Tony Choa4ab1ad2015-10-12 16:56:05 +0900951static s32 Handle_ScanDone(struct host_if_drv *hif_drv,
952 enum scan_event enuEvent)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900953{
Leo Kim31390ee2015-10-19 18:26:08 +0900954 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900955 u8 u8abort_running_scan;
Leo Kim45102f82015-10-28 15:59:28 +0900956 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900957
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900958 PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
959
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900960 if (enuEvent == SCAN_EVENT_ABORTED) {
961 PRINT_D(GENERIC_DBG, "Abort running scan\n");
962 u8abort_running_scan = 1;
Leo Kim45102f82015-10-28 15:59:28 +0900963 wid.id = (u16)WID_ABORT_RUNNING_SCAN;
964 wid.type = WID_CHAR;
965 wid.val = (s8 *)&u8abort_running_scan;
966 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900967
Leo Kim45102f82015-10-28 15:59:28 +0900968 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +0900969 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +0900970
971 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900972 PRINT_ER("Failed to set abort running scan\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900973 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900974 }
975 }
976
Tony Choa4ab1ad2015-10-12 16:56:05 +0900977 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900978 PRINT_ER("Driver handler is NULL\n");
Leo Kim31390ee2015-10-19 18:26:08 +0900979 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900980 }
981
Leo Kimbc801852015-10-29 11:58:50 +0900982 if (hif_drv->usr_scan_req.scan_result) {
983 hif_drv->usr_scan_req.scan_result(enuEvent, NULL,
Leo Kim66eaea32015-10-29 11:58:51 +0900984 hif_drv->usr_scan_req.arg, NULL);
Leo Kimbc801852015-10-29 11:58:50 +0900985 hif_drv->usr_scan_req.scan_result = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900986 }
987
Leo Kim31390ee2015-10-19 18:26:08 +0900988 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900989}
990
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900991u8 u8ConnectedSSID[6] = {0};
Tony Choa4ab1ad2015-10-12 16:56:05 +0900992static s32 Handle_Connect(struct host_if_drv *hif_drv,
Tony Cho120ae592015-09-21 12:16:37 +0900993 struct connect_attr *pstrHostIFconnectAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +0900994{
Leo Kim31390ee2015-10-19 18:26:08 +0900995 s32 result = 0;
Leo Kime9e0c262015-10-12 16:55:41 +0900996 struct wid strWIDList[8];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +0900997 u32 u32WidsCount = 0, dummyval = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +0900998 u8 *pu8CurrByte = NULL;
Leo Kime0a12212015-10-12 16:55:49 +0900999 struct join_bss_param *ptstrJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001000
1001 PRINT_D(GENERIC_DBG, "Handling connect request\n");
1002
Leo Kim9254db02015-10-13 19:49:49 +09001003 if (memcmp(pstrHostIFconnectAttr->bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
Leo Kim31390ee2015-10-19 18:26:08 +09001004 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001005 PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001006 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001007 }
1008
1009 PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
1010
Leo Kimf2bed2c2015-10-13 19:49:59 +09001011 ptstrJoinBssParam = (struct join_bss_param *)pstrHostIFconnectAttr->params;
Leo Kim91109e12015-10-19 18:26:13 +09001012 if (!ptstrJoinBssParam) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001013 PRINT_ER("Required BSSID not found\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001014 result = -ENOENT;
Leo Kim24db7132015-09-16 18:36:01 +09001015 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001016 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001017
Leo Kim91109e12015-10-19 18:26:13 +09001018 if (pstrHostIFconnectAttr->bssid) {
Leo Kimf8b17132015-10-28 15:59:34 +09001019 hif_drv->usr_conn_req.pu8bssid = kmalloc(6, GFP_KERNEL);
1020 memcpy(hif_drv->usr_conn_req.pu8bssid, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001021 }
1022
Leo Kim74ab5e42015-10-29 11:58:53 +09001023 hif_drv->usr_conn_req.ssid_len = pstrHostIFconnectAttr->ssid_len;
Leo Kim91109e12015-10-19 18:26:13 +09001024 if (pstrHostIFconnectAttr->ssid) {
Leo Kimf8b17132015-10-28 15:59:34 +09001025 hif_drv->usr_conn_req.pu8ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL);
1026 memcpy(hif_drv->usr_conn_req.pu8ssid,
Leo Kim8c8360b2015-10-19 18:26:12 +09001027 pstrHostIFconnectAttr->ssid,
1028 pstrHostIFconnectAttr->ssid_len);
Leo Kimf8b17132015-10-28 15:59:34 +09001029 hif_drv->usr_conn_req.pu8ssid[pstrHostIFconnectAttr->ssid_len] = '\0';
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001030 }
1031
Leo Kim331ed082015-10-29 11:58:55 +09001032 hif_drv->usr_conn_req.ies_len = pstrHostIFconnectAttr->ies_len;
Leo Kim91109e12015-10-19 18:26:13 +09001033 if (pstrHostIFconnectAttr->ies) {
Leo Kima3b2f4b2015-10-29 11:58:54 +09001034 hif_drv->usr_conn_req.ies = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
1035 memcpy(hif_drv->usr_conn_req.ies,
Leo Kim8c8360b2015-10-19 18:26:12 +09001036 pstrHostIFconnectAttr->ies,
1037 pstrHostIFconnectAttr->ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001038 }
1039
Leo Kimf8b17132015-10-28 15:59:34 +09001040 hif_drv->usr_conn_req.u8security = pstrHostIFconnectAttr->security;
Leo Kim7d069722015-10-29 12:05:37 +09001041 hif_drv->usr_conn_req.auth_type = pstrHostIFconnectAttr->auth_type;
Leo Kim33bfb192015-10-29 11:58:56 +09001042 hif_drv->usr_conn_req.conn_result = pstrHostIFconnectAttr->result;
Leo Kim73abaa42015-10-29 12:05:27 +09001043 hif_drv->usr_conn_req.arg = pstrHostIFconnectAttr->arg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001044
Leo Kimdaaf16b2015-10-12 16:55:44 +09001045 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001046 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001047 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001048 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001049 u32WidsCount++;
1050
Leo Kimdaaf16b2015-10-12 16:55:44 +09001051 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001052 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001053 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001054 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001055 u32WidsCount++;
1056
Leo Kimdaaf16b2015-10-12 16:55:44 +09001057 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09001058 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09001059 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim900bb4a2015-10-12 16:55:46 +09001060 strWIDList[u32WidsCount].val = (s8 *)(&(dummyval));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001061 u32WidsCount++;
1062
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001063 {
Leo Kimdaaf16b2015-10-12 16:55:44 +09001064 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
Leo Kim416d8322015-10-12 16:55:43 +09001065 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001066 strWIDList[u32WidsCount].val = hif_drv->usr_conn_req.ies;
Leo Kim331ed082015-10-29 11:58:55 +09001067 strWIDList[u32WidsCount].size = hif_drv->usr_conn_req.ies_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001068 u32WidsCount++;
1069
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001070 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Leo Kim331ed082015-10-29 11:58:55 +09001071 info_element_size = hif_drv->usr_conn_req.ies_len;
Leo Kimdfef7b82015-10-15 13:25:14 +09001072 info_element = kmalloc(info_element_size, GFP_KERNEL);
Leo Kima3b2f4b2015-10-29 11:58:54 +09001073 memcpy(info_element, hif_drv->usr_conn_req.ies,
Leo Kimdfef7b82015-10-15 13:25:14 +09001074 info_element_size);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001075 }
1076 }
Leo Kimdaaf16b2015-10-12 16:55:44 +09001077 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
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 Kimf8b17132015-10-28 15:59:34 +09001080 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.u8security;
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 Kimf8b17132015-10-28 15:59:34 +09001084 mode_11i = hif_drv->usr_conn_req.u8security;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001085
Leo Kimf8b17132015-10-28 15:59:34 +09001086 PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", hif_drv->usr_conn_req.u8security);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001087
Leo Kimdaaf16b2015-10-12 16:55:44 +09001088 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001089 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001090 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim7d069722015-10-29 12:05:37 +09001091 strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001092 u32WidsCount++;
1093
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001094 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7))
Leo Kim7d069722015-10-29 12:05:37 +09001095 auth_type = (u8)hif_drv->usr_conn_req.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001096
Leo Kim7d069722015-10-29 12:05:37 +09001097 PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n",
1098 hif_drv->usr_conn_req.auth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001099 PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
Leo Kimf8b17132015-10-28 15:59:34 +09001100 hif_drv->usr_conn_req.pu8ssid, pstrHostIFconnectAttr->ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001101
Leo Kimdaaf16b2015-10-12 16:55:44 +09001102 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
Leo Kim416d8322015-10-12 16:55:43 +09001103 strWIDList[u32WidsCount].type = WID_STR;
Leo Kimae4dfa52015-10-13 19:49:26 +09001104 strWIDList[u32WidsCount].size = 112;
Leo Kim900bb4a2015-10-12 16:55:46 +09001105 strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001106
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001107 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Leo Kim0626baa2015-10-15 13:25:13 +09001108 join_req_size = strWIDList[u32WidsCount].size;
1109 join_req = kmalloc(join_req_size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001110 }
Leo Kim91109e12015-10-19 18:26:13 +09001111 if (!strWIDList[u32WidsCount].val) {
Leo Kim31390ee2015-10-19 18:26:08 +09001112 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09001113 goto ERRORHANDLER;
1114 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001115
Leo Kim900bb4a2015-10-12 16:55:46 +09001116 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001117
Leo Kim91109e12015-10-19 18:26:13 +09001118 if (pstrHostIFconnectAttr->ssid) {
Leo Kim8b3c9fa2015-10-13 19:49:51 +09001119 memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len);
1120 pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0';
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001121 }
1122 pu8CurrByte += MAX_SSID_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001123 *(pu8CurrByte++) = INFRASTRUCTURE;
Leo Kimae4dfa52015-10-13 19:49:26 +09001124
Leo Kim0d1527e2015-10-13 19:49:58 +09001125 if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) {
1126 *(pu8CurrByte++) = pstrHostIFconnectAttr->ch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001127 } else {
1128 PRINT_ER("Channel out of range\n");
1129 *(pu8CurrByte++) = 0xFF;
1130 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001131 *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
1132 *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
1133 PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
1134
Leo Kim91109e12015-10-19 18:26:13 +09001135 if (pstrHostIFconnectAttr->bssid)
Leo Kim9254db02015-10-13 19:49:49 +09001136 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001137 pu8CurrByte += 6;
1138
Tony Choc0f52fb2015-10-20 17:10:46 +09001139 if (pstrHostIFconnectAttr->bssid)
1140 memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6);
1141 pu8CurrByte += 6;
1142
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001143 *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
1144 *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
1145 PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001146 *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
1147 PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
Leo Kimae4dfa52015-10-13 19:49:26 +09001148
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001149 memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001150 pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
1151
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001152 *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
1153 PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001154 *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
1155
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001156 *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
Leo Kimff069822015-10-29 12:05:26 +09001157 hif_drv->usr_conn_req.ht_capable = ptstrJoinBssParam->ht_capable;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001158
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001159 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
1160 PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001161 *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
1162 PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001163 *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
1164 PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
Leo Kimae4dfa52015-10-13 19:49:26 +09001165
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001166 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001167 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
1168
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001169 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001170 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
1171
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001172 memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001173 pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
1174
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001175 *(pu8CurrByte++) = REAL_JOIN_REQ;
Leo Kim7a8d51d2015-10-15 13:24:43 +09001176 *(pu8CurrByte++) = ptstrJoinBssParam->noa_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001177
Leo Kim7a8d51d2015-10-15 13:24:43 +09001178 if (ptstrJoinBssParam->noa_enabled) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001179 PRINT_D(HOSTINF_DBG, "NOA present\n");
1180
1181 *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
1182 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
1183 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
1184 *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
1185
Leo Kimd72b33c2015-10-15 13:24:44 +09001186 *(pu8CurrByte++) = ptstrJoinBssParam->opp_enabled;
Leo Kimcc179002015-10-15 13:24:47 +09001187 *(pu8CurrByte++) = ptstrJoinBssParam->idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001188
Leo Kimd72b33c2015-10-15 13:24:44 +09001189 if (ptstrJoinBssParam->opp_enabled)
Leo Kim99b66942015-10-15 13:24:45 +09001190 *(pu8CurrByte++) = ptstrJoinBssParam->ct_window;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001191
Leo Kimc21047e2015-10-15 13:24:46 +09001192 *(pu8CurrByte++) = ptstrJoinBssParam->cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001193
Leo Kim109e6ca2015-10-15 13:24:48 +09001194 memcpy(pu8CurrByte, ptstrJoinBssParam->duration, sizeof(ptstrJoinBssParam->duration));
1195 pu8CurrByte += sizeof(ptstrJoinBssParam->duration);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001196
Leo Kim1d8b76b2015-10-15 13:24:49 +09001197 memcpy(pu8CurrByte, ptstrJoinBssParam->interval, sizeof(ptstrJoinBssParam->interval));
1198 pu8CurrByte += sizeof(ptstrJoinBssParam->interval);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001199
Leo Kim4be55e22015-10-28 15:59:27 +09001200 memcpy(pu8CurrByte, ptstrJoinBssParam->start_time, sizeof(ptstrJoinBssParam->start_time));
1201 pu8CurrByte += sizeof(ptstrJoinBssParam->start_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001202 } else
1203 PRINT_D(HOSTINF_DBG, "NOA not present\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001204
Leo Kim900bb4a2015-10-12 16:55:46 +09001205 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001206 u32WidsCount++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001207
Leo Kimf7bbd9c2015-10-13 19:49:50 +09001208 if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) {
Leo Kim0626baa2015-10-15 13:25:13 +09001209 memcpy(join_req, pu8CurrByte, join_req_size);
Leo Kim870515c2015-10-15 13:25:15 +09001210 join_req_drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001211 }
1212
1213 PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
1214
Leo Kim91109e12015-10-19 18:26:13 +09001215 if (pstrHostIFconnectAttr->bssid) {
Leo Kim9254db02015-10-13 19:49:49 +09001216 memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001217
Leo Kim9254db02015-10-13 19:49:49 +09001218 PRINT_D(GENERIC_DBG, "save Bssid = %pM\n", pstrHostIFconnectAttr->bssid);
Alexander Kuleshov310a28f2015-09-04 00:48:14 +06001219 PRINT_D(GENERIC_DBG, "save bssid = %pM\n", u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001220 }
1221
Leo Kim31390ee2015-10-19 18:26:08 +09001222 result = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
Leo Kim8c8360b2015-10-19 18:26:12 +09001223 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09001224 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09001225 PRINT_ER("failed to send config packet\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001226 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09001227 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001228 } else {
1229 PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
Leo Kimb60005a2015-10-29 11:58:24 +09001230 hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001231 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001232
Leo Kim24db7132015-09-16 18:36:01 +09001233ERRORHANDLER:
Leo Kim31390ee2015-10-19 18:26:08 +09001234 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001235 tstrConnectInfo strConnectInfo;
1236
Leo Kim81a59502015-10-29 11:58:35 +09001237 del_timer(&hif_drv->connect_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001238
1239 PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
1240
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001241 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001242
Leo Kim91109e12015-10-19 18:26:13 +09001243 if (pstrHostIFconnectAttr->result) {
1244 if (pstrHostIFconnectAttr->bssid)
Leo Kim9254db02015-10-13 19:49:49 +09001245 memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001246
Leo Kim91109e12015-10-19 18:26:13 +09001247 if (pstrHostIFconnectAttr->ies) {
Leo Kimb59d5c52015-10-13 19:49:53 +09001248 strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->ies_len;
1249 strConnectInfo.pu8ReqIEs = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001250 memcpy(strConnectInfo.pu8ReqIEs,
Leo Kim8c8360b2015-10-19 18:26:12 +09001251 pstrHostIFconnectAttr->ies,
1252 pstrHostIFconnectAttr->ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001253 }
1254
Leo Kim6abcc112015-10-13 19:49:55 +09001255 pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001256 &strConnectInfo,
1257 MAC_DISCONNECTED,
1258 NULL,
Leo Kim8f38db82015-10-13 19:49:56 +09001259 pstrHostIFconnectAttr->arg);
Leo Kimb60005a2015-10-29 11:58:24 +09001260 hif_drv->hif_state = HOST_IF_IDLE;
Shraddha Barke95f840f2015-10-14 07:29:19 +05301261 kfree(strConnectInfo.pu8ReqIEs);
1262 strConnectInfo.pu8ReqIEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001263
1264 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001265 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001266 }
1267 }
1268
1269 PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
Shraddha Barke95f840f2015-10-14 07:29:19 +05301270 kfree(pstrHostIFconnectAttr->bssid);
1271 pstrHostIFconnectAttr->bssid = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001272
Shraddha Barke95f840f2015-10-14 07:29:19 +05301273 kfree(pstrHostIFconnectAttr->ssid);
1274 pstrHostIFconnectAttr->ssid = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001275
Shraddha Barke95f840f2015-10-14 07:29:19 +05301276 kfree(pstrHostIFconnectAttr->ies);
1277 pstrHostIFconnectAttr->ies = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001278
Shraddha Barke95f840f2015-10-14 07:29:19 +05301279 kfree(pu8CurrByte);
Leo Kim31390ee2015-10-19 18:26:08 +09001280 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001281}
1282
Tony Choa4ab1ad2015-10-12 16:56:05 +09001283static s32 Handle_FlushConnect(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001284{
Leo Kim31390ee2015-10-19 18:26:08 +09001285 s32 result = 0;
Leo Kime9e0c262015-10-12 16:55:41 +09001286 struct wid strWIDList[5];
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001287 u32 u32WidsCount = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001288 u8 *pu8CurrByte = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001289
Leo Kimdaaf16b2015-10-12 16:55:44 +09001290 strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE;
Leo Kim416d8322015-10-12 16:55:43 +09001291 strWIDList[u32WidsCount].type = WID_BIN_DATA;
Leo Kim48ce2462015-10-15 13:25:10 +09001292 strWIDList[u32WidsCount].val = info_element;
Leo Kimdfef7b82015-10-15 13:25:14 +09001293 strWIDList[u32WidsCount].size = info_element_size;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001294 u32WidsCount++;
1295
Leo Kimdaaf16b2015-10-12 16:55:44 +09001296 strWIDList[u32WidsCount].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001297 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001298 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim1bd9d442015-10-15 13:25:11 +09001299 strWIDList[u32WidsCount].val = (s8 *)(&(mode_11i));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001300 u32WidsCount++;
1301
Leo Kimdaaf16b2015-10-12 16:55:44 +09001302 strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001303 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001304 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kimfba49892015-10-15 13:25:12 +09001305 strWIDList[u32WidsCount].val = (s8 *)(&auth_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001306 u32WidsCount++;
1307
Leo Kimdaaf16b2015-10-12 16:55:44 +09001308 strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED;
Leo Kim416d8322015-10-12 16:55:43 +09001309 strWIDList[u32WidsCount].type = WID_STR;
Leo Kim0626baa2015-10-15 13:25:13 +09001310 strWIDList[u32WidsCount].size = join_req_size;
Leo Kim044a64102015-10-15 13:25:09 +09001311 strWIDList[u32WidsCount].val = (s8 *)join_req;
Leo Kim900bb4a2015-10-12 16:55:46 +09001312 pu8CurrByte = strWIDList[u32WidsCount].val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001313
1314 pu8CurrByte += FLUSHED_BYTE_POS;
1315 *(pu8CurrByte) = FLUSHED_JOIN_REQ;
1316
1317 u32WidsCount++;
1318
Leo Kim31390ee2015-10-19 18:26:08 +09001319 result = send_config_pkt(SET_CFG, strWIDList, u32WidsCount,
Leo Kim8c8360b2015-10-19 18:26:12 +09001320 get_id_from_handler(join_req_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09001321 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09001322 PRINT_ER("failed to send config packet\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001323 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001324 }
1325
Leo Kim31390ee2015-10-19 18:26:08 +09001326 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001327}
1328
Tony Choa4ab1ad2015-10-12 16:56:05 +09001329static s32 Handle_ConnectTimeout(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001330{
Leo Kim31390ee2015-10-19 18:26:08 +09001331 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001332 tstrConnectInfo strConnectInfo;
Leo Kim45102f82015-10-28 15:59:28 +09001333 struct wid wid;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001334 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001335
Tony Choa4ab1ad2015-10-12 16:56:05 +09001336 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001337 PRINT_ER("Driver handler is NULL\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001338 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001339 }
1340
Leo Kimb60005a2015-10-29 11:58:24 +09001341 hif_drv->hif_state = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001342
Leo Kimca8540e42015-10-15 13:25:00 +09001343 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001344
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001345 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001346
Leo Kim33bfb192015-10-29 11:58:56 +09001347 if (hif_drv->usr_conn_req.conn_result) {
Leo Kimf8b17132015-10-28 15:59:34 +09001348 if (hif_drv->usr_conn_req.pu8bssid) {
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001349 memcpy(strConnectInfo.au8bssid,
Leo Kimf8b17132015-10-28 15:59:34 +09001350 hif_drv->usr_conn_req.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001351 }
1352
Leo Kima3b2f4b2015-10-29 11:58:54 +09001353 if (hif_drv->usr_conn_req.ies) {
Leo Kim331ed082015-10-29 11:58:55 +09001354 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len;
1355 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001356 memcpy(strConnectInfo.pu8ReqIEs,
Leo Kima3b2f4b2015-10-29 11:58:54 +09001357 hif_drv->usr_conn_req.ies,
Leo Kim331ed082015-10-29 11:58:55 +09001358 hif_drv->usr_conn_req.ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001359 }
1360
Leo Kim33bfb192015-10-29 11:58:56 +09001361 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1362 &strConnectInfo,
1363 MAC_DISCONNECTED,
1364 NULL,
Leo Kim73abaa42015-10-29 12:05:27 +09001365 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001366
Shraddha Barke95f840f2015-10-14 07:29:19 +05301367 kfree(strConnectInfo.pu8ReqIEs);
1368 strConnectInfo.pu8ReqIEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001369 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001370 PRINT_ER("Connect callback function pointer is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001371 }
1372
Leo Kim45102f82015-10-28 15:59:28 +09001373 wid.id = (u16)WID_DISCONNECT;
1374 wid.type = WID_CHAR;
1375 wid.val = (s8 *)&u16DummyReasonCode;
1376 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001377
1378 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1379
Leo Kim45102f82015-10-28 15:59:28 +09001380 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001381 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09001382 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001383 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001384
Leo Kim74ab5e42015-10-29 11:58:53 +09001385 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09001386 kfree(hif_drv->usr_conn_req.pu8ssid);
1387 kfree(hif_drv->usr_conn_req.pu8bssid);
Leo Kim331ed082015-10-29 11:58:55 +09001388 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001389 kfree(hif_drv->usr_conn_req.ies);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001390
Shraddha Barke281dd5a2015-10-05 17:00:33 +05301391 eth_zero_addr(u8ConnectedSSID);
Leo Kimae4dfa52015-10-13 19:49:26 +09001392
Leo Kim91109e12015-10-19 18:26:13 +09001393 if (join_req && join_req_drv == hif_drv) {
Leo Kim044a64102015-10-15 13:25:09 +09001394 kfree(join_req);
1395 join_req = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001396 }
Leo Kim48ce2462015-10-15 13:25:10 +09001397
Leo Kim91109e12015-10-19 18:26:13 +09001398 if (info_element && join_req_drv == hif_drv) {
Leo Kim48ce2462015-10-15 13:25:10 +09001399 kfree(info_element);
1400 info_element = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001401 }
1402
Leo Kim31390ee2015-10-19 18:26:08 +09001403 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001404}
1405
Tony Choa4ab1ad2015-10-12 16:56:05 +09001406static s32 Handle_RcvdNtwrkInfo(struct host_if_drv *hif_drv,
Tony Cho3bbd59f2015-09-21 12:16:38 +09001407 struct rcvd_net_info *pstrRcvdNetworkInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001408{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001409 u32 i;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001410 bool bNewNtwrkFound;
Leo Kim31390ee2015-10-19 18:26:08 +09001411 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001412 tstrNetworkInfo *pstrNetworkInfo = NULL;
1413 void *pJoinParams = NULL;
1414
Dean Lee72ed4dc2015-06-12 14:11:44 +09001415 bNewNtwrkFound = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001416 PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
1417
Leo Kimbc801852015-10-29 11:58:50 +09001418 if (hif_drv->usr_scan_req.scan_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001419 PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
Leo Kimb021b802015-10-13 20:02:10 +09001420 parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo);
Leo Kim91109e12015-10-19 18:26:13 +09001421 if ((!pstrNetworkInfo) ||
Leo Kimbc801852015-10-29 11:58:50 +09001422 (!hif_drv->usr_scan_req.scan_result)) {
Leo Kim24db7132015-09-16 18:36:01 +09001423 PRINT_ER("driver is null\n");
Leo Kim31390ee2015-10-19 18:26:08 +09001424 result = -EINVAL;
Leo Kim24db7132015-09-16 18:36:01 +09001425 goto done;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001426 }
1427
Leo Kimf79756e2015-10-29 12:05:36 +09001428 for (i = 0; i < hif_drv->usr_scan_req.rcvd_ch_cnt; i++) {
Leo Kimaf973f32015-10-29 11:58:52 +09001429 if ((hif_drv->usr_scan_req.net_info[i].au8bssid) &&
Leo Kim91109e12015-10-19 18:26:13 +09001430 (pstrNetworkInfo->au8bssid)) {
Leo Kimaf973f32015-10-29 11:58:52 +09001431 if (memcmp(hif_drv->usr_scan_req.net_info[i].au8bssid,
Leo Kim8c8360b2015-10-19 18:26:12 +09001432 pstrNetworkInfo->au8bssid, 6) == 0) {
Leo Kimaf973f32015-10-29 11:58:52 +09001433 if (pstrNetworkInfo->s8rssi <= hif_drv->usr_scan_req.net_info[i].s8rssi) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001434 PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
1435 goto done;
1436 } else {
Leo Kimaf973f32015-10-29 11:58:52 +09001437 hif_drv->usr_scan_req.net_info[i].s8rssi = pstrNetworkInfo->s8rssi;
Dean Lee72ed4dc2015-06-12 14:11:44 +09001438 bNewNtwrkFound = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001439 break;
1440 }
1441 }
1442 }
1443 }
1444
Punit Vara047e6642015-10-25 04:01:25 +05301445 if (bNewNtwrkFound) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001446 PRINT_D(HOSTINF_DBG, "New network found\n");
1447
Leo Kimf79756e2015-10-29 12:05:36 +09001448 if (hif_drv->usr_scan_req.rcvd_ch_cnt < MAX_NUM_SCANNED_NETWORKS) {
1449 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 +09001450
Leo Kimf79756e2015-10-29 12:05:36 +09001451 if (hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].au8bssid &&
Leo Kim91109e12015-10-19 18:26:13 +09001452 pstrNetworkInfo->au8bssid) {
Leo Kimf79756e2015-10-29 12:05:36 +09001453 memcpy(hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].au8bssid,
Leo Kim8c8360b2015-10-19 18:26:12 +09001454 pstrNetworkInfo->au8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001455
Leo Kimf79756e2015-10-29 12:05:36 +09001456 hif_drv->usr_scan_req.rcvd_ch_cnt++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001457
Dean Lee72ed4dc2015-06-12 14:11:44 +09001458 pstrNetworkInfo->bNewNetwork = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001459 pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001460
Leo Kimbc801852015-10-29 11:58:50 +09001461 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
Leo Kim66eaea32015-10-29 11:58:51 +09001462 hif_drv->usr_scan_req.arg,
Leo Kimbc801852015-10-29 11:58:50 +09001463 pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001464 }
1465 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001466 PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001467 }
1468 } else {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001469 pstrNetworkInfo->bNewNetwork = false;
Leo Kimbc801852015-10-29 11:58:50 +09001470 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
Leo Kim66eaea32015-10-29 11:58:51 +09001471 hif_drv->usr_scan_req.arg, NULL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001472 }
1473 }
1474
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001475done:
Shraddha Barke95f840f2015-10-14 07:29:19 +05301476 kfree(pstrRcvdNetworkInfo->buffer);
1477 pstrRcvdNetworkInfo->buffer = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001478
Leo Kim91109e12015-10-19 18:26:13 +09001479 if (pstrNetworkInfo) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001480 DeallocateNetworkInfo(pstrNetworkInfo);
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09001481 pstrNetworkInfo = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001482 }
1483
Leo Kim31390ee2015-10-19 18:26:08 +09001484 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001485}
1486
Tony Choa4ab1ad2015-10-12 16:56:05 +09001487static s32 Handle_RcvdGnrlAsyncInfo(struct host_if_drv *hif_drv,
Tony Chof23a9ea2015-09-21 12:16:39 +09001488 struct rcvd_async_info *pstrRcvdGnrlAsyncInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001489{
Leo Kim31390ee2015-10-19 18:26:08 +09001490 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001491 u8 u8MsgType = 0;
1492 u8 u8MsgID = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001493 u16 u16MsgLen = 0;
1494 u16 u16WidID = (u16)WID_NIL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001495 u8 u8WidLen = 0;
1496 u8 u8MacStatus;
1497 u8 u8MacStatusReasonCode;
1498 u8 u8MacStatusAdditionalInfo;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001499 tstrConnectInfo strConnectInfo;
1500 tstrDisconnectNotifInfo strDisconnectNotifInfo;
Leo Kime6e12662015-09-16 18:36:03 +09001501 s32 s32Err = 0;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02001502
Tony Choa4ab1ad2015-10-12 16:56:05 +09001503 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001504 PRINT_ER("Driver handler is NULL\n");
Leo Kim234837d2015-09-22 14:34:43 +09001505 return -ENODEV;
1506 }
Leo Kimb60005a2015-10-29 11:58:24 +09001507 PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n",
1508 hif_drv->hif_state, pstrRcvdGnrlAsyncInfo->buffer[7]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001509
Leo Kimb60005a2015-10-29 11:58:24 +09001510 if ((hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
1511 (hif_drv->hif_state == HOST_IF_CONNECTED) ||
Leo Kimbc801852015-10-29 11:58:50 +09001512 hif_drv->usr_scan_req.scan_result) {
Leo Kim91109e12015-10-19 18:26:13 +09001513 if (!pstrRcvdGnrlAsyncInfo->buffer ||
Leo Kim33bfb192015-10-29 11:58:56 +09001514 !hif_drv->usr_conn_req.conn_result) {
Leo Kim24db7132015-09-16 18:36:01 +09001515 PRINT_ER("driver is null\n");
1516 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001517 }
1518
Leo Kim33722ac72015-10-13 19:50:00 +09001519 u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001520
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001521 if ('I' != u8MsgType) {
1522 PRINT_ER("Received Message format incorrect.\n");
Leo Kim24db7132015-09-16 18:36:01 +09001523 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001524 }
1525
Leo Kim33722ac72015-10-13 19:50:00 +09001526 u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1];
1527 u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]);
1528 u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]);
1529 u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6];
1530 u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7];
1531 u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8];
1532 u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001533 PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
Leo Kimb60005a2015-10-29 11:58:24 +09001534 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09001535 u32 u32RcvdAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001536 tstrConnectRespInfo *pstrConnectRespInfo = NULL;
1537
1538 PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
1539
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001540 memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001541
1542 if (u8MacStatus == MAC_CONNECTED) {
Leo Kima633c0b2015-10-15 13:24:59 +09001543 memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001544
Tony Choa4ab1ad2015-10-12 16:56:05 +09001545 host_int_get_assoc_res_info(hif_drv,
Leo Kima633c0b2015-10-15 13:24:59 +09001546 rcv_assoc_resp,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001547 MAX_ASSOC_RESP_FRAME_SIZE,
1548 &u32RcvdAssocRespInfoLen);
1549
1550 PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
1551
1552 if (u32RcvdAssocRespInfoLen != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001553 PRINT_D(HOSTINF_DBG, "Parsing association response\n");
Leo Kima633c0b2015-10-15 13:24:59 +09001554 s32Err = ParseAssocRespInfo(rcv_assoc_resp, u32RcvdAssocRespInfoLen,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001555 &pstrConnectRespInfo);
1556 if (s32Err) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001557 PRINT_ER("ParseAssocRespInfo() returned error %d\n", s32Err);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001558 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001559 strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
1560
1561 if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
1562 PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
Leo Kim91109e12015-10-19 18:26:13 +09001563 if (pstrConnectRespInfo->pu8RespIEs) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001564 strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
Glen Leef3052582015-09-10 12:03:04 +09001565 strConnectInfo.pu8RespIEs = kmalloc(pstrConnectRespInfo->u16RespIEsLen, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001566 memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001567 pstrConnectRespInfo->u16RespIEsLen);
1568 }
1569 }
1570
Leo Kim91109e12015-10-19 18:26:13 +09001571 if (pstrConnectRespInfo) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001572 DeallocateAssocRespInfo(pstrConnectRespInfo);
1573 pstrConnectRespInfo = NULL;
1574 }
1575 }
1576 }
1577 }
1578
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001579 if ((u8MacStatus == MAC_CONNECTED) &&
1580 (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001581 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 +05301582 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001583
1584 } else if (u8MacStatus == MAC_DISCONNECTED) {
1585 PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
Shraddha Barke281dd5a2015-10-05 17:00:33 +05301586 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001587 }
1588
Leo Kimf8b17132015-10-28 15:59:34 +09001589 if (hif_drv->usr_conn_req.pu8bssid) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001590 PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
Leo Kimf8b17132015-10-28 15:59:34 +09001591 memcpy(strConnectInfo.au8bssid, hif_drv->usr_conn_req.pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001592
1593 if ((u8MacStatus == MAC_CONNECTED) &&
1594 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Leo Kim2a4eded2015-10-29 11:58:25 +09001595 memcpy(hif_drv->assoc_bssid,
Leo Kimf8b17132015-10-28 15:59:34 +09001596 hif_drv->usr_conn_req.pu8bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001597 }
1598 }
1599
Leo Kima3b2f4b2015-10-29 11:58:54 +09001600 if (hif_drv->usr_conn_req.ies) {
Leo Kim331ed082015-10-29 11:58:55 +09001601 strConnectInfo.ReqIEsLen = hif_drv->usr_conn_req.ies_len;
1602 strConnectInfo.pu8ReqIEs = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09001603 memcpy(strConnectInfo.pu8ReqIEs,
Leo Kima3b2f4b2015-10-29 11:58:54 +09001604 hif_drv->usr_conn_req.ies,
Leo Kim331ed082015-10-29 11:58:55 +09001605 hif_drv->usr_conn_req.ies_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001606 }
1607
Leo Kim81a59502015-10-29 11:58:35 +09001608 del_timer(&hif_drv->connect_timer);
Leo Kim33bfb192015-10-29 11:58:56 +09001609 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP,
1610 &strConnectInfo,
1611 u8MacStatus,
1612 NULL,
Leo Kim73abaa42015-10-29 12:05:27 +09001613 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001614
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001615 if ((u8MacStatus == MAC_CONNECTED) &&
1616 (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09001617 host_int_set_power_mgmt(hif_drv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001618
1619 PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
Leo Kimb60005a2015-10-29 11:58:24 +09001620 hif_drv->hif_state = HOST_IF_CONNECTED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001621
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001622 PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
Dean Lee72ed4dc2015-06-12 14:11:44 +09001623 g_obtainingIP = true;
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07001624 mod_timer(&hDuringIpTimer,
1625 jiffies + msecs_to_jiffies(10000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001626 } else {
1627 PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
Leo Kimb60005a2015-10-29 11:58:24 +09001628 hif_drv->hif_state = HOST_IF_IDLE;
Leo Kimca8540e42015-10-15 13:25:00 +09001629 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001630 }
1631
Shraddha Barke95f840f2015-10-14 07:29:19 +05301632 kfree(strConnectInfo.pu8RespIEs);
1633 strConnectInfo.pu8RespIEs = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001634
Shraddha Barke95f840f2015-10-14 07:29:19 +05301635 kfree(strConnectInfo.pu8ReqIEs);
1636 strConnectInfo.pu8ReqIEs = NULL;
Leo Kim74ab5e42015-10-29 11:58:53 +09001637 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09001638 kfree(hif_drv->usr_conn_req.pu8ssid);
1639 kfree(hif_drv->usr_conn_req.pu8bssid);
Leo Kim331ed082015-10-29 11:58:55 +09001640 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001641 kfree(hif_drv->usr_conn_req.ies);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001642 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
Leo Kimb60005a2015-10-29 11:58:24 +09001643 (hif_drv->hif_state == HOST_IF_CONNECTED)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001644 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
1645
Chaehyun Lim2cc46832015-08-07 09:02:01 +09001646 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001647
Leo Kimbc801852015-10-29 11:58:50 +09001648 if (hif_drv->usr_scan_req.scan_result) {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001649 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >>\n\n");
Leo Kim13b313e2015-10-29 11:58:34 +09001650 del_timer(&hif_drv->scan_timer);
Tony Choa4ab1ad2015-10-12 16:56:05 +09001651 Handle_ScanDone((void *)hif_drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001652 }
1653
1654 strDisconnectNotifInfo.u16reason = 0;
1655 strDisconnectNotifInfo.ie = NULL;
1656 strDisconnectNotifInfo.ie_len = 0;
1657
Leo Kim33bfb192015-10-29 11:58:56 +09001658 if (hif_drv->usr_conn_req.conn_result) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09001659 g_obtainingIP = false;
Tony Choa4ab1ad2015-10-12 16:56:05 +09001660 host_int_set_power_mgmt(hif_drv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001661
Leo Kim33bfb192015-10-29 11:58:56 +09001662 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
1663 NULL,
1664 0,
1665 &strDisconnectNotifInfo,
Leo Kim73abaa42015-10-29 12:05:27 +09001666 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001667 } else {
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001668 PRINT_ER("Connect result callback function is NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001669 }
1670
Leo Kim2a4eded2015-10-29 11:58:25 +09001671 eth_zero_addr(hif_drv->assoc_bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001672
Leo Kim74ab5e42015-10-29 11:58:53 +09001673 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09001674 kfree(hif_drv->usr_conn_req.pu8ssid);
1675 kfree(hif_drv->usr_conn_req.pu8bssid);
Leo Kim331ed082015-10-29 11:58:55 +09001676 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09001677 kfree(hif_drv->usr_conn_req.ies);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001678
Leo Kim91109e12015-10-19 18:26:13 +09001679 if (join_req && join_req_drv == hif_drv) {
Leo Kim044a64102015-10-15 13:25:09 +09001680 kfree(join_req);
1681 join_req = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001682 }
Leo Kim48ce2462015-10-15 13:25:10 +09001683
Leo Kim91109e12015-10-19 18:26:13 +09001684 if (info_element && join_req_drv == hif_drv) {
Leo Kim48ce2462015-10-15 13:25:10 +09001685 kfree(info_element);
1686 info_element = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001687 }
1688
Leo Kimb60005a2015-10-29 11:58:24 +09001689 hif_drv->hif_state = HOST_IF_IDLE;
Leo Kimca8540e42015-10-15 13:25:00 +09001690 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001691
1692 } else if ((u8MacStatus == MAC_DISCONNECTED) &&
Leo Kimbc801852015-10-29 11:58:50 +09001693 (hif_drv->usr_scan_req.scan_result)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001694 PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02001695 PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >>\n\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09001696
Leo Kim13b313e2015-10-29 11:58:34 +09001697 del_timer(&hif_drv->scan_timer);
Leo Kimbc801852015-10-29 11:58:50 +09001698 if (hif_drv->usr_scan_req.scan_result)
Tony Choa4ab1ad2015-10-12 16:56:05 +09001699 Handle_ScanDone(hif_drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001700 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001701 }
1702
Shraddha Barke95f840f2015-10-14 07:29:19 +05301703 kfree(pstrRcvdGnrlAsyncInfo->buffer);
1704 pstrRcvdGnrlAsyncInfo->buffer = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001705
Leo Kim31390ee2015-10-19 18:26:08 +09001706 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001707}
1708
Tony Choa4ab1ad2015-10-12 16:56:05 +09001709static int Handle_Key(struct host_if_drv *hif_drv,
Tony Choc98387a2015-09-21 12:16:40 +09001710 struct key_attr *pstrHostIFkeyAttr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001711{
Leo Kim31390ee2015-10-19 18:26:08 +09001712 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09001713 struct wid wid;
Leo Kime9e0c262015-10-12 16:55:41 +09001714 struct wid strWIDList[5];
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09001715 u8 i;
1716 u8 *pu8keybuf;
Chaehyun Limca356ad2015-06-11 14:35:57 +09001717 s8 s8idxarray[1];
1718 s8 ret = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001719
Leo Kim8e9f4272015-10-13 19:49:27 +09001720 switch (pstrHostIFkeyAttr->type) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001721 case WEP:
1722
Leo Kim0d17e382015-10-13 19:49:28 +09001723 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001724 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Leo Kimbafaa692015-10-28 15:59:21 +09001725 PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", pstrHostIFkeyAttr->attr.wep.index);
Leo Kimdaaf16b2015-10-12 16:55:44 +09001726 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001727 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001728 strWIDList[0].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001729 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001730
Leo Kimdaaf16b2015-10-12 16:55:44 +09001731 strWIDList[1].id = WID_AUTH_TYPE;
Leo Kim416d8322015-10-12 16:55:43 +09001732 strWIDList[1].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001733 strWIDList[1].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001734 strWIDList[1].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001735
Leo Kimdaaf16b2015-10-12 16:55:44 +09001736 strWIDList[2].id = (u16)WID_KEY_ID;
Leo Kim416d8322015-10-12 16:55:43 +09001737 strWIDList[2].type = WID_CHAR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001738
Leo Kimbafaa692015-10-28 15:59:21 +09001739 strWIDList[2].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
Leo Kim2fd3e442015-10-12 16:55:45 +09001740 strWIDList[2].size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001741
Shraddha Barke543f5b12015-10-16 10:47:11 +05301742 pu8keybuf = kmemdup(pstrHostIFkeyAttr->attr.wep.key,
1743 pstrHostIFkeyAttr->attr.wep.key_len,
1744 GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001745
1746 if (pu8keybuf == NULL) {
1747 PRINT_ER("No buffer to send Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001748 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001749 }
1750
Leo Kim73b2e382015-10-13 19:49:29 +09001751 kfree(pstrHostIFkeyAttr->attr.wep.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001752
Leo Kimdaaf16b2015-10-12 16:55:44 +09001753 strWIDList[3].id = (u16)WID_WEP_KEY_VALUE;
Leo Kim416d8322015-10-12 16:55:43 +09001754 strWIDList[3].type = WID_STR;
Leo Kim73b2e382015-10-13 19:49:29 +09001755 strWIDList[3].size = pstrHostIFkeyAttr->attr.wep.key_len;
Leo Kim900bb4a2015-10-12 16:55:46 +09001756 strWIDList[3].val = (s8 *)pu8keybuf;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001757
Leo Kim31390ee2015-10-19 18:26:08 +09001758 result = send_config_pkt(SET_CFG, strWIDList, 4,
Leo Kim8c8360b2015-10-19 18:26:12 +09001759 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001760 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001761 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001762
Leo Kim0d17e382015-10-13 19:49:28 +09001763 if (pstrHostIFkeyAttr->action & ADDKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001764 PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
Leo Kim73b2e382015-10-13 19:49:29 +09001765 pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001766 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001767 PRINT_ER("No buffer to send Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001768 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001769 }
Leo Kim73b2e382015-10-13 19:49:29 +09001770 pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index;
1771 memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1);
1772 memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001773 pstrHostIFkeyAttr->attr.wep.key_len);
Leo Kim73b2e382015-10-13 19:49:29 +09001774 kfree(pstrHostIFkeyAttr->attr.wep.key);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001775
Leo Kim45102f82015-10-28 15:59:28 +09001776 wid.id = (u16)WID_ADD_WEP_KEY;
1777 wid.type = WID_STR;
1778 wid.val = (s8 *)pu8keybuf;
1779 wid.size = pstrHostIFkeyAttr->attr.wep.key_len + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001780
Leo Kim45102f82015-10-28 15:59:28 +09001781 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001782 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001783 kfree(pu8keybuf);
Leo Kim0d17e382015-10-13 19:49:28 +09001784 } else if (pstrHostIFkeyAttr->action & REMOVEKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001785 PRINT_D(HOSTINF_DBG, "Removing key\n");
Leo Kim45102f82015-10-28 15:59:28 +09001786 wid.id = (u16)WID_REMOVE_WEP_KEY;
1787 wid.type = WID_STR;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001788
Leo Kim73b2e382015-10-13 19:49:29 +09001789 s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index;
Leo Kim45102f82015-10-28 15:59:28 +09001790 wid.val = s8idxarray;
1791 wid.size = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001792
Leo Kim45102f82015-10-28 15:59:28 +09001793 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001794 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001795 } else {
Leo Kim45102f82015-10-28 15:59:28 +09001796 wid.id = (u16)WID_KEY_ID;
1797 wid.type = WID_CHAR;
1798 wid.val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index;
1799 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001800
1801 PRINT_D(HOSTINF_DBG, "Setting default key index\n");
1802
Leo Kim45102f82015-10-28 15:59:28 +09001803 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001804 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001805 }
Leo Kim9ea47132015-10-29 11:58:28 +09001806 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001807 break;
1808
Leo Kim5cd8f7a2015-10-29 12:05:34 +09001809 case WPA_RX_GTK:
Leo Kim0d17e382015-10-13 19:49:28 +09001810 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Shraddha Barkeb156f1e2015-10-13 23:07:00 +05301811 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001812 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001813 PRINT_ER("No buffer to send RxGTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001814 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001815 goto _WPARxGtk_end_case_;
1816 }
1817
Leo Kim91109e12015-10-19 18:26:13 +09001818 if (pstrHostIFkeyAttr->attr.wpa.seq)
Leo Kim0e74c002015-10-13 19:49:32 +09001819 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001820
Leo Kime2dfbac2015-10-13 19:49:34 +09001821 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
Leo Kim6acf2912015-10-13 19:49:35 +09001822 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001823 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001824 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001825
Leo Kimdaaf16b2015-10-12 16:55:44 +09001826 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001827 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001828 strWIDList[0].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001829 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001830
Leo Kimdaaf16b2015-10-12 16:55:44 +09001831 strWIDList[1].id = (u16)WID_ADD_RX_GTK;
Leo Kim416d8322015-10-12 16:55:43 +09001832 strWIDList[1].type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09001833 strWIDList[1].val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09001834 strWIDList[1].size = RX_MIC_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001835
Leo Kim31390ee2015-10-19 18:26:08 +09001836 result = send_config_pkt(SET_CFG, strWIDList, 2,
Leo Kim8c8360b2015-10-19 18:26:12 +09001837 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001838
Chaehyun Lim49188af2015-08-11 10:32:41 +09001839 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001840 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001841 }
1842
Leo Kim0d17e382015-10-13 19:49:28 +09001843 if (pstrHostIFkeyAttr->action & ADDKEY) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001844 PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
1845
Shraddha Barkeb156f1e2015-10-13 23:07:00 +05301846 pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001847 if (pu8keybuf == NULL) {
1848 PRINT_ER("No buffer to send RxGTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001849 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001850 goto _WPARxGtk_end_case_;
1851 }
1852
Leo Kimb60005a2015-10-29 11:58:24 +09001853 if (hif_drv->hif_state == HOST_IF_CONNECTED)
Leo Kim2a4eded2015-10-29 11:58:25 +09001854 memcpy(pu8keybuf, hif_drv->assoc_bssid, ETH_ALEN);
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05301855 else
Leo Kimb60005a2015-10-29 11:58:24 +09001856 PRINT_ER("Couldn't handle WPARxGtk while state is not HOST_IF_CONNECTED\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001857
Leo Kim0e74c002015-10-13 19:49:32 +09001858 memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8);
Leo Kime2dfbac2015-10-13 19:49:34 +09001859 memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1);
Leo Kim6acf2912015-10-13 19:49:35 +09001860 memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001861 memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001862 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001863
Leo Kim45102f82015-10-28 15:59:28 +09001864 wid.id = (u16)WID_ADD_RX_GTK;
1865 wid.type = WID_STR;
1866 wid.val = (s8 *)pu8keybuf;
1867 wid.size = RX_MIC_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001868
Leo Kim45102f82015-10-28 15:59:28 +09001869 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001870 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001871
Chaehyun Lim49188af2015-08-11 10:32:41 +09001872 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001873 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001874 }
1875_WPARxGtk_end_case_:
Leo Kim124968fc2015-10-13 19:49:30 +09001876 kfree(pstrHostIFkeyAttr->attr.wpa.key);
Leo Kim0e74c002015-10-13 19:49:32 +09001877 kfree(pstrHostIFkeyAttr->attr.wpa.seq);
Luis de Bethencourt90819872015-10-26 05:52:50 +00001878 if (ret)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001879 return ret;
1880
1881 break;
1882
Leo Kim2141fe32015-10-29 12:05:35 +09001883 case WPA_PTK:
Leo Kim0d17e382015-10-13 19:49:28 +09001884 if (pstrHostIFkeyAttr->action & ADDKEY_AP) {
Glen Leef3052582015-09-10 12:03:04 +09001885 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001886 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001887 PRINT_ER("No buffer to send PTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001888 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001889 goto _WPAPtk_end_case_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001890 }
1891
Leo Kim248080a2015-10-13 19:49:31 +09001892 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
Leo Kime2dfbac2015-10-13 19:49:34 +09001893 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1);
Leo Kim6acf2912015-10-13 19:49:35 +09001894 memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001895 memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001896 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001897
Leo Kimdaaf16b2015-10-12 16:55:44 +09001898 strWIDList[0].id = (u16)WID_11I_MODE;
Leo Kim416d8322015-10-12 16:55:43 +09001899 strWIDList[0].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09001900 strWIDList[0].size = sizeof(char);
Leo Kimbafaa692015-10-28 15:59:21 +09001901 strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001902
Leo Kimdaaf16b2015-10-12 16:55:44 +09001903 strWIDList[1].id = (u16)WID_ADD_PTK;
Leo Kim416d8322015-10-12 16:55:43 +09001904 strWIDList[1].type = WID_STR;
Leo Kim900bb4a2015-10-12 16:55:46 +09001905 strWIDList[1].val = (s8 *)pu8keybuf;
Leo Kim2fd3e442015-10-12 16:55:45 +09001906 strWIDList[1].size = PTK_KEY_MSG_LEN + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001907
Leo Kim31390ee2015-10-19 18:26:08 +09001908 result = send_config_pkt(SET_CFG, strWIDList, 2,
Leo Kim8c8360b2015-10-19 18:26:12 +09001909 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001910 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001911 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001912 }
Leo Kim0d17e382015-10-13 19:49:28 +09001913 if (pstrHostIFkeyAttr->action & ADDKEY) {
Glen Leef3052582015-09-10 12:03:04 +09001914 pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001915 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001916 PRINT_ER("No buffer to send PTK Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001917 ret = -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001918 goto _WPAPtk_end_case_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001919 }
1920
Leo Kim248080a2015-10-13 19:49:31 +09001921 memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6);
Leo Kim6acf2912015-10-13 19:49:35 +09001922 memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1);
Leo Kim124968fc2015-10-13 19:49:30 +09001923 memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key,
Leo Kim8c8360b2015-10-19 18:26:12 +09001924 pstrHostIFkeyAttr->attr.wpa.key_len);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001925
Leo Kim45102f82015-10-28 15:59:28 +09001926 wid.id = (u16)WID_ADD_PTK;
1927 wid.type = WID_STR;
1928 wid.val = (s8 *)pu8keybuf;
1929 wid.size = PTK_KEY_MSG_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001930
Leo Kim45102f82015-10-28 15:59:28 +09001931 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001932 get_id_from_handler(hif_drv));
Chaehyun Lim49188af2015-08-11 10:32:41 +09001933 kfree(pu8keybuf);
Leo Kim9ea47132015-10-29 11:58:28 +09001934 up(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001935 }
1936
1937_WPAPtk_end_case_:
Leo Kim124968fc2015-10-13 19:49:30 +09001938 kfree(pstrHostIFkeyAttr->attr.wpa.key);
Luis de Bethencourt90819872015-10-26 05:52:50 +00001939 if (ret)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001940 return ret;
1941
1942 break;
1943
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001944 case PMKSA:
1945
1946 PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
1947
Leo Kim73b2e382015-10-13 19:49:29 +09001948 pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09001949 if (!pu8keybuf) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001950 PRINT_ER("No buffer to send PMKSA Key\n");
Luis de Bethencourt90819872015-10-26 05:52:50 +00001951 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001952 }
1953
Leo Kim73b2e382015-10-13 19:49:29 +09001954 pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001955
Leo Kim73b2e382015-10-13 19:49:29 +09001956 for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) {
1957 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN);
1958 memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001959 }
1960
Leo Kim45102f82015-10-28 15:59:28 +09001961 wid.id = (u16)WID_PMKID_INFO;
1962 wid.type = WID_STR;
1963 wid.val = (s8 *)pu8keybuf;
1964 wid.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001965
Leo Kim45102f82015-10-28 15:59:28 +09001966 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001967 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001968
Chaehyun Lim49188af2015-08-11 10:32:41 +09001969 kfree(pu8keybuf);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001970 break;
1971 }
1972
Leo Kim31390ee2015-10-19 18:26:08 +09001973 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001974 PRINT_ER("Failed to send key config packet\n");
1975
Leo Kim31390ee2015-10-19 18:26:08 +09001976 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001977}
1978
Tony Choa4ab1ad2015-10-12 16:56:05 +09001979static void Handle_Disconnect(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001980{
Leo Kim45102f82015-10-28 15:59:28 +09001981 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001982
Leo Kim31390ee2015-10-19 18:26:08 +09001983 s32 result = 0;
Chaehyun Limd85f5322015-06-11 14:35:54 +09001984 u16 u16DummyReasonCode = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001985
Leo Kim45102f82015-10-28 15:59:28 +09001986 wid.id = (u16)WID_DISCONNECT;
1987 wid.type = WID_CHAR;
1988 wid.val = (s8 *)&u16DummyReasonCode;
1989 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001990
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001991 PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
1992
Dean Lee72ed4dc2015-06-12 14:11:44 +09001993 g_obtainingIP = false;
Tony Choa4ab1ad2015-10-12 16:56:05 +09001994 host_int_set_power_mgmt(hif_drv, 0, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001995
Shraddha Barke281dd5a2015-10-05 17:00:33 +05301996 eth_zero_addr(u8ConnectedSSID);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09001997
Leo Kim45102f82015-10-28 15:59:28 +09001998 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09001999 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002000
Leo Kim31390ee2015-10-19 18:26:08 +09002001 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002002 PRINT_ER("Failed to send dissconect config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002003 } else {
2004 tstrDisconnectNotifInfo strDisconnectNotifInfo;
2005
Chaehyun Lim2cc46832015-08-07 09:02:01 +09002006 memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002007
2008 strDisconnectNotifInfo.u16reason = 0;
2009 strDisconnectNotifInfo.ie = NULL;
2010 strDisconnectNotifInfo.ie_len = 0;
2011
Leo Kimbc801852015-10-29 11:58:50 +09002012 if (hif_drv->usr_scan_req.scan_result) {
Leo Kim13b313e2015-10-29 11:58:34 +09002013 del_timer(&hif_drv->scan_timer);
Leo Kim33bfb192015-10-29 11:58:56 +09002014 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED,
2015 NULL,
2016 hif_drv->usr_scan_req.arg,
2017 NULL);
Leo Kimbc801852015-10-29 11:58:50 +09002018 hif_drv->usr_scan_req.scan_result = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002019 }
2020
Leo Kim33bfb192015-10-29 11:58:56 +09002021 if (hif_drv->usr_conn_req.conn_result) {
Leo Kimb60005a2015-10-29 11:58:24 +09002022 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002023 PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
Leo Kim81a59502015-10-29 11:58:35 +09002024 del_timer(&hif_drv->connect_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002025 }
2026
Leo Kim33bfb192015-10-29 11:58:56 +09002027 hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF,
2028 NULL,
2029 0,
2030 &strDisconnectNotifInfo,
Leo Kim73abaa42015-10-29 12:05:27 +09002031 hif_drv->usr_conn_req.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002032 } else {
Leo Kim33bfb192015-10-29 11:58:56 +09002033 PRINT_ER("usr_conn_req.conn_result = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002034 }
2035
Leo Kimca8540e42015-10-15 13:25:00 +09002036 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002037
Leo Kimb60005a2015-10-29 11:58:24 +09002038 hif_drv->hif_state = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002039
Leo Kim2a4eded2015-10-29 11:58:25 +09002040 eth_zero_addr(hif_drv->assoc_bssid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002041
Leo Kim74ab5e42015-10-29 11:58:53 +09002042 hif_drv->usr_conn_req.ssid_len = 0;
Leo Kimf8b17132015-10-28 15:59:34 +09002043 kfree(hif_drv->usr_conn_req.pu8ssid);
2044 kfree(hif_drv->usr_conn_req.pu8bssid);
Leo Kim331ed082015-10-29 11:58:55 +09002045 hif_drv->usr_conn_req.ies_len = 0;
Leo Kima3b2f4b2015-10-29 11:58:54 +09002046 kfree(hif_drv->usr_conn_req.ies);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002047
Leo Kim91109e12015-10-19 18:26:13 +09002048 if (join_req && join_req_drv == hif_drv) {
Leo Kim044a64102015-10-15 13:25:09 +09002049 kfree(join_req);
2050 join_req = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002051 }
Leo Kim48ce2462015-10-15 13:25:10 +09002052
Leo Kim91109e12015-10-19 18:26:13 +09002053 if (info_element && join_req_drv == hif_drv) {
Leo Kim48ce2462015-10-15 13:25:10 +09002054 kfree(info_element);
2055 info_element = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002056 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002057 }
2058
Leo Kime55e4962015-10-29 11:58:29 +09002059 up(&hif_drv->sem_test_disconn_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002060}
2061
Tony Choa4ab1ad2015-10-12 16:56:05 +09002062void resolve_disconnect_aberration(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002063{
Tony Choa4ab1ad2015-10-12 16:56:05 +09002064 if (!hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002065 return;
Leo Kimb60005a2015-10-29 11:58:24 +09002066 if ((hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) ||
2067 (hif_drv->hif_state == HOST_IF_CONNECTING)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002068 PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
Tony Choa4ab1ad2015-10-12 16:56:05 +09002069 host_int_disconnect(hif_drv, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002070 }
2071}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002072
Tony Choa4ab1ad2015-10-12 16:56:05 +09002073static s32 Handle_GetChnl(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002074{
Leo Kim31390ee2015-10-19 18:26:08 +09002075 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002076 struct wid wid;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002077
Leo Kim45102f82015-10-28 15:59:28 +09002078 wid.id = (u16)WID_CURRENT_CHANNEL;
2079 wid.type = WID_CHAR;
2080 wid.val = (s8 *)&ch_no;
2081 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002082
2083 PRINT_D(HOSTINF_DBG, "Getting channel value\n");
2084
Leo Kim45102f82015-10-28 15:59:28 +09002085 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002086 get_id_from_handler(hif_drv));
Leo Kimae4dfa52015-10-13 19:49:26 +09002087
Leo Kim31390ee2015-10-19 18:26:08 +09002088 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002089 PRINT_ER("Failed to get channel number\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002090 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002091 }
2092
Leo Kim4ea90002015-10-29 11:58:32 +09002093 up(&hif_drv->sem_get_chnl);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002094
Leo Kim31390ee2015-10-19 18:26:08 +09002095 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002096}
2097
Tony Choa4ab1ad2015-10-12 16:56:05 +09002098static void Handle_GetRssi(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002099{
Leo Kim31390ee2015-10-19 18:26:08 +09002100 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002101 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002102
Leo Kim45102f82015-10-28 15:59:28 +09002103 wid.id = (u16)WID_RSSI;
2104 wid.type = WID_CHAR;
2105 wid.val = &rssi;
2106 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002107
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002108 PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
2109
Leo Kim45102f82015-10-28 15:59:28 +09002110 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002111 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002112 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002113 PRINT_ER("Failed to get RSSI value\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002114 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002115 }
2116
Leo Kim7e111f92015-10-29 11:58:30 +09002117 up(&hif_drv->sem_get_rssi);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002118}
2119
Tony Choa4ab1ad2015-10-12 16:56:05 +09002120static void Handle_GetLinkspeed(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002121{
Leo Kim31390ee2015-10-19 18:26:08 +09002122 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002123 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002124
Leo Kim75327a02015-10-15 13:25:02 +09002125 link_speed = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002126
Leo Kim45102f82015-10-28 15:59:28 +09002127 wid.id = (u16)WID_LINKSPEED;
2128 wid.type = WID_CHAR;
2129 wid.val = &link_speed;
2130 wid.size = sizeof(char);
Leo Kimae4dfa52015-10-13 19:49:26 +09002131
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002132 PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
2133
Leo Kim45102f82015-10-28 15:59:28 +09002134 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002135 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002136 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002137 PRINT_ER("Failed to get LINKSPEED value\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002138 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002139 }
2140
Leo Kimbc34da62015-10-29 11:58:31 +09002141 up(&hif_drv->sem_get_link_speed);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002142}
2143
Tony Choa4ab1ad2015-10-12 16:56:05 +09002144s32 Handle_GetStatistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002145{
Leo Kime9e0c262015-10-12 16:55:41 +09002146 struct wid strWIDList[5];
Leo Kim31390ee2015-10-19 18:26:08 +09002147 u32 u32WidsCount = 0, result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002148
Leo Kimdaaf16b2015-10-12 16:55:44 +09002149 strWIDList[u32WidsCount].id = WID_LINKSPEED;
Leo Kim416d8322015-10-12 16:55:43 +09002150 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002151 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim5babeec2015-10-29 12:05:29 +09002152 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->link_speed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002153 u32WidsCount++;
2154
Leo Kimdaaf16b2015-10-12 16:55:44 +09002155 strWIDList[u32WidsCount].id = WID_RSSI;
Leo Kim416d8322015-10-12 16:55:43 +09002156 strWIDList[u32WidsCount].type = WID_CHAR;
Leo Kim2fd3e442015-10-12 16:55:45 +09002157 strWIDList[u32WidsCount].size = sizeof(char);
Leo Kim00c8dfc2015-10-29 12:05:30 +09002158 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rssi;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002159 u32WidsCount++;
2160
Leo Kimdaaf16b2015-10-12 16:55:44 +09002161 strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002162 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002163 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim7e84ff42015-10-29 12:05:31 +09002164 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002165 u32WidsCount++;
2166
Leo Kimdaaf16b2015-10-12 16:55:44 +09002167 strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002168 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002169 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim9b992742015-10-29 12:05:32 +09002170 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rx_cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002171 u32WidsCount++;
2172
Leo Kimdaaf16b2015-10-12 16:55:44 +09002173 strWIDList[u32WidsCount].id = WID_FAILED_COUNT;
Leo Kim416d8322015-10-12 16:55:43 +09002174 strWIDList[u32WidsCount].type = WID_INT;
Leo Kim2fd3e442015-10-12 16:55:45 +09002175 strWIDList[u32WidsCount].size = sizeof(u32);
Leo Kim54160372015-10-29 12:05:33 +09002176 strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_fail_cnt;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002177 u32WidsCount++;
2178
Leo Kim31390ee2015-10-19 18:26:08 +09002179 result = send_config_pkt(GET_CFG, strWIDList, u32WidsCount,
Leo Kim8c8360b2015-10-19 18:26:12 +09002180 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002181
Leo Kim31390ee2015-10-19 18:26:08 +09002182 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002183 PRINT_ER("Failed to send scan paramters config packet\n");
Leo Kim24db7132015-09-16 18:36:01 +09002184
Leo Kim2d25af82015-10-15 13:24:56 +09002185 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002186 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002187}
2188
Tony Choa4ab1ad2015-10-12 16:56:05 +09002189static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,
Tony Cho3d1eac02015-09-21 12:16:49 +09002190 struct sta_inactive_t *strHostIfStaInactiveT)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002191{
Leo Kim31390ee2015-10-19 18:26:08 +09002192 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002193 u8 *stamac;
Leo Kim45102f82015-10-28 15:59:28 +09002194 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002195
Leo Kim45102f82015-10-28 15:59:28 +09002196 wid.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME;
2197 wid.type = WID_STR;
2198 wid.size = ETH_ALEN;
2199 wid.val = kmalloc(wid.size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002200
Leo Kim45102f82015-10-28 15:59:28 +09002201 stamac = wid.val;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09002202 memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002203
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002204 PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
2205
Leo Kim45102f82015-10-28 15:59:28 +09002206 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002207 get_id_from_handler(hif_drv));
Leo Kimae4dfa52015-10-13 19:49:26 +09002208
Leo Kim31390ee2015-10-19 18:26:08 +09002209 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002210 PRINT_ER("Failed to SET incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09002211 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002212 }
2213
Leo Kim45102f82015-10-28 15:59:28 +09002214 wid.id = (u16)WID_GET_INACTIVE_TIME;
2215 wid.type = WID_INT;
2216 wid.val = (s8 *)&inactive_time;
2217 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002218
Leo Kim45102f82015-10-28 15:59:28 +09002219 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002220 get_id_from_handler(hif_drv));
Leo Kimae4dfa52015-10-13 19:49:26 +09002221
Leo Kim31390ee2015-10-19 18:26:08 +09002222 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002223 PRINT_ER("Failed to get incative time\n");
Leo Kim24db7132015-09-16 18:36:01 +09002224 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002225 }
2226
Leo Kimad269062015-10-15 13:25:06 +09002227 PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", inactive_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002228
Leo Kim569a3c62015-10-29 11:58:33 +09002229 up(&hif_drv->sem_inactive_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002230
Leo Kim31390ee2015-10-19 18:26:08 +09002231 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002232}
2233
Tony Choa4ab1ad2015-10-12 16:56:05 +09002234static void Handle_AddBeacon(struct host_if_drv *hif_drv,
Tony Cho7f33fec2015-09-30 18:44:30 +09002235 struct beacon_attr *pstrSetBeaconParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002236{
Leo Kim31390ee2015-10-19 18:26:08 +09002237 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002238 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002239 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002240
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002241 PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
2242
Leo Kim45102f82015-10-28 15:59:28 +09002243 wid.id = (u16)WID_ADD_BEACON;
2244 wid.type = WID_BIN;
2245 wid.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16;
2246 wid.val = kmalloc(wid.size, GFP_KERNEL);
2247 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002248 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002249
Leo Kim45102f82015-10-28 15:59:28 +09002250 pu8CurrByte = wid.val;
Leo Kim12262dd2015-10-13 19:50:03 +09002251 *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF);
2252 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF);
2253 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF);
2254 *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002255
Leo Kime76ab772015-10-13 19:50:04 +09002256 *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF);
2257 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF);
2258 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF);
2259 *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002260
Leo Kim51c66182015-10-13 19:50:05 +09002261 *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF);
2262 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF);
2263 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF);
2264 *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002265
Leo Kim8ce528b2015-10-13 19:50:06 +09002266 memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len);
Leo Kim51c66182015-10-13 19:50:05 +09002267 pu8CurrByte += pstrSetBeaconParam->head_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002268
Leo Kim030c57e2015-10-13 19:50:07 +09002269 *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF);
2270 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF);
2271 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF);
2272 *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002273
Leo Kim7dbcb6d32015-10-13 19:50:08 +09002274 if (pstrSetBeaconParam->tail > 0)
2275 memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len);
Leo Kim030c57e2015-10-13 19:50:07 +09002276 pu8CurrByte += pstrSetBeaconParam->tail_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002277
Leo Kim45102f82015-10-28 15:59:28 +09002278 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002279 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002280 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002281 PRINT_ER("Failed to send add beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002282
Leo Kim24db7132015-09-16 18:36:01 +09002283ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002284 kfree(wid.val);
Leo Kim8ce528b2015-10-13 19:50:06 +09002285 kfree(pstrSetBeaconParam->head);
Leo Kim7dbcb6d32015-10-13 19:50:08 +09002286 kfree(pstrSetBeaconParam->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002287}
2288
Tony Choa4ab1ad2015-10-12 16:56:05 +09002289static void Handle_DelBeacon(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002290{
Leo Kim31390ee2015-10-19 18:26:08 +09002291 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002292 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002293 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002294
Leo Kim45102f82015-10-28 15:59:28 +09002295 wid.id = (u16)WID_DEL_BEACON;
2296 wid.type = WID_CHAR;
2297 wid.size = sizeof(char);
2298 wid.val = &del_beacon;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002299
Leo Kim45102f82015-10-28 15:59:28 +09002300 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002301 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002302
Leo Kim45102f82015-10-28 15:59:28 +09002303 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002304
2305 PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002306
Leo Kim45102f82015-10-28 15:59:28 +09002307 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002308 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002309 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002310 PRINT_ER("Failed to send delete beacon config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002311}
2312
Tony Cho6a89ba92015-09-21 12:16:46 +09002313static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer,
2314 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002315{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002316 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002317
2318 pu8CurrByte = pu8Buffer;
2319
2320 PRINT_D(HOSTINF_DBG, "Packing STA params\n");
Leo Kim2353c382015-10-29 12:05:41 +09002321 memcpy(pu8CurrByte, pstrStationParam->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002322 pu8CurrByte += ETH_ALEN;
2323
Leo Kim4101eb82015-10-29 12:05:42 +09002324 *pu8CurrByte++ = pstrStationParam->aid & 0xFF;
2325 *pu8CurrByte++ = (pstrStationParam->aid >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002326
Leo Kime7342232015-10-29 12:05:43 +09002327 *pu8CurrByte++ = pstrStationParam->rates_len;
2328 if (pstrStationParam->rates_len > 0)
Leo Kima622e012015-10-29 12:05:44 +09002329 memcpy(pu8CurrByte, pstrStationParam->rates,
Leo Kime7342232015-10-29 12:05:43 +09002330 pstrStationParam->rates_len);
2331 pu8CurrByte += pstrStationParam->rates_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002332
Leo Kim22520122015-10-29 12:05:45 +09002333 *pu8CurrByte++ = pstrStationParam->ht_supported;
Leo Kim0d073f62015-10-29 12:05:46 +09002334 *pu8CurrByte++ = pstrStationParam->ht_capa_info & 0xFF;
2335 *pu8CurrByte++ = (pstrStationParam->ht_capa_info >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002336
Leo Kimfba1f2d2015-10-29 12:05:47 +09002337 *pu8CurrByte++ = pstrStationParam->ht_ampdu_params;
Leo Kim5ebbf4f2015-10-29 12:05:48 +09002338 memcpy(pu8CurrByte, pstrStationParam->ht_supp_mcs_set,
2339 WILC_SUPP_MCS_SET_SIZE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002340 pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
2341
Leo Kim223741d2015-10-29 12:05:49 +09002342 *pu8CurrByte++ = pstrStationParam->ht_ext_params & 0xFF;
2343 *pu8CurrByte++ = (pstrStationParam->ht_ext_params >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002344
Leo Kim74fe73c2015-10-29 12:05:50 +09002345 *pu8CurrByte++ = pstrStationParam->ht_tx_bf_cap & 0xFF;
2346 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 8) & 0xFF;
2347 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 16) & 0xFF;
2348 *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 24) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002349
Leo Kima486baf2015-10-29 12:05:51 +09002350 *pu8CurrByte++ = pstrStationParam->ht_ante_sel;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002351
Leo Kimf676e172015-10-29 12:05:52 +09002352 *pu8CurrByte++ = pstrStationParam->flags_mask & 0xFF;
2353 *pu8CurrByte++ = (pstrStationParam->flags_mask >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002354
Leo Kim67ab64e2015-10-29 12:05:53 +09002355 *pu8CurrByte++ = pstrStationParam->flags_set & 0xFF;
2356 *pu8CurrByte++ = (pstrStationParam->flags_set >> 8) & 0xFF;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002357
2358 return pu8CurrByte - pu8Buffer;
2359}
2360
Tony Choa4ab1ad2015-10-12 16:56:05 +09002361static void Handle_AddStation(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09002362 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002363{
Leo Kim31390ee2015-10-19 18:26:08 +09002364 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002365 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002366 u8 *pu8CurrByte;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002367
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002368 PRINT_D(HOSTINF_DBG, "Handling add station\n");
Leo Kim45102f82015-10-28 15:59:28 +09002369 wid.id = (u16)WID_ADD_STA;
2370 wid.type = WID_BIN;
Leo Kime7342232015-10-29 12:05:43 +09002371 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002372
Leo Kim45102f82015-10-28 15:59:28 +09002373 wid.val = kmalloc(wid.size, GFP_KERNEL);
2374 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002375 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002376
Leo Kim45102f82015-10-28 15:59:28 +09002377 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002378 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2379
Leo Kim45102f82015-10-28 15:59:28 +09002380 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002381 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002382 if (result != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002383 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002384
Leo Kim24db7132015-09-16 18:36:01 +09002385ERRORHANDLER:
Leo Kima622e012015-10-29 12:05:44 +09002386 kfree(pstrStationParam->rates);
Leo Kim45102f82015-10-28 15:59:28 +09002387 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002388}
2389
Tony Choa4ab1ad2015-10-12 16:56:05 +09002390static void Handle_DelAllSta(struct host_if_drv *hif_drv,
Tony Chob4e644e2015-09-21 12:17:00 +09002391 struct del_all_sta *pstrDelAllStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002392{
Leo Kim31390ee2015-10-19 18:26:08 +09002393 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002394 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002395 u8 *pu8CurrByte;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002396 u8 i;
Chaehyun Lim37034802015-06-11 14:34:32 +09002397 u8 au8Zero_Buff[6] = {0};
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002398
Leo Kim45102f82015-10-28 15:59:28 +09002399 wid.id = (u16)WID_DEL_ALL_STA;
2400 wid.type = WID_STR;
2401 wid.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002402
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002403 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002404
Leo Kim45102f82015-10-28 15:59:28 +09002405 wid.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL);
2406 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002407 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002408
Leo Kim45102f82015-10-28 15:59:28 +09002409 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002410
Leo Kim8ba18032015-10-13 19:50:10 +09002411 *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002412
2413 for (i = 0; i < MAX_NUM_STA; i++) {
Leo Kime51b9212015-10-13 19:50:09 +09002414 if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN))
2415 memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002416 else
2417 continue;
2418
2419 pu8CurrByte += ETH_ALEN;
2420 }
2421
Leo Kim45102f82015-10-28 15:59:28 +09002422 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002423 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002424 if (result)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02002425 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002426
Leo Kim24db7132015-09-16 18:36:01 +09002427ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002428 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002429
Leo Kim2d25af82015-10-15 13:24:56 +09002430 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002431}
2432
Tony Choa4ab1ad2015-10-12 16:56:05 +09002433static void Handle_DelStation(struct host_if_drv *hif_drv,
Tony Chofb93a1e2015-09-21 12:16:57 +09002434 struct del_sta *pstrDelStaParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002435{
Leo Kim31390ee2015-10-19 18:26:08 +09002436 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002437 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002438 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002439
Leo Kim45102f82015-10-28 15:59:28 +09002440 wid.id = (u16)WID_REMOVE_STA;
2441 wid.type = WID_BIN;
2442 wid.size = ETH_ALEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002443
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002444 PRINT_D(HOSTINF_DBG, "Handling delete station\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002445
Leo Kim45102f82015-10-28 15:59:28 +09002446 wid.val = kmalloc(wid.size, GFP_KERNEL);
2447 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002448 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002449
Leo Kim45102f82015-10-28 15:59:28 +09002450 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002451
Leo Kime4839d32015-10-13 20:02:06 +09002452 memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002453
Leo Kim45102f82015-10-28 15:59:28 +09002454 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002455 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002456 if (result)
Luis de Bethencourt83cc9be2015-06-26 16:47:28 +02002457 PRINT_ER("Failed to send add station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002458
Leo Kim24db7132015-09-16 18:36:01 +09002459ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002460 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002461}
2462
Tony Choa4ab1ad2015-10-12 16:56:05 +09002463static void Handle_EditStation(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09002464 struct add_sta_param *pstrStationParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002465{
Leo Kim31390ee2015-10-19 18:26:08 +09002466 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002467 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002468 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002469
Leo Kim45102f82015-10-28 15:59:28 +09002470 wid.id = (u16)WID_EDIT_STA;
2471 wid.type = WID_BIN;
Leo Kime7342232015-10-29 12:05:43 +09002472 wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002473
2474 PRINT_D(HOSTINF_DBG, "Handling edit station\n");
Leo Kim45102f82015-10-28 15:59:28 +09002475 wid.val = kmalloc(wid.size, GFP_KERNEL);
2476 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002477 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002478
Leo Kim45102f82015-10-28 15:59:28 +09002479 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002480 pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
2481
Leo Kim45102f82015-10-28 15:59:28 +09002482 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002483 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002484 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002485 PRINT_ER("Failed to send edit station config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002486
Leo Kim24db7132015-09-16 18:36:01 +09002487ERRORHANDLER:
Leo Kima622e012015-10-29 12:05:44 +09002488 kfree(pstrStationParam->rates);
Leo Kim45102f82015-10-28 15:59:28 +09002489 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002490}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002491
Tony Choa4ab1ad2015-10-12 16:56:05 +09002492static int Handle_RemainOnChan(struct host_if_drv *hif_drv,
Tony Cho2f9c03f2015-09-21 12:16:58 +09002493 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002494{
Leo Kim31390ee2015-10-19 18:26:08 +09002495 s32 result = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002496 u8 u8remain_on_chan_flag;
Leo Kim45102f82015-10-28 15:59:28 +09002497 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002498
Leo Kim5beef2c2015-10-28 15:59:36 +09002499 if (!hif_drv->remain_on_ch_pending) {
Leo Kimc5cc4b12015-10-29 11:58:44 +09002500 hif_drv->remain_on_ch.arg = pstrHostIfRemainOnChan->arg;
Leo Kimbfb62ab2015-10-29 11:58:42 +09002501 hif_drv->remain_on_ch.expired = pstrHostIfRemainOnChan->expired;
Leo Kim5e5f7912015-10-29 11:58:43 +09002502 hif_drv->remain_on_ch.ready = pstrHostIfRemainOnChan->ready;
Leo Kim839ab702015-10-29 11:58:41 +09002503 hif_drv->remain_on_ch.ch = pstrHostIfRemainOnChan->ch;
Leo Kim9d764e32015-10-29 12:05:38 +09002504 hif_drv->remain_on_ch.id = pstrHostIfRemainOnChan->id;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002505 } else {
Leo Kim839ab702015-10-29 11:58:41 +09002506 pstrHostIfRemainOnChan->ch = hif_drv->remain_on_ch.ch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002507 }
2508
Leo Kimbc801852015-10-29 11:58:50 +09002509 if (hif_drv->usr_scan_req.scan_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002510 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
Leo Kim5beef2c2015-10-28 15:59:36 +09002511 hif_drv->remain_on_ch_pending = 1;
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 }
Leo Kimb60005a2015-10-29 11:58:24 +09002515 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002516 PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002517 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +09002518 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002519 }
2520
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002521 if (g_obtainingIP || connecting) {
2522 PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002523 result = -EBUSY;
Leo Kim24db7132015-09-16 18:36:01 +09002524 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002525 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002526
Leo Kim839ab702015-10-29 11:58:41 +09002527 PRINT_D(HOSTINF_DBG, "Setting channel :%d\n",
2528 pstrHostIfRemainOnChan->ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002529
Dean Lee72ed4dc2015-06-12 14:11:44 +09002530 u8remain_on_chan_flag = true;
Leo Kim45102f82015-10-28 15:59:28 +09002531 wid.id = (u16)WID_REMAIN_ON_CHAN;
2532 wid.type = WID_STR;
2533 wid.size = 2;
2534 wid.val = kmalloc(wid.size, GFP_KERNEL);
2535 if (!wid.val) {
Leo Kim31390ee2015-10-19 18:26:08 +09002536 result = -ENOMEM;
Leo Kim24db7132015-09-16 18:36:01 +09002537 goto ERRORHANDLER;
2538 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002539
Leo Kim45102f82015-10-28 15:59:28 +09002540 wid.val[0] = u8remain_on_chan_flag;
Leo Kim839ab702015-10-29 11:58:41 +09002541 wid.val[1] = (s8)pstrHostIfRemainOnChan->ch;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002542
Leo Kim45102f82015-10-28 15:59:28 +09002543 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002544 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002545 if (result != 0)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002546 PRINT_ER("Failed to set remain on channel\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002547
Leo Kim24db7132015-09-16 18:36:01 +09002548ERRORHANDLER:
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002549 {
2550 P2P_LISTEN_STATE = 1;
Leo Kimcc2d7e92015-10-29 11:58:36 +09002551 hif_drv->remain_on_ch_timer.data = (unsigned long)hif_drv;
2552 mod_timer(&hif_drv->remain_on_ch_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07002553 jiffies +
2554 msecs_to_jiffies(pstrHostIfRemainOnChan->u32duration));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002555
Leo Kim5e5f7912015-10-29 11:58:43 +09002556 if (hif_drv->remain_on_ch.ready)
Leo Kimc5cc4b12015-10-29 11:58:44 +09002557 hif_drv->remain_on_ch.ready(hif_drv->remain_on_ch.arg);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002558
Leo Kim5beef2c2015-10-28 15:59:36 +09002559 if (hif_drv->remain_on_ch_pending)
2560 hif_drv->remain_on_ch_pending = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002561 }
Leo Kim31390ee2015-10-19 18:26:08 +09002562
2563 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002564}
2565
Tony Choa4ab1ad2015-10-12 16:56:05 +09002566static int Handle_RegisterFrame(struct host_if_drv *hif_drv,
Tony Chobc37c5d2015-09-21 12:16:59 +09002567 struct reg_frame *pstrHostIfRegisterFrame)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002568{
Leo Kim31390ee2015-10-19 18:26:08 +09002569 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002570 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002571 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002572
Leo Kim6abf8682015-10-29 11:58:38 +09002573 PRINT_D(HOSTINF_DBG, "Handling frame register : %d FrameType: %d\n",
2574 pstrHostIfRegisterFrame->reg,
Leo Kimd5f654c2015-10-29 11:58:39 +09002575 pstrHostIfRegisterFrame->frame_type);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002576
Leo Kim45102f82015-10-28 15:59:28 +09002577 wid.id = (u16)WID_REGISTER_FRAME;
2578 wid.type = WID_STR;
2579 wid.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL);
2580 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002581 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002582
Leo Kim45102f82015-10-28 15:59:28 +09002583 pu8CurrByte = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002584
Leo Kim6abf8682015-10-29 11:58:38 +09002585 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg;
Leo Kimbcb410b2015-10-29 11:58:40 +09002586 *pu8CurrByte++ = pstrHostIfRegisterFrame->reg_id;
Leo Kimd5f654c2015-10-29 11:58:39 +09002587 memcpy(pu8CurrByte, &pstrHostIfRegisterFrame->frame_type, sizeof(u16));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002588
Leo Kim45102f82015-10-28 15:59:28 +09002589 wid.size = sizeof(u16) + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002590
Leo Kim45102f82015-10-28 15:59:28 +09002591 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002592 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002593 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002594 PRINT_ER("Failed to frame register config packet\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002595 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002596 }
2597
Leo Kim31390ee2015-10-19 18:26:08 +09002598 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002599}
2600
Tony Choa4ab1ad2015-10-12 16:56:05 +09002601static u32 Handle_ListenStateExpired(struct host_if_drv *hif_drv,
Tony Cho2f9c03f2015-09-21 12:16:58 +09002602 struct remain_ch *pstrHostIfRemainOnChan)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002603{
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002604 u8 u8remain_on_chan_flag;
Leo Kim45102f82015-10-28 15:59:28 +09002605 struct wid wid;
Leo Kim31390ee2015-10-19 18:26:08 +09002606 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002607
2608 PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
2609
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002610 if (P2P_LISTEN_STATE) {
Dean Lee72ed4dc2015-06-12 14:11:44 +09002611 u8remain_on_chan_flag = false;
Leo Kim45102f82015-10-28 15:59:28 +09002612 wid.id = (u16)WID_REMAIN_ON_CHAN;
2613 wid.type = WID_STR;
2614 wid.size = 2;
2615 wid.val = kmalloc(wid.size, GFP_KERNEL);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002616
Leo Kim45102f82015-10-28 15:59:28 +09002617 if (!wid.val)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002618 PRINT_ER("Failed to allocate memory\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002619
Leo Kim45102f82015-10-28 15:59:28 +09002620 wid.val[0] = u8remain_on_chan_flag;
2621 wid.val[1] = FALSE_FRMWR_CHANNEL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002622
Leo Kim45102f82015-10-28 15:59:28 +09002623 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002624 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002625 if (result != 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002626 PRINT_ER("Failed to set remain on channel\n");
2627 goto _done_;
2628 }
2629
Leo Kimbfb62ab2015-10-29 11:58:42 +09002630 if (hif_drv->remain_on_ch.expired) {
Leo Kimc5cc4b12015-10-29 11:58:44 +09002631 hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg,
Leo Kim9d764e32015-10-29 12:05:38 +09002632 pstrHostIfRemainOnChan->id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002633 }
2634 P2P_LISTEN_STATE = 0;
2635 } else {
2636 PRINT_D(GENERIC_DBG, "Not in listen state\n");
Leo Kim31390ee2015-10-19 18:26:08 +09002637 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002638 }
2639
2640_done_:
Leo Kim31390ee2015-10-19 18:26:08 +09002641 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002642}
2643
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07002644static void ListenTimerCB(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002645{
Leo Kim31390ee2015-10-19 18:26:08 +09002646 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09002647 struct host_if_msg msg;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002648 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
Leo Kimae4dfa52015-10-13 19:49:26 +09002649
Leo Kimcc2d7e92015-10-29 11:58:36 +09002650 del_timer(&hif_drv->remain_on_ch_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002651
Tony Cho143eb952015-09-21 12:16:32 +09002652 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09002653 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002654 msg.drv = hif_drv;
Leo Kim9d764e32015-10-29 12:05:38 +09002655 msg.body.remain_on_ch.id = hif_drv->remain_on_ch.id;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002656
Leo Kim31390ee2015-10-19 18:26:08 +09002657 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
2658 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09002659 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002660}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002661
Tony Choa4ab1ad2015-10-12 16:56:05 +09002662static void Handle_PowerManagement(struct host_if_drv *hif_drv,
Tony Cho5a008f12015-09-21 12:16:48 +09002663 struct power_mgmt_param *strPowerMgmtParam)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002664{
Leo Kim31390ee2015-10-19 18:26:08 +09002665 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002666 struct wid wid;
Chaehyun Limca356ad2015-06-11 14:35:57 +09002667 s8 s8PowerMode;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02002668
Leo Kim45102f82015-10-28 15:59:28 +09002669 wid.id = (u16)WID_POWER_MANAGEMENT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002670
Punit Vara047e6642015-10-25 04:01:25 +05302671 if (strPowerMgmtParam->enabled)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002672 s8PowerMode = MIN_FAST_PS;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05302673 else
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002674 s8PowerMode = NO_POWERSAVE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002675 PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
Leo Kim45102f82015-10-28 15:59:28 +09002676 wid.val = &s8PowerMode;
2677 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002678
2679 PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
2680
Leo Kim45102f82015-10-28 15:59:28 +09002681 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002682 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002683 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002684 PRINT_ER("Failed to send power management config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002685}
2686
Tony Choa4ab1ad2015-10-12 16:56:05 +09002687static void Handle_SetMulticastFilter(struct host_if_drv *hif_drv,
Tony Cho641210a2015-09-21 12:16:52 +09002688 struct set_multicast *strHostIfSetMulti)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002689{
Leo Kim31390ee2015-10-19 18:26:08 +09002690 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002691 struct wid wid;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09002692 u8 *pu8CurrByte;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002693
2694 PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
2695
Leo Kim45102f82015-10-28 15:59:28 +09002696 wid.id = (u16)WID_SETUP_MULTICAST_FILTER;
2697 wid.type = WID_BIN;
2698 wid.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN);
2699 wid.val = kmalloc(wid.size, GFP_KERNEL);
2700 if (!wid.val)
Leo Kim24db7132015-09-16 18:36:01 +09002701 goto ERRORHANDLER;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002702
Leo Kim45102f82015-10-28 15:59:28 +09002703 pu8CurrByte = wid.val;
Leo Kimbae636eb2015-10-13 20:02:04 +09002704 *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF);
2705 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 8) & 0xFF);
2706 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 16) & 0xFF);
2707 *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002708
Leo Kimadab2f72015-10-13 20:02:05 +09002709 *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF);
2710 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF);
2711 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF);
2712 *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002713
Leo Kimadab2f72015-10-13 20:02:05 +09002714 if ((strHostIfSetMulti->cnt) > 0)
Leo Kimfb70e9f2015-11-05 14:36:09 +09002715 memcpy(pu8CurrByte, multicast_mac_addr_list,
2716 ((strHostIfSetMulti->cnt) * ETH_ALEN));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002717
Leo Kim45102f82015-10-28 15:59:28 +09002718 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002719 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002720 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002721 PRINT_ER("Failed to send setup multicast config packet\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002722
Leo Kim24db7132015-09-16 18:36:01 +09002723ERRORHANDLER:
Leo Kim45102f82015-10-28 15:59:28 +09002724 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002725}
2726
Tony Choa4ab1ad2015-10-12 16:56:05 +09002727static s32 Handle_AddBASession(struct host_if_drv *hif_drv,
Tony Cho54265472015-09-21 12:16:56 +09002728 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002729{
Leo Kim31390ee2015-10-19 18:26:08 +09002730 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002731 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002732 int AddbaTimeout = 100;
2733 char *ptr = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002734
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002735 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 +09002736 strHostIfBASessionInfo->bssid[0],
2737 strHostIfBASessionInfo->bssid[1],
2738 strHostIfBASessionInfo->bssid[2],
Leo Kim277c2132015-10-29 11:58:47 +09002739 strHostIfBASessionInfo->buf_size,
Leo Kim23d0bfa2015-10-29 11:58:48 +09002740 strHostIfBASessionInfo->time_out,
Leo Kim16c9b392015-10-29 11:58:46 +09002741 strHostIfBASessionInfo->tid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002742
Leo Kim45102f82015-10-28 15:59:28 +09002743 wid.id = (u16)WID_11E_P_ACTION_REQ;
2744 wid.type = WID_STR;
2745 wid.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2746 wid.size = BLOCK_ACK_REQ_SIZE;
2747 ptr = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002748 *ptr++ = 0x14;
2749 *ptr++ = 0x3;
2750 *ptr++ = 0x0;
Leo Kim3fc49992015-10-29 11:58:45 +09002751 memcpy(ptr, strHostIfBASessionInfo->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002752 ptr += ETH_ALEN;
Leo Kim16c9b392015-10-29 11:58:46 +09002753 *ptr++ = strHostIfBASessionInfo->tid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002754 *ptr++ = 1;
Leo Kim277c2132015-10-29 11:58:47 +09002755 *ptr++ = (strHostIfBASessionInfo->buf_size & 0xFF);
2756 *ptr++ = ((strHostIfBASessionInfo->buf_size >> 16) & 0xFF);
Leo Kim23d0bfa2015-10-29 11:58:48 +09002757 *ptr++ = (strHostIfBASessionInfo->time_out & 0xFF);
2758 *ptr++ = ((strHostIfBASessionInfo->time_out >> 16) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002759 *ptr++ = (AddbaTimeout & 0xFF);
2760 *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002761 *ptr++ = 8;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002762 *ptr++ = 0;
2763
Leo Kim45102f82015-10-28 15:59:28 +09002764 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002765 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002766 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002767 PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
2768
Leo Kim45102f82015-10-28 15:59:28 +09002769 wid.id = (u16)WID_11E_P_ACTION_REQ;
2770 wid.type = WID_STR;
2771 wid.size = 15;
2772 ptr = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002773 *ptr++ = 15;
2774 *ptr++ = 7;
2775 *ptr++ = 0x2;
Leo Kim3fc49992015-10-29 11:58:45 +09002776 memcpy(ptr, strHostIfBASessionInfo->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002777 ptr += ETH_ALEN;
Leo Kim16c9b392015-10-29 11:58:46 +09002778 *ptr++ = strHostIfBASessionInfo->tid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002779 *ptr++ = 8;
Leo Kim277c2132015-10-29 11:58:47 +09002780 *ptr++ = (strHostIfBASessionInfo->buf_size & 0xFF);
Leo Kim23d0bfa2015-10-29 11:58:48 +09002781 *ptr++ = ((strHostIfBASessionInfo->time_out >> 16) & 0xFF);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002782 *ptr++ = 3;
Leo Kim45102f82015-10-28 15:59:28 +09002783 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002784 get_id_from_handler(hif_drv));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002785
Leo Kim45102f82015-10-28 15:59:28 +09002786 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002787
Leo Kim31390ee2015-10-19 18:26:08 +09002788 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002789}
2790
Tony Choa4ab1ad2015-10-12 16:56:05 +09002791static s32 Handle_DelAllRxBASessions(struct host_if_drv *hif_drv,
Tony Cho54265472015-09-21 12:16:56 +09002792 struct ba_session_info *strHostIfBASessionInfo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002793{
Leo Kim31390ee2015-10-19 18:26:08 +09002794 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09002795 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002796 char *ptr = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002797
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002798 PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x\nTID=%d\n",
Leo Kim3fc49992015-10-29 11:58:45 +09002799 strHostIfBASessionInfo->bssid[0],
2800 strHostIfBASessionInfo->bssid[1],
2801 strHostIfBASessionInfo->bssid[2],
Leo Kim16c9b392015-10-29 11:58:46 +09002802 strHostIfBASessionInfo->tid);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002803
Leo Kim45102f82015-10-28 15:59:28 +09002804 wid.id = (u16)WID_DEL_ALL_RX_BA;
2805 wid.type = WID_STR;
2806 wid.val = kmalloc(BLOCK_ACK_REQ_SIZE, GFP_KERNEL);
2807 wid.size = BLOCK_ACK_REQ_SIZE;
2808 ptr = wid.val;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002809 *ptr++ = 0x14;
2810 *ptr++ = 0x3;
2811 *ptr++ = 0x2;
Leo Kim3fc49992015-10-29 11:58:45 +09002812 memcpy(ptr, strHostIfBASessionInfo->bssid, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002813 ptr += ETH_ALEN;
Leo Kim16c9b392015-10-29 11:58:46 +09002814 *ptr++ = strHostIfBASessionInfo->tid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002815 *ptr++ = 0;
Leo Kimae4dfa52015-10-13 19:49:26 +09002816 *ptr++ = 32;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002817
Leo Kim45102f82015-10-28 15:59:28 +09002818 result = send_config_pkt(SET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09002819 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09002820 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002821 PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
2822
Leo Kim45102f82015-10-28 15:59:28 +09002823 kfree(wid.val);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002824
Leo Kim2d25af82015-10-15 13:24:56 +09002825 up(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002826
Leo Kim31390ee2015-10-19 18:26:08 +09002827 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002828}
2829
Arnd Bergmann1999bd52015-05-29 22:52:14 +02002830static int hostIFthread(void *pvArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002831{
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09002832 u32 u32Ret;
Tony Cho143eb952015-09-21 12:16:32 +09002833 struct host_if_msg msg;
Tony Choa4ab1ad2015-10-12 16:56:05 +09002834 struct host_if_drv *hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002835
Tony Cho143eb952015-09-21 12:16:32 +09002836 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002837
2838 while (1) {
Leo Kimcb067dc2015-10-15 13:24:53 +09002839 wilc_mq_recv(&hif_msg_q, &msg, sizeof(struct host_if_msg), &u32Ret);
Tony Choa4ab1ad2015-10-12 16:56:05 +09002840 hif_drv = (struct host_if_drv *)msg.drv;
Tony Choa9f812a2015-09-21 12:16:33 +09002841 if (msg.id == HOST_IF_MSG_EXIT) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002842 PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
2843 break;
2844 }
2845
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002846 if ((!g_wilc_initialized)) {
2847 PRINT_D(GENERIC_DBG, "--WAIT--");
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07002848 usleep_range(200 * 1000, 200 * 1000);
Leo Kimcb067dc2015-10-15 13:24:53 +09002849 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002850 continue;
2851 }
2852
Leo Kim91109e12015-10-19 18:26:13 +09002853 if (msg.id == HOST_IF_MSG_CONNECT &&
Leo Kimbc801852015-10-29 11:58:50 +09002854 hif_drv->usr_scan_req.scan_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002855 PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
Leo Kimcb067dc2015-10-15 13:24:53 +09002856 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Greg Kroah-Hartman80e29c72015-08-14 19:42:23 -07002857 usleep_range(2 * 1000, 2 * 1000);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002858 continue;
2859 }
2860
Tony Choa9f812a2015-09-21 12:16:33 +09002861 switch (msg.id) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002862 case HOST_IF_MSG_Q_IDLE:
2863 Handle_wait_msg_q_empty();
2864 break;
2865
2866 case HOST_IF_MSG_SCAN:
Leo Kim2482a792015-10-12 16:55:36 +09002867 Handle_Scan(msg.drv, &msg.body.scan_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002868 break;
2869
2870 case HOST_IF_MSG_CONNECT:
Leo Kim2482a792015-10-12 16:55:36 +09002871 Handle_Connect(msg.drv, &msg.body.con_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002872 break;
2873
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002874 case HOST_IF_MSG_FLUSH_CONNECT:
Leo Kim2482a792015-10-12 16:55:36 +09002875 Handle_FlushConnect(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002876 break;
2877
2878 case HOST_IF_MSG_RCVD_NTWRK_INFO:
Leo Kim2482a792015-10-12 16:55:36 +09002879 Handle_RcvdNtwrkInfo(msg.drv, &msg.body.net_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002880 break;
2881
2882 case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
Leo Kim2482a792015-10-12 16:55:36 +09002883 Handle_RcvdGnrlAsyncInfo(msg.drv, &msg.body.async_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002884 break;
2885
2886 case HOST_IF_MSG_KEY:
Leo Kim2482a792015-10-12 16:55:36 +09002887 Handle_Key(msg.drv, &msg.body.key_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002888 break;
2889
2890 case HOST_IF_MSG_CFG_PARAMS:
Leo Kimdc276662015-11-06 11:20:10 +09002891 handle_cfg_param(msg.drv, &msg.body.cfg_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002892 break;
2893
2894 case HOST_IF_MSG_SET_CHANNEL:
Leo Kim3eec50c2015-11-06 11:20:03 +09002895 handle_set_channel(msg.drv, &msg.body.channel_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002896 break;
2897
2898 case HOST_IF_MSG_DISCONNECT:
Leo Kim2482a792015-10-12 16:55:36 +09002899 Handle_Disconnect(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002900 break;
2901
2902 case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
Leo Kim13b313e2015-10-29 11:58:34 +09002903 del_timer(&hif_drv->scan_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002904 PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
2905
Luis de Bethencourt2b9d5b42015-06-26 16:44:24 +02002906 if (!linux_wlan_get_num_conn_ifcs())
Leo Kim1b721bf2015-11-06 11:13:00 +09002907 chip_sleep_manually();
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002908
Leo Kim2482a792015-10-12 16:55:36 +09002909 Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002910
Leo Kim5beef2c2015-10-28 15:59:36 +09002911 if (hif_drv->remain_on_ch_pending)
Leo Kim2482a792015-10-12 16:55:36 +09002912 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002913
2914 break;
2915
2916 case HOST_IF_MSG_GET_RSSI:
Leo Kim2482a792015-10-12 16:55:36 +09002917 Handle_GetRssi(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002918 break;
2919
2920 case HOST_IF_MSG_GET_LINKSPEED:
Leo Kim2482a792015-10-12 16:55:36 +09002921 Handle_GetLinkspeed(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002922 break;
2923
2924 case HOST_IF_MSG_GET_STATISTICS:
Leo Kim03e7b9c2015-10-12 16:55:58 +09002925 Handle_GetStatistics(msg.drv, (struct rf_info *)msg.body.data);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002926 break;
2927
2928 case HOST_IF_MSG_GET_CHNL:
Leo Kim2482a792015-10-12 16:55:36 +09002929 Handle_GetChnl(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002930 break;
2931
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002932 case HOST_IF_MSG_ADD_BEACON:
Leo Kim2482a792015-10-12 16:55:36 +09002933 Handle_AddBeacon(msg.drv, &msg.body.beacon_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002934 break;
2935
2936 case HOST_IF_MSG_DEL_BEACON:
Leo Kim2482a792015-10-12 16:55:36 +09002937 Handle_DelBeacon(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002938 break;
2939
2940 case HOST_IF_MSG_ADD_STATION:
Leo Kim2482a792015-10-12 16:55:36 +09002941 Handle_AddStation(msg.drv, &msg.body.add_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002942 break;
2943
2944 case HOST_IF_MSG_DEL_STATION:
Leo Kim2482a792015-10-12 16:55:36 +09002945 Handle_DelStation(msg.drv, &msg.body.del_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002946 break;
2947
2948 case HOST_IF_MSG_EDIT_STATION:
Leo Kim2482a792015-10-12 16:55:36 +09002949 Handle_EditStation(msg.drv, &msg.body.edit_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002950 break;
2951
2952 case HOST_IF_MSG_GET_INACTIVETIME:
Leo Kim2482a792015-10-12 16:55:36 +09002953 Handle_Get_InActiveTime(msg.drv, &msg.body.mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002954 break;
2955
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002956 case HOST_IF_MSG_SCAN_TIMER_FIRED:
2957 PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
2958
Leo Kim2482a792015-10-12 16:55:36 +09002959 Handle_ScanDone(msg.drv, SCAN_EVENT_ABORTED);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002960 break;
2961
2962 case HOST_IF_MSG_CONNECT_TIMER_FIRED:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02002963 PRINT_D(HOSTINF_DBG, "Connect Timeout\n");
Leo Kim2482a792015-10-12 16:55:36 +09002964 Handle_ConnectTimeout(msg.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002965 break;
2966
2967 case HOST_IF_MSG_POWER_MGMT:
Leo Kim2482a792015-10-12 16:55:36 +09002968 Handle_PowerManagement(msg.drv, &msg.body.pwr_mgmt_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002969 break;
2970
2971 case HOST_IF_MSG_SET_WFIDRV_HANDLER:
Leo Kim23f2bad2015-11-06 11:20:04 +09002972 handle_set_wfi_drv_handler(msg.drv, &msg.body.drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002973 break;
2974
2975 case HOST_IF_MSG_SET_OPERATION_MODE:
Leo Kim97b5c592015-11-06 11:20:05 +09002976 handle_set_operation_mode(msg.drv, &msg.body.mode);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002977 break;
2978
2979 case HOST_IF_MSG_SET_IPADDRESS:
2980 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Leo Kima6e6d482015-11-06 11:20:06 +09002981 handle_set_ip_address(msg.drv,
2982 msg.body.ip_info.ip_addr,
2983 msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002984 break;
2985
2986 case HOST_IF_MSG_GET_IPADDRESS:
2987 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
Leo Kimd4516952015-11-06 11:20:07 +09002988 handle_get_ip_address(msg.drv, msg.body.ip_info.idx);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002989 break;
2990
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002991 case HOST_IF_MSG_SET_MAC_ADDRESS:
Leo Kima8267422015-11-06 11:20:08 +09002992 handle_set_mac_address(msg.drv,
2993 &msg.body.set_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002994 break;
2995
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002996 case HOST_IF_MSG_GET_MAC_ADDRESS:
Leo Kimb3bf8fd2015-11-06 11:20:09 +09002997 handle_get_mac_address(msg.drv,
2998 &msg.body.get_mac_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09002999 break;
3000
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003001 case HOST_IF_MSG_REMAIN_ON_CHAN:
3002 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
Leo Kim2482a792015-10-12 16:55:36 +09003003 Handle_RemainOnChan(msg.drv, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003004 break;
3005
3006 case HOST_IF_MSG_REGISTER_FRAME:
3007 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
Leo Kim2482a792015-10-12 16:55:36 +09003008 Handle_RegisterFrame(msg.drv, &msg.body.reg_frame);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003009 break;
3010
3011 case HOST_IF_MSG_LISTEN_TIMER_FIRED:
Leo Kim2482a792015-10-12 16:55:36 +09003012 Handle_ListenStateExpired(msg.drv, &msg.body.remain_on_ch);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003013 break;
3014
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003015 case HOST_IF_MSG_SET_MULTICAST_FILTER:
3016 PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
Leo Kim2482a792015-10-12 16:55:36 +09003017 Handle_SetMulticastFilter(msg.drv, &msg.body.multicast_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003018 break;
3019
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003020 case HOST_IF_MSG_ADD_BA_SESSION:
Leo Kim2482a792015-10-12 16:55:36 +09003021 Handle_AddBASession(msg.drv, &msg.body.session_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003022 break;
3023
3024 case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
Leo Kim2482a792015-10-12 16:55:36 +09003025 Handle_DelAllRxBASessions(msg.drv, &msg.body.session_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003026 break;
3027
3028 case HOST_IF_MSG_DEL_ALL_STA:
Leo Kim2482a792015-10-12 16:55:36 +09003029 Handle_DelAllSta(msg.drv, &msg.body.del_all_sta_info);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003030 break;
3031
3032 default:
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003033 PRINT_ER("[Host Interface] undefined Received Msg ID\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003034 break;
3035 }
3036 }
3037
3038 PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
Leo Kim834e0cb2015-10-15 13:24:54 +09003039 up(&hif_sema_thread);
Arnd Bergmann1999bd52015-05-29 22:52:14 +02003040 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003041}
3042
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003043static void TimerCB_Scan(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003044{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003045 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09003046 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003047
Tony Cho143eb952015-09-21 12:16:32 +09003048 memset(&msg, 0, sizeof(struct host_if_msg));
Leo Kim2482a792015-10-12 16:55:36 +09003049 msg.drv = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09003050 msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003051
Leo Kimcb067dc2015-10-15 13:24:53 +09003052 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003053}
3054
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003055static void TimerCB_Connect(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003056{
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07003057 void *pvArg = (void *)arg;
Tony Cho143eb952015-09-21 12:16:32 +09003058 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003059
Tony Cho143eb952015-09-21 12:16:32 +09003060 memset(&msg, 0, sizeof(struct host_if_msg));
Leo Kim2482a792015-10-12 16:55:36 +09003061 msg.drv = pvArg;
Tony Choa9f812a2015-09-21 12:16:33 +09003062 msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003063
Leo Kimcb067dc2015-10-15 13:24:53 +09003064 wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003065}
3066
Tony Choa4ab1ad2015-10-12 16:56:05 +09003067s32 host_int_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003068{
Leo Kim45102f82015-10-28 15:59:28 +09003069 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003070
Leo Kim45102f82015-10-28 15:59:28 +09003071 wid.id = (u16)WID_REMOVE_KEY;
3072 wid.type = WID_STR;
3073 wid.val = (s8 *)pu8StaAddress;
3074 wid.size = 6;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003075
Leo Kimb68d820b2015-10-12 16:55:37 +09003076 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003077}
3078
Tony Choa4ab1ad2015-10-12 16:56:05 +09003079int host_int_remove_wep_key(struct host_if_drv *hif_drv, u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003080{
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003081 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003082 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003083
Tony Choa4ab1ad2015-10-12 16:56:05 +09003084 if (!hif_drv) {
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003085 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003086 PRINT_ER("Failed to send setup multicast config packet\n");
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003087 return result;
Leo Kim24db7132015-09-16 18:36:01 +09003088 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003089
Tony Cho143eb952015-09-21 12:16:32 +09003090 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003091
Tony Choa9f812a2015-09-21 12:16:33 +09003092 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003093 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003094 msg.body.key_info.action = REMOVEKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003095 msg.drv = hif_drv;
Leo Kim73b2e382015-10-13 19:49:29 +09003096 msg.body.key_info.attr.wep.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003097
Leo Kimcb067dc2015-10-15 13:24:53 +09003098 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003099 if (result)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02003100 PRINT_ER("Error in sending message queue : Request to remove WEP key\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003101 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003102
Chaehyun Lim9e5e8b42015-10-05 19:35:00 +09003103 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003104}
3105
Chaehyun Limdf8b4832015-10-26 09:44:45 +09003106int host_int_set_wep_default_key(struct host_if_drv *hif_drv, u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003107{
Chaehyun Lim5b41c7c2015-10-26 09:44:42 +09003108 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003109 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003110
Tony Choa4ab1ad2015-10-12 16:56:05 +09003111 if (!hif_drv) {
Leo Kim31390ee2015-10-19 18:26:08 +09003112 result = -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003113 PRINT_ER("driver is null\n");
Leo Kim31390ee2015-10-19 18:26:08 +09003114 return result;
Leo Kim24db7132015-09-16 18:36:01 +09003115 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003116
Tony Cho143eb952015-09-21 12:16:32 +09003117 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003118
Tony Choa9f812a2015-09-21 12:16:33 +09003119 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003120 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003121 msg.body.key_info.action = DEFAULTKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003122 msg.drv = hif_drv;
Chaehyun Lime91d0342015-10-26 09:44:44 +09003123 msg.body.key_info.attr.wep.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003124
Leo Kim31390ee2015-10-19 18:26:08 +09003125 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3126 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003127 PRINT_ER("Error in sending message queue : Default key index\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003128 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003129
Leo Kim31390ee2015-10-19 18:26:08 +09003130 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003131}
3132
Chaehyun Lim66b8cb82015-10-27 20:40:32 +09003133int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
Chaehyun Limfba778b2015-10-27 20:40:34 +09003134 const u8 *key,
Chaehyun Limdbc53192015-10-27 20:40:35 +09003135 u8 len,
Chaehyun Lim0b2cc3e2015-10-27 20:40:36 +09003136 u8 index)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003137{
Chaehyun Lim66b8cb82015-10-27 20:40:32 +09003138 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003139 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003140
Tony Choa4ab1ad2015-10-12 16:56:05 +09003141 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003142 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003143 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003144 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003145
Tony Cho143eb952015-09-21 12:16:32 +09003146 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003147
Tony Choa9f812a2015-09-21 12:16:33 +09003148 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003149 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003150 msg.body.key_info.action = ADDKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003151 msg.drv = hif_drv;
Chaehyun Lim1cc0c322015-10-27 20:40:37 +09003152 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3153 if (!msg.body.key_info.attr.wep.key)
3154 return -ENOMEM;
3155
Chaehyun Limdbc53192015-10-27 20:40:35 +09003156 msg.body.key_info.attr.wep.key_len = len;
Chaehyun Lim0b2cc3e2015-10-27 20:40:36 +09003157 msg.body.key_info.attr.wep.index = index;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003158
Leo Kim31390ee2015-10-19 18:26:08 +09003159 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3160 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003161 PRINT_ER("Error in sending message queue :WEP Key\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003162 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003163
Leo Kim31390ee2015-10-19 18:26:08 +09003164 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003165}
3166
Chaehyun Lim641c20a2015-10-28 08:19:19 +09003167int host_int_add_wep_key_bss_ap(struct host_if_drv *hif_drv,
Chaehyun Lim81117252015-10-28 08:19:22 +09003168 const u8 *key,
Chaehyun Lima5389b02015-10-28 08:19:23 +09003169 u8 len,
Chaehyun Lima76dc952015-10-28 08:19:24 +09003170 u8 index,
Chaehyun Lim730a28d2015-10-28 08:19:25 +09003171 u8 mode,
Chaehyun Limff3bce22015-10-28 08:19:26 +09003172 enum AUTHTYPE auth_type)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003173{
Chaehyun Lim641c20a2015-10-28 08:19:19 +09003174 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003175 struct host_if_msg msg;
Chaehyun Limfd741462015-10-28 08:19:21 +09003176 int i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003177
Tony Choa4ab1ad2015-10-12 16:56:05 +09003178 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003179 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003180 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003181 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003182
Tony Cho143eb952015-09-21 12:16:32 +09003183 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003184
3185 if (INFO) {
Chaehyun Lima5389b02015-10-28 08:19:23 +09003186 for (i = 0; i < len; i++)
Chaehyun Lim81117252015-10-28 08:19:22 +09003187 PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", key[i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003188 }
Tony Choa9f812a2015-09-21 12:16:33 +09003189 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003190 msg.body.key_info.type = WEP;
Leo Kim0d17e382015-10-13 19:49:28 +09003191 msg.body.key_info.action = ADDKEY_AP;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003192 msg.drv = hif_drv;
Chaehyun Lim58eabd62015-10-28 08:19:27 +09003193 msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
3194 if (!msg.body.key_info.attr.wep.key)
3195 return -ENOMEM;
3196
Chaehyun Lima5389b02015-10-28 08:19:23 +09003197 msg.body.key_info.attr.wep.key_len = len;
Chaehyun Lima76dc952015-10-28 08:19:24 +09003198 msg.body.key_info.attr.wep.index = index;
Chaehyun Lim730a28d2015-10-28 08:19:25 +09003199 msg.body.key_info.attr.wep.mode = mode;
Chaehyun Limff3bce22015-10-28 08:19:26 +09003200 msg.body.key_info.attr.wep.auth_type = auth_type;
Leo Kimae4dfa52015-10-13 19:49:26 +09003201
Leo Kim31390ee2015-10-19 18:26:08 +09003202 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003203
Leo Kim31390ee2015-10-19 18:26:08 +09003204 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003205 PRINT_ER("Error in sending message queue :WEP Key\n");
Leo Kim9ea47132015-10-29 11:58:28 +09003206 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003207
Leo Kim31390ee2015-10-19 18:26:08 +09003208 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003209}
Glen Lee108b3432015-09-16 18:53:20 +09003210
Tony Choa4ab1ad2015-10-12 16:56:05 +09003211s32 host_int_add_ptk(struct host_if_drv *hif_drv, const u8 *pu8Ptk,
3212 u8 u8PtkKeylen, const u8 *mac_addr,
3213 const u8 *pu8RxMic, const u8 *pu8TxMic,
3214 u8 mode, u8 u8Ciphermode, u8 u8Idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003215{
Leo Kim31390ee2015-10-19 18:26:08 +09003216 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003217 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003218 u8 u8KeyLen = u8PtkKeylen;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003219 u32 i;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02003220
Tony Choa4ab1ad2015-10-12 16:56:05 +09003221 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003222 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003223 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003224 }
Leo Kim91109e12015-10-19 18:26:13 +09003225
3226 if (pu8RxMic)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003227 u8KeyLen += RX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003228
3229 if (pu8TxMic)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003230 u8KeyLen += TX_MIC_KEY_LEN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003231
Tony Cho143eb952015-09-21 12:16:32 +09003232 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003233
Tony Choa9f812a2015-09-21 12:16:33 +09003234 msg.id = HOST_IF_MSG_KEY;
Leo Kim2141fe32015-10-29 12:05:35 +09003235 msg.body.key_info.type = WPA_PTK;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003236 if (mode == AP_MODE) {
Leo Kim0d17e382015-10-13 19:49:28 +09003237 msg.body.key_info.action = ADDKEY_AP;
Leo Kime2dfbac2015-10-13 19:49:34 +09003238 msg.body.key_info.attr.wpa.index = u8Idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003239 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003240 if (mode == STATION_MODE)
Leo Kim0d17e382015-10-13 19:49:28 +09003241 msg.body.key_info.action = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003242
Leo Kim124968fc2015-10-13 19:49:30 +09003243 msg.body.key_info.attr.wpa.key = kmalloc(u8PtkKeylen, GFP_KERNEL);
3244 memcpy(msg.body.key_info.attr.wpa.key, pu8Ptk, u8PtkKeylen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003245
Leo Kim91109e12015-10-19 18:26:13 +09003246 if (pu8RxMic) {
Leo Kim124968fc2015-10-13 19:49:30 +09003247 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic, RX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003248 if (INFO) {
3249 for (i = 0; i < RX_MIC_KEY_LEN; i++)
3250 PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
3251 }
3252 }
Leo Kim91109e12015-10-19 18:26:13 +09003253 if (pu8TxMic) {
Leo Kim124968fc2015-10-13 19:49:30 +09003254 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic, TX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003255 if (INFO) {
3256 for (i = 0; i < TX_MIC_KEY_LEN; i++)
3257 PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
3258 }
3259 }
3260
Leo Kim6acf2912015-10-13 19:49:35 +09003261 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
Leo Kim248080a2015-10-13 19:49:31 +09003262 msg.body.key_info.attr.wpa.mac_addr = mac_addr;
Leo Kim7b2ebb22015-10-13 19:49:36 +09003263 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003264 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003265
Leo Kim31390ee2015-10-19 18:26:08 +09003266 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003267
Leo Kim31390ee2015-10-19 18:26:08 +09003268 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003269 PRINT_ER("Error in sending message queue: PTK Key\n");
3270
Leo Kim9ea47132015-10-29 11:58:28 +09003271 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003272
Leo Kim31390ee2015-10-19 18:26:08 +09003273 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003274}
3275
Tony Choa4ab1ad2015-10-12 16:56:05 +09003276s32 host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *pu8RxGtk,
3277 u8 u8GtkKeylen, u8 u8KeyIdx,
3278 u32 u32KeyRSClen, const u8 *KeyRSC,
3279 const u8 *pu8RxMic, const u8 *pu8TxMic,
3280 u8 mode, u8 u8Ciphermode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003281{
Leo Kim31390ee2015-10-19 18:26:08 +09003282 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003283 struct host_if_msg msg;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09003284 u8 u8KeyLen = u8GtkKeylen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003285
Tony Choa4ab1ad2015-10-12 16:56:05 +09003286 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003287 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003288 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003289 }
Tony Cho143eb952015-09-21 12:16:32 +09003290 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003291
Leo Kim91109e12015-10-19 18:26:13 +09003292 if (pu8RxMic)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003293 u8KeyLen += RX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003294
3295 if (pu8TxMic)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003296 u8KeyLen += TX_MIC_KEY_LEN;
Leo Kim91109e12015-10-19 18:26:13 +09003297
3298 if (KeyRSC) {
Leo Kim0e74c002015-10-13 19:49:32 +09003299 msg.body.key_info.attr.wpa.seq = kmalloc(u32KeyRSClen, GFP_KERNEL);
3300 memcpy(msg.body.key_info.attr.wpa.seq, KeyRSC, u32KeyRSClen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003301 }
3302
Tony Choa9f812a2015-09-21 12:16:33 +09003303 msg.id = HOST_IF_MSG_KEY;
Leo Kim5cd8f7a2015-10-29 12:05:34 +09003304 msg.body.key_info.type = WPA_RX_GTK;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003305 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003306
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003307 if (mode == AP_MODE) {
Leo Kim0d17e382015-10-13 19:49:28 +09003308 msg.body.key_info.action = ADDKEY_AP;
Leo Kim7b2ebb22015-10-13 19:49:36 +09003309 msg.body.key_info.attr.wpa.mode = u8Ciphermode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003310 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003311 if (mode == STATION_MODE)
Leo Kim0d17e382015-10-13 19:49:28 +09003312 msg.body.key_info.action = ADDKEY;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003313
Leo Kim124968fc2015-10-13 19:49:30 +09003314 msg.body.key_info.attr.wpa.key = kmalloc(u8KeyLen, GFP_KERNEL);
3315 memcpy(msg.body.key_info.attr.wpa.key, pu8RxGtk, u8GtkKeylen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003316
Leo Kimd1666e22015-10-28 15:59:22 +09003317 if (pu8RxMic)
3318 memcpy(msg.body.key_info.attr.wpa.key + 16, pu8RxMic,
3319 RX_MIC_KEY_LEN);
Leo Kim91109e12015-10-19 18:26:13 +09003320
Leo Kimd1666e22015-10-28 15:59:22 +09003321 if (pu8TxMic)
3322 memcpy(msg.body.key_info.attr.wpa.key + 24, pu8TxMic,
3323 TX_MIC_KEY_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003324
Leo Kime2dfbac2015-10-13 19:49:34 +09003325 msg.body.key_info.attr.wpa.index = u8KeyIdx;
Leo Kim6acf2912015-10-13 19:49:35 +09003326 msg.body.key_info.attr.wpa.key_len = u8KeyLen;
Leo Kimdacc5942015-10-13 19:49:33 +09003327 msg.body.key_info.attr.wpa.seq_len = u32KeyRSClen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003328
Leo Kim31390ee2015-10-19 18:26:08 +09003329 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3330 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003331 PRINT_ER("Error in sending message queue: RX GTK\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09003332
Leo Kim9ea47132015-10-29 11:58:28 +09003333 down(&hif_drv->sem_test_key_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003334
Leo Kim31390ee2015-10-19 18:26:08 +09003335 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003336}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003337
Tony Choa4ab1ad2015-10-12 16:56:05 +09003338s32 host_int_set_pmkid_info(struct host_if_drv *hif_drv, struct host_if_pmkid_attr *pu8PmkidInfoArray)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003339{
Leo Kim31390ee2015-10-19 18:26:08 +09003340 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003341 struct host_if_msg msg;
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09003342 u32 i;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003343
Tony Choa4ab1ad2015-10-12 16:56:05 +09003344 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003345 PRINT_ER("driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003346 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003347 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003348
Tony Cho143eb952015-09-21 12:16:32 +09003349 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003350
Tony Choa9f812a2015-09-21 12:16:33 +09003351 msg.id = HOST_IF_MSG_KEY;
Leo Kim8e9f4272015-10-13 19:49:27 +09003352 msg.body.key_info.type = PMKSA;
Leo Kim0d17e382015-10-13 19:49:28 +09003353 msg.body.key_info.action = ADDKEY;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003354 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003355
3356 for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
Leo Kim8c8360b2015-10-19 18:26:12 +09003357 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid,
3358 &pu8PmkidInfoArray->pmkidlist[i].bssid, ETH_ALEN);
3359 memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid,
3360 &pu8PmkidInfoArray->pmkidlist[i].pmkid, PMKID_LEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003361 }
3362
Leo Kim31390ee2015-10-19 18:26:08 +09003363 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3364 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003365 PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
3366
Leo Kim31390ee2015-10-19 18:26:08 +09003367 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003368}
3369
Tony Choa4ab1ad2015-10-12 16:56:05 +09003370s32 host_int_get_pmkid_info(struct host_if_drv *hif_drv,
3371 u8 *pu8PmkidInfoArray,
3372 u32 u32PmkidInfoLen)
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
Leo Kim45102f82015-10-28 15:59:28 +09003376 wid.id = (u16)WID_PMKID_INFO;
3377 wid.type = WID_STR;
3378 wid.size = u32PmkidInfoLen;
3379 wid.val = pu8PmkidInfoArray;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003380
Leo Kimb68d820b2015-10-12 16:55:37 +09003381 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003382}
3383
Tony Choa4ab1ad2015-10-12 16:56:05 +09003384s32 host_int_set_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3385 u8 *pu8PassPhrase,
3386 u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003387{
Leo Kim45102f82015-10-28 15:59:28 +09003388 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003389
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003390 if ((u8Psklength > 7) && (u8Psklength < 65)) {
Leo Kim45102f82015-10-28 15:59:28 +09003391 wid.id = (u16)WID_11I_PSK;
3392 wid.type = WID_STR;
3393 wid.val = pu8PassPhrase;
3394 wid.size = u8Psklength;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003395 }
3396
Leo Kimb68d820b2015-10-12 16:55:37 +09003397 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003398}
Leo Kimae4dfa52015-10-13 19:49:26 +09003399
Leo Kime5f35242015-11-05 14:36:36 +09003400s32 hif_get_mac_address(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003401{
Leo Kim31390ee2015-10-19 18:26:08 +09003402 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003403 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003404
Tony Cho143eb952015-09-21 12:16:32 +09003405 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003406
Tony Choa9f812a2015-09-21 12:16:33 +09003407 msg.id = HOST_IF_MSG_GET_MAC_ADDRESS;
Leo Kim6ceba0a2015-10-28 15:59:32 +09003408 msg.body.get_mac_info.mac_addr = pu8MacAddress;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003409 msg.drv = hif_drv;
Leo Kimae4dfa52015-10-13 19:49:26 +09003410
Leo Kim31390ee2015-10-19 18:26:08 +09003411 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3412 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003413 PRINT_ER("Failed to send get mac address\n");
Leo Kime6e12662015-09-16 18:36:03 +09003414 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003415 }
3416
Leo Kim2d25af82015-10-15 13:24:56 +09003417 down(&hif_sema_wait_response);
Leo Kim31390ee2015-10-19 18:26:08 +09003418 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003419}
3420
Tony Choa4ab1ad2015-10-12 16:56:05 +09003421s32 host_int_set_MacAddress(struct host_if_drv *hif_drv, u8 *pu8MacAddress)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003422{
Leo Kim31390ee2015-10-19 18:26:08 +09003423 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003424 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003425
3426 PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
3427
Tony Cho143eb952015-09-21 12:16:32 +09003428 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003429 msg.id = HOST_IF_MSG_SET_MAC_ADDRESS;
Leo Kimae5e4522015-10-28 15:59:31 +09003430 memcpy(msg.body.set_mac_info.mac_addr, pu8MacAddress, ETH_ALEN);
Tony Choa4ab1ad2015-10-12 16:56:05 +09003431 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003432
Leo Kim31390ee2015-10-19 18:26:08 +09003433 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3434 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003435 PRINT_ER("Failed to send message queue: Set mac address\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003436
Leo Kim31390ee2015-10-19 18:26:08 +09003437 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003438}
3439
Tony Choa4ab1ad2015-10-12 16:56:05 +09003440s32 host_int_get_RSNAConfigPSKPassPhrase(struct host_if_drv *hif_drv,
3441 u8 *pu8PassPhrase, u8 u8Psklength)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003442{
Leo Kim45102f82015-10-28 15:59:28 +09003443 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003444
Leo Kim45102f82015-10-28 15:59:28 +09003445 wid.id = (u16)WID_11I_PSK;
3446 wid.type = WID_STR;
3447 wid.size = u8Psklength;
3448 wid.val = pu8PassPhrase;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003449
Leo Kimb68d820b2015-10-12 16:55:37 +09003450 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003451}
3452
Tony Choa4ab1ad2015-10-12 16:56:05 +09003453s32 host_int_set_start_scan_req(struct host_if_drv *hif_drv, u8 scanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003454{
Leo Kim45102f82015-10-28 15:59:28 +09003455 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003456
Leo Kim45102f82015-10-28 15:59:28 +09003457 wid.id = (u16)WID_START_SCAN_REQ;
3458 wid.type = WID_CHAR;
3459 wid.val = (s8 *)&scanSource;
3460 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003461
Leo Kimb68d820b2015-10-12 16:55:37 +09003462 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003463}
3464
Tony Choa4ab1ad2015-10-12 16:56:05 +09003465s32 host_int_get_start_scan_req(struct host_if_drv *hif_drv, u8 *pu8ScanSource)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003466{
Leo Kim45102f82015-10-28 15:59:28 +09003467 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003468
Leo Kim45102f82015-10-28 15:59:28 +09003469 wid.id = (u16)WID_START_SCAN_REQ;
3470 wid.type = WID_CHAR;
3471 wid.val = (s8 *)pu8ScanSource;
3472 wid.size = sizeof(char);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003473
Leo Kimb68d820b2015-10-12 16:55:37 +09003474 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003475}
3476
Tony Choa4ab1ad2015-10-12 16:56:05 +09003477s32 host_int_set_join_req(struct host_if_drv *hif_drv, u8 *pu8bssid,
3478 const u8 *pu8ssid, size_t ssidLen,
3479 const u8 *pu8IEs, size_t IEsLen,
3480 wilc_connect_result pfConnectResult, void *pvUserArg,
3481 u8 u8security, enum AUTHTYPE tenuAuth_type,
3482 u8 u8channel, void *pJoinParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003483{
Leo Kim31390ee2015-10-19 18:26:08 +09003484 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003485 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003486
Leo Kim91109e12015-10-19 18:26:13 +09003487 if (!hif_drv || !pfConnectResult) {
Leo Kim24db7132015-09-16 18:36:01 +09003488 PRINT_ER("Driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003489 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003490 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003491
Leo Kim91109e12015-10-19 18:26:13 +09003492 if (!pJoinParams) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003493 PRINT_ER("Unable to Join - JoinParams is NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003494 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003495 }
Leo Kim24db7132015-09-16 18:36:01 +09003496
Tony Cho143eb952015-09-21 12:16:32 +09003497 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003498
Tony Choa9f812a2015-09-21 12:16:33 +09003499 msg.id = HOST_IF_MSG_CONNECT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003500
Leo Kima64fd672015-10-13 19:49:54 +09003501 msg.body.con_info.security = u8security;
Leo Kim61b4fd02015-10-13 19:49:57 +09003502 msg.body.con_info.auth_type = tenuAuth_type;
Leo Kim0d1527e2015-10-13 19:49:58 +09003503 msg.body.con_info.ch = u8channel;
Leo Kim6abcc112015-10-13 19:49:55 +09003504 msg.body.con_info.result = pfConnectResult;
Leo Kim8f38db82015-10-13 19:49:56 +09003505 msg.body.con_info.arg = pvUserArg;
Leo Kimf2bed2c2015-10-13 19:49:59 +09003506 msg.body.con_info.params = pJoinParams;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003507 msg.drv = hif_drv ;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003508
Leo Kim91109e12015-10-19 18:26:13 +09003509 if (pu8bssid) {
Leo Kim9254db02015-10-13 19:49:49 +09003510 msg.body.con_info.bssid = kmalloc(6, GFP_KERNEL);
3511 memcpy(msg.body.con_info.bssid, pu8bssid, 6);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003512 }
3513
Leo Kim91109e12015-10-19 18:26:13 +09003514 if (pu8ssid) {
Leo Kim8b3c9fa2015-10-13 19:49:51 +09003515 msg.body.con_info.ssid_len = ssidLen;
Leo Kimf7bbd9c2015-10-13 19:49:50 +09003516 msg.body.con_info.ssid = kmalloc(ssidLen, GFP_KERNEL);
3517 memcpy(msg.body.con_info.ssid, pu8ssid, ssidLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003518 }
3519
Leo Kim91109e12015-10-19 18:26:13 +09003520 if (pu8IEs) {
Leo Kimb59d5c52015-10-13 19:49:53 +09003521 msg.body.con_info.ies_len = IEsLen;
Leo Kim2ea158c2015-10-13 19:49:52 +09003522 msg.body.con_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3523 memcpy(msg.body.con_info.ies, pu8IEs, IEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003524 }
Leo Kimb60005a2015-10-29 11:58:24 +09003525 if (hif_drv->hif_state < HOST_IF_CONNECTING)
3526 hif_drv->hif_state = HOST_IF_CONNECTING;
Chandra S Gorentla78174ad2015-08-08 17:41:36 +05303527 else
Leo Kimb60005a2015-10-29 11:58:24 +09003528 PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' : %d\n",
3529 hif_drv->hif_state);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003530
Leo Kim31390ee2015-10-19 18:26:08 +09003531 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3532 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003533 PRINT_ER("Failed to send message queue: Set join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09003534 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003535 }
3536
Leo Kim81a59502015-10-29 11:58:35 +09003537 hif_drv->connect_timer.data = (unsigned long)hif_drv;
3538 mod_timer(&hif_drv->connect_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003539 jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003540
Leo Kim31390ee2015-10-19 18:26:08 +09003541 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003542}
3543
Tony Choa4ab1ad2015-10-12 16:56:05 +09003544s32 host_int_flush_join_req(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003545{
Leo Kim31390ee2015-10-19 18:26:08 +09003546 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003547 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003548
Leo Kim7717880782015-10-19 18:26:11 +09003549 if (!join_req)
3550 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003551
Tony Choa4ab1ad2015-10-12 16:56:05 +09003552 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003553 PRINT_ER("Driver is null\n");
Leo Kim7717880782015-10-19 18:26:11 +09003554 return -EFAULT;
Leo Kim24db7132015-09-16 18:36:01 +09003555 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003556
Tony Choa9f812a2015-09-21 12:16:33 +09003557 msg.id = HOST_IF_MSG_FLUSH_CONNECT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003558 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003559
Leo Kim31390ee2015-10-19 18:26:08 +09003560 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3561 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003562 PRINT_ER("Failed to send message queue: Flush join request\n");
Leo Kim24db7132015-09-16 18:36:01 +09003563 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003564 }
3565
Leo Kim31390ee2015-10-19 18:26:08 +09003566 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003567}
3568
Tony Choa4ab1ad2015-10-12 16:56:05 +09003569s32 host_int_disconnect(struct host_if_drv *hif_drv, u16 u16ReasonCode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003570{
Leo Kim31390ee2015-10-19 18:26:08 +09003571 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003572 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003573
Tony Choa4ab1ad2015-10-12 16:56:05 +09003574 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003575 PRINT_ER("Driver is null\n");
3576 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003577 }
3578
Tony Cho143eb952015-09-21 12:16:32 +09003579 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003580
Tony Choa9f812a2015-09-21 12:16:33 +09003581 msg.id = HOST_IF_MSG_DISCONNECT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003582 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003583
Leo Kim31390ee2015-10-19 18:26:08 +09003584 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3585 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003586 PRINT_ER("Failed to send message queue: disconnect\n");
Leo Kimae4dfa52015-10-13 19:49:26 +09003587
Leo Kime55e4962015-10-29 11:58:29 +09003588 down(&hif_drv->sem_test_disconn_block);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003589
Leo Kim31390ee2015-10-19 18:26:08 +09003590 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003591}
3592
Tony Choa4ab1ad2015-10-12 16:56:05 +09003593s32 host_int_disconnect_station(struct host_if_drv *hif_drv, u8 assoc_id)
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_DISCONNECT;
3598 wid.type = WID_CHAR;
3599 wid.val = (s8 *)&assoc_id;
3600 wid.size = sizeof(char);
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_req_info(struct host_if_drv *hif_drv,
3606 u8 *pu8AssocReqInfo,
3607 u32 u32AssocReqInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003608{
Leo Kim45102f82015-10-28 15:59:28 +09003609 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003610
Leo Kim45102f82015-10-28 15:59:28 +09003611 wid.id = (u16)WID_ASSOC_REQ_INFO;
3612 wid.type = WID_STR;
3613 wid.val = pu8AssocReqInfo;
3614 wid.size = u32AssocReqInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003615
Leo Kimb68d820b2015-10-12 16:55:37 +09003616 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003617}
3618
Leo Kim8c8360b2015-10-19 18:26:12 +09003619s32 host_int_get_assoc_res_info(struct host_if_drv *hif_drv,
3620 u8 *pu8AssocRespInfo,
3621 u32 u32MaxAssocRespInfoLen,
3622 u32 *pu32RcvdAssocRespInfoLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003623{
Leo Kim31390ee2015-10-19 18:26:08 +09003624 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09003625 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003626
Tony Choa4ab1ad2015-10-12 16:56:05 +09003627 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003628 PRINT_ER("Driver is null\n");
3629 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003630 }
3631
Leo Kim45102f82015-10-28 15:59:28 +09003632 wid.id = (u16)WID_ASSOC_RES_INFO;
3633 wid.type = WID_STR;
3634 wid.val = pu8AssocRespInfo;
3635 wid.size = u32MaxAssocRespInfoLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003636
Leo Kim45102f82015-10-28 15:59:28 +09003637 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09003638 get_id_from_handler(hif_drv));
Leo Kim31390ee2015-10-19 18:26:08 +09003639 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003640 *pu32RcvdAssocRespInfoLen = 0;
Leo Kim24db7132015-09-16 18:36:01 +09003641 PRINT_ER("Failed to send association response config packet\n");
3642 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003643 } else {
Leo Kim45102f82015-10-28 15:59:28 +09003644 *pu32RcvdAssocRespInfoLen = wid.size;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003645 }
3646
Leo Kim31390ee2015-10-19 18:26:08 +09003647 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003648}
3649
Leo Kim8c8360b2015-10-19 18:26:12 +09003650s32 host_int_get_rx_power_level(struct host_if_drv *hif_drv,
3651 u8 *pu8RxPowerLevel,
3652 u32 u32RxPowerLevelLen)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003653{
Leo Kim45102f82015-10-28 15:59:28 +09003654 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003655
Leo Kim45102f82015-10-28 15:59:28 +09003656 wid.id = (u16)WID_RX_POWER_LEVEL;
3657 wid.type = WID_STR;
3658 wid.val = pu8RxPowerLevel;
3659 wid.size = u32RxPowerLevelLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003660
Leo Kimb68d820b2015-10-12 16:55:37 +09003661 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003662}
3663
Tony Choa4ab1ad2015-10-12 16:56:05 +09003664int host_int_set_mac_chnl_num(struct host_if_drv *hif_drv, u8 channel)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003665{
Chaehyun Lim792fb252015-10-05 11:07:22 +09003666 int result;
Tony Cho143eb952015-09-21 12:16:32 +09003667 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003668
Tony Choa4ab1ad2015-10-12 16:56:05 +09003669 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003670 PRINT_ER("driver is null\n");
3671 return -EFAULT;
3672 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003673
Tony Cho143eb952015-09-21 12:16:32 +09003674 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003675 msg.id = HOST_IF_MSG_SET_CHANNEL;
Leo Kim730ee052015-10-13 19:50:02 +09003676 msg.body.channel_info.set_ch = channel;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003677 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003678
Leo Kimcb067dc2015-10-15 13:24:53 +09003679 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lim1ef58e42015-10-02 21:44:49 +09003680 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003681 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim792fb252015-10-05 11:07:22 +09003682 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003683 }
3684
Chaehyun Lim792fb252015-10-05 11:07:22 +09003685 return 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003686}
3687
Chaehyun Lim244efb12015-10-02 21:44:53 +09003688int host_int_wait_msg_queue_idle(void)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003689{
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003690 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003691 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003692
Tony Cho143eb952015-09-21 12:16:32 +09003693 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003694 msg.id = HOST_IF_MSG_Q_IDLE;
Leo Kimcb067dc2015-10-15 13:24:53 +09003695 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003696 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003697 PRINT_ER("wilc mq send fail\n");
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003698 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003699 }
3700
Leo Kim2d25af82015-10-15 13:24:56 +09003701 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003702
Chaehyun Lim6d6c9bb2015-10-02 21:44:54 +09003703 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003704}
3705
Tony Choa4ab1ad2015-10-12 16:56:05 +09003706int host_int_set_wfi_drv_handler(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003707{
Chaehyun Lima0941012015-10-05 19:34:47 +09003708 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003709 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003710
Tony Cho143eb952015-09-21 12:16:32 +09003711 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003712 msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER;
Leo Kima7f3b122015-10-28 15:59:29 +09003713 msg.body.drv.handler = get_id_from_handler(hif_drv);
Tony Choa4ab1ad2015-10-12 16:56:05 +09003714 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003715
Leo Kimcb067dc2015-10-15 13:24:53 +09003716 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lima0941012015-10-05 19:34:47 +09003717 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003718 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0941012015-10-05 19:34:47 +09003719 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003720 }
3721
Chaehyun Lima0941012015-10-05 19:34:47 +09003722 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003723}
3724
Tony Choa4ab1ad2015-10-12 16:56:05 +09003725int host_int_set_operation_mode(struct host_if_drv *hif_drv, u32 mode)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003726{
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003727 int result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003728 struct host_if_msg msg;
Leo Kimc09389a2015-10-28 15:59:24 +09003729
Tony Cho143eb952015-09-21 12:16:32 +09003730 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003731 msg.id = HOST_IF_MSG_SET_OPERATION_MODE;
Leo Kimc96debf2015-10-28 15:59:30 +09003732 msg.body.mode.mode = mode;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003733 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003734
Leo Kimcb067dc2015-10-15 13:24:53 +09003735 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003736 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003737 PRINT_ER("wilc mq send fail\n");
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003738 result = -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003739 }
3740
Chaehyun Lima0c1ee02015-10-05 19:34:50 +09003741 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003742}
3743
Tony Choa4ab1ad2015-10-12 16:56:05 +09003744s32 host_int_get_host_chnl_num(struct host_if_drv *hif_drv, u8 *pu8ChNo)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003745{
Leo Kim31390ee2015-10-19 18:26:08 +09003746 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003747 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003748
Tony Choa4ab1ad2015-10-12 16:56:05 +09003749 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003750 PRINT_ER("driver is null\n");
3751 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003752 }
3753
Tony Cho143eb952015-09-21 12:16:32 +09003754 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003755
Tony Choa9f812a2015-09-21 12:16:33 +09003756 msg.id = HOST_IF_MSG_GET_CHNL;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003757 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003758
Leo Kim31390ee2015-10-19 18:26:08 +09003759 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3760 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09003761 PRINT_ER("wilc mq send fail\n");
Leo Kim4ea90002015-10-29 11:58:32 +09003762 down(&hif_drv->sem_get_chnl);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003763
Leo Kim95ebb0f2015-10-15 13:25:03 +09003764 *pu8ChNo = ch_no;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003765
Leo Kim31390ee2015-10-19 18:26:08 +09003766 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003767}
3768
Tony Choa4ab1ad2015-10-12 16:56:05 +09003769s32 host_int_get_inactive_time(struct host_if_drv *hif_drv,
3770 const u8 *mac, u32 *pu32InactiveTime)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003771{
Leo Kim31390ee2015-10-19 18:26:08 +09003772 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003773 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003774
Tony Choa4ab1ad2015-10-12 16:56:05 +09003775 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003776 PRINT_ER("driver is null\n");
3777 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003778 }
3779
Tony Cho143eb952015-09-21 12:16:32 +09003780 memset(&msg, 0, sizeof(struct host_if_msg));
Leo Kim8c8360b2015-10-19 18:26:12 +09003781 memcpy(msg.body.mac_info.mac, mac, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003782
Tony Choa9f812a2015-09-21 12:16:33 +09003783 msg.id = HOST_IF_MSG_GET_INACTIVETIME;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003784 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003785
Leo Kim31390ee2015-10-19 18:26:08 +09003786 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3787 if (result)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003788 PRINT_ER("Failed to send get host channel param's message queue ");
3789
Leo Kim569a3c62015-10-29 11:58:33 +09003790 down(&hif_drv->sem_inactive_time);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003791
Leo Kimad269062015-10-15 13:25:06 +09003792 *pu32InactiveTime = inactive_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003793
Leo Kim31390ee2015-10-19 18:26:08 +09003794 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003795}
Glen Lee108b3432015-09-16 18:53:20 +09003796
Tony Choa4ab1ad2015-10-12 16:56:05 +09003797s32 host_int_test_get_int_wid(struct host_if_drv *hif_drv, u32 *pu32TestMemAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003798{
Leo Kim31390ee2015-10-19 18:26:08 +09003799 s32 result = 0;
Leo Kim45102f82015-10-28 15:59:28 +09003800 struct wid wid;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003801
Tony Choa4ab1ad2015-10-12 16:56:05 +09003802 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09003803 PRINT_ER("driver is null\n");
3804 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003805 }
3806
Leo Kim45102f82015-10-28 15:59:28 +09003807 wid.id = (u16)WID_MEMORY_ADDRESS;
3808 wid.type = WID_INT;
3809 wid.val = (s8 *)pu32TestMemAddr;
3810 wid.size = sizeof(u32);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003811
Leo Kim45102f82015-10-28 15:59:28 +09003812 result = send_config_pkt(GET_CFG, &wid, 1,
Leo Kim8c8360b2015-10-19 18:26:12 +09003813 get_id_from_handler(hif_drv));
Leo Kimae4dfa52015-10-13 19:49:26 +09003814
Leo Kim31390ee2015-10-19 18:26:08 +09003815 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003816 PRINT_ER("Failed to get wid value\n");
3817 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003818 } else {
3819 PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003820 }
3821
Leo Kim31390ee2015-10-19 18:26:08 +09003822 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003823}
3824
Tony Choa4ab1ad2015-10-12 16:56:05 +09003825s32 host_int_get_rssi(struct host_if_drv *hif_drv, s8 *ps8Rssi)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003826{
Leo Kim31390ee2015-10-19 18:26:08 +09003827 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003828 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003829
Leo Kimc09389a2015-10-28 15:59:24 +09003830 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003831 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003832 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003833
Leo Kim31390ee2015-10-19 18:26:08 +09003834 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3835 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003836 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003837 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003838 }
3839
Leo Kim7e111f92015-10-29 11:58:30 +09003840 down(&hif_drv->sem_get_rssi);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003841
Leo Kim91109e12015-10-19 18:26:13 +09003842 if (!ps8Rssi) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003843 PRINT_ER("RSS pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09003844 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003845 }
3846
Leo Kim144b7b22015-10-15 13:25:01 +09003847 *ps8Rssi = rssi;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003848
Leo Kim31390ee2015-10-19 18:26:08 +09003849 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003850}
3851
Tony Choa4ab1ad2015-10-12 16:56:05 +09003852s32 host_int_get_link_speed(struct host_if_drv *hif_drv, s8 *ps8lnkspd)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003853{
Tony Cho143eb952015-09-21 12:16:32 +09003854 struct host_if_msg msg;
Leo Kim31390ee2015-10-19 18:26:08 +09003855 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003856
Leo Kimc09389a2015-10-28 15:59:24 +09003857 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003858 msg.id = HOST_IF_MSG_GET_LINKSPEED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003859 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003860
Leo Kim31390ee2015-10-19 18:26:08 +09003861 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3862 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003863 PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003864 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003865 }
3866
Leo Kimbc34da62015-10-29 11:58:31 +09003867 down(&hif_drv->sem_get_link_speed);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003868
Leo Kim91109e12015-10-19 18:26:13 +09003869 if (!ps8lnkspd) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003870 PRINT_ER("LINKSPEED pointer value is null");
Leo Kime6e12662015-09-16 18:36:03 +09003871 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003872 }
3873
Leo Kim75327a02015-10-15 13:25:02 +09003874 *ps8lnkspd = link_speed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003875
Leo Kim31390ee2015-10-19 18:26:08 +09003876 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003877}
3878
Tony Choa4ab1ad2015-10-12 16:56:05 +09003879s32 host_int_get_statistics(struct host_if_drv *hif_drv, struct rf_info *pstrStatistics)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003880{
Leo Kim31390ee2015-10-19 18:26:08 +09003881 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003882 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003883
Leo Kimc09389a2015-10-28 15:59:24 +09003884 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003885 msg.id = HOST_IF_MSG_GET_STATISTICS;
Tony Choe60831e2015-10-05 13:50:45 +09003886 msg.body.data = (char *)pstrStatistics;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003887 msg.drv = hif_drv;
Leo Kimae4dfa52015-10-13 19:49:26 +09003888
Leo Kim31390ee2015-10-19 18:26:08 +09003889 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3890 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003891 PRINT_ER("Failed to send get host channel param's message queue ");
Leo Kime6e12662015-09-16 18:36:03 +09003892 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003893 }
3894
Leo Kim2d25af82015-10-15 13:24:56 +09003895 down(&hif_sema_wait_response);
Leo Kim31390ee2015-10-19 18:26:08 +09003896 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003897}
3898
Tony Choa4ab1ad2015-10-12 16:56:05 +09003899s32 host_int_scan(struct host_if_drv *hif_drv, u8 u8ScanSource,
3900 u8 u8ScanType, u8 *pu8ChnlFreqList,
3901 u8 u8ChnlListLen, const u8 *pu8IEs,
3902 size_t IEsLen, wilc_scan_result ScanResult,
3903 void *pvUserArg, struct hidden_network *pstrHiddenNetwork)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003904{
Leo Kim31390ee2015-10-19 18:26:08 +09003905 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003906 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003907
Leo Kim91109e12015-10-19 18:26:13 +09003908 if (!hif_drv || !ScanResult) {
Tony Choa4ab1ad2015-10-12 16:56:05 +09003909 PRINT_ER("hif_drv or ScanResult = NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003910 return -EFAULT;
3911 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003912
Tony Cho143eb952015-09-21 12:16:32 +09003913 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003914
Tony Choa9f812a2015-09-21 12:16:33 +09003915 msg.id = HOST_IF_MSG_SCAN;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003916
Leo Kim91109e12015-10-19 18:26:13 +09003917 if (pstrHiddenNetwork) {
Leo Kim629b9ca2015-10-13 19:49:46 +09003918 msg.body.scan_info.hidden_network.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
3919 msg.body.scan_info.hidden_network.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003920
3921 } else
3922 PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
3923
Tony Choa4ab1ad2015-10-12 16:56:05 +09003924 msg.drv = hif_drv;
Leo Kim42568892015-10-13 19:49:37 +09003925 msg.body.scan_info.src = u8ScanSource;
Leo Kim1e276c82015-10-13 19:49:38 +09003926 msg.body.scan_info.type = u8ScanType;
Leo Kimc17c6da2015-10-13 19:49:44 +09003927 msg.body.scan_info.result = ScanResult;
Leo Kim5f2b50c2015-10-13 19:49:45 +09003928 msg.body.scan_info.arg = pvUserArg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003929
Leo Kimf97bd9c2015-10-13 19:49:41 +09003930 msg.body.scan_info.ch_list_len = u8ChnlListLen;
Leo Kim82eeb0a2015-10-13 19:49:40 +09003931 msg.body.scan_info.ch_freq_list = kmalloc(u8ChnlListLen, GFP_KERNEL);
3932 memcpy(msg.body.scan_info.ch_freq_list, pu8ChnlFreqList, u8ChnlListLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003933
Leo Kim7b1f76c2015-10-13 19:49:43 +09003934 msg.body.scan_info.ies_len = IEsLen;
Leo Kimd6f19aa2015-10-13 19:49:42 +09003935 msg.body.scan_info.ies = kmalloc(IEsLen, GFP_KERNEL);
3936 memcpy(msg.body.scan_info.ies, pu8IEs, IEsLen);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003937
Leo Kim31390ee2015-10-19 18:26:08 +09003938 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
3939 if (result) {
Leo Kim24db7132015-09-16 18:36:01 +09003940 PRINT_ER("Error in sending message queue\n");
3941 return -EINVAL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003942 }
3943
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003944 PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
Leo Kim13b313e2015-10-29 11:58:34 +09003945 hif_drv->scan_timer.data = (unsigned long)hif_drv;
3946 mod_timer(&hif_drv->scan_timer,
Greg Kroah-Hartman9eb06642015-08-17 11:10:55 -07003947 jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003948
Leo Kim31390ee2015-10-19 18:26:08 +09003949 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003950}
Leo Kimae4dfa52015-10-13 19:49:26 +09003951
Tony Choa4ab1ad2015-10-12 16:56:05 +09003952s32 hif_set_cfg(struct host_if_drv *hif_drv,
3953 struct cfg_param_val *pstrCfgParamVal)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003954{
Leo Kim31390ee2015-10-19 18:26:08 +09003955 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09003956 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003957
Tony Choa4ab1ad2015-10-12 16:56:05 +09003958 if (!hif_drv) {
3959 PRINT_ER("hif_drv NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003960 return -EFAULT;
3961 }
Leo Kimae4dfa52015-10-13 19:49:26 +09003962
Tony Cho143eb952015-09-21 12:16:32 +09003963 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09003964 msg.id = HOST_IF_MSG_CFG_PARAMS;
Tony Cho221371e2015-10-12 16:56:06 +09003965 msg.body.cfg_info.cfg_attr_info = *pstrCfgParamVal;
Tony Choa4ab1ad2015-10-12 16:56:05 +09003966 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003967
Leo Kim31390ee2015-10-19 18:26:08 +09003968 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003969
Leo Kim31390ee2015-10-19 18:26:08 +09003970 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003971}
3972
Tony Choa4ab1ad2015-10-12 16:56:05 +09003973s32 hif_get_cfg(struct host_if_drv *hif_drv, u16 u16WID, u16 *pu16WID_Value)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003974{
Leo Kim31390ee2015-10-19 18:26:08 +09003975 s32 result = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003976
Leo Kim33110ad2015-10-29 11:58:27 +09003977 down(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003978
Tony Choa4ab1ad2015-10-12 16:56:05 +09003979 if (!hif_drv) {
3980 PRINT_ER("hif_drv NULL\n");
Leo Kim24db7132015-09-16 18:36:01 +09003981 return -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003982 }
3983 PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
3984 switch (u16WID) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003985 case WID_BSS_TYPE:
Leo Kimace303f2015-10-29 11:58:26 +09003986 *pu16WID_Value = (u16)hif_drv->cfg_values.bss_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003987 break;
3988
3989 case WID_AUTH_TYPE:
Leo Kimace303f2015-10-29 11:58:26 +09003990 *pu16WID_Value = (u16)hif_drv->cfg_values.auth_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003991 break;
3992
3993 case WID_AUTH_TIMEOUT:
Leo Kimace303f2015-10-29 11:58:26 +09003994 *pu16WID_Value = hif_drv->cfg_values.auth_timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003995 break;
3996
3997 case WID_POWER_MANAGEMENT:
Leo Kimace303f2015-10-29 11:58:26 +09003998 *pu16WID_Value = (u16)hif_drv->cfg_values.power_mgmt_mode;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09003999 break;
4000
4001 case WID_SHORT_RETRY_LIMIT:
Leo Kimace303f2015-10-29 11:58:26 +09004002 *pu16WID_Value = hif_drv->cfg_values.short_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004003 break;
4004
4005 case WID_LONG_RETRY_LIMIT:
Leo Kimace303f2015-10-29 11:58:26 +09004006 *pu16WID_Value = hif_drv->cfg_values.long_retry_limit;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004007 break;
4008
4009 case WID_FRAG_THRESHOLD:
Leo Kimace303f2015-10-29 11:58:26 +09004010 *pu16WID_Value = hif_drv->cfg_values.frag_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004011 break;
4012
4013 case WID_RTS_THRESHOLD:
Leo Kimace303f2015-10-29 11:58:26 +09004014 *pu16WID_Value = hif_drv->cfg_values.rts_threshold;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004015 break;
4016
4017 case WID_PREAMBLE:
Leo Kimace303f2015-10-29 11:58:26 +09004018 *pu16WID_Value = (u16)hif_drv->cfg_values.preamble_type;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004019 break;
4020
4021 case WID_SHORT_SLOT_ALLOWED:
Leo Kimace303f2015-10-29 11:58:26 +09004022 *pu16WID_Value = (u16)hif_drv->cfg_values.short_slot_allowed;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004023 break;
4024
4025 case WID_11N_TXOP_PROT_DISABLE:
Leo Kimace303f2015-10-29 11:58:26 +09004026 *pu16WID_Value = (u16)hif_drv->cfg_values.txop_prot_disabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004027 break;
4028
4029 case WID_BEACON_INTERVAL:
Leo Kimace303f2015-10-29 11:58:26 +09004030 *pu16WID_Value = hif_drv->cfg_values.beacon_interval;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004031 break;
4032
4033 case WID_DTIM_PERIOD:
Leo Kimace303f2015-10-29 11:58:26 +09004034 *pu16WID_Value = (u16)hif_drv->cfg_values.dtim_period;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004035 break;
4036
4037 case WID_SITE_SURVEY:
Leo Kimace303f2015-10-29 11:58:26 +09004038 *pu16WID_Value = (u16)hif_drv->cfg_values.site_survey_enabled;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004039 break;
4040
4041 case WID_SITE_SURVEY_SCAN_TIME:
Leo Kimace303f2015-10-29 11:58:26 +09004042 *pu16WID_Value = hif_drv->cfg_values.site_survey_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004043 break;
4044
4045 case WID_ACTIVE_SCAN_TIME:
Leo Kimace303f2015-10-29 11:58:26 +09004046 *pu16WID_Value = hif_drv->cfg_values.active_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004047 break;
4048
4049 case WID_PASSIVE_SCAN_TIME:
Leo Kimace303f2015-10-29 11:58:26 +09004050 *pu16WID_Value = hif_drv->cfg_values.passive_scan_time;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004051 break;
4052
4053 case WID_CURRENT_TX_RATE:
Leo Kimace303f2015-10-29 11:58:26 +09004054 *pu16WID_Value = hif_drv->cfg_values.curr_tx_rate;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004055 break;
4056
4057 default:
4058 break;
4059 }
4060
Leo Kim33110ad2015-10-29 11:58:27 +09004061 up(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004062
Leo Kim31390ee2015-10-19 18:26:08 +09004063 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004064}
4065
Greg Kroah-Hartman93dee8e2015-08-14 20:28:32 -07004066static void GetPeriodicRSSI(unsigned long arg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004067{
Tony Choa4ab1ad2015-10-12 16:56:05 +09004068 struct host_if_drv *hif_drv = (struct host_if_drv *)arg;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004069
Tony Choa4ab1ad2015-10-12 16:56:05 +09004070 if (!hif_drv) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004071 PRINT_ER("Driver handler is NULL\n");
4072 return;
4073 }
4074
Leo Kimb60005a2015-10-29 11:58:24 +09004075 if (hif_drv->hif_state == HOST_IF_CONNECTED) {
Leo Kim31390ee2015-10-19 18:26:08 +09004076 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004077 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004078
Tony Cho143eb952015-09-21 12:16:32 +09004079 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004080
Tony Choa9f812a2015-09-21 12:16:33 +09004081 msg.id = HOST_IF_MSG_GET_RSSI;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004082 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004083
Leo Kim31390ee2015-10-19 18:26:08 +09004084 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4085 if (result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004086 PRINT_ER("Failed to send get host channel param's message queue ");
4087 return;
4088 }
4089 }
Leo Kim262f55e2015-10-15 13:24:58 +09004090 periodic_rssi.data = (unsigned long)hif_drv;
4091 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004092}
4093
Glen Leed53822192015-10-27 18:27:49 +09004094s32 host_int_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004095{
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004096 s32 result = 0;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004097 struct host_if_drv *hif_drv;
Johnny Kimd42ab082015-08-20 16:32:52 +09004098 int err;
Glen Leed53822192015-10-27 18:27:49 +09004099 perInterface_wlan_t *nic;
4100 struct wilc *wilc;
4101
4102 nic = netdev_priv(dev);
4103 wilc = nic->wilc;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004104
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004105 PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
4106
Leo Kimca8540e42015-10-15 13:25:00 +09004107 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004108
Leo Kim2d25af82015-10-15 13:24:56 +09004109 sema_init(&hif_sema_wait_response, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004110
Tony Choa4ab1ad2015-10-12 16:56:05 +09004111 hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
4112 if (!hif_drv) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004113 result = -ENOMEM;
Vincent Stehlé17db84e2015-10-07 07:08:25 +02004114 goto _fail_;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004115 }
Tony Choa4ab1ad2015-10-12 16:56:05 +09004116 *hif_drv_handler = hif_drv;
4117 err = add_handler_in_list(hif_drv);
Johnny Kimd42ab082015-08-20 16:32:52 +09004118 if (err) {
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004119 result = -EFAULT;
Johnny Kimd42ab082015-08-20 16:32:52 +09004120 goto _fail_timer_2;
4121 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004122
Dean Lee72ed4dc2015-06-12 14:11:44 +09004123 g_obtainingIP = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004124
Tony Choa4ab1ad2015-10-12 16:56:05 +09004125 PRINT_D(HOSTINF_DBG, "Global handle pointer value=%p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004126 if (clients_count == 0) {
Leo Kim834e0cb2015-10-15 13:24:54 +09004127 sema_init(&hif_sema_thread, 0);
Leo Kim27ff2162015-10-15 13:24:55 +09004128 sema_init(&hif_sema_driver, 0);
Leo Kim440e89932015-10-15 13:24:57 +09004129 sema_init(&hif_sema_deinit, 1);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004130 }
4131
Leo Kim9ea47132015-10-29 11:58:28 +09004132 sema_init(&hif_drv->sem_test_key_block, 0);
Leo Kime55e4962015-10-29 11:58:29 +09004133 sema_init(&hif_drv->sem_test_disconn_block, 0);
Leo Kim7e111f92015-10-29 11:58:30 +09004134 sema_init(&hif_drv->sem_get_rssi, 0);
Leo Kimbc34da62015-10-29 11:58:31 +09004135 sema_init(&hif_drv->sem_get_link_speed, 0);
Leo Kim4ea90002015-10-29 11:58:32 +09004136 sema_init(&hif_drv->sem_get_chnl, 0);
Leo Kim569a3c62015-10-29 11:58:33 +09004137 sema_init(&hif_drv->sem_inactive_time, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004138
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004139 PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
4140
4141 if (clients_count == 0) {
Leo Kimcb067dc2015-10-15 13:24:53 +09004142 result = wilc_mq_create(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004143
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004144 if (result < 0) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004145 PRINT_ER("Failed to creat MQ\n");
4146 goto _fail_;
4147 }
Leo Kimc2115d82015-10-15 13:24:52 +09004148
Glen Leed53822192015-10-27 18:27:49 +09004149 hif_thread_handler = kthread_run(hostIFthread, wilc,
4150 "WILC_kthread");
Leo Kimc2115d82015-10-15 13:24:52 +09004151
4152 if (IS_ERR(hif_thread_handler)) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004153 PRINT_ER("Failed to creat Thread\n");
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004154 result = -EFAULT;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004155 goto _fail_mq_;
4156 }
Leo Kim262f55e2015-10-15 13:24:58 +09004157 setup_timer(&periodic_rssi, GetPeriodicRSSI,
Tony Choa4ab1ad2015-10-12 16:56:05 +09004158 (unsigned long)hif_drv);
Leo Kim262f55e2015-10-15 13:24:58 +09004159 mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004160 }
4161
Leo Kim13b313e2015-10-29 11:58:34 +09004162 setup_timer(&hif_drv->scan_timer, TimerCB_Scan, 0);
Leo Kim81a59502015-10-29 11:58:35 +09004163 setup_timer(&hif_drv->connect_timer, TimerCB_Connect, 0);
Leo Kimcc2d7e92015-10-29 11:58:36 +09004164 setup_timer(&hif_drv->remain_on_ch_timer, ListenTimerCB, 0);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004165
Leo Kim33110ad2015-10-29 11:58:27 +09004166 sema_init(&hif_drv->sem_cfg_values, 1);
4167 down(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004168
Leo Kimb60005a2015-10-29 11:58:24 +09004169 hif_drv->hif_state = HOST_IF_IDLE;
Leo Kimace303f2015-10-29 11:58:26 +09004170 hif_drv->cfg_values.site_survey_enabled = SITE_SURVEY_OFF;
4171 hif_drv->cfg_values.scan_source = DEFAULT_SCAN;
4172 hif_drv->cfg_values.active_scan_time = ACTIVE_SCAN_TIME;
4173 hif_drv->cfg_values.passive_scan_time = PASSIVE_SCAN_TIME;
4174 hif_drv->cfg_values.curr_tx_rate = AUTORATE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004175
Leo Kim1229b1a2015-10-29 12:05:39 +09004176 hif_drv->p2p_timeout = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004177
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004178 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 +09004179 hif_drv->cfg_values.site_survey_enabled,
4180 hif_drv->cfg_values.scan_source,
4181 hif_drv->cfg_values.active_scan_time,
4182 hif_drv->cfg_values.passive_scan_time,
4183 hif_drv->cfg_values.curr_tx_rate);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004184
Leo Kim33110ad2015-10-29 11:58:27 +09004185 up(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004186
Leo Kimae4dfa52015-10-13 19:49:26 +09004187 clients_count++;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004188
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004189 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004190
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004191_fail_timer_2:
Leo Kim33110ad2015-10-29 11:58:27 +09004192 up(&hif_drv->sem_cfg_values);
Leo Kim81a59502015-10-29 11:58:35 +09004193 del_timer_sync(&hif_drv->connect_timer);
Leo Kim13b313e2015-10-29 11:58:34 +09004194 del_timer_sync(&hif_drv->scan_timer);
Leo Kimc2115d82015-10-15 13:24:52 +09004195 kthread_stop(hif_thread_handler);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004196_fail_mq_:
Leo Kimcb067dc2015-10-15 13:24:53 +09004197 wilc_mq_destroy(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004198_fail_:
Chaehyun Lim5b09bd32015-09-22 18:34:59 +09004199 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004200}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004201
Tony Choa4ab1ad2015-10-12 16:56:05 +09004202s32 host_int_deinit(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004203{
Leo Kim31390ee2015-10-19 18:26:08 +09004204 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004205 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004206 int ret;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004207
Tony Choa4ab1ad2015-10-12 16:56:05 +09004208 if (!hif_drv) {
4209 PRINT_ER("hif_drv = NULL\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004210 return 0;
4211 }
4212
Leo Kim440e89932015-10-15 13:24:57 +09004213 down(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004214
Tony Choa4ab1ad2015-10-12 16:56:05 +09004215 terminated_handle = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004216 PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
4217
Leo Kim13b313e2015-10-29 11:58:34 +09004218 if (del_timer_sync(&hif_drv->scan_timer))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004219 PRINT_D(HOSTINF_DBG, ">> Scan timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004220
Leo Kim81a59502015-10-29 11:58:35 +09004221 if (del_timer_sync(&hif_drv->connect_timer))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004222 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004223
Leo Kim262f55e2015-10-15 13:24:58 +09004224 if (del_timer_sync(&periodic_rssi))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004225 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004226
Leo Kimcc2d7e92015-10-29 11:58:36 +09004227 del_timer_sync(&hif_drv->remain_on_ch_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004228
Johnny Kim218dc402015-08-13 13:41:19 +09004229 host_int_set_wfi_drv_handler(NULL);
Leo Kim27ff2162015-10-15 13:24:55 +09004230 down(&hif_sema_driver);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004231
Leo Kimbc801852015-10-29 11:58:50 +09004232 if (hif_drv->usr_scan_req.scan_result) {
4233 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL,
Leo Kim66eaea32015-10-29 11:58:51 +09004234 hif_drv->usr_scan_req.arg, NULL);
Leo Kimbc801852015-10-29 11:58:50 +09004235 hif_drv->usr_scan_req.scan_result = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004236 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004237
Leo Kimb60005a2015-10-29 11:58:24 +09004238 hif_drv->hif_state = HOST_IF_IDLE;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004239
Leo Kimca8540e42015-10-15 13:25:00 +09004240 scan_while_connected = false;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004241
Tony Cho143eb952015-09-21 12:16:32 +09004242 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004243
4244 if (clients_count == 1) {
Leo Kim262f55e2015-10-15 13:24:58 +09004245 if (del_timer_sync(&periodic_rssi))
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004246 PRINT_D(HOSTINF_DBG, ">> Connect timer is active\n");
Leo Kim262f55e2015-10-15 13:24:58 +09004247
Tony Choa9f812a2015-09-21 12:16:33 +09004248 msg.id = HOST_IF_MSG_EXIT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004249 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004250
Leo Kim31390ee2015-10-19 18:26:08 +09004251 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4252 if (result != 0)
4253 PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004254
Leo Kim834e0cb2015-10-15 13:24:54 +09004255 down(&hif_sema_thread);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004256
Leo Kimcb067dc2015-10-15 13:24:53 +09004257 wilc_mq_destroy(&hif_msg_q);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004258 }
4259
Leo Kim33110ad2015-10-29 11:58:27 +09004260 down(&hif_drv->sem_cfg_values);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004261
Tony Choa4ab1ad2015-10-12 16:56:05 +09004262 ret = remove_handler_in_list(hif_drv);
Johnny Kimd42ab082015-08-20 16:32:52 +09004263 if (ret)
Leo Kim31390ee2015-10-19 18:26:08 +09004264 result = -ENOENT;
Johnny Kimd42ab082015-08-20 16:32:52 +09004265
Tony Choa4ab1ad2015-10-12 16:56:05 +09004266 kfree(hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004267
Leo Kimae4dfa52015-10-13 19:49:26 +09004268 clients_count--;
Greg Kroah-Hartmanb1413b62015-06-02 14:11:12 +09004269 terminated_handle = NULL;
Leo Kim440e89932015-10-15 13:24:57 +09004270 up(&hif_sema_deinit);
Leo Kim31390ee2015-10-19 18:26:08 +09004271 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004272}
4273
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004274void NetworkInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004275{
Leo Kim31390ee2015-10-19 18:26:08 +09004276 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004277 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004278 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004279 struct host_if_drv *hif_drv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004280
Johnny Kimd42ab082015-08-20 16:32:52 +09004281 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09004282 hif_drv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004283
Tony Choa4ab1ad2015-10-12 16:56:05 +09004284 if (!hif_drv || hif_drv == terminated_handle) {
4285 PRINT_ER("NetworkInfo received but driver not init[%p]\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004286 return;
4287 }
4288
Tony Cho143eb952015-09-21 12:16:32 +09004289 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004290
Tony Choa9f812a2015-09-21 12:16:33 +09004291 msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004292 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004293
Leo Kim3bffac62015-10-13 20:02:11 +09004294 msg.body.net_info.len = u32Length;
Leo Kimb021b802015-10-13 20:02:10 +09004295 msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4296 memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004297
Leo Kim31390ee2015-10-19 18:26:08 +09004298 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4299 if (result)
4300 PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004301}
4302
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004303void GnrlAsyncInfoReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004304{
Leo Kim31390ee2015-10-19 18:26:08 +09004305 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004306 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004307 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004308 struct host_if_drv *hif_drv = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004309
Leo Kim440e89932015-10-15 13:24:57 +09004310 down(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004311
Johnny Kimd42ab082015-08-20 16:32:52 +09004312 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09004313 hif_drv = get_handler_from_id(id);
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004314 PRINT_D(HOSTINF_DBG, "General asynchronous info packet received\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004315
Tony Choa4ab1ad2015-10-12 16:56:05 +09004316 if (!hif_drv || hif_drv == terminated_handle) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004317 PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
Leo Kim440e89932015-10-15 13:24:57 +09004318 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004319 return;
4320 }
4321
Leo Kim33bfb192015-10-29 11:58:56 +09004322 if (!hif_drv->usr_conn_req.conn_result) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004323 PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
Leo Kim440e89932015-10-15 13:24:57 +09004324 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004325 return;
4326 }
4327
Tony Cho143eb952015-09-21 12:16:32 +09004328 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004329
Tony Choa9f812a2015-09-21 12:16:33 +09004330 msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004331 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004332
Leo Kimf94f4882015-10-13 19:50:01 +09004333 msg.body.async_info.len = u32Length;
Leo Kim33722ac72015-10-13 19:50:00 +09004334 msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL);
4335 memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004336
Leo Kim31390ee2015-10-19 18:26:08 +09004337 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4338 if (result)
4339 PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004340
Leo Kim440e89932015-10-15 13:24:57 +09004341 up(&hif_sema_deinit);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004342}
4343
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004344void host_int_ScanCompleteReceived(u8 *pu8Buffer, u32 u32Length)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004345{
Leo Kim31390ee2015-10-19 18:26:08 +09004346 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004347 struct host_if_msg msg;
Johnny Kimd42ab082015-08-20 16:32:52 +09004348 int id;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004349 struct host_if_drv *hif_drv = NULL;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004350
Johnny Kimd42ab082015-08-20 16:32:52 +09004351 id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
Tony Choa4ab1ad2015-10-12 16:56:05 +09004352 hif_drv = get_handler_from_id(id);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004353
Tony Choa4ab1ad2015-10-12 16:56:05 +09004354 PRINT_D(GENERIC_DBG, "Scan notification received %p\n", hif_drv);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004355
Tony Choa4ab1ad2015-10-12 16:56:05 +09004356 if (!hif_drv || hif_drv == terminated_handle)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004357 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004358
Leo Kimbc801852015-10-29 11:58:50 +09004359 if (hif_drv->usr_scan_req.scan_result) {
Tony Cho143eb952015-09-21 12:16:32 +09004360 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004361
Tony Choa9f812a2015-09-21 12:16:33 +09004362 msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004363 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004364
Leo Kim31390ee2015-10-19 18:26:08 +09004365 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4366 if (result)
4367 PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", result);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004368 }
4369
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004370 return;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004371}
4372
Tony Choa4ab1ad2015-10-12 16:56:05 +09004373s32 host_int_remain_on_channel(struct host_if_drv *hif_drv, u32 u32SessionID,
4374 u32 u32duration, u16 chan,
4375 wilc_remain_on_chan_expired RemainOnChanExpired,
4376 wilc_remain_on_chan_ready RemainOnChanReady,
4377 void *pvUserArg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004378{
Leo Kim31390ee2015-10-19 18:26:08 +09004379 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004380 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004381
Tony Choa4ab1ad2015-10-12 16:56:05 +09004382 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004383 PRINT_ER("driver is null\n");
4384 return -EFAULT;
4385 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004386
Tony Cho143eb952015-09-21 12:16:32 +09004387 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004388
Tony Choa9f812a2015-09-21 12:16:33 +09004389 msg.id = HOST_IF_MSG_REMAIN_ON_CHAN;
Leo Kim839ab702015-10-29 11:58:41 +09004390 msg.body.remain_on_ch.ch = chan;
Leo Kimbfb62ab2015-10-29 11:58:42 +09004391 msg.body.remain_on_ch.expired = RemainOnChanExpired;
Leo Kim5e5f7912015-10-29 11:58:43 +09004392 msg.body.remain_on_ch.ready = RemainOnChanReady;
Leo Kimc5cc4b12015-10-29 11:58:44 +09004393 msg.body.remain_on_ch.arg = pvUserArg;
Tony Cho070d3652015-09-30 18:55:10 +09004394 msg.body.remain_on_ch.u32duration = u32duration;
Leo Kim9d764e32015-10-29 12:05:38 +09004395 msg.body.remain_on_ch.id = u32SessionID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004396 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004397
Leo Kim31390ee2015-10-19 18:26:08 +09004398 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4399 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004400 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004401
Leo Kim31390ee2015-10-19 18:26:08 +09004402 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004403}
4404
Tony Choa4ab1ad2015-10-12 16:56:05 +09004405s32 host_int_ListenStateExpired(struct host_if_drv *hif_drv, u32 u32SessionID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004406{
Leo Kim31390ee2015-10-19 18:26:08 +09004407 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004408 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004409
Tony Choa4ab1ad2015-10-12 16:56:05 +09004410 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004411 PRINT_ER("driver is null\n");
4412 return -EFAULT;
4413 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004414
Leo Kimcc2d7e92015-10-29 11:58:36 +09004415 del_timer(&hif_drv->remain_on_ch_timer);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004416
Tony Cho143eb952015-09-21 12:16:32 +09004417 memset(&msg, 0, sizeof(struct host_if_msg));
Tony Choa9f812a2015-09-21 12:16:33 +09004418 msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004419 msg.drv = hif_drv;
Leo Kim9d764e32015-10-29 12:05:38 +09004420 msg.body.remain_on_ch.id = u32SessionID;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004421
Leo Kim31390ee2015-10-19 18:26:08 +09004422 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4423 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004424 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004425
Leo Kim31390ee2015-10-19 18:26:08 +09004426 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004427}
4428
Tony Choa4ab1ad2015-10-12 16:56:05 +09004429s32 host_int_frame_register(struct host_if_drv *hif_drv, u16 u16FrameType, bool bReg)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004430{
Leo Kim31390ee2015-10-19 18:26:08 +09004431 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004432 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004433
Tony Choa4ab1ad2015-10-12 16:56:05 +09004434 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004435 PRINT_ER("driver is null\n");
4436 return -EFAULT;
4437 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004438
Tony Cho143eb952015-09-21 12:16:32 +09004439 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004440
Tony Choa9f812a2015-09-21 12:16:33 +09004441 msg.id = HOST_IF_MSG_REGISTER_FRAME;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004442 switch (u16FrameType) {
4443 case ACTION:
4444 PRINT_D(HOSTINF_DBG, "ACTION\n");
Leo Kimbcb410b2015-10-29 11:58:40 +09004445 msg.body.reg_frame.reg_id = ACTION_FRM_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004446 break;
4447
4448 case PROBE_REQ:
4449 PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
Leo Kimbcb410b2015-10-29 11:58:40 +09004450 msg.body.reg_frame.reg_id = PROBE_REQ_IDX;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004451 break;
4452
4453 default:
4454 PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
4455 break;
4456 }
Leo Kimd5f654c2015-10-29 11:58:39 +09004457 msg.body.reg_frame.frame_type = u16FrameType;
Leo Kim6abf8682015-10-29 11:58:38 +09004458 msg.body.reg_frame.reg = bReg;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004459 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004460
Leo Kim31390ee2015-10-19 18:26:08 +09004461 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4462 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004463 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004464
Leo Kim31390ee2015-10-19 18:26:08 +09004465 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004466}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004467
Tony Choa4ab1ad2015-10-12 16:56:05 +09004468s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
4469 u32 u32DTIMPeriod, u32 u32HeadLen, u8 *pu8Head,
4470 u32 u32TailLen, u8 *pu8Tail)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004471{
Leo Kim31390ee2015-10-19 18:26:08 +09004472 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004473 struct host_if_msg msg;
Tony Choa98491e2015-09-30 18:44:31 +09004474 struct beacon_attr *pstrSetBeaconParam = &msg.body.beacon_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004475
Tony Choa4ab1ad2015-10-12 16:56:05 +09004476 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004477 PRINT_ER("driver is null\n");
4478 return -EFAULT;
4479 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004480
Tony Cho143eb952015-09-21 12:16:32 +09004481 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004482
4483 PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
4484
Tony Choa9f812a2015-09-21 12:16:33 +09004485 msg.id = HOST_IF_MSG_ADD_BEACON;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004486 msg.drv = hif_drv;
Leo Kim12262dd2015-10-13 19:50:03 +09004487 pstrSetBeaconParam->interval = u32Interval;
Leo Kime76ab772015-10-13 19:50:04 +09004488 pstrSetBeaconParam->dtim_period = u32DTIMPeriod;
Leo Kim51c66182015-10-13 19:50:05 +09004489 pstrSetBeaconParam->head_len = u32HeadLen;
Shraddha Barke543f5b12015-10-16 10:47:11 +05304490 pstrSetBeaconParam->head = kmemdup(pu8Head, u32HeadLen, GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09004491 if (!pstrSetBeaconParam->head) {
Leo Kim31390ee2015-10-19 18:26:08 +09004492 result = -ENOMEM;
Leo Kim24db7132015-09-16 18:36:01 +09004493 goto ERRORHANDLER;
4494 }
Leo Kim030c57e2015-10-13 19:50:07 +09004495 pstrSetBeaconParam->tail_len = u32TailLen;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004496
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004497 if (u32TailLen > 0) {
Shraddha Barke543f5b12015-10-16 10:47:11 +05304498 pstrSetBeaconParam->tail = kmemdup(pu8Tail, u32TailLen,
4499 GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09004500 if (!pstrSetBeaconParam->tail) {
Leo Kim31390ee2015-10-19 18:26:08 +09004501 result = -ENOMEM;
Leo Kim24db7132015-09-16 18:36:01 +09004502 goto ERRORHANDLER;
4503 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004504 } else {
Leo Kim7dbcb6d32015-10-13 19:50:08 +09004505 pstrSetBeaconParam->tail = NULL;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004506 }
4507
Leo Kim31390ee2015-10-19 18:26:08 +09004508 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4509 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004510 PRINT_ER("wilc mq send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004511
Leo Kim24db7132015-09-16 18:36:01 +09004512ERRORHANDLER:
Leo Kim31390ee2015-10-19 18:26:08 +09004513 if (result) {
Shraddha Barke95f840f2015-10-14 07:29:19 +05304514 kfree(pstrSetBeaconParam->head);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004515
Shraddha Barke95f840f2015-10-14 07:29:19 +05304516 kfree(pstrSetBeaconParam->tail);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004517 }
4518
Leo Kim31390ee2015-10-19 18:26:08 +09004519 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004520}
4521
Tony Choa4ab1ad2015-10-12 16:56:05 +09004522s32 host_int_del_beacon(struct host_if_drv *hif_drv)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004523{
Leo Kim31390ee2015-10-19 18:26:08 +09004524 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004525 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004526
Tony Choa4ab1ad2015-10-12 16:56:05 +09004527 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004528 PRINT_ER("driver is null\n");
4529 return -EFAULT;
4530 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004531
Tony Choa9f812a2015-09-21 12:16:33 +09004532 msg.id = HOST_IF_MSG_DEL_BEACON;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004533 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004534 PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
4535
Leo Kim31390ee2015-10-19 18:26:08 +09004536 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4537 if (result)
Leo Kim7dc1d0c2015-09-16 18:36:00 +09004538 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004539
Leo Kim31390ee2015-10-19 18:26:08 +09004540 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004541}
4542
Tony Choa4ab1ad2015-10-12 16:56:05 +09004543s32 host_int_add_station(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09004544 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004545{
Leo Kim31390ee2015-10-19 18:26:08 +09004546 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004547 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09004548 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004549
Tony Choa4ab1ad2015-10-12 16:56:05 +09004550 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004551 PRINT_ER("driver is null\n");
4552 return -EFAULT;
4553 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004554
Tony Cho143eb952015-09-21 12:16:32 +09004555 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004556
4557 PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
4558
Tony Choa9f812a2015-09-21 12:16:33 +09004559 msg.id = HOST_IF_MSG_ADD_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004560 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004561
Tony Cho6a89ba92015-09-21 12:16:46 +09004562 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Leo Kime7342232015-10-29 12:05:43 +09004563 if (pstrAddStationMsg->rates_len > 0) {
4564 u8 *rates = kmalloc(pstrAddStationMsg->rates_len, GFP_KERNEL);
Leo Kimc09389a2015-10-28 15:59:24 +09004565
Leo Kim7ae43362015-09-16 18:35:59 +09004566 if (!rates)
4567 return -ENOMEM;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004568
Leo Kima622e012015-10-29 12:05:44 +09004569 memcpy(rates, pstrStaParams->rates,
Leo Kime7342232015-10-29 12:05:43 +09004570 pstrAddStationMsg->rates_len);
Leo Kima622e012015-10-29 12:05:44 +09004571 pstrAddStationMsg->rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004572 }
4573
Leo Kim31390ee2015-10-19 18:26:08 +09004574 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4575 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004576 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004577 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004578}
4579
Tony Choa4ab1ad2015-10-12 16:56:05 +09004580s32 host_int_del_station(struct host_if_drv *hif_drv, const u8 *pu8MacAddr)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004581{
Leo Kim31390ee2015-10-19 18:26:08 +09004582 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004583 struct host_if_msg msg;
Tony Cho889c25b2015-09-30 18:44:33 +09004584 struct del_sta *pstrDelStationMsg = &msg.body.del_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004585
Tony Choa4ab1ad2015-10-12 16:56:05 +09004586 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004587 PRINT_ER("driver is null\n");
4588 return -EFAULT;
4589 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004590
Tony Cho143eb952015-09-21 12:16:32 +09004591 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004592
4593 PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
4594
Tony Choa9f812a2015-09-21 12:16:33 +09004595 msg.id = HOST_IF_MSG_DEL_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004596 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004597
Leo Kim91109e12015-10-19 18:26:13 +09004598 if (!pu8MacAddr)
Punit Vara0bc85242015-10-29 01:53:30 +05304599 eth_broadcast_addr(pstrDelStationMsg->mac_addr);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004600 else
Leo Kime4839d32015-10-13 20:02:06 +09004601 memcpy(pstrDelStationMsg->mac_addr, pu8MacAddr, ETH_ALEN);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004602
Leo Kim31390ee2015-10-19 18:26:08 +09004603 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4604 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004605 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004606 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004607}
Leo Kimae4dfa52015-10-13 19:49:26 +09004608
Tony Choa4ab1ad2015-10-12 16:56:05 +09004609s32 host_int_del_allstation(struct host_if_drv *hif_drv,
Leo Kim441dc602015-10-12 16:55:35 +09004610 u8 pu8MacAddr[][ETH_ALEN])
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004611{
Leo Kim31390ee2015-10-19 18:26:08 +09004612 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004613 struct host_if_msg msg;
Tony Chob0c1e802015-10-05 13:50:46 +09004614 struct del_all_sta *pstrDelAllStationMsg = &msg.body.del_all_sta_info;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004615 u8 au8Zero_Buff[ETH_ALEN] = {0};
Chaehyun Lim4e4467f2015-06-11 14:35:55 +09004616 u32 i;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004617 u8 u8AssocNumb = 0;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004618
Tony Choa4ab1ad2015-10-12 16:56:05 +09004619 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004620 PRINT_ER("driver is null\n");
4621 return -EFAULT;
4622 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004623
Tony Cho143eb952015-09-21 12:16:32 +09004624 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004625
4626 PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
4627
Tony Choa9f812a2015-09-21 12:16:33 +09004628 msg.id = HOST_IF_MSG_DEL_ALL_STA;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004629 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004630
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004631 for (i = 0; i < MAX_NUM_STA; i++) {
4632 if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
Leo Kime51b9212015-10-13 19:50:09 +09004633 memcpy(pstrDelAllStationMsg->del_all_sta[i], pu8MacAddr[i], ETH_ALEN);
4634 PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n",
4635 pstrDelAllStationMsg->del_all_sta[i][0],
4636 pstrDelAllStationMsg->del_all_sta[i][1],
4637 pstrDelAllStationMsg->del_all_sta[i][2],
4638 pstrDelAllStationMsg->del_all_sta[i][3],
4639 pstrDelAllStationMsg->del_all_sta[i][4],
4640 pstrDelAllStationMsg->del_all_sta[i][5]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004641 u8AssocNumb++;
4642 }
4643 }
4644 if (!u8AssocNumb) {
4645 PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004646 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004647 }
4648
Leo Kim8ba18032015-10-13 19:50:10 +09004649 pstrDelAllStationMsg->assoc_sta = u8AssocNumb;
Leo Kim31390ee2015-10-19 18:26:08 +09004650 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004651
Leo Kim31390ee2015-10-19 18:26:08 +09004652 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004653 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004654
Leo Kim2d25af82015-10-15 13:24:56 +09004655 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004656
Leo Kim31390ee2015-10-19 18:26:08 +09004657 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004658}
4659
Tony Choa4ab1ad2015-10-12 16:56:05 +09004660s32 host_int_edit_station(struct host_if_drv *hif_drv,
Tony Cho6a89ba92015-09-21 12:16:46 +09004661 struct add_sta_param *pstrStaParams)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004662{
Leo Kim31390ee2015-10-19 18:26:08 +09004663 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004664 struct host_if_msg msg;
Tony Choca8f47f2015-09-30 18:44:32 +09004665 struct add_sta_param *pstrAddStationMsg = &msg.body.add_sta_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004666
Tony Choa4ab1ad2015-10-12 16:56:05 +09004667 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004668 PRINT_ER("driver is null\n");
4669 return -EFAULT;
4670 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004671
4672 PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
4673
Tony Cho143eb952015-09-21 12:16:32 +09004674 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004675
Tony Choa9f812a2015-09-21 12:16:33 +09004676 msg.id = HOST_IF_MSG_EDIT_STATION;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004677 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004678
Tony Cho6a89ba92015-09-21 12:16:46 +09004679 memcpy(pstrAddStationMsg, pstrStaParams, sizeof(struct add_sta_param));
Leo Kime7342232015-10-29 12:05:43 +09004680 if (pstrAddStationMsg->rates_len > 0) {
4681 u8 *rates = kmalloc(pstrAddStationMsg->rates_len, GFP_KERNEL);
Leo Kimc09389a2015-10-28 15:59:24 +09004682
Leo Kim7ae43362015-09-16 18:35:59 +09004683 if (!rates)
4684 return -ENOMEM;
4685
Leo Kima622e012015-10-29 12:05:44 +09004686 memcpy(rates, pstrStaParams->rates,
Leo Kime7342232015-10-29 12:05:43 +09004687 pstrAddStationMsg->rates_len);
Leo Kima622e012015-10-29 12:05:44 +09004688 pstrAddStationMsg->rates = rates;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004689 }
4690
Leo Kim31390ee2015-10-19 18:26:08 +09004691 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4692 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004693 PRINT_ER("wilc_mq_send fail\n");
4694
Leo Kim31390ee2015-10-19 18:26:08 +09004695 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004696}
Glen Lee108b3432015-09-16 18:53:20 +09004697
Tony Choa4ab1ad2015-10-12 16:56:05 +09004698s32 host_int_set_power_mgmt(struct host_if_drv *hif_drv,
4699 bool bIsEnabled,
4700 u32 u32Timeout)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004701{
Leo Kim31390ee2015-10-19 18:26:08 +09004702 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004703 struct host_if_msg msg;
Tony Cho49e1f812015-09-30 18:44:36 +09004704 struct power_mgmt_param *pstrPowerMgmtParam = &msg.body.pwr_mgmt_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004705
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004706 PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d <<\n\n", bIsEnabled);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004707
Tony Choa4ab1ad2015-10-12 16:56:05 +09004708 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004709 PRINT_ER("driver is null\n");
4710 return -EFAULT;
4711 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004712
4713 PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
4714
Tony Cho143eb952015-09-21 12:16:32 +09004715 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004716
Tony Choa9f812a2015-09-21 12:16:33 +09004717 msg.id = HOST_IF_MSG_POWER_MGMT;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004718 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004719
Leo Kim33c70c12015-10-13 20:02:07 +09004720 pstrPowerMgmtParam->enabled = bIsEnabled;
Leo Kim937918f2015-10-13 20:02:08 +09004721 pstrPowerMgmtParam->timeout = u32Timeout;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004722
Leo Kim31390ee2015-10-19 18:26:08 +09004723 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4724 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004725 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004726 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004727}
4728
Tony Choa4ab1ad2015-10-12 16:56:05 +09004729s32 host_int_setup_multicast_filter(struct host_if_drv *hif_drv,
4730 bool bIsEnabled,
4731 u32 u32count)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004732{
Leo Kim31390ee2015-10-19 18:26:08 +09004733 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004734 struct host_if_msg msg;
Tony Choa079cf4d2015-09-30 18:55:05 +09004735 struct set_multicast *pstrMulticastFilterParam = &msg.body.multicast_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004736
Tony Choa4ab1ad2015-10-12 16:56:05 +09004737 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004738 PRINT_ER("driver is null\n");
4739 return -EFAULT;
4740 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004741
4742 PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
4743
Tony Cho143eb952015-09-21 12:16:32 +09004744 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004745
Tony Choa9f812a2015-09-21 12:16:33 +09004746 msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004747 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004748
Leo Kimbae636eb2015-10-13 20:02:04 +09004749 pstrMulticastFilterParam->enabled = bIsEnabled;
Leo Kimadab2f72015-10-13 20:02:05 +09004750 pstrMulticastFilterParam->cnt = u32count;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004751
Leo Kim31390ee2015-10-19 18:26:08 +09004752 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4753 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004754 PRINT_ER("wilc_mq_send fail\n");
Leo Kim31390ee2015-10-19 18:26:08 +09004755 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004756}
4757
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004758static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
4759{
Leo Kime0a12212015-10-12 16:55:49 +09004760 struct join_bss_param *pNewJoinBssParam = NULL;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004761 u8 *pu8IEs;
Chaehyun Limd85f5322015-06-11 14:35:54 +09004762 u16 u16IEsLen;
4763 u16 index = 0;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004764 u8 suppRatesNo = 0;
4765 u8 extSuppRatesNo;
Chaehyun Limd85f5322015-06-11 14:35:54 +09004766 u16 jumpOffset;
Greg Kroah-Hartman63d03e42015-06-02 14:16:04 +09004767 u8 pcipherCount;
4768 u8 authCount;
4769 u8 pcipherTotalCount = 0;
4770 u8 authTotalCount = 0;
4771 u8 i, j;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004772
4773 pu8IEs = ptstrNetworkInfo->pu8IEs;
4774 u16IEsLen = ptstrNetworkInfo->u16IEsLen;
4775
Shraddha Barkeb156f1e2015-10-13 23:07:00 +05304776 pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
Leo Kim91109e12015-10-19 18:26:13 +09004777 if (pNewJoinBssParam) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004778 pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
4779 pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
4780 pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004781 memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
Chaehyun Limd00d2ba2015-08-10 11:33:19 +09004782 memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
Leo Kim619d27b2015-10-15 13:24:42 +09004783 pNewJoinBssParam->ssid_len = ptstrNetworkInfo->u8SsidLen;
Chaehyun Lim2cc46832015-08-07 09:02:01 +09004784 memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
4785 memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004786
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004787 while (index < u16IEsLen) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004788 if (pu8IEs[index] == SUPP_RATES_IE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004789 suppRatesNo = pu8IEs[index + 1];
4790 pNewJoinBssParam->supp_rates[0] = suppRatesNo;
Leo Kimae4dfa52015-10-13 19:49:26 +09004791 index += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004792
Leo Kimd1666e22015-10-28 15:59:22 +09004793 for (i = 0; i < suppRatesNo; i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004794 pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
Leo Kimd1666e22015-10-28 15:59:22 +09004795
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004796 index += suppRatesNo;
4797 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004798 } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004799 extSuppRatesNo = pu8IEs[index + 1];
4800 if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
4801 pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
4802 else
4803 pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
4804 index += 2;
Leo Kimd1666e22015-10-28 15:59:22 +09004805 for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004806 pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
Leo Kimd1666e22015-10-28 15:59:22 +09004807
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004808 index += extSuppRatesNo;
4809 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004810 } else if (pu8IEs[index] == HT_CAPABILITY_IE) {
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004811 pNewJoinBssParam->ht_capable = true;
Leo Kimae4dfa52015-10-13 19:49:26 +09004812 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004813 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004814 } else if ((pu8IEs[index] == WMM_IE) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004815 (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
Leo Kimae4dfa52015-10-13 19:49:26 +09004816 (pu8IEs[index + 4] == 0xF2) &&
4817 (pu8IEs[index + 5] == 0x02) &&
4818 ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004819 (pu8IEs[index + 7] == 0x01)) {
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004820 pNewJoinBssParam->wmm_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004821
Anish Bhattffda2032015-09-29 12:15:49 -07004822 if (pu8IEs[index + 8] & BIT(7))
Chaehyun Lim0be1eb72015-06-13 15:41:18 +09004823 pNewJoinBssParam->uapsd_cap = true;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004824 index += pu8IEs[index + 1] + 2;
4825 continue;
Leo Kimae4dfa52015-10-13 19:49:26 +09004826 } else if ((pu8IEs[index] == P2P_IE) &&
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004827 (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
Leo Kimae4dfa52015-10-13 19:49:26 +09004828 (pu8IEs[index + 4] == 0x9a) &&
4829 (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09004830 u16 u16P2P_count;
Luis de Bethencourt78c87592015-06-26 16:45:14 +02004831
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004832 pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
Leo Kim7a8d51d2015-10-15 13:24:43 +09004833 pNewJoinBssParam->noa_enabled = 1;
Leo Kimcc179002015-10-15 13:24:47 +09004834 pNewJoinBssParam->idx = pu8IEs[index + 9];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004835
Anish Bhattffda2032015-09-29 12:15:49 -07004836 if (pu8IEs[index + 10] & BIT(7)) {
Leo Kimd72b33c2015-10-15 13:24:44 +09004837 pNewJoinBssParam->opp_enabled = 1;
Leo Kim99b66942015-10-15 13:24:45 +09004838 pNewJoinBssParam->ct_window = pu8IEs[index + 10];
Leo Kimd72b33c2015-10-15 13:24:44 +09004839 } else {
4840 pNewJoinBssParam->opp_enabled = 0;
4841 }
Leo Kimae4dfa52015-10-13 19:49:26 +09004842
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004843 PRINT_D(GENERIC_DBG, "P2P Dump\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004844 for (i = 0; i < pu8IEs[index + 7]; i++)
Luis de Bethencourt03b2d5e2015-06-26 16:45:58 +02004845 PRINT_D(GENERIC_DBG, " %x\n", pu8IEs[index + 9 + i]);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004846
Leo Kimc21047e2015-10-15 13:24:46 +09004847 pNewJoinBssParam->cnt = pu8IEs[index + 11];
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004848 u16P2P_count = index + 12;
4849
Leo Kim109e6ca2015-10-15 13:24:48 +09004850 memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004851 u16P2P_count += 4;
4852
Leo Kim1d8b76b2015-10-15 13:24:49 +09004853 memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004854 u16P2P_count += 4;
4855
Leo Kim4be55e22015-10-28 15:59:27 +09004856 memcpy(pNewJoinBssParam->start_time, pu8IEs + u16P2P_count, 4);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004857
4858 index += pu8IEs[index + 1] + 2;
4859 continue;
4860
Leo Kimae4dfa52015-10-13 19:49:26 +09004861 } else if ((pu8IEs[index] == RSN_IE) ||
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004862 ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
4863 (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
4864 (pu8IEs[index + 5] == 0x01))) {
Chaehyun Limd85f5322015-06-11 14:35:54 +09004865 u16 rsnIndex = index;
Leo Kimae4dfa52015-10-13 19:49:26 +09004866
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004867 if (pu8IEs[rsnIndex] == RSN_IE) {
4868 pNewJoinBssParam->mode_802_11i = 2;
Leo Kimae4dfa52015-10-13 19:49:26 +09004869 } else {
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004870 if (pNewJoinBssParam->mode_802_11i == 0)
4871 pNewJoinBssParam->mode_802_11i = 1;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004872 rsnIndex += 4;
4873 }
Leo Kimae4dfa52015-10-13 19:49:26 +09004874
4875 rsnIndex += 7;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004876 pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
4877 rsnIndex++;
Leo Kimae4dfa52015-10-13 19:49:26 +09004878 jumpOffset = pu8IEs[rsnIndex] * 4;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004879 pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
Leo Kimae4dfa52015-10-13 19:49:26 +09004880 rsnIndex += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004881
Leo Kimd1666e22015-10-28 15:59:22 +09004882 for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004883 pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
Leo Kimd1666e22015-10-28 15:59:22 +09004884
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004885 pcipherTotalCount += pcipherCount;
4886 rsnIndex += jumpOffset;
4887
4888 jumpOffset = pu8IEs[rsnIndex] * 4;
4889
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004890 authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
Leo Kimae4dfa52015-10-13 19:49:26 +09004891 rsnIndex += 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004892
Leo Kimd1666e22015-10-28 15:59:22 +09004893 for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004894 pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
Leo Kimd1666e22015-10-28 15:59:22 +09004895
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004896 authTotalCount += authCount;
4897 rsnIndex += jumpOffset;
Leo Kimae4dfa52015-10-13 19:49:26 +09004898
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004899 if (pu8IEs[index] == RSN_IE) {
4900 pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
4901 pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
4902 rsnIndex += 2;
4903 }
Abdul Hussainf717c0eb2015-06-16 09:49:49 +00004904 pNewJoinBssParam->rsn_found = true;
Leo Kimae4dfa52015-10-13 19:49:26 +09004905 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004906 continue;
4907 } else
Leo Kimae4dfa52015-10-13 19:49:26 +09004908 index += pu8IEs[index + 1] + 2;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004909 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004910 }
4911
4912 return (void *)pNewJoinBssParam;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004913}
4914
4915void host_int_freeJoinParams(void *pJoinParams)
4916{
Leo Kim91109e12015-10-19 18:26:13 +09004917 if ((struct bss_param *)pJoinParams)
Leo Kime0a12212015-10-12 16:55:49 +09004918 kfree((struct bss_param *)pJoinParams);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004919 else
4920 PRINT_ER("Unable to FREE null pointer\n");
4921}
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004922
Tony Choa4ab1ad2015-10-12 16:56:05 +09004923s32 host_int_delBASession(struct host_if_drv *hif_drv, char *pBSSID, char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004924{
Leo Kim31390ee2015-10-19 18:26:08 +09004925 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004926 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09004927 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004928
Tony Choa4ab1ad2015-10-12 16:56:05 +09004929 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004930 PRINT_ER("driver is null\n");
4931 return -EFAULT;
4932 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004933
Tony Cho143eb952015-09-21 12:16:32 +09004934 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004935
Tony Choa9f812a2015-09-21 12:16:33 +09004936 msg.id = HOST_IF_MSG_DEL_BA_SESSION;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004937
Leo Kim3fc49992015-10-29 11:58:45 +09004938 memcpy(pBASessionInfo->bssid, pBSSID, ETH_ALEN);
Leo Kim16c9b392015-10-29 11:58:46 +09004939 pBASessionInfo->tid = TID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004940 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004941
Leo Kim31390ee2015-10-19 18:26:08 +09004942 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4943 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004944 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004945
Leo Kim2d25af82015-10-15 13:24:56 +09004946 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004947
Leo Kim31390ee2015-10-19 18:26:08 +09004948 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004949}
4950
Tony Choa4ab1ad2015-10-12 16:56:05 +09004951s32 host_int_del_All_Rx_BASession(struct host_if_drv *hif_drv,
4952 char *pBSSID,
4953 char TID)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004954{
Leo Kim31390ee2015-10-19 18:26:08 +09004955 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004956 struct host_if_msg msg;
Tony Choc833b472015-09-30 18:55:09 +09004957 struct ba_session_info *pBASessionInfo = &msg.body.session_info;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004958
Tony Choa4ab1ad2015-10-12 16:56:05 +09004959 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004960 PRINT_ER("driver is null\n");
4961 return -EFAULT;
4962 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004963
Tony Cho143eb952015-09-21 12:16:32 +09004964 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004965
Tony Choa9f812a2015-09-21 12:16:33 +09004966 msg.id = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004967
Leo Kim3fc49992015-10-29 11:58:45 +09004968 memcpy(pBASessionInfo->bssid, pBSSID, ETH_ALEN);
Leo Kim16c9b392015-10-29 11:58:46 +09004969 pBASessionInfo->tid = TID;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004970 msg.drv = hif_drv;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004971
Leo Kim31390ee2015-10-19 18:26:08 +09004972 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
4973 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09004974 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004975
Leo Kim2d25af82015-10-15 13:24:56 +09004976 down(&hif_sema_wait_response);
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004977
Leo Kim31390ee2015-10-19 18:26:08 +09004978 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004979}
4980
Tony Choa4ab1ad2015-10-12 16:56:05 +09004981s32 host_int_setup_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004982{
Leo Kim31390ee2015-10-19 18:26:08 +09004983 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09004984 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004985
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004986 return 0;
4987
Tony Choa4ab1ad2015-10-12 16:56:05 +09004988 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09004989 PRINT_ER("driver is null\n");
4990 return -EFAULT;
4991 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004992
Tony Cho143eb952015-09-21 12:16:32 +09004993 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004994
Tony Choa9f812a2015-09-21 12:16:33 +09004995 msg.id = HOST_IF_MSG_SET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09004996
Leo Kim78675be2015-10-13 20:02:09 +09004997 msg.body.ip_info.ip_addr = u16ipadd;
Tony Choa4ab1ad2015-10-12 16:56:05 +09004998 msg.drv = hif_drv;
Tony Chofb2d65e2015-09-30 18:44:39 +09004999 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005000
Leo Kim31390ee2015-10-19 18:26:08 +09005001 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5002 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09005003 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005004
Leo Kim31390ee2015-10-19 18:26:08 +09005005 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005006}
5007
Tony Choa4ab1ad2015-10-12 16:56:05 +09005008s32 host_int_get_ipaddress(struct host_if_drv *hif_drv, u8 *u16ipadd, u8 idx)
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005009{
Leo Kim31390ee2015-10-19 18:26:08 +09005010 s32 result = 0;
Tony Cho143eb952015-09-21 12:16:32 +09005011 struct host_if_msg msg;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005012
Tony Choa4ab1ad2015-10-12 16:56:05 +09005013 if (!hif_drv) {
Leo Kim24db7132015-09-16 18:36:01 +09005014 PRINT_ER("driver is null\n");
5015 return -EFAULT;
5016 }
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005017
Tony Cho143eb952015-09-21 12:16:32 +09005018 memset(&msg, 0, sizeof(struct host_if_msg));
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005019
Tony Choa9f812a2015-09-21 12:16:33 +09005020 msg.id = HOST_IF_MSG_GET_IPADDRESS;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005021
Leo Kim78675be2015-10-13 20:02:09 +09005022 msg.body.ip_info.ip_addr = u16ipadd;
Tony Choa4ab1ad2015-10-12 16:56:05 +09005023 msg.drv = hif_drv;
Tony Chofb2d65e2015-09-30 18:44:39 +09005024 msg.body.ip_info.idx = idx;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005025
Leo Kim31390ee2015-10-19 18:26:08 +09005026 result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
5027 if (result)
Leo Kim24db7132015-09-16 18:36:01 +09005028 PRINT_ER("wilc_mq_send fail\n");
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005029
Leo Kim31390ee2015-10-19 18:26:08 +09005030 return result;
Johnny Kimc5c77ba2015-05-11 14:30:56 +09005031}