linux/drivers/net/wireless/ath/wil6210/wil6210.h

/* SPDX-License-Identifier: ISC */
/*
 * Copyright (c) 2012-2017 Qualcomm Atheros, Inc.
 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 */

#ifndef __WIL6210_H__
#define __WIL6210_H__

#include <linux/etherdevice.h>
#include <linux/netdevice.h>
#include <linux/wireless.h>
#include <net/cfg80211.h>
#include <linux/timex.h>
#include <linux/types.h>
#include <linux/irqreturn.h>
#include "wmi.h"
#include "wil_platform.h"
#include "fw.h"

extern bool no_fw_recovery;
extern unsigned int mtu_max;
extern unsigned short rx_ring_overflow_thrsh;
extern int agg_wsize;
extern bool rx_align_2;
extern bool rx_large_buf;
extern bool debug_fw;
extern bool disable_ap_sme;
extern bool ftm_mode;
extern bool drop_if_ring_full;
extern uint max_assoc_sta;

struct wil6210_priv;
struct wil6210_vif;
wil_tx_desc;

#define WIL_NAME

#define WIL_FW_NAME_DEFAULT
#define WIL_FW_NAME_FTM_DEFAULT

#define WIL_FW_NAME_SPARROW_PLUS
#define WIL_FW_NAME_FTM_SPARROW_PLUS

#define WIL_FW_NAME_TALYN
#define WIL_FW_NAME_FTM_TALYN
#define WIL_BRD_NAME_TALYN

#define WIL_BOARD_FILE_NAME

#define WIL_DEFAULT_BUS_REQUEST_KBPS
#define WIL_MAX_BUS_REQUEST_KBPS

#define WIL_NUM_LATENCY_BINS

/* maximum number of virtual interfaces the driver supports
 * (including the main interface)
 */
#define WIL_MAX_VIFS

/**
 * extract bits [@b0:@b1] (inclusive) from the value @x
 * it should be @b0 <= @b1, or result is incorrect
 */
static inline u32 WIL_GET_BITS(u32 x, int b0, int b1)
{}

#define WIL6210_MIN_MEM_SIZE
#define WIL6210_MAX_MEM_SIZE

#define WIL_TX_Q_LEN_DEFAULT
#define WIL_RX_RING_SIZE_ORDER_DEFAULT
#define WIL_RX_RING_SIZE_ORDER_TALYN_DEFAULT
#define WIL_TX_RING_SIZE_ORDER_DEFAULT
#define WIL_BCAST_RING_SIZE_ORDER_DEFAULT
#define WIL_BCAST_MCS0_LIMIT
/* limit ring size in range [32..32k] */
#define WIL_RING_SIZE_ORDER_MIN
#define WIL_RING_SIZE_ORDER_MAX
#define WIL6210_MAX_TX_RINGS
#define WIL6210_MAX_CID
#define WIL6210_RX_DESC_MAX_CID
#define WIL_MAX_AMPDU_SIZE
#define WIL_MAX_AGG_WSIZE
#define WIL_MAX_AMPDU_SIZE_128
#define WIL_MAX_AGG_WSIZE_64
#define WIL6210_MAX_STATUS_RINGS
#define WIL_WMI_CALL_GENERAL_TO_MS
#define WIL_EXTENDED_MCS_26
#define WIL_BASE_MCS_FOR_EXTENDED_26
#define WIL_EXTENDED_MCS_CHECK(x)

/* Hardware offload block adds the following:
 * 26 bytes - 3-address QoS data header
 *  8 bytes - IV + EIV (for GCMP)
 *  8 bytes - SNAP
 * 16 bytes - MIC (for GCMP)
 *  4 bytes - CRC
 */
#define WIL_MAX_MPDU_OVERHEAD

struct wil_suspend_count_stats {};

struct wil_suspend_stats {};

/* Calculate MAC buffer size for the firmware. It includes all overhead,
 * as it will go over the air, and need to be 8 byte aligned
 */
static inline u32 wil_mtu2macbuf(u32 mtu)
{}

/* MTU for Ethernet need to take into account 8-byte SNAP header
 * to be added when encapsulating Ethernet frame into 802.11
 */
#define WIL_MAX_ETH_MTU
/* Max supported by wil6210 value for interrupt threshold is 5sec. */
#define WIL6210_ITR_TRSH_MAX
#define WIL6210_ITR_TX_INTERFRAME_TIMEOUT_DEFAULT
#define WIL6210_ITR_RX_INTERFRAME_TIMEOUT_DEFAULT
#define WIL6210_ITR_TX_MAX_BURST_DURATION_DEFAULT
#define WIL6210_ITR_RX_MAX_BURST_DURATION_DEFAULT
#define WIL6210_FW_RECOVERY_RETRIES
#define WIL6210_FW_RECOVERY_TO
#define WIL6210_SCAN_TO
#define WIL6210_DISCONNECT_TO_MS
#define WIL6210_RX_HIGH_TRSH_INIT
#define WIL6210_RX_HIGH_TRSH_DEFAULT
#define WIL_MAX_DMG_AID
/* Hardware definitions begin */

/*
 * Mapping
 * RGF File      | Host addr    |  FW addr
 *               |              |
 * user_rgf      | 0x000000     | 0x880000
 *  dma_rgf      | 0x001000     | 0x881000
 * pcie_rgf      | 0x002000     | 0x882000
 *               |              |
 */

