18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/****************************************************************************
38c2ecf20Sopenharmony_ci * Driver for Solarflare network controllers and boards
48c2ecf20Sopenharmony_ci * Copyright 2005-2006 Fen Systems Ltd.
58c2ecf20Sopenharmony_ci * Copyright 2005-2013 Solarflare Communications Inc.
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci/* Common definitions for all Efx net driver code */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef EFX_NET_DRIVER_H
118c2ecf20Sopenharmony_ci#define EFX_NET_DRIVER_H
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <linux/netdevice.h>
148c2ecf20Sopenharmony_ci#include <linux/etherdevice.h>
158c2ecf20Sopenharmony_ci#include <linux/ethtool.h>
168c2ecf20Sopenharmony_ci#include <linux/if_vlan.h>
178c2ecf20Sopenharmony_ci#include <linux/timer.h>
188c2ecf20Sopenharmony_ci#include <linux/mdio.h>
198c2ecf20Sopenharmony_ci#include <linux/list.h>
208c2ecf20Sopenharmony_ci#include <linux/pci.h>
218c2ecf20Sopenharmony_ci#include <linux/device.h>
228c2ecf20Sopenharmony_ci#include <linux/highmem.h>
238c2ecf20Sopenharmony_ci#include <linux/workqueue.h>
248c2ecf20Sopenharmony_ci#include <linux/mutex.h>
258c2ecf20Sopenharmony_ci#include <linux/rwsem.h>
268c2ecf20Sopenharmony_ci#include <linux/vmalloc.h>
278c2ecf20Sopenharmony_ci#include <linux/mtd/mtd.h>
288c2ecf20Sopenharmony_ci#include <net/busy_poll.h>
298c2ecf20Sopenharmony_ci#include <net/xdp.h>
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#include "enum.h"
328c2ecf20Sopenharmony_ci#include "bitfield.h"
338c2ecf20Sopenharmony_ci#include "filter.h"
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci/**************************************************************************
368c2ecf20Sopenharmony_ci *
378c2ecf20Sopenharmony_ci * Build definitions
388c2ecf20Sopenharmony_ci *
398c2ecf20Sopenharmony_ci **************************************************************************/
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#ifdef DEBUG
428c2ecf20Sopenharmony_ci#define EFX_WARN_ON_ONCE_PARANOID(x) WARN_ON_ONCE(x)
438c2ecf20Sopenharmony_ci#define EFX_WARN_ON_PARANOID(x) WARN_ON(x)
448c2ecf20Sopenharmony_ci#else
458c2ecf20Sopenharmony_ci#define EFX_WARN_ON_ONCE_PARANOID(x) do {} while (0)
468c2ecf20Sopenharmony_ci#define EFX_WARN_ON_PARANOID(x) do {} while (0)
478c2ecf20Sopenharmony_ci#endif
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci/**************************************************************************
508c2ecf20Sopenharmony_ci *
518c2ecf20Sopenharmony_ci * Efx data structures
528c2ecf20Sopenharmony_ci *
538c2ecf20Sopenharmony_ci **************************************************************************/
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci#define EFX_MAX_CHANNELS 32U
568c2ecf20Sopenharmony_ci#define EFX_MAX_RX_QUEUES EFX_MAX_CHANNELS
578c2ecf20Sopenharmony_ci#define EFX_EXTRA_CHANNEL_IOV	0
588c2ecf20Sopenharmony_ci#define EFX_EXTRA_CHANNEL_PTP	1
598c2ecf20Sopenharmony_ci#define EFX_MAX_EXTRA_CHANNELS	2U
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/* Checksum generation is a per-queue option in hardware, so each
628c2ecf20Sopenharmony_ci * queue visible to the networking core is backed by two hardware TX
638c2ecf20Sopenharmony_ci * queues. */
648c2ecf20Sopenharmony_ci#define EFX_MAX_TX_TC		2
658c2ecf20Sopenharmony_ci#define EFX_MAX_CORE_TX_QUEUES	(EFX_MAX_TX_TC * EFX_MAX_CHANNELS)
668c2ecf20Sopenharmony_ci#define EFX_TXQ_TYPE_OUTER_CSUM	1	/* Outer checksum offload */
678c2ecf20Sopenharmony_ci#define EFX_TXQ_TYPE_INNER_CSUM	2	/* Inner checksum offload */
688c2ecf20Sopenharmony_ci#define EFX_TXQ_TYPE_HIGHPRI	4	/* High-priority (for TC) */
698c2ecf20Sopenharmony_ci#define EFX_TXQ_TYPES		8
708c2ecf20Sopenharmony_ci/* HIGHPRI is Siena-only, and INNER_CSUM is EF10, so no need for both */
718c2ecf20Sopenharmony_ci#define EFX_MAX_TXQ_PER_CHANNEL	4
728c2ecf20Sopenharmony_ci#define EFX_MAX_TX_QUEUES	(EFX_MAX_TXQ_PER_CHANNEL * EFX_MAX_CHANNELS)
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci/* Maximum possible MTU the driver supports */
758c2ecf20Sopenharmony_ci#define EFX_MAX_MTU (9 * 1024)
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/* Minimum MTU, from RFC791 (IP) */
788c2ecf20Sopenharmony_ci#define EFX_MIN_MTU 68
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci/* Maximum total header length for TSOv2 */
818c2ecf20Sopenharmony_ci#define EFX_TSO2_MAX_HDRLEN	208
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci/* Size of an RX scatter buffer.  Small enough to pack 2 into a 4K page,
848c2ecf20Sopenharmony_ci * and should be a multiple of the cache line size.
858c2ecf20Sopenharmony_ci */
868c2ecf20Sopenharmony_ci#define EFX_RX_USR_BUF_SIZE	(2048 - 256)
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci/* If possible, we should ensure cache line alignment at start and end
898c2ecf20Sopenharmony_ci * of every buffer.  Otherwise, we just need to ensure 4-byte
908c2ecf20Sopenharmony_ci * alignment of the network header.
918c2ecf20Sopenharmony_ci */
928c2ecf20Sopenharmony_ci#if NET_IP_ALIGN == 0
938c2ecf20Sopenharmony_ci#define EFX_RX_BUF_ALIGNMENT	L1_CACHE_BYTES
948c2ecf20Sopenharmony_ci#else
958c2ecf20Sopenharmony_ci#define EFX_RX_BUF_ALIGNMENT	4
968c2ecf20Sopenharmony_ci#endif
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci/* Non-standard XDP_PACKET_HEADROOM and tailroom to satisfy XDP_REDIRECT and
998c2ecf20Sopenharmony_ci * still fit two standard MTU size packets into a single 4K page.
1008c2ecf20Sopenharmony_ci */
1018c2ecf20Sopenharmony_ci#define EFX_XDP_HEADROOM	128
1028c2ecf20Sopenharmony_ci#define EFX_XDP_TAILROOM	SKB_DATA_ALIGN(sizeof(struct skb_shared_info))
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci/* Forward declare Precision Time Protocol (PTP) support structure. */
1058c2ecf20Sopenharmony_cistruct efx_ptp_data;
1068c2ecf20Sopenharmony_cistruct hwtstamp_config;
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_cistruct efx_self_tests;
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci/**
1118c2ecf20Sopenharmony_ci * struct efx_buffer - A general-purpose DMA buffer
1128c2ecf20Sopenharmony_ci * @addr: host base address of the buffer
1138c2ecf20Sopenharmony_ci * @dma_addr: DMA base address of the buffer
1148c2ecf20Sopenharmony_ci * @len: Buffer length, in bytes
1158c2ecf20Sopenharmony_ci *
1168c2ecf20Sopenharmony_ci * The NIC uses these buffers for its interrupt status registers and
1178c2ecf20Sopenharmony_ci * MAC stats dumps.
1188c2ecf20Sopenharmony_ci */
1198c2ecf20Sopenharmony_cistruct efx_buffer {
1208c2ecf20Sopenharmony_ci	void *addr;
1218c2ecf20Sopenharmony_ci	dma_addr_t dma_addr;
1228c2ecf20Sopenharmony_ci	unsigned int len;
1238c2ecf20Sopenharmony_ci};
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci/**
1268c2ecf20Sopenharmony_ci * struct efx_special_buffer - DMA buffer entered into buffer table
1278c2ecf20Sopenharmony_ci * @buf: Standard &struct efx_buffer
1288c2ecf20Sopenharmony_ci * @index: Buffer index within controller;s buffer table
1298c2ecf20Sopenharmony_ci * @entries: Number of buffer table entries
1308c2ecf20Sopenharmony_ci *
1318c2ecf20Sopenharmony_ci * The NIC has a buffer table that maps buffers of size %EFX_BUF_SIZE.
1328c2ecf20Sopenharmony_ci * Event and descriptor rings are addressed via one or more buffer
1338c2ecf20Sopenharmony_ci * table entries (and so can be physically non-contiguous, although we
1348c2ecf20Sopenharmony_ci * currently do not take advantage of that).  On Falcon and Siena we
1358c2ecf20Sopenharmony_ci * have to take care of allocating and initialising the entries
1368c2ecf20Sopenharmony_ci * ourselves.  On later hardware this is managed by the firmware and
1378c2ecf20Sopenharmony_ci * @index and @entries are left as 0.
1388c2ecf20Sopenharmony_ci */
1398c2ecf20Sopenharmony_cistruct efx_special_buffer {
1408c2ecf20Sopenharmony_ci	struct efx_buffer buf;
1418c2ecf20Sopenharmony_ci	unsigned int index;
1428c2ecf20Sopenharmony_ci	unsigned int entries;
1438c2ecf20Sopenharmony_ci};
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci/**
1468c2ecf20Sopenharmony_ci * struct efx_tx_buffer - buffer state for a TX descriptor
1478c2ecf20Sopenharmony_ci * @skb: When @flags & %EFX_TX_BUF_SKB, the associated socket buffer to be
1488c2ecf20Sopenharmony_ci *	freed when descriptor completes
1498c2ecf20Sopenharmony_ci * @xdpf: When @flags & %EFX_TX_BUF_XDP, the XDP frame information; its @data
1508c2ecf20Sopenharmony_ci *	member is the associated buffer to drop a page reference on.
1518c2ecf20Sopenharmony_ci * @option: When @flags & %EFX_TX_BUF_OPTION, an EF10-specific option
1528c2ecf20Sopenharmony_ci *	descriptor.
1538c2ecf20Sopenharmony_ci * @dma_addr: DMA address of the fragment.
1548c2ecf20Sopenharmony_ci * @flags: Flags for allocation and DMA mapping type
1558c2ecf20Sopenharmony_ci * @len: Length of this fragment.
1568c2ecf20Sopenharmony_ci *	This field is zero when the queue slot is empty.
1578c2ecf20Sopenharmony_ci * @unmap_len: Length of this fragment to unmap
1588c2ecf20Sopenharmony_ci * @dma_offset: Offset of @dma_addr from the address of the backing DMA mapping.
1598c2ecf20Sopenharmony_ci * Only valid if @unmap_len != 0.
1608c2ecf20Sopenharmony_ci */
1618c2ecf20Sopenharmony_cistruct efx_tx_buffer {
1628c2ecf20Sopenharmony_ci	union {
1638c2ecf20Sopenharmony_ci		const struct sk_buff *skb;
1648c2ecf20Sopenharmony_ci		struct xdp_frame *xdpf;
1658c2ecf20Sopenharmony_ci	};
1668c2ecf20Sopenharmony_ci	union {
1678c2ecf20Sopenharmony_ci		efx_qword_t option;    /* EF10 */
1688c2ecf20Sopenharmony_ci		dma_addr_t dma_addr;
1698c2ecf20Sopenharmony_ci	};
1708c2ecf20Sopenharmony_ci	unsigned short flags;
1718c2ecf20Sopenharmony_ci	unsigned short len;
1728c2ecf20Sopenharmony_ci	unsigned short unmap_len;
1738c2ecf20Sopenharmony_ci	unsigned short dma_offset;
1748c2ecf20Sopenharmony_ci};
1758c2ecf20Sopenharmony_ci#define EFX_TX_BUF_CONT		1	/* not last descriptor of packet */
1768c2ecf20Sopenharmony_ci#define EFX_TX_BUF_SKB		2	/* buffer is last part of skb */
1778c2ecf20Sopenharmony_ci#define EFX_TX_BUF_MAP_SINGLE	8	/* buffer was mapped with dma_map_single() */
1788c2ecf20Sopenharmony_ci#define EFX_TX_BUF_OPTION	0x10	/* empty buffer for option descriptor */
1798c2ecf20Sopenharmony_ci#define EFX_TX_BUF_XDP		0x20	/* buffer was sent with XDP */
1808c2ecf20Sopenharmony_ci#define EFX_TX_BUF_TSO_V3	0x40	/* empty buffer for a TSO_V3 descriptor */
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci/**
1838c2ecf20Sopenharmony_ci * struct efx_tx_queue - An Efx TX queue
1848c2ecf20Sopenharmony_ci *
1858c2ecf20Sopenharmony_ci * This is a ring buffer of TX fragments.
1868c2ecf20Sopenharmony_ci * Since the TX completion path always executes on the same
1878c2ecf20Sopenharmony_ci * CPU and the xmit path can operate on different CPUs,
1888c2ecf20Sopenharmony_ci * performance is increased by ensuring that the completion
1898c2ecf20Sopenharmony_ci * path and the xmit path operate on different cache lines.
1908c2ecf20Sopenharmony_ci * This is particularly important if the xmit path is always
1918c2ecf20Sopenharmony_ci * executing on one CPU which is different from the completion
1928c2ecf20Sopenharmony_ci * path.  There is also a cache line for members which are
1938c2ecf20Sopenharmony_ci * read but not written on the fast path.
1948c2ecf20Sopenharmony_ci *
1958c2ecf20Sopenharmony_ci * @efx: The associated Efx NIC
1968c2ecf20Sopenharmony_ci * @queue: DMA queue number
1978c2ecf20Sopenharmony_ci * @label: Label for TX completion events.
1988c2ecf20Sopenharmony_ci *	Is our index within @channel->tx_queue array.
1998c2ecf20Sopenharmony_ci * @type: configuration type of this TX queue.  A bitmask of %EFX_TXQ_TYPE_* flags.
2008c2ecf20Sopenharmony_ci * @tso_version: Version of TSO in use for this queue.
2018c2ecf20Sopenharmony_ci * @tso_encap: Is encapsulated TSO supported? Supported in TSOv2 on 8000 series.
2028c2ecf20Sopenharmony_ci * @channel: The associated channel
2038c2ecf20Sopenharmony_ci * @core_txq: The networking core TX queue structure
2048c2ecf20Sopenharmony_ci * @buffer: The software buffer ring
2058c2ecf20Sopenharmony_ci * @cb_page: Array of pages of copy buffers.  Carved up according to
2068c2ecf20Sopenharmony_ci *	%EFX_TX_CB_ORDER into %EFX_TX_CB_SIZE-sized chunks.
2078c2ecf20Sopenharmony_ci * @txd: The hardware descriptor ring
2088c2ecf20Sopenharmony_ci * @ptr_mask: The size of the ring minus 1.
2098c2ecf20Sopenharmony_ci * @piobuf: PIO buffer region for this TX queue (shared with its partner).
2108c2ecf20Sopenharmony_ci *	Size of the region is efx_piobuf_size.
2118c2ecf20Sopenharmony_ci * @piobuf_offset: Buffer offset to be specified in PIO descriptors
2128c2ecf20Sopenharmony_ci * @initialised: Has hardware queue been initialised?
2138c2ecf20Sopenharmony_ci * @timestamping: Is timestamping enabled for this channel?
2148c2ecf20Sopenharmony_ci * @xdp_tx: Is this an XDP tx queue?
2158c2ecf20Sopenharmony_ci * @read_count: Current read pointer.
2168c2ecf20Sopenharmony_ci *	This is the number of buffers that have been removed from both rings.
2178c2ecf20Sopenharmony_ci * @old_write_count: The value of @write_count when last checked.
2188c2ecf20Sopenharmony_ci *	This is here for performance reasons.  The xmit path will
2198c2ecf20Sopenharmony_ci *	only get the up-to-date value of @write_count if this
2208c2ecf20Sopenharmony_ci *	variable indicates that the queue is empty.  This is to
2218c2ecf20Sopenharmony_ci *	avoid cache-line ping-pong between the xmit path and the
2228c2ecf20Sopenharmony_ci *	completion path.
2238c2ecf20Sopenharmony_ci * @merge_events: Number of TX merged completion events
2248c2ecf20Sopenharmony_ci * @completed_timestamp_major: Top part of the most recent tx timestamp.
2258c2ecf20Sopenharmony_ci * @completed_timestamp_minor: Low part of the most recent tx timestamp.
2268c2ecf20Sopenharmony_ci * @insert_count: Current insert pointer
2278c2ecf20Sopenharmony_ci *	This is the number of buffers that have been added to the
2288c2ecf20Sopenharmony_ci *	software ring.
2298c2ecf20Sopenharmony_ci * @write_count: Current write pointer
2308c2ecf20Sopenharmony_ci *	This is the number of buffers that have been added to the
2318c2ecf20Sopenharmony_ci *	hardware ring.
2328c2ecf20Sopenharmony_ci * @packet_write_count: Completable write pointer
2338c2ecf20Sopenharmony_ci *	This is the write pointer of the last packet written.
2348c2ecf20Sopenharmony_ci *	Normally this will equal @write_count, but as option descriptors
2358c2ecf20Sopenharmony_ci *	don't produce completion events, they won't update this.
2368c2ecf20Sopenharmony_ci *	Filled in iff @efx->type->option_descriptors; only used for PIO.
2378c2ecf20Sopenharmony_ci *	Thus, this is written and used on EF10, and neither on farch.
2388c2ecf20Sopenharmony_ci * @old_read_count: The value of read_count when last checked.
2398c2ecf20Sopenharmony_ci *	This is here for performance reasons.  The xmit path will
2408c2ecf20Sopenharmony_ci *	only get the up-to-date value of read_count if this
2418c2ecf20Sopenharmony_ci *	variable indicates that the queue is full.  This is to
2428c2ecf20Sopenharmony_ci *	avoid cache-line ping-pong between the xmit path and the
2438c2ecf20Sopenharmony_ci *	completion path.
2448c2ecf20Sopenharmony_ci * @tso_bursts: Number of times TSO xmit invoked by kernel
2458c2ecf20Sopenharmony_ci * @tso_long_headers: Number of packets with headers too long for standard
2468c2ecf20Sopenharmony_ci *	blocks
2478c2ecf20Sopenharmony_ci * @tso_packets: Number of packets via the TSO xmit path
2488c2ecf20Sopenharmony_ci * @tso_fallbacks: Number of times TSO fallback used
2498c2ecf20Sopenharmony_ci * @pushes: Number of times the TX push feature has been used
2508c2ecf20Sopenharmony_ci * @pio_packets: Number of times the TX PIO feature has been used
2518c2ecf20Sopenharmony_ci * @xmit_pending: Are any packets waiting to be pushed to the NIC
2528c2ecf20Sopenharmony_ci * @cb_packets: Number of times the TX copybreak feature has been used
2538c2ecf20Sopenharmony_ci * @notify_count: Count of notified descriptors to the NIC
2548c2ecf20Sopenharmony_ci * @empty_read_count: If the completion path has seen the queue as empty
2558c2ecf20Sopenharmony_ci *	and the transmission path has not yet checked this, the value of
2568c2ecf20Sopenharmony_ci *	@read_count bitwise-added to %EFX_EMPTY_COUNT_VALID; otherwise 0.
2578c2ecf20Sopenharmony_ci */
2588c2ecf20Sopenharmony_cistruct efx_tx_queue {
2598c2ecf20Sopenharmony_ci	/* Members which don't change on the fast path */
2608c2ecf20Sopenharmony_ci	struct efx_nic *efx ____cacheline_aligned_in_smp;
2618c2ecf20Sopenharmony_ci	unsigned int queue;
2628c2ecf20Sopenharmony_ci	unsigned int label;
2638c2ecf20Sopenharmony_ci	unsigned int type;
2648c2ecf20Sopenharmony_ci	unsigned int tso_version;
2658c2ecf20Sopenharmony_ci	bool tso_encap;
2668c2ecf20Sopenharmony_ci	struct efx_channel *channel;
2678c2ecf20Sopenharmony_ci	struct netdev_queue *core_txq;
2688c2ecf20Sopenharmony_ci	struct efx_tx_buffer *buffer;
2698c2ecf20Sopenharmony_ci	struct efx_buffer *cb_page;
2708c2ecf20Sopenharmony_ci	struct efx_special_buffer txd;
2718c2ecf20Sopenharmony_ci	unsigned int ptr_mask;
2728c2ecf20Sopenharmony_ci	void __iomem *piobuf;
2738c2ecf20Sopenharmony_ci	unsigned int piobuf_offset;
2748c2ecf20Sopenharmony_ci	bool initialised;
2758c2ecf20Sopenharmony_ci	bool timestamping;
2768c2ecf20Sopenharmony_ci	bool xdp_tx;
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci	/* Members used mainly on the completion path */
2798c2ecf20Sopenharmony_ci	unsigned int read_count ____cacheline_aligned_in_smp;
2808c2ecf20Sopenharmony_ci	unsigned int old_write_count;
2818c2ecf20Sopenharmony_ci	unsigned int merge_events;
2828c2ecf20Sopenharmony_ci	unsigned int bytes_compl;
2838c2ecf20Sopenharmony_ci	unsigned int pkts_compl;
2848c2ecf20Sopenharmony_ci	u32 completed_timestamp_major;
2858c2ecf20Sopenharmony_ci	u32 completed_timestamp_minor;
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci	/* Members used only on the xmit path */
2888c2ecf20Sopenharmony_ci	unsigned int insert_count ____cacheline_aligned_in_smp;
2898c2ecf20Sopenharmony_ci	unsigned int write_count;
2908c2ecf20Sopenharmony_ci	unsigned int packet_write_count;
2918c2ecf20Sopenharmony_ci	unsigned int old_read_count;
2928c2ecf20Sopenharmony_ci	unsigned int tso_bursts;
2938c2ecf20Sopenharmony_ci	unsigned int tso_long_headers;
2948c2ecf20Sopenharmony_ci	unsigned int tso_packets;
2958c2ecf20Sopenharmony_ci	unsigned int tso_fallbacks;
2968c2ecf20Sopenharmony_ci	unsigned int pushes;
2978c2ecf20Sopenharmony_ci	unsigned int pio_packets;
2988c2ecf20Sopenharmony_ci	bool xmit_pending;
2998c2ecf20Sopenharmony_ci	unsigned int cb_packets;
3008c2ecf20Sopenharmony_ci	unsigned int notify_count;
3018c2ecf20Sopenharmony_ci	/* Statistics to supplement MAC stats */
3028c2ecf20Sopenharmony_ci	unsigned long tx_packets;
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ci	/* Members shared between paths and sometimes updated */
3058c2ecf20Sopenharmony_ci	unsigned int empty_read_count ____cacheline_aligned_in_smp;
3068c2ecf20Sopenharmony_ci#define EFX_EMPTY_COUNT_VALID 0x80000000
3078c2ecf20Sopenharmony_ci	atomic_t flush_outstanding;
3088c2ecf20Sopenharmony_ci};
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci#define EFX_TX_CB_ORDER	7
3118c2ecf20Sopenharmony_ci#define EFX_TX_CB_SIZE	(1 << EFX_TX_CB_ORDER) - NET_IP_ALIGN
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci/**
3148c2ecf20Sopenharmony_ci * struct efx_rx_buffer - An Efx RX data buffer
3158c2ecf20Sopenharmony_ci * @dma_addr: DMA base address of the buffer
3168c2ecf20Sopenharmony_ci * @page: The associated page buffer.
3178c2ecf20Sopenharmony_ci *	Will be %NULL if the buffer slot is currently free.
3188c2ecf20Sopenharmony_ci * @page_offset: If pending: offset in @page of DMA base address.
3198c2ecf20Sopenharmony_ci *	If completed: offset in @page of Ethernet header.
3208c2ecf20Sopenharmony_ci * @len: If pending: length for DMA descriptor.
3218c2ecf20Sopenharmony_ci *	If completed: received length, excluding hash prefix.
3228c2ecf20Sopenharmony_ci * @flags: Flags for buffer and packet state.  These are only set on the
3238c2ecf20Sopenharmony_ci *	first buffer of a scattered packet.
3248c2ecf20Sopenharmony_ci */
3258c2ecf20Sopenharmony_cistruct efx_rx_buffer {
3268c2ecf20Sopenharmony_ci	dma_addr_t dma_addr;
3278c2ecf20Sopenharmony_ci	struct page *page;
3288c2ecf20Sopenharmony_ci	u16 page_offset;
3298c2ecf20Sopenharmony_ci	u16 len;
3308c2ecf20Sopenharmony_ci	u16 flags;
3318c2ecf20Sopenharmony_ci};
3328c2ecf20Sopenharmony_ci#define EFX_RX_BUF_LAST_IN_PAGE	0x0001
3338c2ecf20Sopenharmony_ci#define EFX_RX_PKT_CSUMMED	0x0002
3348c2ecf20Sopenharmony_ci#define EFX_RX_PKT_DISCARD	0x0004
3358c2ecf20Sopenharmony_ci#define EFX_RX_PKT_TCP		0x0040
3368c2ecf20Sopenharmony_ci#define EFX_RX_PKT_PREFIX_LEN	0x0080	/* length is in prefix only */
3378c2ecf20Sopenharmony_ci#define EFX_RX_PKT_CSUM_LEVEL	0x0200
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci/**
3408c2ecf20Sopenharmony_ci * struct efx_rx_page_state - Page-based rx buffer state
3418c2ecf20Sopenharmony_ci *
3428c2ecf20Sopenharmony_ci * Inserted at the start of every page allocated for receive buffers.
3438c2ecf20Sopenharmony_ci * Used to facilitate sharing dma mappings between recycled rx buffers
3448c2ecf20Sopenharmony_ci * and those passed up to the kernel.
3458c2ecf20Sopenharmony_ci *
3468c2ecf20Sopenharmony_ci * @dma_addr: The dma address of this page.
3478c2ecf20Sopenharmony_ci */
3488c2ecf20Sopenharmony_cistruct efx_rx_page_state {
3498c2ecf20Sopenharmony_ci	dma_addr_t dma_addr;
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci	unsigned int __pad[] ____cacheline_aligned;
3528c2ecf20Sopenharmony_ci};
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_ci/**
3558c2ecf20Sopenharmony_ci * struct efx_rx_queue - An Efx RX queue
3568c2ecf20Sopenharmony_ci * @efx: The associated Efx NIC
3578c2ecf20Sopenharmony_ci * @core_index:  Index of network core RX queue.  Will be >= 0 iff this
3588c2ecf20Sopenharmony_ci *	is associated with a real RX queue.
3598c2ecf20Sopenharmony_ci * @buffer: The software buffer ring
3608c2ecf20Sopenharmony_ci * @rxd: The hardware descriptor ring
3618c2ecf20Sopenharmony_ci * @ptr_mask: The size of the ring minus 1.
3628c2ecf20Sopenharmony_ci * @refill_enabled: Enable refill whenever fill level is low
3638c2ecf20Sopenharmony_ci * @flush_pending: Set when a RX flush is pending. Has the same lifetime as
3648c2ecf20Sopenharmony_ci *	@rxq_flush_pending.
3658c2ecf20Sopenharmony_ci * @added_count: Number of buffers added to the receive queue.
3668c2ecf20Sopenharmony_ci * @notified_count: Number of buffers given to NIC (<= @added_count).
3678c2ecf20Sopenharmony_ci * @removed_count: Number of buffers removed from the receive queue.
3688c2ecf20Sopenharmony_ci * @scatter_n: Used by NIC specific receive code.
3698c2ecf20Sopenharmony_ci * @scatter_len: Used by NIC specific receive code.
3708c2ecf20Sopenharmony_ci * @page_ring: The ring to store DMA mapped pages for reuse.
3718c2ecf20Sopenharmony_ci * @page_add: Counter to calculate the write pointer for the recycle ring.
3728c2ecf20Sopenharmony_ci * @page_remove: Counter to calculate the read pointer for the recycle ring.
3738c2ecf20Sopenharmony_ci * @page_recycle_count: The number of pages that have been recycled.
3748c2ecf20Sopenharmony_ci * @page_recycle_failed: The number of pages that couldn't be recycled because
3758c2ecf20Sopenharmony_ci *      the kernel still held a reference to them.
3768c2ecf20Sopenharmony_ci * @page_recycle_full: The number of pages that were released because the
3778c2ecf20Sopenharmony_ci *      recycle ring was full.
3788c2ecf20Sopenharmony_ci * @page_ptr_mask: The number of pages in the RX recycle ring minus 1.
3798c2ecf20Sopenharmony_ci * @max_fill: RX descriptor maximum fill level (<= ring size)
3808c2ecf20Sopenharmony_ci * @fast_fill_trigger: RX descriptor fill level that will trigger a fast fill
3818c2ecf20Sopenharmony_ci *	(<= @max_fill)
3828c2ecf20Sopenharmony_ci * @min_fill: RX descriptor minimum non-zero fill level.
3838c2ecf20Sopenharmony_ci *	This records the minimum fill level observed when a ring
3848c2ecf20Sopenharmony_ci *	refill was triggered.
3858c2ecf20Sopenharmony_ci * @recycle_count: RX buffer recycle counter.
3868c2ecf20Sopenharmony_ci * @slow_fill: Timer used to defer efx_nic_generate_fill_event().
3878c2ecf20Sopenharmony_ci * @xdp_rxq_info: XDP specific RX queue information.
3888c2ecf20Sopenharmony_ci * @xdp_rxq_info_valid: Is xdp_rxq_info valid data?.
3898c2ecf20Sopenharmony_ci */
3908c2ecf20Sopenharmony_cistruct efx_rx_queue {
3918c2ecf20Sopenharmony_ci	struct efx_nic *efx;
3928c2ecf20Sopenharmony_ci	int core_index;
3938c2ecf20Sopenharmony_ci	struct efx_rx_buffer *buffer;
3948c2ecf20Sopenharmony_ci	struct efx_special_buffer rxd;
3958c2ecf20Sopenharmony_ci	unsigned int ptr_mask;
3968c2ecf20Sopenharmony_ci	bool refill_enabled;
3978c2ecf20Sopenharmony_ci	bool flush_pending;
3988c2ecf20Sopenharmony_ci
3998c2ecf20Sopenharmony_ci	unsigned int added_count;
4008c2ecf20Sopenharmony_ci	unsigned int notified_count;
4018c2ecf20Sopenharmony_ci	unsigned int removed_count;
4028c2ecf20Sopenharmony_ci	unsigned int scatter_n;
4038c2ecf20Sopenharmony_ci	unsigned int scatter_len;
4048c2ecf20Sopenharmony_ci	struct page **page_ring;
4058c2ecf20Sopenharmony_ci	unsigned int page_add;
4068c2ecf20Sopenharmony_ci	unsigned int page_remove;
4078c2ecf20Sopenharmony_ci	unsigned int page_recycle_count;
4088c2ecf20Sopenharmony_ci	unsigned int page_recycle_failed;
4098c2ecf20Sopenharmony_ci	unsigned int page_recycle_full;
4108c2ecf20Sopenharmony_ci	unsigned int page_ptr_mask;
4118c2ecf20Sopenharmony_ci	unsigned int max_fill;
4128c2ecf20Sopenharmony_ci	unsigned int fast_fill_trigger;
4138c2ecf20Sopenharmony_ci	unsigned int min_fill;
4148c2ecf20Sopenharmony_ci	unsigned int min_overfill;
4158c2ecf20Sopenharmony_ci	unsigned int recycle_count;
4168c2ecf20Sopenharmony_ci	struct timer_list slow_fill;
4178c2ecf20Sopenharmony_ci	unsigned int slow_fill_count;
4188c2ecf20Sopenharmony_ci	/* Statistics to supplement MAC stats */
4198c2ecf20Sopenharmony_ci	unsigned long rx_packets;
4208c2ecf20Sopenharmony_ci	struct xdp_rxq_info xdp_rxq_info;
4218c2ecf20Sopenharmony_ci	bool xdp_rxq_info_valid;
4228c2ecf20Sopenharmony_ci};
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_cienum efx_sync_events_state {
4258c2ecf20Sopenharmony_ci	SYNC_EVENTS_DISABLED = 0,
4268c2ecf20Sopenharmony_ci	SYNC_EVENTS_QUIESCENT,
4278c2ecf20Sopenharmony_ci	SYNC_EVENTS_REQUESTED,
4288c2ecf20Sopenharmony_ci	SYNC_EVENTS_VALID,
4298c2ecf20Sopenharmony_ci};
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ci/**
4328c2ecf20Sopenharmony_ci * struct efx_channel - An Efx channel
4338c2ecf20Sopenharmony_ci *
4348c2ecf20Sopenharmony_ci * A channel comprises an event queue, at least one TX queue, at least
4358c2ecf20Sopenharmony_ci * one RX queue, and an associated tasklet for processing the event
4368c2ecf20Sopenharmony_ci * queue.
4378c2ecf20Sopenharmony_ci *
4388c2ecf20Sopenharmony_ci * @efx: Associated Efx NIC
4398c2ecf20Sopenharmony_ci * @channel: Channel instance number
4408c2ecf20Sopenharmony_ci * @type: Channel type definition
4418c2ecf20Sopenharmony_ci * @eventq_init: Event queue initialised flag
4428c2ecf20Sopenharmony_ci * @enabled: Channel enabled indicator
4438c2ecf20Sopenharmony_ci * @irq: IRQ number (MSI and MSI-X only)
4448c2ecf20Sopenharmony_ci * @irq_moderation_us: IRQ moderation value (in microseconds)
4458c2ecf20Sopenharmony_ci * @napi_dev: Net device used with NAPI
4468c2ecf20Sopenharmony_ci * @napi_str: NAPI control structure
4478c2ecf20Sopenharmony_ci * @state: state for NAPI vs busy polling
4488c2ecf20Sopenharmony_ci * @state_lock: lock protecting @state
4498c2ecf20Sopenharmony_ci * @eventq: Event queue buffer
4508c2ecf20Sopenharmony_ci * @eventq_mask: Event queue pointer mask
4518c2ecf20Sopenharmony_ci * @eventq_read_ptr: Event queue read pointer
4528c2ecf20Sopenharmony_ci * @event_test_cpu: Last CPU to handle interrupt or test event for this channel
4538c2ecf20Sopenharmony_ci * @irq_count: Number of IRQs since last adaptive moderation decision
4548c2ecf20Sopenharmony_ci * @irq_mod_score: IRQ moderation score
4558c2ecf20Sopenharmony_ci * @rfs_filter_count: number of accelerated RFS filters currently in place;
4568c2ecf20Sopenharmony_ci *	equals the count of @rps_flow_id slots filled
4578c2ecf20Sopenharmony_ci * @rfs_last_expiry: value of jiffies last time some accelerated RFS filters
4588c2ecf20Sopenharmony_ci *	were checked for expiry
4598c2ecf20Sopenharmony_ci * @rfs_expire_index: next accelerated RFS filter ID to check for expiry
4608c2ecf20Sopenharmony_ci * @n_rfs_succeeded: number of successful accelerated RFS filter insertions
4618c2ecf20Sopenharmony_ci * @n_rfs_failed: number of failed accelerated RFS filter insertions
4628c2ecf20Sopenharmony_ci * @filter_work: Work item for efx_filter_rfs_expire()
4638c2ecf20Sopenharmony_ci * @rps_flow_id: Flow IDs of filters allocated for accelerated RFS,
4648c2ecf20Sopenharmony_ci *      indexed by filter ID
4658c2ecf20Sopenharmony_ci * @n_rx_tobe_disc: Count of RX_TOBE_DISC errors
4668c2ecf20Sopenharmony_ci * @n_rx_ip_hdr_chksum_err: Count of RX IP header checksum errors
4678c2ecf20Sopenharmony_ci * @n_rx_tcp_udp_chksum_err: Count of RX TCP and UDP checksum errors
4688c2ecf20Sopenharmony_ci * @n_rx_mcast_mismatch: Count of unmatched multicast frames
4698c2ecf20Sopenharmony_ci * @n_rx_frm_trunc: Count of RX_FRM_TRUNC errors
4708c2ecf20Sopenharmony_ci * @n_rx_overlength: Count of RX_OVERLENGTH errors
4718c2ecf20Sopenharmony_ci * @n_skbuff_leaks: Count of skbuffs leaked due to RX overrun
4728c2ecf20Sopenharmony_ci * @n_rx_nodesc_trunc: Number of RX packets truncated and then dropped due to
4738c2ecf20Sopenharmony_ci *	lack of descriptors
4748c2ecf20Sopenharmony_ci * @n_rx_merge_events: Number of RX merged completion events
4758c2ecf20Sopenharmony_ci * @n_rx_merge_packets: Number of RX packets completed by merged events
4768c2ecf20Sopenharmony_ci * @n_rx_xdp_drops: Count of RX packets intentionally dropped due to XDP
4778c2ecf20Sopenharmony_ci * @n_rx_xdp_bad_drops: Count of RX packets dropped due to XDP errors
4788c2ecf20Sopenharmony_ci * @n_rx_xdp_tx: Count of RX packets retransmitted due to XDP
4798c2ecf20Sopenharmony_ci * @n_rx_xdp_redirect: Count of RX packets redirected to a different NIC by XDP
4808c2ecf20Sopenharmony_ci * @rx_pkt_n_frags: Number of fragments in next packet to be delivered by
4818c2ecf20Sopenharmony_ci *	__efx_rx_packet(), or zero if there is none
4828c2ecf20Sopenharmony_ci * @rx_pkt_index: Ring index of first buffer for next packet to be delivered
4838c2ecf20Sopenharmony_ci *	by __efx_rx_packet(), if @rx_pkt_n_frags != 0
4848c2ecf20Sopenharmony_ci * @rx_list: list of SKBs from current RX, awaiting processing
4858c2ecf20Sopenharmony_ci * @rx_queue: RX queue for this channel
4868c2ecf20Sopenharmony_ci * @tx_queue: TX queues for this channel
4878c2ecf20Sopenharmony_ci * @tx_queue_by_type: pointers into @tx_queue, or %NULL, indexed by txq type
4888c2ecf20Sopenharmony_ci * @sync_events_state: Current state of sync events on this channel
4898c2ecf20Sopenharmony_ci * @sync_timestamp_major: Major part of the last ptp sync event
4908c2ecf20Sopenharmony_ci * @sync_timestamp_minor: Minor part of the last ptp sync event
4918c2ecf20Sopenharmony_ci */
4928c2ecf20Sopenharmony_cistruct efx_channel {
4938c2ecf20Sopenharmony_ci	struct efx_nic *efx;
4948c2ecf20Sopenharmony_ci	int channel;
4958c2ecf20Sopenharmony_ci	const struct efx_channel_type *type;
4968c2ecf20Sopenharmony_ci	bool eventq_init;
4978c2ecf20Sopenharmony_ci	bool enabled;
4988c2ecf20Sopenharmony_ci	int irq;
4998c2ecf20Sopenharmony_ci	unsigned int irq_moderation_us;
5008c2ecf20Sopenharmony_ci	struct net_device *napi_dev;
5018c2ecf20Sopenharmony_ci	struct napi_struct napi_str;
5028c2ecf20Sopenharmony_ci#ifdef CONFIG_NET_RX_BUSY_POLL
5038c2ecf20Sopenharmony_ci	unsigned long busy_poll_state;
5048c2ecf20Sopenharmony_ci#endif
5058c2ecf20Sopenharmony_ci	struct efx_special_buffer eventq;
5068c2ecf20Sopenharmony_ci	unsigned int eventq_mask;
5078c2ecf20Sopenharmony_ci	unsigned int eventq_read_ptr;
5088c2ecf20Sopenharmony_ci	int event_test_cpu;
5098c2ecf20Sopenharmony_ci
5108c2ecf20Sopenharmony_ci	unsigned int irq_count;
5118c2ecf20Sopenharmony_ci	unsigned int irq_mod_score;
5128c2ecf20Sopenharmony_ci#ifdef CONFIG_RFS_ACCEL
5138c2ecf20Sopenharmony_ci	unsigned int rfs_filter_count;
5148c2ecf20Sopenharmony_ci	unsigned int rfs_last_expiry;
5158c2ecf20Sopenharmony_ci	unsigned int rfs_expire_index;
5168c2ecf20Sopenharmony_ci	unsigned int n_rfs_succeeded;
5178c2ecf20Sopenharmony_ci	unsigned int n_rfs_failed;
5188c2ecf20Sopenharmony_ci	struct delayed_work filter_work;
5198c2ecf20Sopenharmony_ci#define RPS_FLOW_ID_INVALID 0xFFFFFFFF
5208c2ecf20Sopenharmony_ci	u32 *rps_flow_id;
5218c2ecf20Sopenharmony_ci#endif
5228c2ecf20Sopenharmony_ci
5238c2ecf20Sopenharmony_ci	unsigned int n_rx_tobe_disc;
5248c2ecf20Sopenharmony_ci	unsigned int n_rx_ip_hdr_chksum_err;
5258c2ecf20Sopenharmony_ci	unsigned int n_rx_tcp_udp_chksum_err;
5268c2ecf20Sopenharmony_ci	unsigned int n_rx_outer_ip_hdr_chksum_err;
5278c2ecf20Sopenharmony_ci	unsigned int n_rx_outer_tcp_udp_chksum_err;
5288c2ecf20Sopenharmony_ci	unsigned int n_rx_inner_ip_hdr_chksum_err;
5298c2ecf20Sopenharmony_ci	unsigned int n_rx_inner_tcp_udp_chksum_err;
5308c2ecf20Sopenharmony_ci	unsigned int n_rx_eth_crc_err;
5318c2ecf20Sopenharmony_ci	unsigned int n_rx_mcast_mismatch;
5328c2ecf20Sopenharmony_ci	unsigned int n_rx_frm_trunc;
5338c2ecf20Sopenharmony_ci	unsigned int n_rx_overlength;
5348c2ecf20Sopenharmony_ci	unsigned int n_skbuff_leaks;
5358c2ecf20Sopenharmony_ci	unsigned int n_rx_nodesc_trunc;
5368c2ecf20Sopenharmony_ci	unsigned int n_rx_merge_events;
5378c2ecf20Sopenharmony_ci	unsigned int n_rx_merge_packets;
5388c2ecf20Sopenharmony_ci	unsigned int n_rx_xdp_drops;
5398c2ecf20Sopenharmony_ci	unsigned int n_rx_xdp_bad_drops;
5408c2ecf20Sopenharmony_ci	unsigned int n_rx_xdp_tx;
5418c2ecf20Sopenharmony_ci	unsigned int n_rx_xdp_redirect;
5428c2ecf20Sopenharmony_ci
5438c2ecf20Sopenharmony_ci	unsigned int rx_pkt_n_frags;
5448c2ecf20Sopenharmony_ci	unsigned int rx_pkt_index;
5458c2ecf20Sopenharmony_ci
5468c2ecf20Sopenharmony_ci	struct list_head *rx_list;
5478c2ecf20Sopenharmony_ci
5488c2ecf20Sopenharmony_ci	struct efx_rx_queue rx_queue;
5498c2ecf20Sopenharmony_ci	struct efx_tx_queue tx_queue[EFX_MAX_TXQ_PER_CHANNEL];
5508c2ecf20Sopenharmony_ci	struct efx_tx_queue *tx_queue_by_type[EFX_TXQ_TYPES];
5518c2ecf20Sopenharmony_ci
5528c2ecf20Sopenharmony_ci	enum efx_sync_events_state sync_events_state;
5538c2ecf20Sopenharmony_ci	u32 sync_timestamp_major;
5548c2ecf20Sopenharmony_ci	u32 sync_timestamp_minor;
5558c2ecf20Sopenharmony_ci};
5568c2ecf20Sopenharmony_ci
5578c2ecf20Sopenharmony_ci/**
5588c2ecf20Sopenharmony_ci * struct efx_msi_context - Context for each MSI
5598c2ecf20Sopenharmony_ci * @efx: The associated NIC
5608c2ecf20Sopenharmony_ci * @index: Index of the channel/IRQ
5618c2ecf20Sopenharmony_ci * @name: Name of the channel/IRQ
5628c2ecf20Sopenharmony_ci *
5638c2ecf20Sopenharmony_ci * Unlike &struct efx_channel, this is never reallocated and is always
5648c2ecf20Sopenharmony_ci * safe for the IRQ handler to access.
5658c2ecf20Sopenharmony_ci */
5668c2ecf20Sopenharmony_cistruct efx_msi_context {
5678c2ecf20Sopenharmony_ci	struct efx_nic *efx;
5688c2ecf20Sopenharmony_ci	unsigned int index;
5698c2ecf20Sopenharmony_ci	char name[IFNAMSIZ + 6];
5708c2ecf20Sopenharmony_ci};
5718c2ecf20Sopenharmony_ci
5728c2ecf20Sopenharmony_ci/**
5738c2ecf20Sopenharmony_ci * struct efx_channel_type - distinguishes traffic and extra channels
5748c2ecf20Sopenharmony_ci * @handle_no_channel: Handle failure to allocate an extra channel
5758c2ecf20Sopenharmony_ci * @pre_probe: Set up extra state prior to initialisation
5768c2ecf20Sopenharmony_ci * @post_remove: Tear down extra state after finalisation, if allocated.
5778c2ecf20Sopenharmony_ci *	May be called on channels that have not been probed.
5788c2ecf20Sopenharmony_ci * @get_name: Generate the channel's name (used for its IRQ handler)
5798c2ecf20Sopenharmony_ci * @copy: Copy the channel state prior to reallocation.  May be %NULL if
5808c2ecf20Sopenharmony_ci *	reallocation is not supported.
5818c2ecf20Sopenharmony_ci * @receive_skb: Handle an skb ready to be passed to netif_receive_skb()
5828c2ecf20Sopenharmony_ci * @want_txqs: Determine whether this channel should have TX queues
5838c2ecf20Sopenharmony_ci *	created.  If %NULL, TX queues are not created.
5848c2ecf20Sopenharmony_ci * @keep_eventq: Flag for whether event queue should be kept initialised
5858c2ecf20Sopenharmony_ci *	while the device is stopped
5868c2ecf20Sopenharmony_ci * @want_pio: Flag for whether PIO buffers should be linked to this
5878c2ecf20Sopenharmony_ci *	channel's TX queues.
5888c2ecf20Sopenharmony_ci */
5898c2ecf20Sopenharmony_cistruct efx_channel_type {
5908c2ecf20Sopenharmony_ci	void (*handle_no_channel)(struct efx_nic *);
5918c2ecf20Sopenharmony_ci	int (*pre_probe)(struct efx_channel *);
5928c2ecf20Sopenharmony_ci	void (*post_remove)(struct efx_channel *);
5938c2ecf20Sopenharmony_ci	void (*get_name)(struct efx_channel *, char *buf, size_t len);
5948c2ecf20Sopenharmony_ci	struct efx_channel *(*copy)(const struct efx_channel *);
5958c2ecf20Sopenharmony_ci	bool (*receive_skb)(struct efx_channel *, struct sk_buff *);
5968c2ecf20Sopenharmony_ci	bool (*want_txqs)(struct efx_channel *);
5978c2ecf20Sopenharmony_ci	bool keep_eventq;
5988c2ecf20Sopenharmony_ci	bool want_pio;
5998c2ecf20Sopenharmony_ci};
6008c2ecf20Sopenharmony_ci
6018c2ecf20Sopenharmony_cienum efx_led_mode {
6028c2ecf20Sopenharmony_ci	EFX_LED_OFF	= 0,
6038c2ecf20Sopenharmony_ci	EFX_LED_ON	= 1,
6048c2ecf20Sopenharmony_ci	EFX_LED_DEFAULT	= 2
6058c2ecf20Sopenharmony_ci};
6068c2ecf20Sopenharmony_ci
6078c2ecf20Sopenharmony_ci#define STRING_TABLE_LOOKUP(val, member) \
6088c2ecf20Sopenharmony_ci	((val) < member ## _max) ? member ## _names[val] : "(invalid)"
6098c2ecf20Sopenharmony_ci
6108c2ecf20Sopenharmony_ciextern const char *const efx_loopback_mode_names[];
6118c2ecf20Sopenharmony_ciextern const unsigned int efx_loopback_mode_max;
6128c2ecf20Sopenharmony_ci#define LOOPBACK_MODE(efx) \
6138c2ecf20Sopenharmony_ci	STRING_TABLE_LOOKUP((efx)->loopback_mode, efx_loopback_mode)
6148c2ecf20Sopenharmony_ci
6158c2ecf20Sopenharmony_ciextern const char *const efx_reset_type_names[];
6168c2ecf20Sopenharmony_ciextern const unsigned int efx_reset_type_max;
6178c2ecf20Sopenharmony_ci#define RESET_TYPE(type) \
6188c2ecf20Sopenharmony_ci	STRING_TABLE_LOOKUP(type, efx_reset_type)
6198c2ecf20Sopenharmony_ci
6208c2ecf20Sopenharmony_cienum efx_int_mode {
6218c2ecf20Sopenharmony_ci	/* Be careful if altering to correct macro below */
6228c2ecf20Sopenharmony_ci	EFX_INT_MODE_MSIX = 0,
6238c2ecf20Sopenharmony_ci	EFX_INT_MODE_MSI = 1,
6248c2ecf20Sopenharmony_ci	EFX_INT_MODE_LEGACY = 2,
6258c2ecf20Sopenharmony_ci	EFX_INT_MODE_MAX	/* Insert any new items before this */
6268c2ecf20Sopenharmony_ci};
6278c2ecf20Sopenharmony_ci#define EFX_INT_MODE_USE_MSI(x) (((x)->interrupt_mode) <= EFX_INT_MODE_MSI)
6288c2ecf20Sopenharmony_ci
6298c2ecf20Sopenharmony_cienum nic_state {
6308c2ecf20Sopenharmony_ci	STATE_UNINIT = 0,	/* device being probed/removed */
6318c2ecf20Sopenharmony_ci	STATE_NET_DOWN,		/* hardware probed and netdev registered */
6328c2ecf20Sopenharmony_ci	STATE_NET_UP,		/* ready for traffic */
6338c2ecf20Sopenharmony_ci	STATE_DISABLED,		/* device disabled due to hardware errors */
6348c2ecf20Sopenharmony_ci
6358c2ecf20Sopenharmony_ci	STATE_RECOVERY = 0x100,/* recovering from PCI error */
6368c2ecf20Sopenharmony_ci	STATE_FROZEN = 0x200,	/* frozen by power management */
6378c2ecf20Sopenharmony_ci};
6388c2ecf20Sopenharmony_ci
6398c2ecf20Sopenharmony_cistatic inline bool efx_net_active(enum nic_state state)
6408c2ecf20Sopenharmony_ci{
6418c2ecf20Sopenharmony_ci	return state == STATE_NET_DOWN || state == STATE_NET_UP;
6428c2ecf20Sopenharmony_ci}
6438c2ecf20Sopenharmony_ci
6448c2ecf20Sopenharmony_cistatic inline bool efx_frozen(enum nic_state state)
6458c2ecf20Sopenharmony_ci{
6468c2ecf20Sopenharmony_ci	return state & STATE_FROZEN;
6478c2ecf20Sopenharmony_ci}
6488c2ecf20Sopenharmony_ci
6498c2ecf20Sopenharmony_cistatic inline bool efx_recovering(enum nic_state state)
6508c2ecf20Sopenharmony_ci{
6518c2ecf20Sopenharmony_ci	return state & STATE_RECOVERY;
6528c2ecf20Sopenharmony_ci}
6538c2ecf20Sopenharmony_ci
6548c2ecf20Sopenharmony_cistatic inline enum nic_state efx_freeze(enum nic_state state)
6558c2ecf20Sopenharmony_ci{
6568c2ecf20Sopenharmony_ci	WARN_ON(!efx_net_active(state));
6578c2ecf20Sopenharmony_ci	return state | STATE_FROZEN;
6588c2ecf20Sopenharmony_ci}
6598c2ecf20Sopenharmony_ci
6608c2ecf20Sopenharmony_cistatic inline enum nic_state efx_thaw(enum nic_state state)
6618c2ecf20Sopenharmony_ci{
6628c2ecf20Sopenharmony_ci	WARN_ON(!efx_frozen(state));
6638c2ecf20Sopenharmony_ci	return state & ~STATE_FROZEN;
6648c2ecf20Sopenharmony_ci}
6658c2ecf20Sopenharmony_ci
6668c2ecf20Sopenharmony_cistatic inline enum nic_state efx_recover(enum nic_state state)
6678c2ecf20Sopenharmony_ci{
6688c2ecf20Sopenharmony_ci	WARN_ON(!efx_net_active(state));
6698c2ecf20Sopenharmony_ci	return state | STATE_RECOVERY;
6708c2ecf20Sopenharmony_ci}
6718c2ecf20Sopenharmony_ci
6728c2ecf20Sopenharmony_cistatic inline enum nic_state efx_recovered(enum nic_state state)
6738c2ecf20Sopenharmony_ci{
6748c2ecf20Sopenharmony_ci	WARN_ON(!efx_recovering(state));
6758c2ecf20Sopenharmony_ci	return state & ~STATE_RECOVERY;
6768c2ecf20Sopenharmony_ci}
6778c2ecf20Sopenharmony_ci
6788c2ecf20Sopenharmony_ci/* Forward declaration */
6798c2ecf20Sopenharmony_cistruct efx_nic;
6808c2ecf20Sopenharmony_ci
6818c2ecf20Sopenharmony_ci/* Pseudo bit-mask flow control field */
6828c2ecf20Sopenharmony_ci#define EFX_FC_RX	FLOW_CTRL_RX
6838c2ecf20Sopenharmony_ci#define EFX_FC_TX	FLOW_CTRL_TX
6848c2ecf20Sopenharmony_ci#define EFX_FC_AUTO	4
6858c2ecf20Sopenharmony_ci
6868c2ecf20Sopenharmony_ci/**
6878c2ecf20Sopenharmony_ci * struct efx_link_state - Current state of the link
6888c2ecf20Sopenharmony_ci * @up: Link is up
6898c2ecf20Sopenharmony_ci * @fd: Link is full-duplex
6908c2ecf20Sopenharmony_ci * @fc: Actual flow control flags
6918c2ecf20Sopenharmony_ci * @speed: Link speed (Mbps)
6928c2ecf20Sopenharmony_ci */
6938c2ecf20Sopenharmony_cistruct efx_link_state {
6948c2ecf20Sopenharmony_ci	bool up;
6958c2ecf20Sopenharmony_ci	bool fd;
6968c2ecf20Sopenharmony_ci	u8 fc;
6978c2ecf20Sopenharmony_ci	unsigned int speed;
6988c2ecf20Sopenharmony_ci};
6998c2ecf20Sopenharmony_ci
7008c2ecf20Sopenharmony_cistatic inline bool efx_link_state_equal(const struct efx_link_state *left,
7018c2ecf20Sopenharmony_ci					const struct efx_link_state *right)
7028c2ecf20Sopenharmony_ci{
7038c2ecf20Sopenharmony_ci	return left->up == right->up && left->fd == right->fd &&
7048c2ecf20Sopenharmony_ci		left->fc == right->fc && left->speed == right->speed;
7058c2ecf20Sopenharmony_ci}
7068c2ecf20Sopenharmony_ci
7078c2ecf20Sopenharmony_ci/**
7088c2ecf20Sopenharmony_ci * enum efx_phy_mode - PHY operating mode flags
7098c2ecf20Sopenharmony_ci * @PHY_MODE_NORMAL: on and should pass traffic
7108c2ecf20Sopenharmony_ci * @PHY_MODE_TX_DISABLED: on with TX disabled
7118c2ecf20Sopenharmony_ci * @PHY_MODE_LOW_POWER: set to low power through MDIO
7128c2ecf20Sopenharmony_ci * @PHY_MODE_OFF: switched off through external control
7138c2ecf20Sopenharmony_ci * @PHY_MODE_SPECIAL: on but will not pass traffic
7148c2ecf20Sopenharmony_ci */
7158c2ecf20Sopenharmony_cienum efx_phy_mode {
7168c2ecf20Sopenharmony_ci	PHY_MODE_NORMAL		= 0,
7178c2ecf20Sopenharmony_ci	PHY_MODE_TX_DISABLED	= 1,
7188c2ecf20Sopenharmony_ci	PHY_MODE_LOW_POWER	= 2,
7198c2ecf20Sopenharmony_ci	PHY_MODE_OFF		= 4,
7208c2ecf20Sopenharmony_ci	PHY_MODE_SPECIAL	= 8,
7218c2ecf20Sopenharmony_ci};
7228c2ecf20Sopenharmony_ci
7238c2ecf20Sopenharmony_cistatic inline bool efx_phy_mode_disabled(enum efx_phy_mode mode)
7248c2ecf20Sopenharmony_ci{
7258c2ecf20Sopenharmony_ci	return !!(mode & ~PHY_MODE_TX_DISABLED);
7268c2ecf20Sopenharmony_ci}
7278c2ecf20Sopenharmony_ci
7288c2ecf20Sopenharmony_ci/**
7298c2ecf20Sopenharmony_ci * struct efx_hw_stat_desc - Description of a hardware statistic
7308c2ecf20Sopenharmony_ci * @name: Name of the statistic as visible through ethtool, or %NULL if
7318c2ecf20Sopenharmony_ci *	it should not be exposed
7328c2ecf20Sopenharmony_ci * @dma_width: Width in bits (0 for non-DMA statistics)
7338c2ecf20Sopenharmony_ci * @offset: Offset within stats (ignored for non-DMA statistics)
7348c2ecf20Sopenharmony_ci */
7358c2ecf20Sopenharmony_cistruct efx_hw_stat_desc {
7368c2ecf20Sopenharmony_ci	const char *name;
7378c2ecf20Sopenharmony_ci	u16 dma_width;
7388c2ecf20Sopenharmony_ci	u16 offset;
7398c2ecf20Sopenharmony_ci};
7408c2ecf20Sopenharmony_ci
7418c2ecf20Sopenharmony_ci/* Number of bits used in a multicast filter hash address */
7428c2ecf20Sopenharmony_ci#define EFX_MCAST_HASH_BITS 8
7438c2ecf20Sopenharmony_ci
7448c2ecf20Sopenharmony_ci/* Number of (single-bit) entries in a multicast filter hash */
7458c2ecf20Sopenharmony_ci#define EFX_MCAST_HASH_ENTRIES (1 << EFX_MCAST_HASH_BITS)
7468c2ecf20Sopenharmony_ci
7478c2ecf20Sopenharmony_ci/* An Efx multicast filter hash */
7488c2ecf20Sopenharmony_ciunion efx_multicast_hash {
7498c2ecf20Sopenharmony_ci	u8 byte[EFX_MCAST_HASH_ENTRIES / 8];
7508c2ecf20Sopenharmony_ci	efx_oword_t oword[EFX_MCAST_HASH_ENTRIES / sizeof(efx_oword_t) / 8];
7518c2ecf20Sopenharmony_ci};
7528c2ecf20Sopenharmony_ci
7538c2ecf20Sopenharmony_cistruct vfdi_status;
7548c2ecf20Sopenharmony_ci
7558c2ecf20Sopenharmony_ci/* The reserved RSS context value */
7568c2ecf20Sopenharmony_ci#define EFX_MCDI_RSS_CONTEXT_INVALID	0xffffffff
7578c2ecf20Sopenharmony_ci/**
7588c2ecf20Sopenharmony_ci * struct efx_rss_context - A user-defined RSS context for filtering
7598c2ecf20Sopenharmony_ci * @list: node of linked list on which this struct is stored
7608c2ecf20Sopenharmony_ci * @context_id: the RSS_CONTEXT_ID returned by MC firmware, or
7618c2ecf20Sopenharmony_ci *	%EFX_MCDI_RSS_CONTEXT_INVALID if this context is not present on the NIC.
7628c2ecf20Sopenharmony_ci *	For Siena, 0 if RSS is active, else %EFX_MCDI_RSS_CONTEXT_INVALID.
7638c2ecf20Sopenharmony_ci * @user_id: the rss_context ID exposed to userspace over ethtool.
7648c2ecf20Sopenharmony_ci * @rx_hash_udp_4tuple: UDP 4-tuple hashing enabled
7658c2ecf20Sopenharmony_ci * @rx_hash_key: Toeplitz hash key for this RSS context
7668c2ecf20Sopenharmony_ci * @indir_table: Indirection table for this RSS context
7678c2ecf20Sopenharmony_ci */
7688c2ecf20Sopenharmony_cistruct efx_rss_context {
7698c2ecf20Sopenharmony_ci	struct list_head list;
7708c2ecf20Sopenharmony_ci	u32 context_id;
7718c2ecf20Sopenharmony_ci	u32 user_id;
7728c2ecf20Sopenharmony_ci	bool rx_hash_udp_4tuple;
7738c2ecf20Sopenharmony_ci	u8 rx_hash_key[40];
7748c2ecf20Sopenharmony_ci	u32 rx_indir_table[128];
7758c2ecf20Sopenharmony_ci};
7768c2ecf20Sopenharmony_ci
7778c2ecf20Sopenharmony_ci#ifdef CONFIG_RFS_ACCEL
7788c2ecf20Sopenharmony_ci/* Order of these is important, since filter_id >= %EFX_ARFS_FILTER_ID_PENDING
7798c2ecf20Sopenharmony_ci * is used to test if filter does or will exist.
7808c2ecf20Sopenharmony_ci */
7818c2ecf20Sopenharmony_ci#define EFX_ARFS_FILTER_ID_PENDING	-1
7828c2ecf20Sopenharmony_ci#define EFX_ARFS_FILTER_ID_ERROR	-2
7838c2ecf20Sopenharmony_ci#define EFX_ARFS_FILTER_ID_REMOVING	-3
7848c2ecf20Sopenharmony_ci/**
7858c2ecf20Sopenharmony_ci * struct efx_arfs_rule - record of an ARFS filter and its IDs
7868c2ecf20Sopenharmony_ci * @node: linkage into hash table
7878c2ecf20Sopenharmony_ci * @spec: details of the filter (used as key for hash table).  Use efx->type to
7888c2ecf20Sopenharmony_ci *	determine which member to use.
7898c2ecf20Sopenharmony_ci * @rxq_index: channel to which the filter will steer traffic.
7908c2ecf20Sopenharmony_ci * @arfs_id: filter ID which was returned to ARFS
7918c2ecf20Sopenharmony_ci * @filter_id: index in software filter table.  May be
7928c2ecf20Sopenharmony_ci *	%EFX_ARFS_FILTER_ID_PENDING if filter was not inserted yet,
7938c2ecf20Sopenharmony_ci *	%EFX_ARFS_FILTER_ID_ERROR if filter insertion failed, or
7948c2ecf20Sopenharmony_ci *	%EFX_ARFS_FILTER_ID_REMOVING if expiry is currently removing the filter.
7958c2ecf20Sopenharmony_ci */
7968c2ecf20Sopenharmony_cistruct efx_arfs_rule {
7978c2ecf20Sopenharmony_ci	struct hlist_node node;
7988c2ecf20Sopenharmony_ci	struct efx_filter_spec spec;
7998c2ecf20Sopenharmony_ci	u16 rxq_index;
8008c2ecf20Sopenharmony_ci	u16 arfs_id;
8018c2ecf20Sopenharmony_ci	s32 filter_id;
8028c2ecf20Sopenharmony_ci};
8038c2ecf20Sopenharmony_ci
8048c2ecf20Sopenharmony_ci/* Size chosen so that the table is one page (4kB) */
8058c2ecf20Sopenharmony_ci#define EFX_ARFS_HASH_TABLE_SIZE	512
8068c2ecf20Sopenharmony_ci
8078c2ecf20Sopenharmony_ci/**
8088c2ecf20Sopenharmony_ci * struct efx_async_filter_insertion - Request to asynchronously insert a filter
8098c2ecf20Sopenharmony_ci * @net_dev: Reference to the netdevice
8108c2ecf20Sopenharmony_ci * @spec: The filter to insert
8118c2ecf20Sopenharmony_ci * @work: Workitem for this request
8128c2ecf20Sopenharmony_ci * @rxq_index: Identifies the channel for which this request was made
8138c2ecf20Sopenharmony_ci * @flow_id: Identifies the kernel-side flow for which this request was made
8148c2ecf20Sopenharmony_ci */
8158c2ecf20Sopenharmony_cistruct efx_async_filter_insertion {
8168c2ecf20Sopenharmony_ci	struct net_device *net_dev;
8178c2ecf20Sopenharmony_ci	struct efx_filter_spec spec;
8188c2ecf20Sopenharmony_ci	struct work_struct work;
8198c2ecf20Sopenharmony_ci	u16 rxq_index;
8208c2ecf20Sopenharmony_ci	u32 flow_id;
8218c2ecf20Sopenharmony_ci};
8228c2ecf20Sopenharmony_ci
8238c2ecf20Sopenharmony_ci/* Maximum number of ARFS workitems that may be in flight on an efx_nic */
8248c2ecf20Sopenharmony_ci#define EFX_RPS_MAX_IN_FLIGHT	8
8258c2ecf20Sopenharmony_ci#endif /* CONFIG_RFS_ACCEL */
8268c2ecf20Sopenharmony_ci
8278c2ecf20Sopenharmony_ci/**
8288c2ecf20Sopenharmony_ci * struct efx_nic - an Efx NIC
8298c2ecf20Sopenharmony_ci * @name: Device name (net device name or bus id before net device registered)
8308c2ecf20Sopenharmony_ci * @pci_dev: The PCI device
8318c2ecf20Sopenharmony_ci * @node: List node for maintaning primary/secondary function lists
8328c2ecf20Sopenharmony_ci * @primary: &struct efx_nic instance for the primary function of this
8338c2ecf20Sopenharmony_ci *	controller.  May be the same structure, and may be %NULL if no
8348c2ecf20Sopenharmony_ci *	primary function is bound.  Serialised by rtnl_lock.
8358c2ecf20Sopenharmony_ci * @secondary_list: List of &struct efx_nic instances for the secondary PCI
8368c2ecf20Sopenharmony_ci *	functions of the controller, if this is for the primary function.
8378c2ecf20Sopenharmony_ci *	Serialised by rtnl_lock.
8388c2ecf20Sopenharmony_ci * @type: Controller type attributes
8398c2ecf20Sopenharmony_ci * @legacy_irq: IRQ number
8408c2ecf20Sopenharmony_ci * @workqueue: Workqueue for port reconfigures and the HW monitor.
8418c2ecf20Sopenharmony_ci *	Work items do not hold and must not acquire RTNL.
8428c2ecf20Sopenharmony_ci * @workqueue_name: Name of workqueue
8438c2ecf20Sopenharmony_ci * @reset_work: Scheduled reset workitem
8448c2ecf20Sopenharmony_ci * @membase_phys: Memory BAR value as physical address
8458c2ecf20Sopenharmony_ci * @membase: Memory BAR value
8468c2ecf20Sopenharmony_ci * @vi_stride: step between per-VI registers / memory regions
8478c2ecf20Sopenharmony_ci * @interrupt_mode: Interrupt mode
8488c2ecf20Sopenharmony_ci * @timer_quantum_ns: Interrupt timer quantum, in nanoseconds
8498c2ecf20Sopenharmony_ci * @timer_max_ns: Interrupt timer maximum value, in nanoseconds
8508c2ecf20Sopenharmony_ci * @irq_rx_adaptive: Adaptive IRQ moderation enabled for RX event queues
8518c2ecf20Sopenharmony_ci * @irqs_hooked: Channel interrupts are hooked
8528c2ecf20Sopenharmony_ci * @irq_rx_mod_step_us: Step size for IRQ moderation for RX event queues
8538c2ecf20Sopenharmony_ci * @irq_rx_moderation_us: IRQ moderation time for RX event queues
8548c2ecf20Sopenharmony_ci * @msg_enable: Log message enable flags
8558c2ecf20Sopenharmony_ci * @state: Device state number (%STATE_*). Serialised by the rtnl_lock.
8568c2ecf20Sopenharmony_ci * @reset_pending: Bitmask for pending resets
8578c2ecf20Sopenharmony_ci * @tx_queue: TX DMA queues
8588c2ecf20Sopenharmony_ci * @rx_queue: RX DMA queues
8598c2ecf20Sopenharmony_ci * @channel: Channels
8608c2ecf20Sopenharmony_ci * @msi_context: Context for each MSI
8618c2ecf20Sopenharmony_ci * @extra_channel_types: Types of extra (non-traffic) channels that
8628c2ecf20Sopenharmony_ci *	should be allocated for this NIC
8638c2ecf20Sopenharmony_ci * @xdp_tx_queue_count: Number of entries in %xdp_tx_queues.
8648c2ecf20Sopenharmony_ci * @xdp_tx_queues: Array of pointers to tx queues used for XDP transmit.
8658c2ecf20Sopenharmony_ci * @rxq_entries: Size of receive queues requested by user.
8668c2ecf20Sopenharmony_ci * @txq_entries: Size of transmit queues requested by user.
8678c2ecf20Sopenharmony_ci * @txq_stop_thresh: TX queue fill level at or above which we stop it.
8688c2ecf20Sopenharmony_ci * @txq_wake_thresh: TX queue fill level at or below which we wake it.
8698c2ecf20Sopenharmony_ci * @tx_dc_base: Base qword address in SRAM of TX queue descriptor caches
8708c2ecf20Sopenharmony_ci * @rx_dc_base: Base qword address in SRAM of RX queue descriptor caches
8718c2ecf20Sopenharmony_ci * @sram_lim_qw: Qword address limit of SRAM
8728c2ecf20Sopenharmony_ci * @next_buffer_table: First available buffer table id
8738c2ecf20Sopenharmony_ci * @n_channels: Number of channels in use
8748c2ecf20Sopenharmony_ci * @n_rx_channels: Number of channels used for RX (= number of RX queues)
8758c2ecf20Sopenharmony_ci * @n_tx_channels: Number of channels used for TX
8768c2ecf20Sopenharmony_ci * @n_extra_tx_channels: Number of extra channels with TX queues
8778c2ecf20Sopenharmony_ci * @tx_queues_per_channel: number of TX queues probed on each channel
8788c2ecf20Sopenharmony_ci * @n_xdp_channels: Number of channels used for XDP TX
8798c2ecf20Sopenharmony_ci * @xdp_channel_offset: Offset of zeroth channel used for XPD TX.
8808c2ecf20Sopenharmony_ci * @xdp_tx_per_channel: Max number of TX queues on an XDP TX channel.
8818c2ecf20Sopenharmony_ci * @rx_ip_align: RX DMA address offset to have IP header aligned in
8828c2ecf20Sopenharmony_ci *	in accordance with NET_IP_ALIGN
8838c2ecf20Sopenharmony_ci * @rx_dma_len: Current maximum RX DMA length
8848c2ecf20Sopenharmony_ci * @rx_buffer_order: Order (log2) of number of pages for each RX buffer
8858c2ecf20Sopenharmony_ci * @rx_buffer_truesize: Amortised allocation size of an RX buffer,
8868c2ecf20Sopenharmony_ci *	for use in sk_buff::truesize
8878c2ecf20Sopenharmony_ci * @rx_prefix_size: Size of RX prefix before packet data
8888c2ecf20Sopenharmony_ci * @rx_packet_hash_offset: Offset of RX flow hash from start of packet data
8898c2ecf20Sopenharmony_ci *	(valid only if @rx_prefix_size != 0; always negative)
8908c2ecf20Sopenharmony_ci * @rx_packet_len_offset: Offset of RX packet length from start of packet data
8918c2ecf20Sopenharmony_ci *	(valid only for NICs that set %EFX_RX_PKT_PREFIX_LEN; always negative)
8928c2ecf20Sopenharmony_ci * @rx_packet_ts_offset: Offset of timestamp from start of packet data
8938c2ecf20Sopenharmony_ci *	(valid only if channel->sync_timestamps_enabled; always negative)
8948c2ecf20Sopenharmony_ci * @rx_scatter: Scatter mode enabled for receives
8958c2ecf20Sopenharmony_ci * @rss_context: Main RSS context.  Its @list member is the head of the list of
8968c2ecf20Sopenharmony_ci *	RSS contexts created by user requests
8978c2ecf20Sopenharmony_ci * @rss_lock: Protects custom RSS context software state in @rss_context.list
8988c2ecf20Sopenharmony_ci * @vport_id: The function's vport ID, only relevant for PFs
8998c2ecf20Sopenharmony_ci * @int_error_count: Number of internal errors seen recently
9008c2ecf20Sopenharmony_ci * @int_error_expire: Time at which error count will be expired
9018c2ecf20Sopenharmony_ci * @must_realloc_vis: Flag: VIs have yet to be reallocated after MC reboot
9028c2ecf20Sopenharmony_ci * @irq_soft_enabled: Are IRQs soft-enabled? If not, IRQ handler will
9038c2ecf20Sopenharmony_ci *	acknowledge but do nothing else.
9048c2ecf20Sopenharmony_ci * @irq_status: Interrupt status buffer
9058c2ecf20Sopenharmony_ci * @irq_zero_count: Number of legacy IRQs seen with queue flags == 0
9068c2ecf20Sopenharmony_ci * @irq_level: IRQ level/index for IRQs not triggered by an event queue
9078c2ecf20Sopenharmony_ci * @selftest_work: Work item for asynchronous self-test
9088c2ecf20Sopenharmony_ci * @mtd_list: List of MTDs attached to the NIC
9098c2ecf20Sopenharmony_ci * @nic_data: Hardware dependent state
9108c2ecf20Sopenharmony_ci * @mcdi: Management-Controller-to-Driver Interface state
9118c2ecf20Sopenharmony_ci * @mac_lock: MAC access lock. Protects @port_enabled, @phy_mode,
9128c2ecf20Sopenharmony_ci *	efx_monitor() and efx_reconfigure_port()
9138c2ecf20Sopenharmony_ci * @port_enabled: Port enabled indicator.
9148c2ecf20Sopenharmony_ci *	Serialises efx_stop_all(), efx_start_all(), efx_monitor() and
9158c2ecf20Sopenharmony_ci *	efx_mac_work() with kernel interfaces. Safe to read under any
9168c2ecf20Sopenharmony_ci *	one of the rtnl_lock, mac_lock, or netif_tx_lock, but all three must
9178c2ecf20Sopenharmony_ci *	be held to modify it.
9188c2ecf20Sopenharmony_ci * @port_initialized: Port initialized?
9198c2ecf20Sopenharmony_ci * @net_dev: Operating system network device. Consider holding the rtnl lock
9208c2ecf20Sopenharmony_ci * @fixed_features: Features which cannot be turned off
9218c2ecf20Sopenharmony_ci * @num_mac_stats: Number of MAC stats reported by firmware (MAC_STATS_NUM_STATS
9228c2ecf20Sopenharmony_ci *	field of %MC_CMD_GET_CAPABILITIES_V4 response, or %MC_CMD_MAC_NSTATS)
9238c2ecf20Sopenharmony_ci * @stats_buffer: DMA buffer for statistics
9248c2ecf20Sopenharmony_ci * @phy_type: PHY type
9258c2ecf20Sopenharmony_ci * @phy_data: PHY private data (including PHY-specific stats)
9268c2ecf20Sopenharmony_ci * @mdio: PHY MDIO interface
9278c2ecf20Sopenharmony_ci * @mdio_bus: PHY MDIO bus ID (only used by Siena)
9288c2ecf20Sopenharmony_ci * @phy_mode: PHY operating mode. Serialised by @mac_lock.
9298c2ecf20Sopenharmony_ci * @link_advertising: Autonegotiation advertising flags
9308c2ecf20Sopenharmony_ci * @fec_config: Forward Error Correction configuration flags.  For bit positions
9318c2ecf20Sopenharmony_ci *	see &enum ethtool_fec_config_bits.
9328c2ecf20Sopenharmony_ci * @link_state: Current state of the link
9338c2ecf20Sopenharmony_ci * @n_link_state_changes: Number of times the link has changed state
9348c2ecf20Sopenharmony_ci * @unicast_filter: Flag for Falcon-arch simple unicast filter.
9358c2ecf20Sopenharmony_ci *	Protected by @mac_lock.
9368c2ecf20Sopenharmony_ci * @multicast_hash: Multicast hash table for Falcon-arch.
9378c2ecf20Sopenharmony_ci *	Protected by @mac_lock.
9388c2ecf20Sopenharmony_ci * @wanted_fc: Wanted flow control flags
9398c2ecf20Sopenharmony_ci * @fc_disable: When non-zero flow control is disabled. Typically used to
9408c2ecf20Sopenharmony_ci *	ensure that network back pressure doesn't delay dma queue flushes.
9418c2ecf20Sopenharmony_ci *	Serialised by the rtnl lock.
9428c2ecf20Sopenharmony_ci * @mac_work: Work item for changing MAC promiscuity and multicast hash
9438c2ecf20Sopenharmony_ci * @loopback_mode: Loopback status
9448c2ecf20Sopenharmony_ci * @loopback_modes: Supported loopback mode bitmask
9458c2ecf20Sopenharmony_ci * @loopback_selftest: Offline self-test private state
9468c2ecf20Sopenharmony_ci * @xdp_prog: Current XDP programme for this interface
9478c2ecf20Sopenharmony_ci * @filter_sem: Filter table rw_semaphore, protects existence of @filter_state
9488c2ecf20Sopenharmony_ci * @filter_state: Architecture-dependent filter table state
9498c2ecf20Sopenharmony_ci * @rps_mutex: Protects RPS state of all channels
9508c2ecf20Sopenharmony_ci * @rps_slot_map: bitmap of in-flight entries in @rps_slot
9518c2ecf20Sopenharmony_ci * @rps_slot: array of ARFS insertion requests for efx_filter_rfs_work()
9528c2ecf20Sopenharmony_ci * @rps_hash_lock: Protects ARFS filter mapping state (@rps_hash_table and
9538c2ecf20Sopenharmony_ci *	@rps_next_id).
9548c2ecf20Sopenharmony_ci * @rps_hash_table: Mapping between ARFS filters and their various IDs
9558c2ecf20Sopenharmony_ci * @rps_next_id: next arfs_id for an ARFS filter
9568c2ecf20Sopenharmony_ci * @active_queues: Count of RX and TX queues that haven't been flushed and drained.
9578c2ecf20Sopenharmony_ci * @rxq_flush_pending: Count of number of receive queues that need to be flushed.
9588c2ecf20Sopenharmony_ci *	Decremented when the efx_flush_rx_queue() is called.
9598c2ecf20Sopenharmony_ci * @rxq_flush_outstanding: Count of number of RX flushes started but not yet
9608c2ecf20Sopenharmony_ci *	completed (either success or failure). Not used when MCDI is used to
9618c2ecf20Sopenharmony_ci *	flush receive queues.
9628c2ecf20Sopenharmony_ci * @flush_wq: wait queue used by efx_nic_flush_queues() to wait for flush completions.
9638c2ecf20Sopenharmony_ci * @vf_count: Number of VFs intended to be enabled.
9648c2ecf20Sopenharmony_ci * @vf_init_count: Number of VFs that have been fully initialised.
9658c2ecf20Sopenharmony_ci * @vi_scale: log2 number of vnics per VF.
9668c2ecf20Sopenharmony_ci * @ptp_data: PTP state data
9678c2ecf20Sopenharmony_ci * @ptp_warned: has this NIC seen and warned about unexpected PTP events?
9688c2ecf20Sopenharmony_ci * @vpd_sn: Serial number read from VPD
9698c2ecf20Sopenharmony_ci * @xdp_rxq_info_failed: Have any of the rx queues failed to initialise their
9708c2ecf20Sopenharmony_ci *      xdp_rxq_info structures?
9718c2ecf20Sopenharmony_ci * @netdev_notifier: Netdevice notifier.
9728c2ecf20Sopenharmony_ci * @mem_bar: The BAR that is mapped into membase.
9738c2ecf20Sopenharmony_ci * @reg_base: Offset from the start of the bar to the function control window.
9748c2ecf20Sopenharmony_ci * @monitor_work: Hardware monitor workitem
9758c2ecf20Sopenharmony_ci * @biu_lock: BIU (bus interface unit) lock
9768c2ecf20Sopenharmony_ci * @last_irq_cpu: Last CPU to handle a possible test interrupt.  This
9778c2ecf20Sopenharmony_ci *	field is used by efx_test_interrupts() to verify that an
9788c2ecf20Sopenharmony_ci *	interrupt has occurred.
9798c2ecf20Sopenharmony_ci * @stats_lock: Statistics update lock. Must be held when calling
9808c2ecf20Sopenharmony_ci *	efx_nic_type::{update,start,stop}_stats.
9818c2ecf20Sopenharmony_ci * @n_rx_noskb_drops: Count of RX packets dropped due to failure to allocate an skb
9828c2ecf20Sopenharmony_ci *
9838c2ecf20Sopenharmony_ci * This is stored in the private area of the &struct net_device.
9848c2ecf20Sopenharmony_ci */
9858c2ecf20Sopenharmony_cistruct efx_nic {
9868c2ecf20Sopenharmony_ci	/* The following fields should be written very rarely */
9878c2ecf20Sopenharmony_ci
9888c2ecf20Sopenharmony_ci	char name[IFNAMSIZ];
9898c2ecf20Sopenharmony_ci	struct list_head node;
9908c2ecf20Sopenharmony_ci	struct efx_nic *primary;
9918c2ecf20Sopenharmony_ci	struct list_head secondary_list;
9928c2ecf20Sopenharmony_ci	struct pci_dev *pci_dev;
9938c2ecf20Sopenharmony_ci	unsigned int port_num;
9948c2ecf20Sopenharmony_ci	const struct efx_nic_type *type;
9958c2ecf20Sopenharmony_ci	int legacy_irq;
9968c2ecf20Sopenharmony_ci	bool eeh_disabled_legacy_irq;
9978c2ecf20Sopenharmony_ci	struct workqueue_struct *workqueue;
9988c2ecf20Sopenharmony_ci	char workqueue_name[16];
9998c2ecf20Sopenharmony_ci	struct work_struct reset_work;
10008c2ecf20Sopenharmony_ci	resource_size_t membase_phys;
10018c2ecf20Sopenharmony_ci	void __iomem *membase;
10028c2ecf20Sopenharmony_ci
10038c2ecf20Sopenharmony_ci	unsigned int vi_stride;
10048c2ecf20Sopenharmony_ci
10058c2ecf20Sopenharmony_ci	enum efx_int_mode interrupt_mode;
10068c2ecf20Sopenharmony_ci	unsigned int timer_quantum_ns;
10078c2ecf20Sopenharmony_ci	unsigned int timer_max_ns;
10088c2ecf20Sopenharmony_ci	bool irq_rx_adaptive;
10098c2ecf20Sopenharmony_ci	bool irqs_hooked;
10108c2ecf20Sopenharmony_ci	unsigned int irq_mod_step_us;
10118c2ecf20Sopenharmony_ci	unsigned int irq_rx_moderation_us;
10128c2ecf20Sopenharmony_ci	u32 msg_enable;
10138c2ecf20Sopenharmony_ci
10148c2ecf20Sopenharmony_ci	enum nic_state state;
10158c2ecf20Sopenharmony_ci	unsigned long reset_pending;
10168c2ecf20Sopenharmony_ci
10178c2ecf20Sopenharmony_ci	struct efx_channel *channel[EFX_MAX_CHANNELS];
10188c2ecf20Sopenharmony_ci	struct efx_msi_context msi_context[EFX_MAX_CHANNELS];
10198c2ecf20Sopenharmony_ci	const struct efx_channel_type *
10208c2ecf20Sopenharmony_ci	extra_channel_type[EFX_MAX_EXTRA_CHANNELS];
10218c2ecf20Sopenharmony_ci
10228c2ecf20Sopenharmony_ci	unsigned int xdp_tx_queue_count;
10238c2ecf20Sopenharmony_ci	struct efx_tx_queue **xdp_tx_queues;
10248c2ecf20Sopenharmony_ci
10258c2ecf20Sopenharmony_ci	unsigned rxq_entries;
10268c2ecf20Sopenharmony_ci	unsigned txq_entries;
10278c2ecf20Sopenharmony_ci	unsigned int txq_stop_thresh;
10288c2ecf20Sopenharmony_ci	unsigned int txq_wake_thresh;
10298c2ecf20Sopenharmony_ci
10308c2ecf20Sopenharmony_ci	unsigned tx_dc_base;
10318c2ecf20Sopenharmony_ci	unsigned rx_dc_base;
10328c2ecf20Sopenharmony_ci	unsigned sram_lim_qw;
10338c2ecf20Sopenharmony_ci	unsigned next_buffer_table;
10348c2ecf20Sopenharmony_ci
10358c2ecf20Sopenharmony_ci	unsigned int max_channels;
10368c2ecf20Sopenharmony_ci	unsigned int max_vis;
10378c2ecf20Sopenharmony_ci	unsigned int max_tx_channels;
10388c2ecf20Sopenharmony_ci	unsigned n_channels;
10398c2ecf20Sopenharmony_ci	unsigned n_rx_channels;
10408c2ecf20Sopenharmony_ci	unsigned rss_spread;
10418c2ecf20Sopenharmony_ci	unsigned tx_channel_offset;
10428c2ecf20Sopenharmony_ci	unsigned n_tx_channels;
10438c2ecf20Sopenharmony_ci	unsigned n_extra_tx_channels;
10448c2ecf20Sopenharmony_ci	unsigned int tx_queues_per_channel;
10458c2ecf20Sopenharmony_ci	unsigned int n_xdp_channels;
10468c2ecf20Sopenharmony_ci	unsigned int xdp_channel_offset;
10478c2ecf20Sopenharmony_ci	unsigned int xdp_tx_per_channel;
10488c2ecf20Sopenharmony_ci	unsigned int rx_ip_align;
10498c2ecf20Sopenharmony_ci	unsigned int rx_dma_len;
10508c2ecf20Sopenharmony_ci	unsigned int rx_buffer_order;
10518c2ecf20Sopenharmony_ci	unsigned int rx_buffer_truesize;
10528c2ecf20Sopenharmony_ci	unsigned int rx_page_buf_step;
10538c2ecf20Sopenharmony_ci	unsigned int rx_bufs_per_page;
10548c2ecf20Sopenharmony_ci	unsigned int rx_pages_per_batch;
10558c2ecf20Sopenharmony_ci	unsigned int rx_prefix_size;
10568c2ecf20Sopenharmony_ci	int rx_packet_hash_offset;
10578c2ecf20Sopenharmony_ci	int rx_packet_len_offset;
10588c2ecf20Sopenharmony_ci	int rx_packet_ts_offset;
10598c2ecf20Sopenharmony_ci	bool rx_scatter;
10608c2ecf20Sopenharmony_ci	struct efx_rss_context rss_context;
10618c2ecf20Sopenharmony_ci	struct mutex rss_lock;
10628c2ecf20Sopenharmony_ci	u32 vport_id;
10638c2ecf20Sopenharmony_ci
10648c2ecf20Sopenharmony_ci	unsigned int_error_count;
10658c2ecf20Sopenharmony_ci	unsigned long int_error_expire;
10668c2ecf20Sopenharmony_ci
10678c2ecf20Sopenharmony_ci	bool must_realloc_vis;
10688c2ecf20Sopenharmony_ci	bool irq_soft_enabled;
10698c2ecf20Sopenharmony_ci	struct efx_buffer irq_status;
10708c2ecf20Sopenharmony_ci	unsigned irq_zero_count;
10718c2ecf20Sopenharmony_ci	unsigned irq_level;
10728c2ecf20Sopenharmony_ci	struct delayed_work selftest_work;
10738c2ecf20Sopenharmony_ci
10748c2ecf20Sopenharmony_ci#ifdef CONFIG_SFC_MTD
10758c2ecf20Sopenharmony_ci	struct list_head mtd_list;
10768c2ecf20Sopenharmony_ci#endif
10778c2ecf20Sopenharmony_ci
10788c2ecf20Sopenharmony_ci	void *nic_data;
10798c2ecf20Sopenharmony_ci	struct efx_mcdi_data *mcdi;
10808c2ecf20Sopenharmony_ci
10818c2ecf20Sopenharmony_ci	struct mutex mac_lock;
10828c2ecf20Sopenharmony_ci	struct work_struct mac_work;
10838c2ecf20Sopenharmony_ci	bool port_enabled;
10848c2ecf20Sopenharmony_ci
10858c2ecf20Sopenharmony_ci	bool mc_bist_for_other_fn;
10868c2ecf20Sopenharmony_ci	bool port_initialized;
10878c2ecf20Sopenharmony_ci	struct net_device *net_dev;
10888c2ecf20Sopenharmony_ci
10898c2ecf20Sopenharmony_ci	netdev_features_t fixed_features;
10908c2ecf20Sopenharmony_ci
10918c2ecf20Sopenharmony_ci	u16 num_mac_stats;
10928c2ecf20Sopenharmony_ci	struct efx_buffer stats_buffer;
10938c2ecf20Sopenharmony_ci	u64 rx_nodesc_drops_total;
10948c2ecf20Sopenharmony_ci	u64 rx_nodesc_drops_while_down;
10958c2ecf20Sopenharmony_ci	bool rx_nodesc_drops_prev_state;
10968c2ecf20Sopenharmony_ci
10978c2ecf20Sopenharmony_ci	unsigned int phy_type;
10988c2ecf20Sopenharmony_ci	void *phy_data;
10998c2ecf20Sopenharmony_ci	struct mdio_if_info mdio;
11008c2ecf20Sopenharmony_ci	unsigned int mdio_bus;
11018c2ecf20Sopenharmony_ci	enum efx_phy_mode phy_mode;
11028c2ecf20Sopenharmony_ci
11038c2ecf20Sopenharmony_ci	__ETHTOOL_DECLARE_LINK_MODE_MASK(link_advertising);
11048c2ecf20Sopenharmony_ci	u32 fec_config;
11058c2ecf20Sopenharmony_ci	struct efx_link_state link_state;
11068c2ecf20Sopenharmony_ci	unsigned int n_link_state_changes;
11078c2ecf20Sopenharmony_ci
11088c2ecf20Sopenharmony_ci	bool unicast_filter;
11098c2ecf20Sopenharmony_ci	union efx_multicast_hash multicast_hash;
11108c2ecf20Sopenharmony_ci	u8 wanted_fc;
11118c2ecf20Sopenharmony_ci	unsigned fc_disable;
11128c2ecf20Sopenharmony_ci
11138c2ecf20Sopenharmony_ci	atomic_t rx_reset;
11148c2ecf20Sopenharmony_ci	enum efx_loopback_mode loopback_mode;
11158c2ecf20Sopenharmony_ci	u64 loopback_modes;
11168c2ecf20Sopenharmony_ci
11178c2ecf20Sopenharmony_ci	void *loopback_selftest;
11188c2ecf20Sopenharmony_ci	/* We access loopback_selftest immediately before running XDP,
11198c2ecf20Sopenharmony_ci	 * so we want them next to each other.
11208c2ecf20Sopenharmony_ci	 */
11218c2ecf20Sopenharmony_ci	struct bpf_prog __rcu *xdp_prog;
11228c2ecf20Sopenharmony_ci
11238c2ecf20Sopenharmony_ci	struct rw_semaphore filter_sem;
11248c2ecf20Sopenharmony_ci	void *filter_state;
11258c2ecf20Sopenharmony_ci#ifdef CONFIG_RFS_ACCEL
11268c2ecf20Sopenharmony_ci	struct mutex rps_mutex;
11278c2ecf20Sopenharmony_ci	unsigned long rps_slot_map;
11288c2ecf20Sopenharmony_ci	struct efx_async_filter_insertion rps_slot[EFX_RPS_MAX_IN_FLIGHT];
11298c2ecf20Sopenharmony_ci	spinlock_t rps_hash_lock;
11308c2ecf20Sopenharmony_ci	struct hlist_head *rps_hash_table;
11318c2ecf20Sopenharmony_ci	u32 rps_next_id;
11328c2ecf20Sopenharmony_ci#endif
11338c2ecf20Sopenharmony_ci
11348c2ecf20Sopenharmony_ci	atomic_t active_queues;
11358c2ecf20Sopenharmony_ci	atomic_t rxq_flush_pending;
11368c2ecf20Sopenharmony_ci	atomic_t rxq_flush_outstanding;
11378c2ecf20Sopenharmony_ci	wait_queue_head_t flush_wq;
11388c2ecf20Sopenharmony_ci
11398c2ecf20Sopenharmony_ci#ifdef CONFIG_SFC_SRIOV
11408c2ecf20Sopenharmony_ci	unsigned vf_count;
11418c2ecf20Sopenharmony_ci	unsigned vf_init_count;
11428c2ecf20Sopenharmony_ci	unsigned vi_scale;
11438c2ecf20Sopenharmony_ci#endif
11448c2ecf20Sopenharmony_ci
11458c2ecf20Sopenharmony_ci	struct efx_ptp_data *ptp_data;
11468c2ecf20Sopenharmony_ci	bool ptp_warned;
11478c2ecf20Sopenharmony_ci
11488c2ecf20Sopenharmony_ci	char *vpd_sn;
11498c2ecf20Sopenharmony_ci	bool xdp_rxq_info_failed;
11508c2ecf20Sopenharmony_ci
11518c2ecf20Sopenharmony_ci	struct notifier_block netdev_notifier;
11528c2ecf20Sopenharmony_ci
11538c2ecf20Sopenharmony_ci	unsigned int mem_bar;
11548c2ecf20Sopenharmony_ci	u32 reg_base;
11558c2ecf20Sopenharmony_ci
11568c2ecf20Sopenharmony_ci	/* The following fields may be written more often */
11578c2ecf20Sopenharmony_ci
11588c2ecf20Sopenharmony_ci	struct delayed_work monitor_work ____cacheline_aligned_in_smp;
11598c2ecf20Sopenharmony_ci	spinlock_t biu_lock;
11608c2ecf20Sopenharmony_ci	int last_irq_cpu;
11618c2ecf20Sopenharmony_ci	spinlock_t stats_lock;
11628c2ecf20Sopenharmony_ci	atomic_t n_rx_noskb_drops;
11638c2ecf20Sopenharmony_ci};
11648c2ecf20Sopenharmony_ci
11658c2ecf20Sopenharmony_cistatic inline int efx_dev_registered(struct efx_nic *efx)
11668c2ecf20Sopenharmony_ci{
11678c2ecf20Sopenharmony_ci	return efx->net_dev->reg_state == NETREG_REGISTERED;
11688c2ecf20Sopenharmony_ci}
11698c2ecf20Sopenharmony_ci
11708c2ecf20Sopenharmony_cistatic inline unsigned int efx_port_num(struct efx_nic *efx)
11718c2ecf20Sopenharmony_ci{
11728c2ecf20Sopenharmony_ci	return efx->port_num;
11738c2ecf20Sopenharmony_ci}
11748c2ecf20Sopenharmony_ci
11758c2ecf20Sopenharmony_cistruct efx_mtd_partition {
11768c2ecf20Sopenharmony_ci	struct list_head node;
11778c2ecf20Sopenharmony_ci	struct mtd_info mtd;
11788c2ecf20Sopenharmony_ci	const char *dev_type_name;
11798c2ecf20Sopenharmony_ci	const char *type_name;
11808c2ecf20Sopenharmony_ci	char name[IFNAMSIZ + 20];
11818c2ecf20Sopenharmony_ci};
11828c2ecf20Sopenharmony_ci
11838c2ecf20Sopenharmony_cistruct efx_udp_tunnel {
11848c2ecf20Sopenharmony_ci#define TUNNEL_ENCAP_UDP_PORT_ENTRY_INVALID	0xffff
11858c2ecf20Sopenharmony_ci	u16 type; /* TUNNEL_ENCAP_UDP_PORT_ENTRY_foo, see mcdi_pcol.h */
11868c2ecf20Sopenharmony_ci	__be16 port;
11878c2ecf20Sopenharmony_ci};
11888c2ecf20Sopenharmony_ci
11898c2ecf20Sopenharmony_ci/**
11908c2ecf20Sopenharmony_ci * struct efx_nic_type - Efx device type definition
11918c2ecf20Sopenharmony_ci * @mem_bar: Get the memory BAR
11928c2ecf20Sopenharmony_ci * @mem_map_size: Get memory BAR mapped size
11938c2ecf20Sopenharmony_ci * @probe: Probe the controller
11948c2ecf20Sopenharmony_ci * @remove: Free resources allocated by probe()
11958c2ecf20Sopenharmony_ci * @init: Initialise the controller
11968c2ecf20Sopenharmony_ci * @dimension_resources: Dimension controller resources (buffer table,
11978c2ecf20Sopenharmony_ci *	and VIs once the available interrupt resources are clear)
11988c2ecf20Sopenharmony_ci * @fini: Shut down the controller
11998c2ecf20Sopenharmony_ci * @monitor: Periodic function for polling link state and hardware monitor
12008c2ecf20Sopenharmony_ci * @map_reset_reason: Map ethtool reset reason to a reset method
12018c2ecf20Sopenharmony_ci * @map_reset_flags: Map ethtool reset flags to a reset method, if possible
12028c2ecf20Sopenharmony_ci * @reset: Reset the controller hardware and possibly the PHY.  This will
12038c2ecf20Sopenharmony_ci *	be called while the controller is uninitialised.
12048c2ecf20Sopenharmony_ci * @probe_port: Probe the MAC and PHY
12058c2ecf20Sopenharmony_ci * @remove_port: Free resources allocated by probe_port()
12068c2ecf20Sopenharmony_ci * @handle_global_event: Handle a "global" event (may be %NULL)
12078c2ecf20Sopenharmony_ci * @fini_dmaq: Flush and finalise DMA queues (RX and TX queues)
12088c2ecf20Sopenharmony_ci * @prepare_flush: Prepare the hardware for flushing the DMA queues
12098c2ecf20Sopenharmony_ci *	(for Falcon architecture)
12108c2ecf20Sopenharmony_ci * @finish_flush: Clean up after flushing the DMA queues (for Falcon
12118c2ecf20Sopenharmony_ci *	architecture)
12128c2ecf20Sopenharmony_ci * @prepare_flr: Prepare for an FLR
12138c2ecf20Sopenharmony_ci * @finish_flr: Clean up after an FLR
12148c2ecf20Sopenharmony_ci * @describe_stats: Describe statistics for ethtool
12158c2ecf20Sopenharmony_ci * @update_stats: Update statistics not provided by event handling.
12168c2ecf20Sopenharmony_ci *	Either argument may be %NULL.
12178c2ecf20Sopenharmony_ci * @update_stats_atomic: Update statistics while in atomic context, if that
12188c2ecf20Sopenharmony_ci *	is more limiting than @update_stats.  Otherwise, leave %NULL and
12198c2ecf20Sopenharmony_ci *	driver core will call @update_stats.
12208c2ecf20Sopenharmony_ci * @start_stats: Start the regular fetching of statistics
12218c2ecf20Sopenharmony_ci * @pull_stats: Pull stats from the NIC and wait until they arrive.
12228c2ecf20Sopenharmony_ci * @stop_stats: Stop the regular fetching of statistics
12238c2ecf20Sopenharmony_ci * @push_irq_moderation: Apply interrupt moderation value
12248c2ecf20Sopenharmony_ci * @reconfigure_port: Push loopback/power/txdis changes to the MAC and PHY
12258c2ecf20Sopenharmony_ci * @prepare_enable_fc_tx: Prepare MAC to enable pause frame TX (may be %NULL)
12268c2ecf20Sopenharmony_ci * @reconfigure_mac: Push MAC address, MTU, flow control and filter settings
12278c2ecf20Sopenharmony_ci *	to the hardware.  Serialised by the mac_lock.
12288c2ecf20Sopenharmony_ci * @check_mac_fault: Check MAC fault state. True if fault present.
12298c2ecf20Sopenharmony_ci * @get_wol: Get WoL configuration from driver state
12308c2ecf20Sopenharmony_ci * @set_wol: Push WoL configuration to the NIC
12318c2ecf20Sopenharmony_ci * @resume_wol: Synchronise WoL state between driver and MC (e.g. after resume)
12328c2ecf20Sopenharmony_ci * @test_chip: Test registers.  May use efx_farch_test_registers(), and is
12338c2ecf20Sopenharmony_ci *	expected to reset the NIC.
12348c2ecf20Sopenharmony_ci * @test_nvram: Test validity of NVRAM contents
12358c2ecf20Sopenharmony_ci * @mcdi_request: Send an MCDI request with the given header and SDU.
12368c2ecf20Sopenharmony_ci *	The SDU length may be any value from 0 up to the protocol-
12378c2ecf20Sopenharmony_ci *	defined maximum, but its buffer will be padded to a multiple
12388c2ecf20Sopenharmony_ci *	of 4 bytes.
12398c2ecf20Sopenharmony_ci * @mcdi_poll_response: Test whether an MCDI response is available.
12408c2ecf20Sopenharmony_ci * @mcdi_read_response: Read the MCDI response PDU.  The offset will
12418c2ecf20Sopenharmony_ci *	be a multiple of 4.  The length may not be, but the buffer
12428c2ecf20Sopenharmony_ci *	will be padded so it is safe to round up.
12438c2ecf20Sopenharmony_ci * @mcdi_poll_reboot: Test whether the MCDI has rebooted.  If so,
12448c2ecf20Sopenharmony_ci *	return an appropriate error code for aborting any current
12458c2ecf20Sopenharmony_ci *	request; otherwise return 0.
12468c2ecf20Sopenharmony_ci * @irq_enable_master: Enable IRQs on the NIC.  Each event queue must
12478c2ecf20Sopenharmony_ci *	be separately enabled after this.
12488c2ecf20Sopenharmony_ci * @irq_test_generate: Generate a test IRQ
12498c2ecf20Sopenharmony_ci * @irq_disable_non_ev: Disable non-event IRQs on the NIC.  Each event
12508c2ecf20Sopenharmony_ci *	queue must be separately disabled before this.
12518c2ecf20Sopenharmony_ci * @irq_handle_msi: Handle MSI for a channel.  The @dev_id argument is
12528c2ecf20Sopenharmony_ci *	a pointer to the &struct efx_msi_context for the channel.
12538c2ecf20Sopenharmony_ci * @irq_handle_legacy: Handle legacy interrupt.  The @dev_id argument
12548c2ecf20Sopenharmony_ci *	is a pointer to the &struct efx_nic.
12558c2ecf20Sopenharmony_ci * @tx_probe: Allocate resources for TX queue (and select TXQ type)
12568c2ecf20Sopenharmony_ci * @tx_init: Initialise TX queue on the NIC
12578c2ecf20Sopenharmony_ci * @tx_remove: Free resources for TX queue
12588c2ecf20Sopenharmony_ci * @tx_write: Write TX descriptors and doorbell
12598c2ecf20Sopenharmony_ci * @tx_enqueue: Add an SKB to TX queue
12608c2ecf20Sopenharmony_ci * @rx_push_rss_config: Write RSS hash key and indirection table to the NIC
12618c2ecf20Sopenharmony_ci * @rx_pull_rss_config: Read RSS hash key and indirection table back from the NIC
12628c2ecf20Sopenharmony_ci * @rx_push_rss_context_config: Write RSS hash key and indirection table for
12638c2ecf20Sopenharmony_ci *	user RSS context to the NIC
12648c2ecf20Sopenharmony_ci * @rx_pull_rss_context_config: Read RSS hash key and indirection table for user
12658c2ecf20Sopenharmony_ci *	RSS context back from the NIC
12668c2ecf20Sopenharmony_ci * @rx_probe: Allocate resources for RX queue
12678c2ecf20Sopenharmony_ci * @rx_init: Initialise RX queue on the NIC
12688c2ecf20Sopenharmony_ci * @rx_remove: Free resources for RX queue
12698c2ecf20Sopenharmony_ci * @rx_write: Write RX descriptors and doorbell
12708c2ecf20Sopenharmony_ci * @rx_defer_refill: Generate a refill reminder event
12718c2ecf20Sopenharmony_ci * @rx_packet: Receive the queued RX buffer on a channel
12728c2ecf20Sopenharmony_ci * @rx_buf_hash_valid: Determine whether the RX prefix contains a valid hash
12738c2ecf20Sopenharmony_ci * @ev_probe: Allocate resources for event queue
12748c2ecf20Sopenharmony_ci * @ev_init: Initialise event queue on the NIC
12758c2ecf20Sopenharmony_ci * @ev_fini: Deinitialise event queue on the NIC
12768c2ecf20Sopenharmony_ci * @ev_remove: Free resources for event queue
12778c2ecf20Sopenharmony_ci * @ev_process: Process events for a queue, up to the given NAPI quota
12788c2ecf20Sopenharmony_ci * @ev_read_ack: Acknowledge read events on a queue, rearming its IRQ
12798c2ecf20Sopenharmony_ci * @ev_test_generate: Generate a test event
12808c2ecf20Sopenharmony_ci * @filter_table_probe: Probe filter capabilities and set up filter software state
12818c2ecf20Sopenharmony_ci * @filter_table_restore: Restore filters removed from hardware
12828c2ecf20Sopenharmony_ci * @filter_table_remove: Remove filters from hardware and tear down software state
12838c2ecf20Sopenharmony_ci * @filter_update_rx_scatter: Update filters after change to rx scatter setting
12848c2ecf20Sopenharmony_ci * @filter_insert: add or replace a filter
12858c2ecf20Sopenharmony_ci * @filter_remove_safe: remove a filter by ID, carefully
12868c2ecf20Sopenharmony_ci * @filter_get_safe: retrieve a filter by ID, carefully
12878c2ecf20Sopenharmony_ci * @filter_clear_rx: Remove all RX filters whose priority is less than or
12888c2ecf20Sopenharmony_ci *	equal to the given priority and is not %EFX_FILTER_PRI_AUTO
12898c2ecf20Sopenharmony_ci * @filter_count_rx_used: Get the number of filters in use at a given priority
12908c2ecf20Sopenharmony_ci * @filter_get_rx_id_limit: Get maximum value of a filter id, plus 1
12918c2ecf20Sopenharmony_ci * @filter_get_rx_ids: Get list of RX filters at a given priority
12928c2ecf20Sopenharmony_ci * @filter_rfs_expire_one: Consider expiring a filter inserted for RFS.
12938c2ecf20Sopenharmony_ci *	This must check whether the specified table entry is used by RFS
12948c2ecf20Sopenharmony_ci *	and that rps_may_expire_flow() returns true for it.
12958c2ecf20Sopenharmony_ci * @mtd_probe: Probe and add MTD partitions associated with this net device,
12968c2ecf20Sopenharmony_ci *	 using efx_mtd_add()
12978c2ecf20Sopenharmony_ci * @mtd_rename: Set an MTD partition name using the net device name
12988c2ecf20Sopenharmony_ci * @mtd_read: Read from an MTD partition
12998c2ecf20Sopenharmony_ci * @mtd_erase: Erase part of an MTD partition
13008c2ecf20Sopenharmony_ci * @mtd_write: Write to an MTD partition
13018c2ecf20Sopenharmony_ci * @mtd_sync: Wait for write-back to complete on MTD partition.  This
13028c2ecf20Sopenharmony_ci *	also notifies the driver that a writer has finished using this
13038c2ecf20Sopenharmony_ci *	partition.
13048c2ecf20Sopenharmony_ci * @ptp_write_host_time: Send host time to MC as part of sync protocol
13058c2ecf20Sopenharmony_ci * @ptp_set_ts_sync_events: Enable or disable sync events for inline RX
13068c2ecf20Sopenharmony_ci *	timestamping, possibly only temporarily for the purposes of a reset.
13078c2ecf20Sopenharmony_ci * @ptp_set_ts_config: Set hardware timestamp configuration.  The flags
13088c2ecf20Sopenharmony_ci *	and tx_type will already have been validated but this operation
13098c2ecf20Sopenharmony_ci *	must validate and update rx_filter.
13108c2ecf20Sopenharmony_ci * @get_phys_port_id: Get the underlying physical port id.
13118c2ecf20Sopenharmony_ci * @set_mac_address: Set the MAC address of the device
13128c2ecf20Sopenharmony_ci * @tso_versions: Returns mask of firmware-assisted TSO versions supported.
13138c2ecf20Sopenharmony_ci *	If %NULL, then device does not support any TSO version.
13148c2ecf20Sopenharmony_ci * @udp_tnl_push_ports: Push the list of UDP tunnel ports to the NIC if required.
13158c2ecf20Sopenharmony_ci * @udp_tnl_has_port: Check if a port has been added as UDP tunnel
13168c2ecf20Sopenharmony_ci * @print_additional_fwver: Dump NIC-specific additional FW version info
13178c2ecf20Sopenharmony_ci * @sensor_event: Handle a sensor event from MCDI
13188c2ecf20Sopenharmony_ci * @revision: Hardware architecture revision
13198c2ecf20Sopenharmony_ci * @txd_ptr_tbl_base: TX descriptor ring base address
13208c2ecf20Sopenharmony_ci * @rxd_ptr_tbl_base: RX descriptor ring base address
13218c2ecf20Sopenharmony_ci * @buf_tbl_base: Buffer table base address
13228c2ecf20Sopenharmony_ci * @evq_ptr_tbl_base: Event queue pointer table base address
13238c2ecf20Sopenharmony_ci * @evq_rptr_tbl_base: Event queue read-pointer table base address
13248c2ecf20Sopenharmony_ci * @max_dma_mask: Maximum possible DMA mask
13258c2ecf20Sopenharmony_ci * @rx_prefix_size: Size of RX prefix before packet data
13268c2ecf20Sopenharmony_ci * @rx_hash_offset: Offset of RX flow hash within prefix
13278c2ecf20Sopenharmony_ci * @rx_ts_offset: Offset of timestamp within prefix
13288c2ecf20Sopenharmony_ci * @rx_buffer_padding: Size of padding at end of RX packet
13298c2ecf20Sopenharmony_ci * @can_rx_scatter: NIC is able to scatter packets to multiple buffers
13308c2ecf20Sopenharmony_ci * @always_rx_scatter: NIC will always scatter packets to multiple buffers
13318c2ecf20Sopenharmony_ci * @option_descriptors: NIC supports TX option descriptors
13328c2ecf20Sopenharmony_ci * @min_interrupt_mode: Lowest capability interrupt mode supported
13338c2ecf20Sopenharmony_ci *	from &enum efx_int_mode.
13348c2ecf20Sopenharmony_ci * @timer_period_max: Maximum period of interrupt timer (in ticks)
13358c2ecf20Sopenharmony_ci * @offload_features: net_device feature flags for protocol offload
13368c2ecf20Sopenharmony_ci *	features implemented in hardware
13378c2ecf20Sopenharmony_ci * @mcdi_max_ver: Maximum MCDI version supported
13388c2ecf20Sopenharmony_ci * @hwtstamp_filters: Mask of hardware timestamp filter types supported
13398c2ecf20Sopenharmony_ci */
13408c2ecf20Sopenharmony_cistruct efx_nic_type {
13418c2ecf20Sopenharmony_ci	bool is_vf;
13428c2ecf20Sopenharmony_ci	unsigned int (*mem_bar)(struct efx_nic *efx);
13438c2ecf20Sopenharmony_ci	unsigned int (*mem_map_size)(struct efx_nic *efx);
13448c2ecf20Sopenharmony_ci	int (*probe)(struct efx_nic *efx);
13458c2ecf20Sopenharmony_ci	void (*remove)(struct efx_nic *efx);
13468c2ecf20Sopenharmony_ci	int (*init)(struct efx_nic *efx);
13478c2ecf20Sopenharmony_ci	int (*dimension_resources)(struct efx_nic *efx);
13488c2ecf20Sopenharmony_ci	void (*fini)(struct efx_nic *efx);
13498c2ecf20Sopenharmony_ci	void (*monitor)(struct efx_nic *efx);
13508c2ecf20Sopenharmony_ci	enum reset_type (*map_reset_reason)(enum reset_type reason);
13518c2ecf20Sopenharmony_ci	int (*map_reset_flags)(u32 *flags);
13528c2ecf20Sopenharmony_ci	int (*reset)(struct efx_nic *efx, enum reset_type method);
13538c2ecf20Sopenharmony_ci	int (*probe_port)(struct efx_nic *efx);
13548c2ecf20Sopenharmony_ci	void (*remove_port)(struct efx_nic *efx);
13558c2ecf20Sopenharmony_ci	bool (*handle_global_event)(struct efx_channel *channel, efx_qword_t *);
13568c2ecf20Sopenharmony_ci	int (*fini_dmaq)(struct efx_nic *efx);
13578c2ecf20Sopenharmony_ci	void (*prepare_flush)(struct efx_nic *efx);
13588c2ecf20Sopenharmony_ci	void (*finish_flush)(struct efx_nic *efx);
13598c2ecf20Sopenharmony_ci	void (*prepare_flr)(struct efx_nic *efx);
13608c2ecf20Sopenharmony_ci	void (*finish_flr)(struct efx_nic *efx);
13618c2ecf20Sopenharmony_ci	size_t (*describe_stats)(struct efx_nic *efx, u8 *names);
13628c2ecf20Sopenharmony_ci	size_t (*update_stats)(struct efx_nic *efx, u64 *full_stats,
13638c2ecf20Sopenharmony_ci			       struct rtnl_link_stats64 *core_stats);
13648c2ecf20Sopenharmony_ci	size_t (*update_stats_atomic)(struct efx_nic *efx, u64 *full_stats,
13658c2ecf20Sopenharmony_ci				      struct rtnl_link_stats64 *core_stats);
13668c2ecf20Sopenharmony_ci	void (*start_stats)(struct efx_nic *efx);
13678c2ecf20Sopenharmony_ci	void (*pull_stats)(struct efx_nic *efx);
13688c2ecf20Sopenharmony_ci	void (*stop_stats)(struct efx_nic *efx);
13698c2ecf20Sopenharmony_ci	void (*push_irq_moderation)(struct efx_channel *channel);
13708c2ecf20Sopenharmony_ci	int (*reconfigure_port)(struct efx_nic *efx);
13718c2ecf20Sopenharmony_ci	void (*prepare_enable_fc_tx)(struct efx_nic *efx);
13728c2ecf20Sopenharmony_ci	int (*reconfigure_mac)(struct efx_nic *efx, bool mtu_only);
13738c2ecf20Sopenharmony_ci	bool (*check_mac_fault)(struct efx_nic *efx);
13748c2ecf20Sopenharmony_ci	void (*get_wol)(struct efx_nic *efx, struct ethtool_wolinfo *wol);
13758c2ecf20Sopenharmony_ci	int (*set_wol)(struct efx_nic *efx, u32 type);
13768c2ecf20Sopenharmony_ci	void (*resume_wol)(struct efx_nic *efx);
13778c2ecf20Sopenharmony_ci	unsigned int (*check_caps)(const struct efx_nic *efx,
13788c2ecf20Sopenharmony_ci				   u8 flag,
13798c2ecf20Sopenharmony_ci				   u32 offset);
13808c2ecf20Sopenharmony_ci	int (*test_chip)(struct efx_nic *efx, struct efx_self_tests *tests);
13818c2ecf20Sopenharmony_ci	int (*test_nvram)(struct efx_nic *efx);
13828c2ecf20Sopenharmony_ci	void (*mcdi_request)(struct efx_nic *efx,
13838c2ecf20Sopenharmony_ci			     const efx_dword_t *hdr, size_t hdr_len,
13848c2ecf20Sopenharmony_ci			     const efx_dword_t *sdu, size_t sdu_len);
13858c2ecf20Sopenharmony_ci	bool (*mcdi_poll_response)(struct efx_nic *efx);
13868c2ecf20Sopenharmony_ci	void (*mcdi_read_response)(struct efx_nic *efx, efx_dword_t *pdu,
13878c2ecf20Sopenharmony_ci				   size_t pdu_offset, size_t pdu_len);
13888c2ecf20Sopenharmony_ci	int (*mcdi_poll_reboot)(struct efx_nic *efx);
13898c2ecf20Sopenharmony_ci	void (*mcdi_reboot_detected)(struct efx_nic *efx);
13908c2ecf20Sopenharmony_ci	void (*irq_enable_master)(struct efx_nic *efx);
13918c2ecf20Sopenharmony_ci	int (*irq_test_generate)(struct efx_nic *efx);
13928c2ecf20Sopenharmony_ci	void (*irq_disable_non_ev)(struct efx_nic *efx);
13938c2ecf20Sopenharmony_ci	irqreturn_t (*irq_handle_msi)(int irq, void *dev_id);
13948c2ecf20Sopenharmony_ci	irqreturn_t (*irq_handle_legacy)(int irq, void *dev_id);
13958c2ecf20Sopenharmony_ci	int (*tx_probe)(struct efx_tx_queue *tx_queue);
13968c2ecf20Sopenharmony_ci	void (*tx_init)(struct efx_tx_queue *tx_queue);
13978c2ecf20Sopenharmony_ci	void (*tx_remove)(struct efx_tx_queue *tx_queue);
13988c2ecf20Sopenharmony_ci	void (*tx_write)(struct efx_tx_queue *tx_queue);
13998c2ecf20Sopenharmony_ci	netdev_tx_t (*tx_enqueue)(struct efx_tx_queue *tx_queue, struct sk_buff *skb);
14008c2ecf20Sopenharmony_ci	unsigned int (*tx_limit_len)(struct efx_tx_queue *tx_queue,
14018c2ecf20Sopenharmony_ci				     dma_addr_t dma_addr, unsigned int len);
14028c2ecf20Sopenharmony_ci	int (*rx_push_rss_config)(struct efx_nic *efx, bool user,
14038c2ecf20Sopenharmony_ci				  const u32 *rx_indir_table, const u8 *key);
14048c2ecf20Sopenharmony_ci	int (*rx_pull_rss_config)(struct efx_nic *efx);
14058c2ecf20Sopenharmony_ci	int (*rx_push_rss_context_config)(struct efx_nic *efx,
14068c2ecf20Sopenharmony_ci					  struct efx_rss_context *ctx,
14078c2ecf20Sopenharmony_ci					  const u32 *rx_indir_table,
14088c2ecf20Sopenharmony_ci					  const u8 *key);
14098c2ecf20Sopenharmony_ci	int (*rx_pull_rss_context_config)(struct efx_nic *efx,
14108c2ecf20Sopenharmony_ci					  struct efx_rss_context *ctx);
14118c2ecf20Sopenharmony_ci	void (*rx_restore_rss_contexts)(struct efx_nic *efx);
14128c2ecf20Sopenharmony_ci	int (*rx_probe)(struct efx_rx_queue *rx_queue);
14138c2ecf20Sopenharmony_ci	void (*rx_init)(struct efx_rx_queue *rx_queue);
14148c2ecf20Sopenharmony_ci	void (*rx_remove)(struct efx_rx_queue *rx_queue);
14158c2ecf20Sopenharmony_ci	void (*rx_write)(struct efx_rx_queue *rx_queue);
14168c2ecf20Sopenharmony_ci	void (*rx_defer_refill)(struct efx_rx_queue *rx_queue);
14178c2ecf20Sopenharmony_ci	void (*rx_packet)(struct efx_channel *channel);
14188c2ecf20Sopenharmony_ci	bool (*rx_buf_hash_valid)(const u8 *prefix);
14198c2ecf20Sopenharmony_ci	int (*ev_probe)(struct efx_channel *channel);
14208c2ecf20Sopenharmony_ci	int (*ev_init)(struct efx_channel *channel);
14218c2ecf20Sopenharmony_ci	void (*ev_fini)(struct efx_channel *channel);
14228c2ecf20Sopenharmony_ci	void (*ev_remove)(struct efx_channel *channel);
14238c2ecf20Sopenharmony_ci	int (*ev_process)(struct efx_channel *channel, int quota);
14248c2ecf20Sopenharmony_ci	void (*ev_read_ack)(struct efx_channel *channel);
14258c2ecf20Sopenharmony_ci	void (*ev_test_generate)(struct efx_channel *channel);
14268c2ecf20Sopenharmony_ci	int (*filter_table_probe)(struct efx_nic *efx);
14278c2ecf20Sopenharmony_ci	void (*filter_table_restore)(struct efx_nic *efx);
14288c2ecf20Sopenharmony_ci	void (*filter_table_remove)(struct efx_nic *efx);
14298c2ecf20Sopenharmony_ci	void (*filter_update_rx_scatter)(struct efx_nic *efx);
14308c2ecf20Sopenharmony_ci	s32 (*filter_insert)(struct efx_nic *efx,
14318c2ecf20Sopenharmony_ci			     struct efx_filter_spec *spec, bool replace);
14328c2ecf20Sopenharmony_ci	int (*filter_remove_safe)(struct efx_nic *efx,
14338c2ecf20Sopenharmony_ci				  enum efx_filter_priority priority,
14348c2ecf20Sopenharmony_ci				  u32 filter_id);
14358c2ecf20Sopenharmony_ci	int (*filter_get_safe)(struct efx_nic *efx,
14368c2ecf20Sopenharmony_ci			       enum efx_filter_priority priority,
14378c2ecf20Sopenharmony_ci			       u32 filter_id, struct efx_filter_spec *);
14388c2ecf20Sopenharmony_ci	int (*filter_clear_rx)(struct efx_nic *efx,
14398c2ecf20Sopenharmony_ci			       enum efx_filter_priority priority);
14408c2ecf20Sopenharmony_ci	u32 (*filter_count_rx_used)(struct efx_nic *efx,
14418c2ecf20Sopenharmony_ci				    enum efx_filter_priority priority);
14428c2ecf20Sopenharmony_ci	u32 (*filter_get_rx_id_limit)(struct efx_nic *efx);
14438c2ecf20Sopenharmony_ci	s32 (*filter_get_rx_ids)(struct efx_nic *efx,
14448c2ecf20Sopenharmony_ci				 enum efx_filter_priority priority,
14458c2ecf20Sopenharmony_ci				 u32 *buf, u32 size);
14468c2ecf20Sopenharmony_ci#ifdef CONFIG_RFS_ACCEL
14478c2ecf20Sopenharmony_ci	bool (*filter_rfs_expire_one)(struct efx_nic *efx, u32 flow_id,
14488c2ecf20Sopenharmony_ci				      unsigned int index);
14498c2ecf20Sopenharmony_ci#endif
14508c2ecf20Sopenharmony_ci#ifdef CONFIG_SFC_MTD
14518c2ecf20Sopenharmony_ci	int (*mtd_probe)(struct efx_nic *efx);
14528c2ecf20Sopenharmony_ci	void (*mtd_rename)(struct efx_mtd_partition *part);
14538c2ecf20Sopenharmony_ci	int (*mtd_read)(struct mtd_info *mtd, loff_t start, size_t len,
14548c2ecf20Sopenharmony_ci			size_t *retlen, u8 *buffer);
14558c2ecf20Sopenharmony_ci	int (*mtd_erase)(struct mtd_info *mtd, loff_t start, size_t len);
14568c2ecf20Sopenharmony_ci	int (*mtd_write)(struct mtd_info *mtd, loff_t start, size_t len,
14578c2ecf20Sopenharmony_ci			 size_t *retlen, const u8 *buffer);
14588c2ecf20Sopenharmony_ci	int (*mtd_sync)(struct mtd_info *mtd);
14598c2ecf20Sopenharmony_ci#endif
14608c2ecf20Sopenharmony_ci	void (*ptp_write_host_time)(struct efx_nic *efx, u32 host_time);
14618c2ecf20Sopenharmony_ci	int (*ptp_set_ts_sync_events)(struct efx_nic *efx, bool en, bool temp);
14628c2ecf20Sopenharmony_ci	int (*ptp_set_ts_config)(struct efx_nic *efx,
14638c2ecf20Sopenharmony_ci				 struct hwtstamp_config *init);
14648c2ecf20Sopenharmony_ci	int (*sriov_configure)(struct efx_nic *efx, int num_vfs);
14658c2ecf20Sopenharmony_ci	int (*vlan_rx_add_vid)(struct efx_nic *efx, __be16 proto, u16 vid);
14668c2ecf20Sopenharmony_ci	int (*vlan_rx_kill_vid)(struct efx_nic *efx, __be16 proto, u16 vid);
14678c2ecf20Sopenharmony_ci	int (*get_phys_port_id)(struct efx_nic *efx,
14688c2ecf20Sopenharmony_ci				struct netdev_phys_item_id *ppid);
14698c2ecf20Sopenharmony_ci	int (*sriov_init)(struct efx_nic *efx);
14708c2ecf20Sopenharmony_ci	void (*sriov_fini)(struct efx_nic *efx);
14718c2ecf20Sopenharmony_ci	bool (*sriov_wanted)(struct efx_nic *efx);
14728c2ecf20Sopenharmony_ci	void (*sriov_reset)(struct efx_nic *efx);
14738c2ecf20Sopenharmony_ci	void (*sriov_flr)(struct efx_nic *efx, unsigned vf_i);
14748c2ecf20Sopenharmony_ci	int (*sriov_set_vf_mac)(struct efx_nic *efx, int vf_i, u8 *mac);
14758c2ecf20Sopenharmony_ci	int (*sriov_set_vf_vlan)(struct efx_nic *efx, int vf_i, u16 vlan,
14768c2ecf20Sopenharmony_ci				 u8 qos);
14778c2ecf20Sopenharmony_ci	int (*sriov_set_vf_spoofchk)(struct efx_nic *efx, int vf_i,
14788c2ecf20Sopenharmony_ci				     bool spoofchk);
14798c2ecf20Sopenharmony_ci	int (*sriov_get_vf_config)(struct efx_nic *efx, int vf_i,
14808c2ecf20Sopenharmony_ci				   struct ifla_vf_info *ivi);
14818c2ecf20Sopenharmony_ci	int (*sriov_set_vf_link_state)(struct efx_nic *efx, int vf_i,
14828c2ecf20Sopenharmony_ci				       int link_state);
14838c2ecf20Sopenharmony_ci	int (*vswitching_probe)(struct efx_nic *efx);
14848c2ecf20Sopenharmony_ci	int (*vswitching_restore)(struct efx_nic *efx);
14858c2ecf20Sopenharmony_ci	void (*vswitching_remove)(struct efx_nic *efx);
14868c2ecf20Sopenharmony_ci	int (*get_mac_address)(struct efx_nic *efx, unsigned char *perm_addr);
14878c2ecf20Sopenharmony_ci	int (*set_mac_address)(struct efx_nic *efx);
14888c2ecf20Sopenharmony_ci	u32 (*tso_versions)(struct efx_nic *efx);
14898c2ecf20Sopenharmony_ci	int (*udp_tnl_push_ports)(struct efx_nic *efx);
14908c2ecf20Sopenharmony_ci	bool (*udp_tnl_has_port)(struct efx_nic *efx, __be16 port);
14918c2ecf20Sopenharmony_ci	size_t (*print_additional_fwver)(struct efx_nic *efx, char *buf,
14928c2ecf20Sopenharmony_ci					 size_t len);
14938c2ecf20Sopenharmony_ci	void (*sensor_event)(struct efx_nic *efx, efx_qword_t *ev);
14948c2ecf20Sopenharmony_ci
14958c2ecf20Sopenharmony_ci	int revision;
14968c2ecf20Sopenharmony_ci	unsigned int txd_ptr_tbl_base;
14978c2ecf20Sopenharmony_ci	unsigned int rxd_ptr_tbl_base;
14988c2ecf20Sopenharmony_ci	unsigned int buf_tbl_base;
14998c2ecf20Sopenharmony_ci	unsigned int evq_ptr_tbl_base;
15008c2ecf20Sopenharmony_ci	unsigned int evq_rptr_tbl_base;
15018c2ecf20Sopenharmony_ci	u64 max_dma_mask;
15028c2ecf20Sopenharmony_ci	unsigned int rx_prefix_size;
15038c2ecf20Sopenharmony_ci	unsigned int rx_hash_offset;
15048c2ecf20Sopenharmony_ci	unsigned int rx_ts_offset;
15058c2ecf20Sopenharmony_ci	unsigned int rx_buffer_padding;
15068c2ecf20Sopenharmony_ci	bool can_rx_scatter;
15078c2ecf20Sopenharmony_ci	bool always_rx_scatter;
15088c2ecf20Sopenharmony_ci	bool option_descriptors;
15098c2ecf20Sopenharmony_ci	unsigned int min_interrupt_mode;
15108c2ecf20Sopenharmony_ci	unsigned int timer_period_max;
15118c2ecf20Sopenharmony_ci	netdev_features_t offload_features;
15128c2ecf20Sopenharmony_ci	int mcdi_max_ver;
15138c2ecf20Sopenharmony_ci	unsigned int max_rx_ip_filters;
15148c2ecf20Sopenharmony_ci	u32 hwtstamp_filters;
15158c2ecf20Sopenharmony_ci	unsigned int rx_hash_key_size;
15168c2ecf20Sopenharmony_ci};
15178c2ecf20Sopenharmony_ci
15188c2ecf20Sopenharmony_ci/**************************************************************************
15198c2ecf20Sopenharmony_ci *
15208c2ecf20Sopenharmony_ci * Prototypes and inline functions
15218c2ecf20Sopenharmony_ci *
15228c2ecf20Sopenharmony_ci *************************************************************************/
15238c2ecf20Sopenharmony_ci
15248c2ecf20Sopenharmony_cistatic inline struct efx_channel *
15258c2ecf20Sopenharmony_ciefx_get_channel(struct efx_nic *efx, unsigned index)
15268c2ecf20Sopenharmony_ci{
15278c2ecf20Sopenharmony_ci	EFX_WARN_ON_ONCE_PARANOID(index >= efx->n_channels);
15288c2ecf20Sopenharmony_ci	return efx->channel[index];
15298c2ecf20Sopenharmony_ci}
15308c2ecf20Sopenharmony_ci
15318c2ecf20Sopenharmony_ci/* Iterate over all used channels */
15328c2ecf20Sopenharmony_ci#define efx_for_each_channel(_channel, _efx)				\
15338c2ecf20Sopenharmony_ci	for (_channel = (_efx)->channel[0];				\
15348c2ecf20Sopenharmony_ci	     _channel;							\
15358c2ecf20Sopenharmony_ci	     _channel = (_channel->channel + 1 < (_efx)->n_channels) ?	\
15368c2ecf20Sopenharmony_ci		     (_efx)->channel[_channel->channel + 1] : NULL)
15378c2ecf20Sopenharmony_ci
15388c2ecf20Sopenharmony_ci/* Iterate over all used channels in reverse */
15398c2ecf20Sopenharmony_ci#define efx_for_each_channel_rev(_channel, _efx)			\
15408c2ecf20Sopenharmony_ci	for (_channel = (_efx)->channel[(_efx)->n_channels - 1];	\
15418c2ecf20Sopenharmony_ci	     _channel;							\
15428c2ecf20Sopenharmony_ci	     _channel = _channel->channel ?				\
15438c2ecf20Sopenharmony_ci		     (_efx)->channel[_channel->channel - 1] : NULL)
15448c2ecf20Sopenharmony_ci
15458c2ecf20Sopenharmony_cistatic inline struct efx_channel *
15468c2ecf20Sopenharmony_ciefx_get_tx_channel(struct efx_nic *efx, unsigned int index)
15478c2ecf20Sopenharmony_ci{
15488c2ecf20Sopenharmony_ci	EFX_WARN_ON_ONCE_PARANOID(index >= efx->n_tx_channels);
15498c2ecf20Sopenharmony_ci	return efx->channel[efx->tx_channel_offset + index];
15508c2ecf20Sopenharmony_ci}
15518c2ecf20Sopenharmony_ci
15528c2ecf20Sopenharmony_cistatic inline struct efx_channel *
15538c2ecf20Sopenharmony_ciefx_get_xdp_channel(struct efx_nic *efx, unsigned int index)
15548c2ecf20Sopenharmony_ci{
15558c2ecf20Sopenharmony_ci	EFX_WARN_ON_ONCE_PARANOID(index >= efx->n_xdp_channels);
15568c2ecf20Sopenharmony_ci	return efx->channel[efx->xdp_channel_offset + index];
15578c2ecf20Sopenharmony_ci}
15588c2ecf20Sopenharmony_ci
15598c2ecf20Sopenharmony_cistatic inline bool efx_channel_is_xdp_tx(struct efx_channel *channel)
15608c2ecf20Sopenharmony_ci{
15618c2ecf20Sopenharmony_ci	return channel->channel - channel->efx->xdp_channel_offset <
15628c2ecf20Sopenharmony_ci	       channel->efx->n_xdp_channels;
15638c2ecf20Sopenharmony_ci}
15648c2ecf20Sopenharmony_ci
15658c2ecf20Sopenharmony_cistatic inline bool efx_channel_has_tx_queues(struct efx_channel *channel)
15668c2ecf20Sopenharmony_ci{
15678c2ecf20Sopenharmony_ci	return channel && channel->channel >= channel->efx->tx_channel_offset;
15688c2ecf20Sopenharmony_ci}
15698c2ecf20Sopenharmony_ci
15708c2ecf20Sopenharmony_cistatic inline unsigned int efx_channel_num_tx_queues(struct efx_channel *channel)
15718c2ecf20Sopenharmony_ci{
15728c2ecf20Sopenharmony_ci	if (efx_channel_is_xdp_tx(channel))
15738c2ecf20Sopenharmony_ci		return channel->efx->xdp_tx_per_channel;
15748c2ecf20Sopenharmony_ci	return channel->efx->tx_queues_per_channel;
15758c2ecf20Sopenharmony_ci}
15768c2ecf20Sopenharmony_ci
15778c2ecf20Sopenharmony_cistatic inline struct efx_tx_queue *
15788c2ecf20Sopenharmony_ciefx_channel_get_tx_queue(struct efx_channel *channel, unsigned int type)
15798c2ecf20Sopenharmony_ci{
15808c2ecf20Sopenharmony_ci	EFX_WARN_ON_ONCE_PARANOID(type >= EFX_TXQ_TYPES);
15818c2ecf20Sopenharmony_ci	return channel->tx_queue_by_type[type];
15828c2ecf20Sopenharmony_ci}
15838c2ecf20Sopenharmony_ci
15848c2ecf20Sopenharmony_cistatic inline struct efx_tx_queue *
15858c2ecf20Sopenharmony_ciefx_get_tx_queue(struct efx_nic *efx, unsigned int index, unsigned int type)
15868c2ecf20Sopenharmony_ci{
15878c2ecf20Sopenharmony_ci	struct efx_channel *channel = efx_get_tx_channel(efx, index);
15888c2ecf20Sopenharmony_ci
15898c2ecf20Sopenharmony_ci	return efx_channel_get_tx_queue(channel, type);
15908c2ecf20Sopenharmony_ci}
15918c2ecf20Sopenharmony_ci
15928c2ecf20Sopenharmony_ci/* Iterate over all TX queues belonging to a channel */
15938c2ecf20Sopenharmony_ci#define efx_for_each_channel_tx_queue(_tx_queue, _channel)		\
15948c2ecf20Sopenharmony_ci	if (!efx_channel_has_tx_queues(_channel))			\
15958c2ecf20Sopenharmony_ci		;							\
15968c2ecf20Sopenharmony_ci	else								\
15978c2ecf20Sopenharmony_ci		for (_tx_queue = (_channel)->tx_queue;			\
15988c2ecf20Sopenharmony_ci		     _tx_queue < (_channel)->tx_queue +			\
15998c2ecf20Sopenharmony_ci				 efx_channel_num_tx_queues(_channel);		\
16008c2ecf20Sopenharmony_ci		     _tx_queue++)
16018c2ecf20Sopenharmony_ci
16028c2ecf20Sopenharmony_cistatic inline bool efx_channel_has_rx_queue(struct efx_channel *channel)
16038c2ecf20Sopenharmony_ci{
16048c2ecf20Sopenharmony_ci	return channel->rx_queue.core_index >= 0;
16058c2ecf20Sopenharmony_ci}
16068c2ecf20Sopenharmony_ci
16078c2ecf20Sopenharmony_cistatic inline struct efx_rx_queue *
16088c2ecf20Sopenharmony_ciefx_channel_get_rx_queue(struct efx_channel *channel)
16098c2ecf20Sopenharmony_ci{
16108c2ecf20Sopenharmony_ci	EFX_WARN_ON_ONCE_PARANOID(!efx_channel_has_rx_queue(channel));
16118c2ecf20Sopenharmony_ci	return &channel->rx_queue;
16128c2ecf20Sopenharmony_ci}
16138c2ecf20Sopenharmony_ci
16148c2ecf20Sopenharmony_ci/* Iterate over all RX queues belonging to a channel */
16158c2ecf20Sopenharmony_ci#define efx_for_each_channel_rx_queue(_rx_queue, _channel)		\
16168c2ecf20Sopenharmony_ci	if (!efx_channel_has_rx_queue(_channel))			\
16178c2ecf20Sopenharmony_ci		;							\
16188c2ecf20Sopenharmony_ci	else								\
16198c2ecf20Sopenharmony_ci		for (_rx_queue = &(_channel)->rx_queue;			\
16208c2ecf20Sopenharmony_ci		     _rx_queue;						\
16218c2ecf20Sopenharmony_ci		     _rx_queue = NULL)
16228c2ecf20Sopenharmony_ci
16238c2ecf20Sopenharmony_cistatic inline struct efx_channel *
16248c2ecf20Sopenharmony_ciefx_rx_queue_channel(struct efx_rx_queue *rx_queue)
16258c2ecf20Sopenharmony_ci{
16268c2ecf20Sopenharmony_ci	return container_of(rx_queue, struct efx_channel, rx_queue);
16278c2ecf20Sopenharmony_ci}
16288c2ecf20Sopenharmony_ci
16298c2ecf20Sopenharmony_cistatic inline int efx_rx_queue_index(struct efx_rx_queue *rx_queue)
16308c2ecf20Sopenharmony_ci{
16318c2ecf20Sopenharmony_ci	return efx_rx_queue_channel(rx_queue)->channel;
16328c2ecf20Sopenharmony_ci}
16338c2ecf20Sopenharmony_ci
16348c2ecf20Sopenharmony_ci/* Returns a pointer to the specified receive buffer in the RX
16358c2ecf20Sopenharmony_ci * descriptor queue.
16368c2ecf20Sopenharmony_ci */
16378c2ecf20Sopenharmony_cistatic inline struct efx_rx_buffer *efx_rx_buffer(struct efx_rx_queue *rx_queue,
16388c2ecf20Sopenharmony_ci						  unsigned int index)
16398c2ecf20Sopenharmony_ci{
16408c2ecf20Sopenharmony_ci	return &rx_queue->buffer[index];
16418c2ecf20Sopenharmony_ci}
16428c2ecf20Sopenharmony_ci
16438c2ecf20Sopenharmony_cistatic inline struct efx_rx_buffer *
16448c2ecf20Sopenharmony_ciefx_rx_buf_next(struct efx_rx_queue *rx_queue, struct efx_rx_buffer *rx_buf)
16458c2ecf20Sopenharmony_ci{
16468c2ecf20Sopenharmony_ci	if (unlikely(rx_buf == efx_rx_buffer(rx_queue, rx_queue->ptr_mask)))
16478c2ecf20Sopenharmony_ci		return efx_rx_buffer(rx_queue, 0);
16488c2ecf20Sopenharmony_ci	else
16498c2ecf20Sopenharmony_ci		return rx_buf + 1;
16508c2ecf20Sopenharmony_ci}
16518c2ecf20Sopenharmony_ci
16528c2ecf20Sopenharmony_ci/**
16538c2ecf20Sopenharmony_ci * EFX_MAX_FRAME_LEN - calculate maximum frame length
16548c2ecf20Sopenharmony_ci *
16558c2ecf20Sopenharmony_ci * This calculates the maximum frame length that will be used for a
16568c2ecf20Sopenharmony_ci * given MTU.  The frame length will be equal to the MTU plus a
16578c2ecf20Sopenharmony_ci * constant amount of header space and padding.  This is the quantity
16588c2ecf20Sopenharmony_ci * that the net driver will program into the MAC as the maximum frame
16598c2ecf20Sopenharmony_ci * length.
16608c2ecf20Sopenharmony_ci *
16618c2ecf20Sopenharmony_ci * The 10G MAC requires 8-byte alignment on the frame
16628c2ecf20Sopenharmony_ci * length, so we round up to the nearest 8.
16638c2ecf20Sopenharmony_ci *
16648c2ecf20Sopenharmony_ci * Re-clocking by the XGXS on RX can reduce an IPG to 32 bits (half an
16658c2ecf20Sopenharmony_ci * XGMII cycle).  If the frame length reaches the maximum value in the
16668c2ecf20Sopenharmony_ci * same cycle, the XMAC can miss the IPG altogether.  We work around
16678c2ecf20Sopenharmony_ci * this by adding a further 16 bytes.
16688c2ecf20Sopenharmony_ci */
16698c2ecf20Sopenharmony_ci#define EFX_FRAME_PAD	16
16708c2ecf20Sopenharmony_ci#define EFX_MAX_FRAME_LEN(mtu) \
16718c2ecf20Sopenharmony_ci	(ALIGN(((mtu) + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN + EFX_FRAME_PAD), 8))
16728c2ecf20Sopenharmony_ci
16738c2ecf20Sopenharmony_cistatic inline bool efx_xmit_with_hwtstamp(struct sk_buff *skb)
16748c2ecf20Sopenharmony_ci{
16758c2ecf20Sopenharmony_ci	return skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP;
16768c2ecf20Sopenharmony_ci}
16778c2ecf20Sopenharmony_cistatic inline void efx_xmit_hwtstamp_pending(struct sk_buff *skb)
16788c2ecf20Sopenharmony_ci{
16798c2ecf20Sopenharmony_ci	skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
16808c2ecf20Sopenharmony_ci}
16818c2ecf20Sopenharmony_ci
16828c2ecf20Sopenharmony_ci/* Get the max fill level of the TX queues on this channel */
16838c2ecf20Sopenharmony_cistatic inline unsigned int
16848c2ecf20Sopenharmony_ciefx_channel_tx_fill_level(struct efx_channel *channel)
16858c2ecf20Sopenharmony_ci{
16868c2ecf20Sopenharmony_ci	struct efx_tx_queue *tx_queue;
16878c2ecf20Sopenharmony_ci	unsigned int fill_level = 0;
16888c2ecf20Sopenharmony_ci
16898c2ecf20Sopenharmony_ci	efx_for_each_channel_tx_queue(tx_queue, channel)
16908c2ecf20Sopenharmony_ci		fill_level = max(fill_level,
16918c2ecf20Sopenharmony_ci				 tx_queue->insert_count - tx_queue->read_count);
16928c2ecf20Sopenharmony_ci
16938c2ecf20Sopenharmony_ci	return fill_level;
16948c2ecf20Sopenharmony_ci}
16958c2ecf20Sopenharmony_ci
16968c2ecf20Sopenharmony_ci/* Conservative approximation of efx_channel_tx_fill_level using cached value */
16978c2ecf20Sopenharmony_cistatic inline unsigned int
16988c2ecf20Sopenharmony_ciefx_channel_tx_old_fill_level(struct efx_channel *channel)
16998c2ecf20Sopenharmony_ci{
17008c2ecf20Sopenharmony_ci	struct efx_tx_queue *tx_queue;
17018c2ecf20Sopenharmony_ci	unsigned int fill_level = 0;
17028c2ecf20Sopenharmony_ci
17038c2ecf20Sopenharmony_ci	efx_for_each_channel_tx_queue(tx_queue, channel)
17048c2ecf20Sopenharmony_ci		fill_level = max(fill_level,
17058c2ecf20Sopenharmony_ci				 tx_queue->insert_count - tx_queue->old_read_count);
17068c2ecf20Sopenharmony_ci
17078c2ecf20Sopenharmony_ci	return fill_level;
17088c2ecf20Sopenharmony_ci}
17098c2ecf20Sopenharmony_ci
17108c2ecf20Sopenharmony_ci/* Get all supported features.
17118c2ecf20Sopenharmony_ci * If a feature is not fixed, it is present in hw_features.
17128c2ecf20Sopenharmony_ci * If a feature is fixed, it does not present in hw_features, but
17138c2ecf20Sopenharmony_ci * always in features.
17148c2ecf20Sopenharmony_ci */
17158c2ecf20Sopenharmony_cistatic inline netdev_features_t efx_supported_features(const struct efx_nic *efx)
17168c2ecf20Sopenharmony_ci{
17178c2ecf20Sopenharmony_ci	const struct net_device *net_dev = efx->net_dev;
17188c2ecf20Sopenharmony_ci
17198c2ecf20Sopenharmony_ci	return net_dev->features | net_dev->hw_features;
17208c2ecf20Sopenharmony_ci}
17218c2ecf20Sopenharmony_ci
17228c2ecf20Sopenharmony_ci/* Get the current TX queue insert index. */
17238c2ecf20Sopenharmony_cistatic inline unsigned int
17248c2ecf20Sopenharmony_ciefx_tx_queue_get_insert_index(const struct efx_tx_queue *tx_queue)
17258c2ecf20Sopenharmony_ci{
17268c2ecf20Sopenharmony_ci	return tx_queue->insert_count & tx_queue->ptr_mask;
17278c2ecf20Sopenharmony_ci}
17288c2ecf20Sopenharmony_ci
17298c2ecf20Sopenharmony_ci/* Get a TX buffer. */
17308c2ecf20Sopenharmony_cistatic inline struct efx_tx_buffer *
17318c2ecf20Sopenharmony_ci__efx_tx_queue_get_insert_buffer(const struct efx_tx_queue *tx_queue)
17328c2ecf20Sopenharmony_ci{
17338c2ecf20Sopenharmony_ci	return &tx_queue->buffer[efx_tx_queue_get_insert_index(tx_queue)];
17348c2ecf20Sopenharmony_ci}
17358c2ecf20Sopenharmony_ci
17368c2ecf20Sopenharmony_ci/* Get a TX buffer, checking it's not currently in use. */
17378c2ecf20Sopenharmony_cistatic inline struct efx_tx_buffer *
17388c2ecf20Sopenharmony_ciefx_tx_queue_get_insert_buffer(const struct efx_tx_queue *tx_queue)
17398c2ecf20Sopenharmony_ci{
17408c2ecf20Sopenharmony_ci	struct efx_tx_buffer *buffer =
17418c2ecf20Sopenharmony_ci		__efx_tx_queue_get_insert_buffer(tx_queue);
17428c2ecf20Sopenharmony_ci
17438c2ecf20Sopenharmony_ci	EFX_WARN_ON_ONCE_PARANOID(buffer->len);
17448c2ecf20Sopenharmony_ci	EFX_WARN_ON_ONCE_PARANOID(buffer->flags);
17458c2ecf20Sopenharmony_ci	EFX_WARN_ON_ONCE_PARANOID(buffer->unmap_len);
17468c2ecf20Sopenharmony_ci
17478c2ecf20Sopenharmony_ci	return buffer;
17488c2ecf20Sopenharmony_ci}
17498c2ecf20Sopenharmony_ci
17508c2ecf20Sopenharmony_ci#endif /* EFX_NET_DRIVER_H */
1751