xref: /openbmc/linux/drivers/net/wireless/microchip/wilc1000/hif.h (revision 2612e3bbc0386368a850140a6c9b990cd496a5ec)
15625f965SAjay Singh /* SPDX-License-Identifier: GPL-2.0 */
25625f965SAjay Singh /*
35625f965SAjay Singh  * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries
45625f965SAjay Singh  * All rights reserved.
55625f965SAjay Singh  */
65625f965SAjay Singh 
75625f965SAjay Singh #ifndef WILC_HIF_H
85625f965SAjay Singh #define WILC_HIF_H
95625f965SAjay Singh #include <linux/ieee80211.h>
105625f965SAjay Singh #include "wlan_if.h"
115625f965SAjay Singh 
125625f965SAjay Singh enum {
135625f965SAjay Singh 	WILC_IDLE_MODE = 0x0,
145625f965SAjay Singh 	WILC_AP_MODE = 0x1,
155625f965SAjay Singh 	WILC_STATION_MODE = 0x2,
165625f965SAjay Singh 	WILC_GO_MODE = 0x3,
175625f965SAjay Singh 	WILC_CLIENT_MODE = 0x4
185625f965SAjay Singh };
195625f965SAjay Singh 
205625f965SAjay Singh #define WILC_MAX_NUM_PROBED_SSID		10
215625f965SAjay Singh 
225625f965SAjay Singh #define WILC_TX_MIC_KEY_LEN			8
235625f965SAjay Singh #define WILC_RX_MIC_KEY_LEN			8
245625f965SAjay Singh 
255625f965SAjay Singh #define WILC_ADD_STA_LENGTH			40
265625f965SAjay Singh #define WILC_NUM_CONCURRENT_IFC			2
275625f965SAjay Singh 
285625f965SAjay Singh enum {
295625f965SAjay Singh 	WILC_SET_CFG = 0,
305625f965SAjay Singh 	WILC_GET_CFG
315625f965SAjay Singh };
325625f965SAjay Singh 
335625f965SAjay Singh struct rf_info {
345625f965SAjay Singh 	u8 link_speed;
355625f965SAjay Singh 	s8 rssi;
365625f965SAjay Singh 	u32 tx_cnt;
375625f965SAjay Singh 	u32 rx_cnt;
385625f965SAjay Singh 	u32 tx_fail_cnt;
395625f965SAjay Singh };
405625f965SAjay Singh 
415625f965SAjay Singh enum host_if_state {
425625f965SAjay Singh 	HOST_IF_IDLE			= 0,
435625f965SAjay Singh 	HOST_IF_SCANNING		= 1,
445625f965SAjay Singh 	HOST_IF_CONNECTING		= 2,
455625f965SAjay Singh 	HOST_IF_WAITING_CONN_RESP	= 3,
465625f965SAjay Singh 	HOST_IF_CONNECTED		= 4,
475625f965SAjay Singh 	HOST_IF_P2P_LISTEN		= 5,
48c5b331d4SAjay Singh 	HOST_IF_EXTERNAL_AUTH           = 6,
495625f965SAjay Singh 	HOST_IF_FORCE_32BIT		= 0xFFFFFFFF
505625f965SAjay Singh };
515625f965SAjay Singh 
525625f965SAjay Singh struct cfg_param_attr {
535625f965SAjay Singh 	u32 flag;
545625f965SAjay Singh 	u16 short_retry_limit;
555625f965SAjay Singh 	u16 long_retry_limit;
565625f965SAjay Singh 	u16 frag_threshold;
575625f965SAjay Singh 	u16 rts_threshold;
585625f965SAjay Singh };
595625f965SAjay Singh 
605625f965SAjay Singh enum cfg_param {
615625f965SAjay Singh 	WILC_CFG_PARAM_RETRY_SHORT = BIT(0),
625625f965SAjay Singh 	WILC_CFG_PARAM_RETRY_LONG = BIT(1),
635625f965SAjay Singh 	WILC_CFG_PARAM_FRAG_THRESHOLD = BIT(2),
645625f965SAjay Singh 	WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3)
655625f965SAjay Singh };
665625f965SAjay Singh 
675625f965SAjay Singh enum scan_event {
685625f965SAjay Singh 	SCAN_EVENT_NETWORK_FOUND	= 0,
695625f965SAjay Singh 	SCAN_EVENT_DONE			= 1,
705625f965SAjay Singh 	SCAN_EVENT_ABORTED		= 2,
715625f965SAjay Singh 	SCAN_EVENT_FORCE_32BIT		= 0xFFFFFFFF
725625f965SAjay Singh };
735625f965SAjay Singh 
745625f965SAjay Singh enum conn_event {
755625f965SAjay Singh 	CONN_DISCONN_EVENT_CONN_RESP		= 0,
765625f965SAjay Singh 	CONN_DISCONN_EVENT_DISCONN_NOTIF	= 1,
775625f965SAjay Singh 	CONN_DISCONN_EVENT_FORCE_32BIT		= 0xFFFFFFFF
785625f965SAjay Singh };
795625f965SAjay Singh 
805625f965SAjay Singh enum {
815625f965SAjay Singh 	WILC_HIF_SDIO = 0,
825625f965SAjay Singh 	WILC_HIF_SPI = BIT(0)
835625f965SAjay Singh };
845625f965SAjay Singh 
855625f965SAjay Singh enum {
865625f965SAjay Singh 	WILC_MAC_STATUS_INIT = -1,
875625f965SAjay Singh 	WILC_MAC_STATUS_DISCONNECTED = 0,
885625f965SAjay Singh 	WILC_MAC_STATUS_CONNECTED = 1
895625f965SAjay Singh };
905625f965SAjay Singh 
915625f965SAjay Singh struct wilc_rcvd_net_info {
925625f965SAjay Singh 	s8 rssi;
935625f965SAjay Singh 	u8 ch;
945625f965SAjay Singh 	u16 frame_len;
955625f965SAjay Singh 	struct ieee80211_mgmt *mgmt;
965625f965SAjay Singh };
975625f965SAjay Singh 
985625f965SAjay Singh struct wilc_user_scan_req {
995625f965SAjay Singh 	void (*scan_result)(enum scan_event evt,
1005625f965SAjay Singh 			    struct wilc_rcvd_net_info *info, void *priv);
1015625f965SAjay Singh 	void *arg;
1025625f965SAjay Singh 	u32 ch_cnt;
1035625f965SAjay Singh };
1045625f965SAjay Singh 
1055625f965SAjay Singh struct wilc_conn_info {
1065625f965SAjay Singh 	u8 bssid[ETH_ALEN];
1075625f965SAjay Singh 	u8 security;
1085625f965SAjay Singh 	enum authtype auth_type;
1090e703de3SAjay Singh 	enum mfptype mfp_type;
1105625f965SAjay Singh 	u8 ch;
1115625f965SAjay Singh 	u8 *req_ies;
1125625f965SAjay Singh 	size_t req_ies_len;
1135625f965SAjay Singh 	u8 *resp_ies;
1145625f965SAjay Singh 	u16 resp_ies_len;
1155625f965SAjay Singh 	u16 status;
1165625f965SAjay Singh 	void (*conn_result)(enum conn_event evt, u8 status, void *priv_data);
1175625f965SAjay Singh 	void *arg;
1185625f965SAjay Singh 	void *param;
1195625f965SAjay Singh };
1205625f965SAjay Singh 
1215625f965SAjay Singh struct wilc_remain_ch {
1225625f965SAjay Singh 	u16 ch;
1235625f965SAjay Singh 	u32 duration;
1245625f965SAjay Singh 	void (*expired)(void *priv, u64 cookie);
1255625f965SAjay Singh 	void *arg;
126819b161bSAjay Singh 	u64 cookie;
1275625f965SAjay Singh };
1285625f965SAjay Singh 
1295625f965SAjay Singh struct wilc;
1305625f965SAjay Singh struct host_if_drv {
1315625f965SAjay Singh 	struct wilc_user_scan_req usr_scan_req;
1325625f965SAjay Singh 	struct wilc_conn_info conn_info;
1335625f965SAjay Singh 	struct wilc_remain_ch remain_on_ch;
1345625f965SAjay Singh 	u64 p2p_timeout;
1355625f965SAjay Singh 
1365625f965SAjay Singh 	enum host_if_state hif_state;
1375625f965SAjay Singh 
1385625f965SAjay Singh 	u8 assoc_bssid[ETH_ALEN];
1395625f965SAjay Singh 
1405625f965SAjay Singh 	struct timer_list scan_timer;
1415625f965SAjay Singh 	struct wilc_vif *scan_timer_vif;
1425625f965SAjay Singh 
1435625f965SAjay Singh 	struct timer_list connect_timer;
1445625f965SAjay Singh 	struct wilc_vif *connect_timer_vif;
1455625f965SAjay Singh 
1465625f965SAjay Singh 	struct timer_list remain_on_ch_timer;
1475625f965SAjay Singh 	struct wilc_vif *remain_on_ch_timer_vif;
1485625f965SAjay Singh 
1495625f965SAjay Singh 	bool ifc_up;
1505625f965SAjay Singh 	u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE];
1515625f965SAjay Singh };
1525625f965SAjay Singh 
1535625f965SAjay Singh struct wilc_vif;
1545625f965SAjay Singh int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len,
1555625f965SAjay Singh 		 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic,
1565625f965SAjay Singh 		 u8 mode, u8 cipher_mode, u8 index);
1570e703de3SAjay Singh int wilc_add_igtk(struct wilc_vif *vif, const u8 *igtk, u8 igtk_key_len,
1580e703de3SAjay Singh 		  const u8 *pn, u8 pn_len, const u8 *mac_addr, u8 mode,
1590e703de3SAjay Singh 		  u8 index);
1605625f965SAjay Singh s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac,
1615625f965SAjay Singh 			   u32 *out_val);
1625625f965SAjay Singh int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len,
1635625f965SAjay Singh 		    u8 index, u32 key_rsc_len, const u8 *key_rsc,
1645625f965SAjay Singh 		    const u8 *rx_mic, const u8 *tx_mic, u8 mode,
1655625f965SAjay Singh 		    u8 cipher_mode);
1665625f965SAjay Singh int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid);
1675625f965SAjay Singh int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr);
168c04fabacSAjay Singh int wilc_set_mac_address(struct wilc_vif *vif, u8 *mac_addr);
1695625f965SAjay Singh int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies,
1705625f965SAjay Singh 		      size_t ies_len);
1715625f965SAjay Singh int wilc_disconnect(struct wilc_vif *vif);
1725625f965SAjay Singh int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel);
1735625f965SAjay Singh int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level);
1745625f965SAjay Singh int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
1755625f965SAjay Singh 	      u8 *ch_freq_list, u8 ch_list_len,
1765625f965SAjay Singh 	      void (*scan_result_fn)(enum scan_event,
1775625f965SAjay Singh 				     struct wilc_rcvd_net_info *, void *),
1785625f965SAjay Singh 	      void *user_arg, struct cfg80211_scan_request *request);
1795625f965SAjay Singh int wilc_hif_set_cfg(struct wilc_vif *vif,
1805625f965SAjay Singh 		     struct cfg_param_attr *cfg_param);
1815625f965SAjay Singh int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler);
1825625f965SAjay Singh int wilc_deinit(struct wilc_vif *vif);
1835625f965SAjay Singh int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period,
1845625f965SAjay Singh 		    struct cfg80211_beacon_data *params);
1855625f965SAjay Singh int wilc_del_beacon(struct wilc_vif *vif);
1865625f965SAjay Singh int wilc_add_station(struct wilc_vif *vif, const u8 *mac,
1875625f965SAjay Singh 		     struct station_parameters *params);
1885625f965SAjay Singh int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]);
1895625f965SAjay Singh int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr);
1905625f965SAjay Singh int wilc_edit_station(struct wilc_vif *vif, const u8 *mac,
1915625f965SAjay Singh 		      struct station_parameters *params);
1925625f965SAjay Singh int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout);
1935625f965SAjay Singh int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count,
1945625f965SAjay Singh 				u8 *mc_list);
1955625f965SAjay Singh int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie,
1965625f965SAjay Singh 			   u32 duration, u16 chan,
1975625f965SAjay Singh 			   void (*expired)(void *, u64),
1985625f965SAjay Singh 			   void *user_arg);
1995625f965SAjay Singh int wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie);
2005625f965SAjay Singh void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg);
2015625f965SAjay Singh int wilc_set_operation_mode(struct wilc_vif *vif, int index, u8 mode,
2025625f965SAjay Singh 			    u8 ifc_id);
2035625f965SAjay Singh int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats);
2045625f965SAjay Singh int wilc_get_vif_idx(struct wilc_vif *vif);
2055625f965SAjay Singh int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power);
2065625f965SAjay Singh int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power);
2070ec5408cSAjay Singh void wilc_set_wowlan_trigger(struct wilc_vif *vif, bool enabled);
208c5b331d4SAjay Singh int wilc_set_external_auth_param(struct wilc_vif *vif,
209c5b331d4SAjay Singh 				 struct cfg80211_external_auth_params *param);
2105625f965SAjay Singh void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length);
2115625f965SAjay Singh void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length);
2125625f965SAjay Singh void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length);
2135625f965SAjay Singh void *wilc_parse_join_bss_param(struct cfg80211_bss *bss,
2145625f965SAjay Singh 				struct cfg80211_crypto_settings *crypto);
2150e703de3SAjay Singh int wilc_set_default_mgmt_key_index(struct wilc_vif *vif, u8 index);
216*f01272eeSKalle Valo void wilc_handle_disconnect(struct wilc_vif *vif);
217*f01272eeSKalle Valo 
2185625f965SAjay Singh #endif
219