/* Where various structures placed in host address space */
#define WIL6210_FW_HOST_OFF

#define HOSTADDR(fwaddr)

/*
 * Interrupt control registers block
 *
 * each interrupt controlled by the same bit in all registers
 */
struct RGF_ICR {} __packed;

/* registers - FW addresses */
#define RGF_USER_USAGE_1
#define RGF_USER_USAGE_2
#define RGF_USER_USAGE_6
	#define BIT_USER_OOB_MODE
	#define BIT_USER_OOB_R2_MODE
#define RGF_USER_USAGE_8
	#define BIT_USER_PREVENT_DEEP_SLEEP
	#define BIT_USER_SUPPORT_T_POWER_ON_0
	#define BIT_USER_EXT_CLK
#define RGF_USER_HW_MACHINE_STATE
	#define HW_MACHINE_BOOT_DONE
#define RGF_USER_USER_CPU_0
	#define BIT_USER_USER_CPU_MAN_RST
#define RGF_USER_CPU_PC
#define RGF_USER_MAC_CPU_0
	#define BIT_USER_MAC_CPU_MAN_RST
#define RGF_USER_USER_SCRATCH_PAD
#define RGF_USER_BL
#define RGF_USER_FW_REV_ID
#define RGF_USER_FW_CALIB_RESULT
	#define CALIB_RESULT_SIGNATURE
#define RGF_USER_CLKS_CTL_0
	#define BIT_USER_CLKS_CAR_AHB_SW_SEL
	#define BIT_USER_CLKS_RST_PWGD
#define RGF_USER_CLKS_CTL_SW_RST_VEC_0
#define RGF_USER_CLKS_CTL_SW_RST_VEC_1
#define RGF_USER_CLKS_CTL_SW_RST_VEC_2
#define RGF_USER_CLKS_CTL_SW_RST_VEC_3
#define RGF_USER_CLKS_CTL_SW_RST_MASK_0
	#define BIT_HPAL_PERST_FROM_PAD
	#define BIT_CAR_PERST_RST
#define RGF_USER_USER_ICR
	#define BIT_USER_USER_ICR_SW_INT_2
#define RGF_USER_CLKS_CTL_EXT_SW_RST_VEC_0
#define RGF_USER_CLKS_CTL_EXT_SW_RST_VEC_1
#define RGF_USER_SPARROW_M_4
	#define BIT_SPARROW_M_4_SEL_SLEEP_OR_REF
#define RGF_USER_OTP_HW_RD_MACHINE_1
	#define BIT_OTP_SIGNATURE_ERR_TALYN_MB
	#define BIT_OTP_HW_SECTION_DONE_TALYN_MB
	#define BIT_NO_FLASH_INDICATION
#define RGF_USER_XPM_IFC_RD_TIME1
#define RGF_USER_XPM_IFC_RD_TIME2
#define RGF_USER_XPM_IFC_RD_TIME3
#define RGF_USER_XPM_IFC_RD_TIME4
#define RGF_USER_XPM_IFC_RD_TIME5
#define RGF_USER_XPM_IFC_RD_TIME6
#define RGF_USER_XPM_IFC_RD_TIME7
#define RGF_USER_XPM_IFC_RD_TIME8
#define RGF_USER_XPM_IFC_RD_TIME9
#define RGF_USER_XPM_IFC_RD_TIME10
#define RGF_USER_XPM_RD_DOUT_SAMPLE_TIME

#define RGF_DMA_EP_TX_ICR
	#define BIT_DMA_EP_TX_ICR_TX_DONE
	#define BIT_DMA_EP_TX_ICR_TX_DONE_N(n)
#define RGF_DMA_EP_RX_ICR
	#define BIT_DMA_EP_RX_ICR_RX_DONE
	#define BIT_DMA_EP_RX_ICR_RX_HTRSH
#define RGF_DMA_EP_MISC_ICR
	#define BIT_DMA_EP_MISC_ICR_RX_HTRSH
	#define BIT_DMA_EP_MISC_ICR_TX_NO_ACT
	#define BIT_DMA_EP_MISC_ICR_HALP
	#define BIT_DMA_EP_MISC_ICR_FW_INT(n)

/* Legacy interrupt moderation control (before Sparrow v2)*/
#define RGF_DMA_ITR_CNT_TRSH
#define RGF_DMA_ITR_CNT_DATA
#define RGF_DMA_ITR_CNT_CRL
	#define BIT_DMA_ITR_CNT_CRL_EN
	#define BIT_DMA_ITR_CNT_CRL_EXT_TICK
	#define BIT_DMA_ITR_CNT_CRL_FOREVER
	#define BIT_DMA_ITR_CNT_CRL_CLR
	#define BIT_DMA_ITR_CNT_CRL_REACH_TRSH

/* Offload control (Sparrow B0+) */
#define RGF_DMA_OFUL_NID_0
	#define BIT_DMA_OFUL_NID_0_RX_EXT_TR_EN
	#define BIT_DMA_OFUL_NID_0_TX_EXT_TR_EN
	#define BIT_DMA_OFUL_NID_0_RX_EXT_A3_SRC
	#define BIT_DMA_OFUL_NID_0_TX_EXT_A3_SRC

