18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries
48c2ecf20Sopenharmony_ci * All rights reserved.
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef WILC_HIF_H
88c2ecf20Sopenharmony_ci#define WILC_HIF_H
98c2ecf20Sopenharmony_ci#include <linux/ieee80211.h>
108c2ecf20Sopenharmony_ci#include "wlan_if.h"
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_cienum {
138c2ecf20Sopenharmony_ci	WILC_IDLE_MODE = 0x0,
148c2ecf20Sopenharmony_ci	WILC_AP_MODE = 0x1,
158c2ecf20Sopenharmony_ci	WILC_STATION_MODE = 0x2,
168c2ecf20Sopenharmony_ci	WILC_GO_MODE = 0x3,
178c2ecf20Sopenharmony_ci	WILC_CLIENT_MODE = 0x4
188c2ecf20Sopenharmony_ci};
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define WILC_MAX_NUM_PROBED_SSID		10
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define WILC_TX_MIC_KEY_LEN			8
238c2ecf20Sopenharmony_ci#define WILC_RX_MIC_KEY_LEN			8
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#define WILC_ADD_STA_LENGTH			40
268c2ecf20Sopenharmony_ci#define WILC_NUM_CONCURRENT_IFC			2
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_cienum {
298c2ecf20Sopenharmony_ci	WILC_SET_CFG = 0,
308c2ecf20Sopenharmony_ci	WILC_GET_CFG
318c2ecf20Sopenharmony_ci};
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define WILC_MAX_ASSOC_RESP_FRAME_SIZE   256
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistruct rf_info {
368c2ecf20Sopenharmony_ci	u8 link_speed;
378c2ecf20Sopenharmony_ci	s8 rssi;
388c2ecf20Sopenharmony_ci	u32 tx_cnt;
398c2ecf20Sopenharmony_ci	u32 rx_cnt;
408c2ecf20Sopenharmony_ci	u32 tx_fail_cnt;
418c2ecf20Sopenharmony_ci};
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_cienum host_if_state {
448c2ecf20Sopenharmony_ci	HOST_IF_IDLE			= 0,
458c2ecf20Sopenharmony_ci	HOST_IF_SCANNING		= 1,
468c2ecf20Sopenharmony_ci	HOST_IF_CONNECTING		= 2,
478c2ecf20Sopenharmony_ci	HOST_IF_WAITING_CONN_RESP	= 3,
488c2ecf20Sopenharmony_ci	HOST_IF_CONNECTED		= 4,
498c2ecf20Sopenharmony_ci	HOST_IF_P2P_LISTEN		= 5,
508c2ecf20Sopenharmony_ci	HOST_IF_FORCE_32BIT		= 0xFFFFFFFF
518c2ecf20Sopenharmony_ci};
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_cistruct cfg_param_attr {
548c2ecf20Sopenharmony_ci	u32 flag;
558c2ecf20Sopenharmony_ci	u16 short_retry_limit;
568c2ecf20Sopenharmony_ci	u16 long_retry_limit;
578c2ecf20Sopenharmony_ci	u16 frag_threshold;
588c2ecf20Sopenharmony_ci	u16 rts_threshold;
598c2ecf20Sopenharmony_ci};
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cienum cfg_param {
628c2ecf20Sopenharmony_ci	WILC_CFG_PARAM_RETRY_SHORT = BIT(0),
638c2ecf20Sopenharmony_ci	WILC_CFG_PARAM_RETRY_LONG = BIT(1),
648c2ecf20Sopenharmony_ci	WILC_CFG_PARAM_FRAG_THRESHOLD = BIT(2),
658c2ecf20Sopenharmony_ci	WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3)
668c2ecf20Sopenharmony_ci};
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_cienum scan_event {
698c2ecf20Sopenharmony_ci	SCAN_EVENT_NETWORK_FOUND	= 0,
708c2ecf20Sopenharmony_ci	SCAN_EVENT_DONE			= 1,
718c2ecf20Sopenharmony_ci	SCAN_EVENT_ABORTED		= 2,
728c2ecf20Sopenharmony_ci	SCAN_EVENT_FORCE_32BIT		= 0xFFFFFFFF
738c2ecf20Sopenharmony_ci};
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_cienum conn_event {
768c2ecf20Sopenharmony_ci	CONN_DISCONN_EVENT_CONN_RESP		= 0,
778c2ecf20Sopenharmony_ci	CONN_DISCONN_EVENT_DISCONN_NOTIF	= 1,
788c2ecf20Sopenharmony_ci	CONN_DISCONN_EVENT_FORCE_32BIT		= 0xFFFFFFFF
798c2ecf20Sopenharmony_ci};
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_cienum {
828c2ecf20Sopenharmony_ci	WILC_HIF_SDIO = 0,
838c2ecf20Sopenharmony_ci	WILC_HIF_SPI = BIT(0)
848c2ecf20Sopenharmony_ci};
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_cienum {
878c2ecf20Sopenharmony_ci	WILC_MAC_STATUS_INIT = -1,
888c2ecf20Sopenharmony_ci	WILC_MAC_STATUS_DISCONNECTED = 0,
898c2ecf20Sopenharmony_ci	WILC_MAC_STATUS_CONNECTED = 1
908c2ecf20Sopenharmony_ci};
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_cistruct wilc_rcvd_net_info {
938c2ecf20Sopenharmony_ci	s8 rssi;
948c2ecf20Sopenharmony_ci	u8 ch;
958c2ecf20Sopenharmony_ci	u16 frame_len;
968c2ecf20Sopenharmony_ci	struct ieee80211_mgmt *mgmt;
978c2ecf20Sopenharmony_ci};
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_cistruct wilc_user_scan_req {
1008c2ecf20Sopenharmony_ci	void (*scan_result)(enum scan_event evt,
1018c2ecf20Sopenharmony_ci			    struct wilc_rcvd_net_info *info, void *priv);
1028c2ecf20Sopenharmony_ci	void *arg;
1038c2ecf20Sopenharmony_ci	u32 ch_cnt;
1048c2ecf20Sopenharmony_ci};
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_cistruct wilc_conn_info {
1078c2ecf20Sopenharmony_ci	u8 bssid[ETH_ALEN];
1088c2ecf20Sopenharmony_ci	u8 security;
1098c2ecf20Sopenharmony_ci	enum authtype auth_type;
1108c2ecf20Sopenharmony_ci	u8 ch;
1118c2ecf20Sopenharmony_ci	u8 *req_ies;
1128c2ecf20Sopenharmony_ci	size_t req_ies_len;
1138c2ecf20Sopenharmony_ci	u8 *resp_ies;
1148c2ecf20Sopenharmony_ci	u16 resp_ies_len;
1158c2ecf20Sopenharmony_ci	u16 status;
1168c2ecf20Sopenharmony_ci	void (*conn_result)(enum conn_event evt, u8 status, void *priv_data);
1178c2ecf20Sopenharmony_ci	void *arg;
1188c2ecf20Sopenharmony_ci	void *param;
1198c2ecf20Sopenharmony_ci};
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_cistruct wilc_remain_ch {
1228c2ecf20Sopenharmony_ci	u16 ch;
1238c2ecf20Sopenharmony_ci	u32 duration;
1248c2ecf20Sopenharmony_ci	void (*expired)(void *priv, u64 cookie);
1258c2ecf20Sopenharmony_ci	void *arg;
1268c2ecf20Sopenharmony_ci	u32 cookie;
1278c2ecf20Sopenharmony_ci};
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_cistruct wilc;
1308c2ecf20Sopenharmony_cistruct host_if_drv {
1318c2ecf20Sopenharmony_ci	struct wilc_user_scan_req usr_scan_req;
1328c2ecf20Sopenharmony_ci	struct wilc_conn_info conn_info;
1338c2ecf20Sopenharmony_ci	struct wilc_remain_ch remain_on_ch;
1348c2ecf20Sopenharmony_ci	u64 p2p_timeout;
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci	enum host_if_state hif_state;
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci	u8 assoc_bssid[ETH_ALEN];
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci	struct timer_list scan_timer;
1418c2ecf20Sopenharmony_ci	struct wilc_vif *scan_timer_vif;
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci	struct timer_list connect_timer;
1448c2ecf20Sopenharmony_ci	struct wilc_vif *connect_timer_vif;
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci	struct timer_list remain_on_ch_timer;
1478c2ecf20Sopenharmony_ci	struct wilc_vif *remain_on_ch_timer_vif;
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci	bool ifc_up;
1508c2ecf20Sopenharmony_ci	u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE];
1518c2ecf20Sopenharmony_ci};
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_cistruct wilc_vif;
1548c2ecf20Sopenharmony_ciint wilc_remove_wep_key(struct wilc_vif *vif, u8 index);
1558c2ecf20Sopenharmony_ciint wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index);
1568c2ecf20Sopenharmony_ciint wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len,
1578c2ecf20Sopenharmony_ci			     u8 index);
1588c2ecf20Sopenharmony_ciint wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len,
1598c2ecf20Sopenharmony_ci			    u8 index, u8 mode, enum authtype auth_type);
1608c2ecf20Sopenharmony_ciint wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
1618c2ecf20Sopenharmony_ci		 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
1628c2ecf20Sopenharmony_ci		 u8 mode, u8 cipher_mode, u8 index);
1638c2ecf20Sopenharmony_cis32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
1648c2ecf20Sopenharmony_ci			   u32 *out_val);
1658c2ecf20Sopenharmony_ciint wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
1668c2ecf20Sopenharmony_ci		    u8 index, u32 key_rsc_len, const u8 *key_rsc,
1678c2ecf20Sopenharmony_ci		    const u8 *rx_mic, const u8 *tx_mic, u8 mode,
1688c2ecf20Sopenharmony_ci		    u8 cipher_mode);
1698c2ecf20Sopenharmony_ciint wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid);
1708c2ecf20Sopenharmony_ciint wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr);
1718c2ecf20Sopenharmony_ciint wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
1728c2ecf20Sopenharmony_ci		      size_t ies_len);
1738c2ecf20Sopenharmony_ciint wilc_disconnect(struct wilc_vif *vif);
1748c2ecf20Sopenharmony_ciint wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel);
1758c2ecf20Sopenharmony_ciint wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level);
1768c2ecf20Sopenharmony_ciint wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
1778c2ecf20Sopenharmony_ci	      u8 *ch_freq_list, u8 ch_list_len,
1788c2ecf20Sopenharmony_ci	      void (*scan_result_fn)(enum scan_event,
1798c2ecf20Sopenharmony_ci				     struct wilc_rcvd_net_info *, void *),
1808c2ecf20Sopenharmony_ci	      void *user_arg, struct cfg80211_scan_request *request);
1818c2ecf20Sopenharmony_ciint wilc_hif_set_cfg(struct wilc_vif *vif,
1828c2ecf20Sopenharmony_ci		     struct cfg_param_attr *cfg_param);
1838c2ecf20Sopenharmony_ciint wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler);
1848c2ecf20Sopenharmony_ciint wilc_deinit(struct wilc_vif *vif);
1858c2ecf20Sopenharmony_ciint wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
1868c2ecf20Sopenharmony_ci		    struct cfg80211_beacon_data *params);
1878c2ecf20Sopenharmony_ciint wilc_del_beacon(struct wilc_vif *vif);
1888c2ecf20Sopenharmony_ciint wilc_add_station(struct wilc_vif *vif, const u8 *mac,
1898c2ecf20Sopenharmony_ci		     struct station_parameters *params);
1908c2ecf20Sopenharmony_ciint wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]);
1918c2ecf20Sopenharmony_ciint wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr);
1928c2ecf20Sopenharmony_ciint wilc_edit_station(struct wilc_vif *vif, const u8 *mac,
1938c2ecf20Sopenharmony_ci		      struct station_parameters *params);
1948c2ecf20Sopenharmony_ciint wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout);
1958c2ecf20Sopenharmony_ciint wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count,
1968c2ecf20Sopenharmony_ci				u8 *mc_list);
1978c2ecf20Sopenharmony_ciint wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie,
1988c2ecf20Sopenharmony_ci			   u32 duration, u16 chan,
1998c2ecf20Sopenharmony_ci			   void (*expired)(void *, u64),
2008c2ecf20Sopenharmony_ci			   void *user_arg);
2018c2ecf20Sopenharmony_ciint wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie);
2028c2ecf20Sopenharmony_civoid wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg);
2038c2ecf20Sopenharmony_ciint wilc_set_operation_mode(struct wilc_vif *vif, int index, u8 mode,
2048c2ecf20Sopenharmony_ci			    u8 ifc_id);
2058c2ecf20Sopenharmony_ciint wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats);
2068c2ecf20Sopenharmony_ciint wilc_get_vif_idx(struct wilc_vif *vif);
2078c2ecf20Sopenharmony_ciint wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power);
2088c2ecf20Sopenharmony_ciint wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power);
2098c2ecf20Sopenharmony_civoid wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length);
2108c2ecf20Sopenharmony_civoid wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length);
2118c2ecf20Sopenharmony_civoid wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length);
2128c2ecf20Sopenharmony_civoid *wilc_parse_join_bss_param(struct cfg80211_bss *bss,
2138c2ecf20Sopenharmony_ci				struct cfg80211_crypto_settings *crypto);
2148c2ecf20Sopenharmony_ci#endif
215