162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries
462306a36Sopenharmony_ci * All rights reserved.
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#ifndef WILC_HIF_H
862306a36Sopenharmony_ci#define WILC_HIF_H
962306a36Sopenharmony_ci#include <linux/ieee80211.h>
1062306a36Sopenharmony_ci#include "wlan_if.h"
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_cienum {
1362306a36Sopenharmony_ci	WILC_IDLE_MODE = 0x0,
1462306a36Sopenharmony_ci	WILC_AP_MODE = 0x1,
1562306a36Sopenharmony_ci	WILC_STATION_MODE = 0x2,
1662306a36Sopenharmony_ci	WILC_GO_MODE = 0x3,
1762306a36Sopenharmony_ci	WILC_CLIENT_MODE = 0x4
1862306a36Sopenharmony_ci};
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#define WILC_MAX_NUM_PROBED_SSID		10
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci#define WILC_TX_MIC_KEY_LEN			8
2362306a36Sopenharmony_ci#define WILC_RX_MIC_KEY_LEN			8
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci#define WILC_ADD_STA_LENGTH			40
2662306a36Sopenharmony_ci#define WILC_NUM_CONCURRENT_IFC			2
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_cienum {
2962306a36Sopenharmony_ci	WILC_SET_CFG = 0,
3062306a36Sopenharmony_ci	WILC_GET_CFG
3162306a36Sopenharmony_ci};
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_cistruct rf_info {
3462306a36Sopenharmony_ci	u8 link_speed;
3562306a36Sopenharmony_ci	s8 rssi;
3662306a36Sopenharmony_ci	u32 tx_cnt;
3762306a36Sopenharmony_ci	u32 rx_cnt;
3862306a36Sopenharmony_ci	u32 tx_fail_cnt;
3962306a36Sopenharmony_ci};
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_cienum host_if_state {
4262306a36Sopenharmony_ci	HOST_IF_IDLE			= 0,
4362306a36Sopenharmony_ci	HOST_IF_SCANNING		= 1,
4462306a36Sopenharmony_ci	HOST_IF_CONNECTING		= 2,
4562306a36Sopenharmony_ci	HOST_IF_WAITING_CONN_RESP	= 3,
4662306a36Sopenharmony_ci	HOST_IF_CONNECTED		= 4,
4762306a36Sopenharmony_ci	HOST_IF_P2P_LISTEN		= 5,
4862306a36Sopenharmony_ci	HOST_IF_EXTERNAL_AUTH           = 6,
4962306a36Sopenharmony_ci	HOST_IF_FORCE_32BIT		= 0xFFFFFFFF
5062306a36Sopenharmony_ci};
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_cistruct cfg_param_attr {
5362306a36Sopenharmony_ci	u32 flag;
5462306a36Sopenharmony_ci	u16 short_retry_limit;
5562306a36Sopenharmony_ci	u16 long_retry_limit;
5662306a36Sopenharmony_ci	u16 frag_threshold;
5762306a36Sopenharmony_ci	u16 rts_threshold;
5862306a36Sopenharmony_ci};
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_cienum cfg_param {
6162306a36Sopenharmony_ci	WILC_CFG_PARAM_RETRY_SHORT = BIT(0),
6262306a36Sopenharmony_ci	WILC_CFG_PARAM_RETRY_LONG = BIT(1),
6362306a36Sopenharmony_ci	WILC_CFG_PARAM_FRAG_THRESHOLD = BIT(2),
6462306a36Sopenharmony_ci	WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3)
6562306a36Sopenharmony_ci};
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_cienum scan_event {
6862306a36Sopenharmony_ci	SCAN_EVENT_NETWORK_FOUND	= 0,
6962306a36Sopenharmony_ci	SCAN_EVENT_DONE			= 1,
7062306a36Sopenharmony_ci	SCAN_EVENT_ABORTED		= 2,
7162306a36Sopenharmony_ci	SCAN_EVENT_FORCE_32BIT		= 0xFFFFFFFF
7262306a36Sopenharmony_ci};
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_cienum conn_event {
7562306a36Sopenharmony_ci	CONN_DISCONN_EVENT_CONN_RESP		= 0,
7662306a36Sopenharmony_ci	CONN_DISCONN_EVENT_DISCONN_NOTIF	= 1,
7762306a36Sopenharmony_ci	CONN_DISCONN_EVENT_FORCE_32BIT		= 0xFFFFFFFF
7862306a36Sopenharmony_ci};
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_cienum {
8162306a36Sopenharmony_ci	WILC_HIF_SDIO = 0,
8262306a36Sopenharmony_ci	WILC_HIF_SPI = BIT(0)
8362306a36Sopenharmony_ci};
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_cienum {
8662306a36Sopenharmony_ci	WILC_MAC_STATUS_INIT = -1,
8762306a36Sopenharmony_ci	WILC_MAC_STATUS_DISCONNECTED = 0,
8862306a36Sopenharmony_ci	WILC_MAC_STATUS_CONNECTED = 1
8962306a36Sopenharmony_ci};
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_cistruct wilc_rcvd_net_info {
9262306a36Sopenharmony_ci	s8 rssi;
9362306a36Sopenharmony_ci	u8 ch;
9462306a36Sopenharmony_ci	u16 frame_len;
9562306a36Sopenharmony_ci	struct ieee80211_mgmt *mgmt;
9662306a36Sopenharmony_ci};
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_cistruct wilc_user_scan_req {
9962306a36Sopenharmony_ci	void (*scan_result)(enum scan_event evt,
10062306a36Sopenharmony_ci			    struct wilc_rcvd_net_info *info, void *priv);
10162306a36Sopenharmony_ci	void *arg;
10262306a36Sopenharmony_ci	u32 ch_cnt;
10362306a36Sopenharmony_ci};
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_cistruct wilc_conn_info {
10662306a36Sopenharmony_ci	u8 bssid[ETH_ALEN];
10762306a36Sopenharmony_ci	u8 security;
10862306a36Sopenharmony_ci	enum authtype auth_type;
10962306a36Sopenharmony_ci	enum mfptype mfp_type;
11062306a36Sopenharmony_ci	u8 ch;
11162306a36Sopenharmony_ci	u8 *req_ies;
11262306a36Sopenharmony_ci	size_t req_ies_len;
11362306a36Sopenharmony_ci	u8 *resp_ies;
11462306a36Sopenharmony_ci	u16 resp_ies_len;
11562306a36Sopenharmony_ci	u16 status;
11662306a36Sopenharmony_ci	void (*conn_result)(enum conn_event evt, u8 status, void *priv_data);
11762306a36Sopenharmony_ci	void *arg;
11862306a36Sopenharmony_ci	void *param;
11962306a36Sopenharmony_ci};
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_cistruct wilc_remain_ch {
12262306a36Sopenharmony_ci	u16 ch;
12362306a36Sopenharmony_ci	u32 duration;
12462306a36Sopenharmony_ci	void (*expired)(void *priv, u64 cookie);
12562306a36Sopenharmony_ci	void *arg;
12662306a36Sopenharmony_ci	u64 cookie;
12762306a36Sopenharmony_ci};
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_cistruct wilc;
13062306a36Sopenharmony_cistruct host_if_drv {
13162306a36Sopenharmony_ci	struct wilc_user_scan_req usr_scan_req;
13262306a36Sopenharmony_ci	struct wilc_conn_info conn_info;
13362306a36Sopenharmony_ci	struct wilc_remain_ch remain_on_ch;
13462306a36Sopenharmony_ci	u64 p2p_timeout;
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci	enum host_if_state hif_state;
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci	u8 assoc_bssid[ETH_ALEN];
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ci	struct timer_list scan_timer;
14162306a36Sopenharmony_ci	struct wilc_vif *scan_timer_vif;
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci	struct timer_list connect_timer;
14462306a36Sopenharmony_ci	struct wilc_vif *connect_timer_vif;
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci	struct timer_list remain_on_ch_timer;
14762306a36Sopenharmony_ci	struct wilc_vif *remain_on_ch_timer_vif;
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci	bool ifc_up;
15062306a36Sopenharmony_ci	u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE];
15162306a36Sopenharmony_ci};
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_cistruct wilc_vif;
15462306a36Sopenharmony_ciint wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
15562306a36Sopenharmony_ci		 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
15662306a36Sopenharmony_ci		 u8 mode, u8 cipher_mode, u8 index);
15762306a36Sopenharmony_ciint wilc_add_igtk(struct wilc_vif *vif, const u8 *igtk, u8 igtk_key_len,
15862306a36Sopenharmony_ci		  const u8 *pn, u8 pn_len, const u8 *mac_addr, u8 mode,
15962306a36Sopenharmony_ci		  u8 index);
16062306a36Sopenharmony_cis32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
16162306a36Sopenharmony_ci			   u32 *out_val);
16262306a36Sopenharmony_ciint wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
16362306a36Sopenharmony_ci		    u8 index, u32 key_rsc_len, const u8 *key_rsc,
16462306a36Sopenharmony_ci		    const u8 *rx_mic, const u8 *tx_mic, u8 mode,
16562306a36Sopenharmony_ci		    u8 cipher_mode);
16662306a36Sopenharmony_ciint wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid);
16762306a36Sopenharmony_ciint wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr);
16862306a36Sopenharmony_ciint wilc_set_mac_address(struct wilc_vif *vif, u8 *mac_addr);
16962306a36Sopenharmony_ciint wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
17062306a36Sopenharmony_ci		      size_t ies_len);
17162306a36Sopenharmony_ciint wilc_disconnect(struct wilc_vif *vif);
17262306a36Sopenharmony_ciint wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel);
17362306a36Sopenharmony_ciint wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level);
17462306a36Sopenharmony_ciint wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
17562306a36Sopenharmony_ci	      u8 *ch_freq_list, u8 ch_list_len,
17662306a36Sopenharmony_ci	      void (*scan_result_fn)(enum scan_event,
17762306a36Sopenharmony_ci				     struct wilc_rcvd_net_info *, void *),
17862306a36Sopenharmony_ci	      void *user_arg, struct cfg80211_scan_request *request);
17962306a36Sopenharmony_ciint wilc_hif_set_cfg(struct wilc_vif *vif,
18062306a36Sopenharmony_ci		     struct cfg_param_attr *cfg_param);
18162306a36Sopenharmony_ciint wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler);
18262306a36Sopenharmony_ciint wilc_deinit(struct wilc_vif *vif);
18362306a36Sopenharmony_ciint wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
18462306a36Sopenharmony_ci		    struct cfg80211_beacon_data *params);
18562306a36Sopenharmony_ciint wilc_del_beacon(struct wilc_vif *vif);
18662306a36Sopenharmony_ciint wilc_add_station(struct wilc_vif *vif, const u8 *mac,
18762306a36Sopenharmony_ci		     struct station_parameters *params);
18862306a36Sopenharmony_ciint wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]);
18962306a36Sopenharmony_ciint wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr);
19062306a36Sopenharmony_ciint wilc_edit_station(struct wilc_vif *vif, const u8 *mac,
19162306a36Sopenharmony_ci		      struct station_parameters *params);
19262306a36Sopenharmony_ciint wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout);
19362306a36Sopenharmony_ciint wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count,
19462306a36Sopenharmony_ci				u8 *mc_list);
19562306a36Sopenharmony_ciint wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie,
19662306a36Sopenharmony_ci			   u32 duration, u16 chan,
19762306a36Sopenharmony_ci			   void (*expired)(void *, u64),
19862306a36Sopenharmony_ci			   void *user_arg);
19962306a36Sopenharmony_ciint wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie);
20062306a36Sopenharmony_civoid wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg);
20162306a36Sopenharmony_ciint wilc_set_operation_mode(struct wilc_vif *vif, int index, u8 mode,
20262306a36Sopenharmony_ci			    u8 ifc_id);
20362306a36Sopenharmony_ciint wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats);
20462306a36Sopenharmony_ciint wilc_get_vif_idx(struct wilc_vif *vif);
20562306a36Sopenharmony_ciint wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power);
20662306a36Sopenharmony_ciint wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power);
20762306a36Sopenharmony_civoid wilc_set_wowlan_trigger(struct wilc_vif *vif, bool enabled);
20862306a36Sopenharmony_ciint wilc_set_external_auth_param(struct wilc_vif *vif,
20962306a36Sopenharmony_ci				 struct cfg80211_external_auth_params *param);
21062306a36Sopenharmony_civoid wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length);
21162306a36Sopenharmony_civoid wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length);
21262306a36Sopenharmony_civoid wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length);
21362306a36Sopenharmony_civoid *wilc_parse_join_bss_param(struct cfg80211_bss *bss,
21462306a36Sopenharmony_ci				struct cfg80211_crypto_settings *crypto);
21562306a36Sopenharmony_ciint wilc_set_default_mgmt_key_index(struct wilc_vif *vif, u8 index);
21662306a36Sopenharmony_civoid wilc_handle_disconnect(struct wilc_vif *vif);
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_ci#endif
219