/* New (sparrow v2+) interrupt moderation control */
#define RGF_DMA_ITR_TX_DESQ_NO_MOD
#define RGF_DMA_ITR_TX_CNT_TRSH
#define RGF_DMA_ITR_TX_CNT_DATA
#define RGF_DMA_ITR_TX_CNT_CTL
	#define BIT_DMA_ITR_TX_CNT_CTL_EN
	#define BIT_DMA_ITR_TX_CNT_CTL_EXT_TIC_SEL
	#define BIT_DMA_ITR_TX_CNT_CTL_FOREVER
	#define BIT_DMA_ITR_TX_CNT_CTL_CLR
	#define BIT_DMA_ITR_TX_CNT_CTL_REACHED_TRESH
	#define BIT_DMA_ITR_TX_CNT_CTL_CROSS_EN
	#define BIT_DMA_ITR_TX_CNT_CTL_FREE_RUNNIG
#define RGF_DMA_ITR_TX_IDL_CNT_TRSH
#define RGF_DMA_ITR_TX_IDL_CNT_DATA
#define RGF_DMA_ITR_TX_IDL_CNT_CTL
	#define BIT_DMA_ITR_TX_IDL_CNT_CTL_EN
	#define BIT_DMA_ITR_TX_IDL_CNT_CTL_EXT_TIC_SEL
	#define BIT_DMA_ITR_TX_IDL_CNT_CTL_FOREVER
	#define BIT_DMA_ITR_TX_IDL_CNT_CTL_CLR
	#define BIT_DMA_ITR_TX_IDL_CNT_CTL_REACHED_TRESH
#define RGF_DMA_ITR_RX_DESQ_NO_MOD
#define RGF_DMA_ITR_RX_CNT_TRSH
#define RGF_DMA_ITR_RX_CNT_DATA
#define RGF_DMA_ITR_RX_CNT_CTL
	#define BIT_DMA_ITR_RX_CNT_CTL_EN
	#define BIT_DMA_ITR_RX_CNT_CTL_EXT_TIC_SEL
	#define BIT_DMA_ITR_RX_CNT_CTL_FOREVER
	#define BIT_DMA_ITR_RX_CNT_CTL_CLR
	#define BIT_DMA_ITR_RX_CNT_CTL_REACHED_TRESH
	#define BIT_DMA_ITR_RX_CNT_CTL_CROSS_EN
	#define BIT_DMA_ITR_RX_CNT_CTL_FREE_RUNNIG
#define RGF_DMA_ITR_RX_IDL_CNT_TRSH
#define RGF_DMA_ITR_RX_IDL_CNT_DATA
#define RGF_DMA_ITR_RX_IDL_CNT_CTL
	#define BIT_DMA_ITR_RX_IDL_CNT_CTL_EN
	#define BIT_DMA_ITR_RX_IDL_CNT_CTL_EXT_TIC_SEL
	#define BIT_DMA_ITR_RX_IDL_CNT_CTL_FOREVER
	#define BIT_DMA_ITR_RX_IDL_CNT_CTL_CLR
	#define BIT_DMA_ITR_RX_IDL_CNT_CTL_REACHED_TRESH
#define RGF_DMA_MISC_CTL
	#define BIT_OFUL34_RDY_VALID_BUG_FIX_EN

#define RGF_DMA_PSEUDO_CAUSE
#define RGF_DMA_PSEUDO_CAUSE_MASK_SW
#define RGF_DMA_PSEUDO_CAUSE_MASK_FW
	#define BIT_DMA_PSEUDO_CAUSE_RX
	#define BIT_DMA_PSEUDO_CAUSE_TX
	#define BIT_DMA_PSEUDO_CAUSE_MISC

#define RGF_HP_CTRL
#define RGF_PAL_UNIT_ICR
#define RGF_PCIE_LOS_COUNTER_CTL

/* MAC timer, usec, for packet lifetime */
#define RGF_MAC_MTRL_COUNTER_0

#define RGF_CAF_ICR_TALYN_MB
#define RGF_CAF_ICR
#define RGF_CAF_OSC_CONTROL
	#define BIT_CAF_OSC_XTAL_EN
#define RGF_CAF_PLL_LOCK_STATUS
	#define BIT_CAF_OSC_DIG_XTAL_STABLE

#define RGF_OTP_QC_SECURED
	#define BIT_BOOT_FROM_ROM

/* eDMA */
#define RGF_SCM_PTRS_SUBQ_RD_PTR
#define RGF_SCM_PTRS_COMPQ_RD_PTR
#define RGF_DMA_SCM_SUBQ_CONS
#define RGF_DMA_SCM_COMPQ_PROD

#define RGF_INT_COUNT_ON_SPECIAL_EVT

#define RGF_INT_CTRL_INT_GEN_CFG_0
#define RGF_INT_CTRL_INT_GEN_CFG_1
#define RGF_INT_GEN_TIME_UNIT_LIMIT

#define RGF_INT_GEN_CTRL
	#define BIT_CONTROL_0

/* eDMA status interrupts */
#define RGF_INT_GEN_RX_ICR
	#define BIT_RX_STATUS_IRQ
#define RGF_INT_GEN_TX_ICR
	#define BIT_TX_STATUS_IRQ
#define RGF_INT_CTRL_RX_INT_MASK
#define RGF_INT_CTRL_TX_INT_MASK

#define RGF_INT_GEN_IDLE_TIME_LIMIT

#define USER_EXT_USER_PMU_3
	#define BIT_PMU_DEVICE_RDY

