1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries 4 * All rights reserved. 5 */ 6 7 #ifndef HOST_INT_H 8 #define HOST_INT_H 9 #include <linux/ieee80211.h> 10 #include "coreconfigurator.h" 11 12 #define IP_ALEN 4 13 14 #define IDLE_MODE 0x00 15 #define AP_MODE 0x01 16 #define STATION_MODE 0x02 17 #define GO_MODE 0x03 18 #define CLIENT_MODE 0x04 19 #define ACTION 0xD0 20 #define PROBE_REQ 0x40 21 #define PROBE_RESP 0x50 22 23 #define ACTION_FRM_IDX 0 24 #define PROBE_REQ_IDX 1 25 #define MAX_NUM_STA 9 26 #define ACTIVE_SCAN_TIME 10 27 #define PASSIVE_SCAN_TIME 1200 28 #define MIN_SCAN_TIME 10 29 #define MAX_SCAN_TIME 1200 30 #define DEFAULT_SCAN 0 31 #define USER_SCAN BIT(0) 32 #define OBSS_PERIODIC_SCAN BIT(1) 33 #define OBSS_ONETIME_SCAN BIT(2) 34 #define GTK_RX_KEY_BUFF_LEN 24 35 #define ADDKEY 0x1 36 #define REMOVEKEY 0x2 37 #define DEFAULTKEY 0x4 38 #define ADDKEY_AP 0x8 39 #define MAX_NUM_SCANNED_NETWORKS 100 40 #define MAX_NUM_SCANNED_NETWORKS_SHADOW 130 41 #define MAX_NUM_PROBED_SSID 10 42 #define CHANNEL_SCAN_TIME 250 43 44 #define TX_MIC_KEY_LEN 8 45 #define RX_MIC_KEY_LEN 8 46 #define PTK_KEY_LEN 16 47 48 #define TX_MIC_KEY_MSG_LEN 26 49 #define RX_MIC_KEY_MSG_LEN 48 50 #define PTK_KEY_MSG_LEN 39 51 52 #define PMKSA_KEY_LEN 22 53 #define ETH_ALEN 6 54 #define PMKID_LEN 16 55 #define WILC_MAX_NUM_PMKIDS 16 56 #define WILC_ADD_STA_LENGTH 40 57 #define NUM_CONCURRENT_IFC 2 58 #define DRV_HANDLER_SIZE 5 59 #define DRV_HANDLER_MASK 0x000000FF 60 61 struct rf_info { 62 u8 link_speed; 63 s8 rssi; 64 u32 tx_cnt; 65 u32 rx_cnt; 66 u32 tx_fail_cnt; 67 }; 68 69 enum host_if_state { 70 HOST_IF_IDLE = 0, 71 HOST_IF_SCANNING = 1, 72 HOST_IF_CONNECTING = 2, 73 HOST_IF_WAITING_CONN_RESP = 3, 74 HOST_IF_CONNECTED = 4, 75 HOST_IF_P2P_LISTEN = 5, 76 HOST_IF_FORCE_32BIT = 0xFFFFFFFF 77 }; 78 79 struct host_if_pmkid { 80 u8 bssid[ETH_ALEN]; 81 u8 pmkid[PMKID_LEN]; 82 }; 83 84 struct host_if_pmkid_attr { 85 u8 numpmkid; 86 struct host_if_pmkid pmkidlist[WILC_MAX_NUM_PMKIDS]; 87 }; 88 89 enum current_tx_rate { 90 AUTORATE = 0, 91 MBPS_1 = 1, 92 MBPS_2 = 2, 93 MBPS_5_5 = 5, 94 MBPS_11 = 11, 95 MBPS_6 = 6, 96 MBPS_9 = 9, 97 MBPS_12 = 12, 98 MBPS_18 = 18, 99 MBPS_24 = 24, 100 MBPS_36 = 36, 101 MBPS_48 = 48, 102 MBPS_54 = 54 103 }; 104 105 struct cfg_param_attr { 106 u32 flag; 107 u8 ht_enable; 108 u8 bss_type; 109 u8 auth_type; 110 u16 auth_timeout; 111 u8 power_mgmt_mode; 112 u16 short_retry_limit; 113 u16 long_retry_limit; 114 u16 frag_threshold; 115 u16 rts_threshold; 116 u16 preamble_type; 117 u8 short_slot_allowed; 118 u8 txop_prot_disabled; 119 u16 beacon_interval; 120 u16 dtim_period; 121 enum site_survey site_survey_enabled; 122 u16 site_survey_scan_time; 123 u8 scan_source; 124 u16 active_scan_time; 125 u16 passive_scan_time; 126 enum current_tx_rate curr_tx_rate; 127 128 }; 129 130 enum cfg_param { 131 RETRY_SHORT = BIT(0), 132 RETRY_LONG = BIT(1), 133 FRAG_THRESHOLD = BIT(2), 134 RTS_THRESHOLD = BIT(3), 135 BSS_TYPE = BIT(4), 136 AUTH_TYPE = BIT(5), 137 AUTHEN_TIMEOUT = BIT(6), 138 POWER_MANAGEMENT = BIT(7), 139 PREAMBLE = BIT(8), 140 SHORT_SLOT_ALLOWED = BIT(9), 141 TXOP_PROT_DISABLE = BIT(10), 142 BEACON_INTERVAL = BIT(11), 143 DTIM_PERIOD = BIT(12), 144 SITE_SURVEY = BIT(13), 145 SITE_SURVEY_SCAN_TIME = BIT(14), 146 ACTIVE_SCANTIME = BIT(15), 147 PASSIVE_SCANTIME = BIT(16), 148 CURRENT_TX_RATE = BIT(17), 149 HT_ENABLE = BIT(18), 150 }; 151 152 struct found_net_info { 153 u8 bssid[6]; 154 s8 rssi; 155 }; 156 157 enum scan_event { 158 SCAN_EVENT_NETWORK_FOUND = 0, 159 SCAN_EVENT_DONE = 1, 160 SCAN_EVENT_ABORTED = 2, 161 SCAN_EVENT_FORCE_32BIT = 0xFFFFFFFF 162 }; 163 164 enum conn_event { 165 CONN_DISCONN_EVENT_CONN_RESP = 0, 166 CONN_DISCONN_EVENT_DISCONN_NOTIF = 1, 167 CONN_DISCONN_EVENT_FORCE_32BIT = 0xFFFFFFFF 168 }; 169 170 enum KEY_TYPE { 171 WEP, 172 WPA_RX_GTK, 173 WPA_PTK, 174 PMKSA, 175 }; 176 177 typedef void (*wilc_scan_result)(enum scan_event, struct network_info *, 178 void *, void *); 179 180 typedef void (*wilc_connect_result)(enum conn_event, 181 struct connect_info *, 182 u8, 183 struct disconnect_info *, 184 void *); 185 186 typedef void (*wilc_remain_on_chan_expired)(void *, u32); 187 typedef void (*wilc_remain_on_chan_ready)(void *); 188 189 struct rcvd_net_info { 190 u8 *buffer; 191 u32 len; 192 }; 193 194 struct hidden_net_info { 195 u8 *ssid; 196 u8 ssid_len; 197 }; 198 199 struct hidden_network { 200 struct hidden_net_info *net_info; 201 u8 n_ssids; 202 }; 203 204 struct user_scan_req { 205 wilc_scan_result scan_result; 206 void *arg; 207 u32 ch_cnt; 208 struct found_net_info net_info[MAX_NUM_SCANNED_NETWORKS]; 209 }; 210 211 struct user_conn_req { 212 u8 *bssid; 213 u8 *ssid; 214 u8 security; 215 enum authtype auth_type; 216 size_t ssid_len; 217 u8 *ies; 218 size_t ies_len; 219 wilc_connect_result conn_result; 220 bool ht_capable; 221 void *arg; 222 }; 223 224 struct drv_handler { 225 u32 handler; 226 u8 mode; 227 u8 name; 228 }; 229 230 struct op_mode { 231 u32 mode; 232 }; 233 234 struct get_mac_addr { 235 u8 *mac_addr; 236 }; 237 238 struct ba_session_info { 239 u8 bssid[ETH_ALEN]; 240 u8 tid; 241 u16 buf_size; 242 u16 time_out; 243 }; 244 245 struct remain_ch { 246 u16 ch; 247 u32 duration; 248 wilc_remain_on_chan_expired expired; 249 wilc_remain_on_chan_ready ready; 250 void *arg; 251 u32 id; 252 }; 253 254 struct reg_frame { 255 bool reg; 256 u16 frame_type; 257 u8 reg_id; 258 }; 259 260 struct wilc; 261 struct host_if_drv { 262 struct user_scan_req usr_scan_req; 263 struct user_conn_req usr_conn_req; 264 struct remain_ch remain_on_ch; 265 u8 remain_on_ch_pending; 266 u64 p2p_timeout; 267 u8 p2p_connect; 268 269 enum host_if_state hif_state; 270 271 u8 assoc_bssid[ETH_ALEN]; 272 struct cfg_param_attr cfg_values; 273 /*lock to protect concurrent setting of cfg params*/ 274 struct mutex cfg_values_lock; 275 276 struct timer_list scan_timer; 277 struct wilc_vif *scan_timer_vif; 278 279 struct timer_list connect_timer; 280 struct wilc_vif *connect_timer_vif; 281 282 struct timer_list remain_on_ch_timer; 283 struct wilc_vif *remain_on_ch_timer_vif; 284 285 bool ifc_up; 286 int driver_handler_id; 287 }; 288 289 struct add_sta_param { 290 u8 bssid[ETH_ALEN]; 291 u16 aid; 292 u8 rates_len; 293 const u8 *rates; 294 bool ht_supported; 295 struct ieee80211_ht_cap ht_capa; 296 u16 flags_mask; 297 u16 flags_set; 298 }; 299 300 struct wilc_vif; 301 int wilc_remove_wep_key(struct wilc_vif *vif, u8 index); 302 int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index); 303 int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, 304 u8 index); 305 int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, 306 u8 index, u8 mode, enum authtype auth_type); 307 int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, 308 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic, 309 u8 mode, u8 cipher_mode, u8 index); 310 s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, 311 u32 *out_val); 312 int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, 313 u8 index, u32 key_rsc_len, const u8 *key_rsc, 314 const u8 *rx_mic, const u8 *tx_mic, u8 mode, 315 u8 cipher_mode); 316 int wilc_set_pmkid_info(struct wilc_vif *vif, 317 struct host_if_pmkid_attr *pmkid); 318 int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr); 319 int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, 320 size_t ssid_len, const u8 *ies, size_t ies_len, 321 wilc_connect_result connect_result, void *user_arg, 322 u8 security, enum authtype auth_type, 323 u8 channel, void *join_params); 324 int wilc_disconnect(struct wilc_vif *vif, u16 reason_code); 325 int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel); 326 int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level); 327 int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, 328 u8 *ch_freq_list, u8 ch_list_len, const u8 *ies, 329 size_t ies_len, wilc_scan_result scan_result, void *user_arg, 330 struct hidden_network *hidden_network); 331 int wilc_hif_set_cfg(struct wilc_vif *vif, 332 struct cfg_param_attr *cfg_param); 333 int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler); 334 int wilc_deinit(struct wilc_vif *vif); 335 int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, 336 u32 head_len, u8 *head, u32 tail_len, u8 *tail); 337 int wilc_del_beacon(struct wilc_vif *vif); 338 int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param); 339 int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]); 340 int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr); 341 int wilc_edit_station(struct wilc_vif *vif, 342 struct add_sta_param *sta_param); 343 int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout); 344 int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, 345 u32 count); 346 int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx); 347 int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id, 348 u32 duration, u16 chan, 349 wilc_remain_on_chan_expired expired, 350 wilc_remain_on_chan_ready ready, 351 void *user_arg); 352 int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id); 353 int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg); 354 int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode, 355 u8 ifc_id); 356 int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode); 357 int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats, 358 bool is_sync); 359 void wilc_resolve_disconnect_aberration(struct wilc_vif *vif); 360 int wilc_get_vif_idx(struct wilc_vif *vif); 361 int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power); 362 int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power); 363 364 extern bool wilc_optaining_ip; 365 extern u8 wilc_connected_ssid[6]; 366 extern u8 wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN]; 367 368 extern int wilc_connecting; 369 extern struct timer_list wilc_during_ip_timer; 370 371 #endif 372