#define RGF_USER_JTAG_DEV_ID
	#define JTAG_DEV_ID_SPARROW
	#define JTAG_DEV_ID_TALYN
	#define JTAG_DEV_ID_TALYN_MB

#define RGF_USER_REVISION_ID
#define RGF_USER_REVISION_ID_MASK
	#define REVISION_ID_SPARROW_B0
	#define REVISION_ID_SPARROW_D0

#define RGF_OTP_MAC_TALYN_MB
#define RGF_OTP_OEM_MAC
#define RGF_OTP_MAC

/* Talyn-MB */
#define RGF_USER_USER_CPU_0_TALYN_MB
#define RGF_USER_MAC_CPU_0_TALYN_MB

/* crash codes for FW/Ucode stored here */

/* ASSERT RGFs */
#define SPARROW_RGF_FW_ASSERT_CODE
#define SPARROW_RGF_UCODE_ASSERT_CODE
#define TALYN_RGF_FW_ASSERT_CODE
#define TALYN_RGF_UCODE_ASSERT_CODE

enum {};

/* popular locations */
#define RGF_MBOX
#define HOST_MBOX
#define SW_INT_MBOX

/* ISR register bits */
#define ISR_MISC_FW_READY
#define ISR_MISC_MBOX_EVT
#define ISR_MISC_FW_ERROR

#define WIL_DATA_COMPLETION_TO_MS

/* Hardware definitions end */
#define SPARROW_FW_MAPPING_TABLE_SIZE
#define TALYN_FW_MAPPING_TABLE_SIZE
#define TALYN_MB_FW_MAPPING_TABLE_SIZE
#define MAX_FW_MAPPING_TABLE_SIZE

/* Common representation of physical address in wil ring */
struct wil_ring_dma_addr {} __packed;

struct fw_map {};

/* array size should be in sync with actual definition in the wmi.c */
extern const struct fw_map sparrow_fw_mapping[SPARROW_FW_MAPPING_TABLE_SIZE];
extern const struct fw_map sparrow_d0_mac_rgf_ext;
extern const struct fw_map talyn_fw_mapping[TALYN_FW_MAPPING_TABLE_SIZE];
extern const struct fw_map talyn_mb_fw_mapping[TALYN_MB_FW_MAPPING_TABLE_SIZE];
extern struct fw_map fw_mapping[MAX_FW_MAPPING_TABLE_SIZE];

/**
 * mk_cidxtid - construct @cidxtid field
 * @cid: CID value
 * @tid: TID value
 *
 * @cidxtid field encoded as bits 0..3 - CID; 4..7 - TID
 */
static inline u8 mk_cidxtid(u8 cid, u8 tid)
{}

/**
 * parse_cidxtid - parse @cidxtid field
 * @cid: store CID value here
 * @tid: store TID value here
 *
 * @cidxtid field encoded as bits 0..3 - CID; 4..7 - TID
 */
static inline void parse_cidxtid(u8 cidxtid, u8 *cid, u8 *tid)
{}

struct wil6210_mbox_ring {} __packed;

struct wil6210_mbox_ring_desc {} __packed;

/* at HOST_OFF_WIL6210_MBOX_CTL */
struct wil6210_mbox_ctl {} __packed;

struct wil6210_mbox_hdr {} __packed;

#define WIL_MBOX_HDR_TYPE_WMI

/* max. value for wil6210_mbox_hdr.len */
#define MAX_MBOXITEM_SIZE

struct pending_wmi_event {};

enum {};

/**
 * struct wil_ctx - software context for ring descriptor
 */
struct wil_ctx {};

struct wil_desc_ring_rx_swtail {};

/**
 * A general ring structure, used for RX and TX.
 * In legacy DMA it represents the vring,
 * In enahnced DMA it represents the descriptor ring (vrings are handled by FW)
 */
struct wil_ring {};

/**
 * Additional data for Rx ring.
 * Used for enhanced DMA RX chaining.
 */
struct wil_ring_rx_data {};

/**
 * Status ring structure, used for enhanced DMA completions for RX and TX.
 */
struct wil_status_ring {};

#define WIL_STA_TID_NUM
#define WIL_MCS_MAX

struct wil_net_stats {};

/**
 * struct tx_rx_ops - different TX/RX ops for legacy and enhanced
 * DMA flow
 */
struct wil_txrx_ops {};

/**
 * Additional data for Tx ring
 */
struct wil_ring_tx_data {};

enum {};

struct pci_dev;

/**
 * struct tid_ampdu_rx - TID aggregation information (Rx).
 *
 * @reorder_buf: buffer to reorder incoming aggregated MPDUs
 * @last_rx: jiffies of last rx activity
 * @head_seq_num: head sequence number in reordering buffer.
 * @stored_mpdu_num: number of MPDUs in reordering buffer
 * @ssn: Starting Sequence Number expected to be aggregated.
 * @buf_size: buffer size for incoming A-MPDUs
 * @ssn_last_drop: SSN of the last dropped frame
 * @total: total number of processed incoming frames
 * @drop_dup: duplicate frames dropped for this reorder buffer
 * @drop_old: old frames dropped for this reorder buffer
 * @first_time: true when this buffer used 1-st time
 * @mcast_last_seq: sequence number (SN) of last received multicast packet
 * @drop_dup_mcast: duplicate multicast frames dropped for this reorder buffer
 */
struct wil_tid_ampdu_rx {};

/**
 * struct wil_tid_crypto_rx_single - TID crypto information (Rx).
 *
 * @pn: GCMP PN for the session
 * @key_set: valid key present
 */
struct wil_tid_crypto_rx_single {};

struct wil_tid_crypto_rx {};

struct wil_p2p_info {};

enum wil_sta_status {};

enum wil_rekey_state {};

/**
 * struct wil_sta_info - data for peer
 *
 * Peer identified by its CID (connection ID)
 * NIC performs beam forming for each peer;
 * if no beam forming done, frame exchange is not
 * possible.
 */
struct wil_sta_info {};

enum {};

enum {};

struct wil_probe_client_req {};

struct pmc_ctx {};

struct wil_halp {};

struct wil_blob_wrapper {};

#define WIL_LED_MAX_ID
#define WIL_LED_INVALID_ID
#define WIL_LED_BLINK_ON_SLOW_MS
#define WIL_LED_BLINK_OFF_SLOW_MS
#define WIL_LED_BLINK_ON_MED_MS
#define WIL_LED_BLINK_OFF_MED_MS
#define WIL_LED_BLINK_ON_FAST_MS
#define WIL_LED_BLINK_OFF_FAST_MS
enum {};

struct blink_on_off_time {};

struct wil_debugfs_iomem_data {};

struct wil_debugfs_data {};

extern struct blink_on_off_time led_blink_time[WIL_LED_TIME_LAST];
extern u8 led_id;
extern u8 led_polarity;

enum wil6210_vif_status {};

struct wil6210_vif {};

/**
 * RX buffer allocated for enhanced DMA RX descriptors
 */
struct wil_rx_buff {};

/**
 * During Rx completion processing, the driver extracts a buffer ID which
 * is used as an index to the rx_buff_mgmt.buff_arr array and then the SKB
 * is given to the network stack and the buffer is moved from the 'active'
 * list to the 'free' list.
 * During Rx refill, SKBs are attached to free buffers and moved to the
 * 'active' list.
 */
struct wil_rx_buff_mgmt {};

struct wil_fw_stats_global {};

struct wil_brd_info {};

struct wil6210_priv {};

#define wil_to_wiphy(i)
#define wil_to_dev(i)
#define wiphy_to_wil(w)
#define wdev_to_wil(w)
#define ndev_to_wil(n)
#define ndev_to_vif(n)
#define vif_to_wil(v)
#define vif_to_ndev(v)
#define vif_to_wdev(v)
#define GET_MAX_VIFS(wil)

static inline struct wil6210_vif *wdev_to_vif(struct wil6210_priv *wil,
					      struct wireless_dev *wdev)
{}

static inline struct wireless_dev *
vif_to_radio_wdev(struct wil6210_priv *wil, struct wil6210_vif *vif)
{}

__printf(2, 3)
void wil_dbg_trace(struct wil6210_priv *wil, const char *fmt, ...);
__printf(2, 3)
void __wil_err(struct wil6210_priv *wil, const char *fmt, ...);
__printf(2, 3)
void __wil_err_ratelimited(struct wil6210_priv *wil, const char *fmt, ...);
__printf(2, 3)
void __wil_info(struct wil6210_priv *wil, const char *fmt, ...);
__printf(2, 3)
void wil_dbg_ratelimited(const struct wil6210_priv *wil, const char *fmt, ...);
#define wil_dbg(wil, fmt, arg...)

#define wil_dbg_irq(wil, fmt, arg...)
#define wil_dbg_txrx(wil, fmt, arg...)
#define wil_dbg_wmi(wil, fmt, arg...)
#define wil_dbg_misc(wil, fmt, arg...)
#define wil_dbg_pm(wil, fmt, arg...)
#define wil_err(wil, fmt, arg...)
#define wil_info(wil, fmt, arg...)
#define wil_err_ratelimited(wil, fmt, arg...)

/* target operations */
/* register read */
static inline u32 wil_r(struct wil6210_priv *wil, u32 reg)
{}

/* register write. wmb() to make sure it is completed */
static inline void wil_w(struct wil6210_priv *wil, u32 reg, u32 val)
{}

/* register set = read, OR, write */
static inline void wil_s(struct wil6210_priv *wil, u32 reg, u32 val)
{}

/* register clear = read, AND with inverted, write */
static inline void wil_c(struct wil6210_priv *wil, u32 reg, u32 val)
{}

/**
 * wil_cid_valid - check cid is valid
 */
static inline bool wil_cid_valid(struct wil6210_priv *wil, int cid)
{}

void wil_get_board_file(struct wil6210_priv *wil, char *buf, size_t len);

#if defined(CONFIG_DYNAMIC_DEBUG)
#define wil_hex_dump_txrx(prefix_str, prefix_type, rowsize,	\
			  groupsize, buf, len, ascii)

#define wil_hex_dump_wmi(prefix_str, prefix_type, rowsize,	\
			 groupsize, buf, len, ascii)

#define wil_hex_dump_misc(prefix_str, prefix_type, rowsize,	\
			  groupsize, buf, len, ascii)
#else /* defined(CONFIG_DYNAMIC_DEBUG) */
static inline
void wil_hex_dump_txrx(const char *prefix_str, int prefix_type, int rowsize,
		       int groupsize, const void *buf, size_t len, bool ascii)
{
}

static inline
void wil_hex_dump_wmi(const char *prefix_str, int prefix_type, int rowsize,
		      int groupsize, const void *buf, size_t len, bool ascii)
{
}

static inline
void wil_hex_dump_misc(const char *prefix_str, int prefix_type, int rowsize,
		       int groupsize, const void *buf, size_t len, bool ascii)
{
}
#endif /* defined(CONFIG_DYNAMIC_DEBUG) */

void wil_memcpy_fromio_32(void *dst, const volatile void __iomem *src,
			  size_t count);
void wil_memcpy_toio_32(volatile void __iomem *dst, const void *src,
			size_t count);
int wil_mem_access_lock(struct wil6210_priv *wil);
void wil_mem_access_unlock(struct wil6210_priv *wil);

struct wil6210_vif *
wil_vif_alloc(struct wil6210_priv *wil, const char *name,
	      unsigned char name_assign_type, enum nl80211_iftype iftype);
void wil_vif_free(struct wil6210_vif *vif);
void *wil_if_alloc(struct device *dev);
bool wil_has_other_active_ifaces(struct wil6210_priv *wil,
				 struct net_device *ndev, bool up, bool ok);
bool wil_has_active_ifaces(struct wil6210_priv *wil, bool up, bool ok);
void wil_if_free(struct wil6210_priv *wil);
int wil_vif_add(struct wil6210_priv *wil, struct wil6210_vif *vif);
int wil_if_add(struct wil6210_priv *wil);
void wil_vif_remove(struct wil6210_priv *wil, u8 mid);
void wil_if_remove(struct wil6210_priv *wil);
int wil_priv_init(struct wil6210_priv *wil);
void wil_priv_deinit(struct wil6210_priv *wil);
int wil_ps_update(struct wil6210_priv *wil,
		  enum wmi_ps_profile_type ps_profile);
int wil_reset(struct wil6210_priv *wil, bool no_fw);
void wil_fw_error_recovery(struct wil6210_priv *wil);
void wil_set_recovery_state(struct wil6210_priv *wil, int state);
bool wil_is_recovery_blocked(struct wil6210_priv *wil);
int wil_up(struct wil6210_priv *wil);
int __wil_up(struct wil6210_priv *wil);
int wil_down(struct wil6210_priv *wil);
int __wil_down(struct wil6210_priv *wil);
void wil_refresh_fw_capabilities(struct wil6210_priv *wil);
void wil_mbox_ring_le2cpus(struct wil6210_mbox_ring *r);
int wil_find_cid(struct wil6210_priv *wil, u8 mid, const u8 *mac);
int wil_find_cid_by_idx(struct wil6210_priv *wil, u8 mid, int idx);
void wil_set_ethtoolops(struct net_device *ndev);

struct fw_map *wil_find_fw_mapping(const char *section);
void __iomem *wmi_buffer_block(struct wil6210_priv *wil, __le32 ptr, u32 size);
void __iomem *wmi_buffer(struct wil6210_priv *wil, __le32 ptr);
void __iomem *wmi_addr(struct wil6210_priv *wil, u32 ptr);
int wmi_read_hdr(struct wil6210_priv *wil, __le32 ptr,
		 struct wil6210_mbox_hdr *hdr);
int wmi_send(struct wil6210_priv *wil, u16 cmdid, u8 mid, void *buf, u16 len);
void wmi_recv_cmd(struct wil6210_priv *wil);
int wmi_call(struct wil6210_priv *wil, u16 cmdid, u8 mid, void *buf, u16 len,
	     u16 reply_id, void *reply, u16 reply_size, int to_msec);
void wmi_event_worker(struct work_struct *work);
void wmi_event_flush(struct wil6210_priv *wil);
int wmi_set_ssid(struct wil6210_vif *vif, u8 ssid_len, const void *ssid);
int wmi_get_ssid(struct wil6210_vif *vif, u8 *ssid_len, void *ssid);
int wmi_set_channel(struct wil6210_priv *wil, int channel);
int wmi_get_channel(struct wil6210_priv *wil, int *channel);
int wmi_del_cipher_key(struct wil6210_vif *vif, u8 key_index,
		       const void *mac_addr, int key_usage);
int wmi_add_cipher_key(struct wil6210_vif *vif, u8 key_index,
		       const void *mac_addr, int key_len, const void *key,
		       int key_usage);
int wmi_echo(struct wil6210_priv *wil);
int wmi_set_ie(struct wil6210_vif *vif, u8 type, u16 ie_len, const void *ie);
int wmi_rx_chain_add(struct wil6210_priv *wil, struct wil_ring *vring);
int wmi_update_ft_ies(struct wil6210_vif *vif, u16 ie_len, const void *ie);
int wmi_rxon(struct wil6210_priv *wil, bool on);
int wmi_get_temperature(struct wil6210_priv *wil, u32 *t_m, u32 *t_r);
int wmi_get_all_temperatures(struct wil6210_priv *wil,
			     struct wmi_temp_sense_all_done_event
			     *sense_all_evt);
int wmi_disconnect_sta(struct wil6210_vif *vif, const u8 *mac, u16 reason,
		       bool del_sta);
int wmi_addba(struct wil6210_priv *wil, u8 mid,
	      u8 ringid, u8 size, u16 timeout);
int wmi_delba_tx(struct wil6210_priv *wil, u8 mid, u8 ringid, u16 reason);
int wmi_delba_rx(struct wil6210_priv *wil, u8 mid, u8 cid, u8 tid, u16 reason);
int wmi_addba_rx_resp(struct wil6210_priv *wil,
		      u8 mid, u8 cid, u8 tid, u8 token,
		      u16 status, bool amsdu, u16 agg_wsize, u16 timeout);
int wmi_ps_dev_profile_cfg(struct wil6210_priv *wil,
			   enum wmi_ps_profile_type ps_profile);
int wmi_set_mgmt_retry(struct wil6210_priv *wil, u8 retry_short);
int wmi_get_mgmt_retry(struct wil6210_priv *wil, u8 *retry_short);
int wmi_new_sta(struct wil6210_vif *vif, const u8 *mac, u8 aid);
int wmi_port_allocate(struct wil6210_priv *wil, u8 mid,
		      const u8 *mac, enum nl80211_iftype iftype);
int wmi_port_delete(struct wil6210_priv *wil, u8 mid);
int wmi_link_stats_cfg(struct wil6210_vif *vif, u32 type, u8 cid, u32 interval);
int wil_addba_rx_request(struct wil6210_priv *wil, u8 mid, u8 cid, u8 tid,
			 u8 dialog_token, __le16 ba_param_set,
			 __le16 ba_timeout, __le16 ba_seq_ctrl);
int wil_addba_tx_request(struct wil6210_priv *wil, u8 ringid, u16 wsize);

void wil6210_clear_irq(struct wil6210_priv *wil);
int wil6210_init_irq(struct wil6210_priv *wil, int irq);
void wil6210_fini_irq(struct wil6210_priv *wil, int irq);
void wil_mask_irq(struct wil6210_priv *wil);
void wil_unmask_irq(struct wil6210_priv *wil);
void wil_configure_interrupt_moderation(struct wil6210_priv *wil);
void wil_disable_irq(struct wil6210_priv *wil);
void wil_enable_irq(struct wil6210_priv *wil);
void wil6210_mask_halp(struct wil6210_priv *wil);

/* P2P */
bool wil_p2p_is_social_scan(struct cfg80211_scan_request *request);
int wil_p2p_search(struct wil6210_vif *vif,
		   struct cfg80211_scan_request *request);
int wil_p2p_listen(struct wil6210_priv *wil, struct wireless_dev *wdev,
		   unsigned int duration, struct ieee80211_channel *chan,
		   u64 *cookie);
u8 wil_p2p_stop_discovery(struct wil6210_vif *vif);
int wil_p2p_cancel_listen(struct wil6210_vif *vif, u64 cookie);
void wil_p2p_listen_expired(struct work_struct *work);
void wil_p2p_search_expired(struct work_struct *work);
void wil_p2p_stop_radio_operations(struct wil6210_priv *wil);
void wil_p2p_delayed_listen_work(struct work_struct *work);

/* WMI for P2P */
int wmi_p2p_cfg(struct wil6210_vif *vif, int channel, int bi);
int wmi_start_listen(struct wil6210_vif *vif);
int wmi_start_search(struct wil6210_vif *vif);
int wmi_stop_discovery(struct wil6210_vif *vif);

int wil_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
			 struct cfg80211_mgmt_tx_params *params,
			 u64 *cookie);
void wil_cfg80211_ap_recovery(struct wil6210_priv *wil);
int wil_cfg80211_iface_combinations_from_fw(
	struct wil6210_priv *wil,
	const struct wil_fw_record_concurrency *conc);
int wil_vif_prepare_stop(struct wil6210_vif *vif);

#if defined(CONFIG_WIL6210_DEBUGFS)
int wil6210_debugfs_init(struct wil6210_priv *wil);
void wil6210_debugfs_remove(struct wil6210_priv *wil);
#else
static inline int wil6210_debugfs_init(struct wil6210_priv *wil) { return 0; }
static inline void wil6210_debugfs_remove(struct wil6210_priv *wil) {}
#endif

int wil_cid_fill_sinfo(struct wil6210_vif *vif, int cid,
		       struct station_info *sinfo);

struct wil6210_priv *wil_cfg80211_init(struct device *dev);
void wil_cfg80211_deinit(struct wil6210_priv *wil);
void wil_p2p_wdev_free(struct wil6210_priv *wil);

int wmi_set_mac_address(struct wil6210_priv *wil, const void *addr);
int wmi_pcp_start(struct wil6210_vif *vif, int bi, u8 wmi_nettype, u8 chan,
		  u8 edmg_chan, u8 hidden_ssid, u8 is_go);
int wmi_pcp_stop(struct wil6210_vif *vif);
int wmi_led_cfg(struct wil6210_priv *wil, bool enable);
int wmi_abort_scan(struct wil6210_vif *vif);
void wil_abort_scan(struct wil6210_vif *vif, bool sync);
void wil_abort_scan_all_vifs(struct wil6210_priv *wil, bool sync);
void wil6210_bus_request(struct wil6210_priv *wil, u32 kbps);
void wil6210_disconnect(struct wil6210_vif *vif, const u8 *bssid,
			u16 reason_code);
void wil6210_disconnect_complete(struct wil6210_vif *vif, const u8 *bssid,
				 u16 reason_code);
void wil_probe_client_flush(struct wil6210_vif *vif);
void wil_probe_client_worker(struct work_struct *work);
void wil_disconnect_worker(struct work_struct *work);
void wil_enable_tx_key_worker(struct work_struct *work);

void wil_init_txrx_ops(struct wil6210_priv *wil);

/* TX API */
int wil_ring_init_tx(struct wil6210_vif *vif, int cid);
int wil_vring_init_bcast(struct wil6210_vif *vif, int id, int size);
int wil_bcast_init(struct wil6210_vif *vif);
void wil_bcast_fini(struct wil6210_vif *vif);
void wil_bcast_fini_all(struct wil6210_priv *wil);

void wil_update_net_queues(struct wil6210_priv *wil, struct wil6210_vif *vif,
			   struct wil_ring *ring, bool should_stop);
void wil_update_net_queues_bh(struct wil6210_priv *wil, struct wil6210_vif *vif,
			      struct wil_ring *ring, bool check_stop);
netdev_tx_t wil_start_xmit(struct sk_buff *skb, struct net_device *ndev);
int wil_tx_complete(struct wil6210_vif *vif, int ringid);
void wil_tx_complete_handle_eapol(struct wil6210_vif *vif,
				  struct sk_buff *skb);
void wil6210_unmask_irq_tx(struct wil6210_priv *wil);
void wil6210_unmask_irq_tx_edma(struct wil6210_priv *wil);

/* RX API */
void wil_rx_handle(struct wil6210_priv *wil, int *quota);
void wil6210_unmask_irq_rx(struct wil6210_priv *wil);
void wil6210_unmask_irq_rx_edma(struct wil6210_priv *wil);
void wil_set_crypto_rx(u8 key_index, enum wmi_key_usage key_usage,
		       struct wil_sta_info *cs,
		       struct key_params *params);

int wil_iftype_nl2wmi(enum nl80211_iftype type);

int wil_request_firmware(struct wil6210_priv *wil, const char *name,
			 bool load);
int wil_request_board(struct wil6210_priv *wil, const char *name);
bool wil_fw_verify_file_exists(struct wil6210_priv *wil, const char *name);

void wil_pm_runtime_allow(struct wil6210_priv *wil);
void wil_pm_runtime_forbid(struct wil6210_priv *wil);
int wil_pm_runtime_get(struct wil6210_priv *wil);
void wil_pm_runtime_put(struct wil6210_priv *wil);

int wil_can_suspend(struct wil6210_priv *wil, bool is_runtime);
int wil_suspend(struct wil6210_priv *wil, bool is_runtime, bool keep_radio_on);
int wil_resume(struct wil6210_priv *wil, bool is_runtime, bool keep_radio_on);
bool wil_is_wmi_idle(struct wil6210_priv *wil);
int wmi_resume(struct wil6210_priv *wil);
int wmi_suspend(struct wil6210_priv *wil);
bool wil_is_tx_idle(struct wil6210_priv *wil);

int wil_fw_copy_crash_dump(struct wil6210_priv *wil, void *dest, u32 size);
void wil_fw_core_dump(struct wil6210_priv *wil);

void wil_halp_vote(struct wil6210_priv *wil);
void wil_halp_unvote(struct wil6210_priv *wil);
void wil6210_set_halp(struct wil6210_priv *wil);
void wil6210_clear_halp(struct wil6210_priv *wil);

int wmi_start_sched_scan(struct wil6210_priv *wil,
			 struct cfg80211_sched_scan_request *request);
int wmi_stop_sched_scan(struct wil6210_priv *wil);
int wmi_mgmt_tx(struct wil6210_vif *vif, const u8 *buf, size_t len);
int wmi_mgmt_tx_ext(struct wil6210_vif *vif, const u8 *buf, size_t len,
		    u8 channel, u16 duration_ms);
int wmi_rbufcap_cfg(struct wil6210_priv *wil, bool enable, u16 threshold);

int wil_wmi2spec_ch(u8 wmi_ch, u8 *spec_ch);
int wil_spec2wmi_ch(u8 spec_ch, u8 *wmi_ch);
void wil_update_supported_bands(struct wil6210_priv *wil);

int reverse_memcmp(const void *cs, const void *ct, size_t count);

/* WMI for enhanced DMA */
int wil_wmi_tx_sring_cfg(struct wil6210_priv *wil, int ring_id);
int wil_wmi_cfg_def_rx_offload(struct wil6210_priv *wil,
			       u16 max_rx_pl_per_desc);
int wil_wmi_rx_sring_add(struct wil6210_priv *wil, u16 ring_id);
int wil_wmi_rx_desc_ring_add(struct wil6210_priv *wil, int status_ring_id);
int wil_wmi_tx_desc_ring_add(struct wil6210_vif *vif, int ring_id, int cid,
			     int tid);
int wil_wmi_bcast_desc_ring_add(struct wil6210_vif *vif, int ring_id);
int wmi_addba_rx_resp_edma(struct wil6210_priv *wil, u8 mid, u8 cid,
			   u8 tid, u8 token, u16 status, bool amsdu,
			   u16 agg_wsize, u16 timeout);

void update_supported_bands(struct wil6210_priv *wil);

void wil_clear_fw_log_addr(struct wil6210_priv *wil);
int wmi_set_cqm_rssi_config(struct wil6210_priv *wil,
			    s32 rssi_thold, u32 rssi_hyst);
#endif /* __WIL6210_H__ */