196de2506SJakub Kicinski /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
296de2506SJakub Kicinski /* Copyright (C) 2015-2018 Netronome Systems, Inc. */
34c352362SJakub Kicinski 
44c352362SJakub Kicinski /*
54c352362SJakub Kicinski  * nfp_net.h
64c352362SJakub Kicinski  * Declarations for Netronome network device driver.
74c352362SJakub Kicinski  * Authors: Jakub Kicinski <jakub.kicinski@netronome.com>
84c352362SJakub Kicinski  *          Jason McMullan <jason.mcmullan@netronome.com>
94c352362SJakub Kicinski  *          Rolf Neugebauer <rolf.neugebauer@netronome.com>
104c352362SJakub Kicinski  */
114c352362SJakub Kicinski 
124c352362SJakub Kicinski #ifndef _NFP_NET_H_
134c352362SJakub Kicinski #define _NFP_NET_H_
144c352362SJakub Kicinski 
1551a5e563SJakub Kicinski #include <linux/atomic.h>
164c352362SJakub Kicinski #include <linux/interrupt.h>
1763461a02SJakub Kicinski #include <linux/list.h>
184c352362SJakub Kicinski #include <linux/netdevice.h>
194c352362SJakub Kicinski #include <linux/pci.h>
20a1cbaad7SArnd Bergmann #include <linux/io-64-nonatomic-hi-lo.h>
213ed77bf7SJakub Kicinski #include <linux/semaphore.h>
22e2c7114aSJakub Kicinski #include <linux/workqueue.h>
237f1c684aSJesper Dangaard Brouer #include <net/xdp.h>
244c352362SJakub Kicinski 
254c352362SJakub Kicinski #include "nfp_net_ctrl.h"
264c352362SJakub Kicinski 
27c821e617SJakub Kicinski #define nn_pr(nn, lvl, fmt, args...)					\
28c821e617SJakub Kicinski 	({								\
29c821e617SJakub Kicinski 		struct nfp_net *__nn = (nn);				\
30c821e617SJakub Kicinski 									\
31c821e617SJakub Kicinski 		if (__nn->dp.netdev)					\
32c821e617SJakub Kicinski 			netdev_printk(lvl, __nn->dp.netdev, fmt, ## args); \
33c821e617SJakub Kicinski 		else							\
34c821e617SJakub Kicinski 			dev_printk(lvl, __nn->dp.dev, "ctrl: " fmt, ## args); \
35c821e617SJakub Kicinski 	})
36c821e617SJakub Kicinski 
37c821e617SJakub Kicinski #define nn_err(nn, fmt, args...)	nn_pr(nn, KERN_ERR, fmt, ## args)
38c821e617SJakub Kicinski #define nn_warn(nn, fmt, args...)	nn_pr(nn, KERN_WARNING, fmt, ## args)
39c821e617SJakub Kicinski #define nn_info(nn, fmt, args...)	nn_pr(nn, KERN_INFO, fmt, ## args)
40c821e617SJakub Kicinski #define nn_dbg(nn, fmt, args...)	nn_pr(nn, KERN_DEBUG, fmt, ## args)
41c821e617SJakub Kicinski 
4279c12a75SJakub Kicinski #define nn_dp_warn(dp, fmt, args...)					\
43c821e617SJakub Kicinski 	({								\
44c821e617SJakub Kicinski 		struct nfp_net_dp *__dp = (dp);				\
45c821e617SJakub Kicinski 									\
46c821e617SJakub Kicinski 		if (unlikely(net_ratelimit())) {			\
47c821e617SJakub Kicinski 			if (__dp->netdev)				\
48c821e617SJakub Kicinski 				netdev_warn(__dp->netdev, fmt, ## args); \
49c821e617SJakub Kicinski 			else						\
50c821e617SJakub Kicinski 				dev_warn(__dp->dev, fmt, ## args);	\
51c821e617SJakub Kicinski 		}							\
52c821e617SJakub Kicinski 	})
534c352362SJakub Kicinski 
543d780b92SJakub Kicinski /* Max time to wait for NFP to respond on updates (in seconds) */
553d780b92SJakub Kicinski #define NFP_NET_POLL_TIMEOUT	5
564c352362SJakub Kicinski 
5766860bebSJakub Kicinski /* Interval for reading offloaded filter stats */
5866860bebSJakub Kicinski #define NFP_NET_STAT_POLL_IVL	msecs_to_jiffies(100)
5966860bebSJakub Kicinski 
604c352362SJakub Kicinski /* Bar allocation */
61796312cdSJakub Kicinski #define NFP_NET_CTRL_BAR	0
624c352362SJakub Kicinski #define NFP_NET_Q0_BAR		2
634c352362SJakub Kicinski #define NFP_NET_Q1_BAR		4	/* OBSOLETE */
644c352362SJakub Kicinski 
654c352362SJakub Kicinski /* Max bits in DMA address */
664c352362SJakub Kicinski #define NFP_NET_MAX_DMA_BITS	40
674c352362SJakub Kicinski 
684c352362SJakub Kicinski /* Default size for MTU and freelist buffer sizes */
694c352362SJakub Kicinski #define NFP_NET_DEFAULT_MTU		1500
704c352362SJakub Kicinski 
714c352362SJakub Kicinski /* Maximum number of bytes prepended to a packet */
724c352362SJakub Kicinski #define NFP_NET_MAX_PREPEND		64
734c352362SJakub Kicinski 
744c352362SJakub Kicinski /* Interrupt definitions */
754c352362SJakub Kicinski #define NFP_NET_NON_Q_VECTORS		2
764c352362SJakub Kicinski #define NFP_NET_IRQ_LSC_IDX		0
774c352362SJakub Kicinski #define NFP_NET_IRQ_EXN_IDX		1
78d4e7f092SJakub Kicinski #define NFP_NET_MIN_VNIC_IRQS		(NFP_NET_NON_Q_VECTORS + 1)
794c352362SJakub Kicinski 
804c352362SJakub Kicinski /* Queue/Ring definitions */
814c352362SJakub Kicinski #define NFP_NET_MAX_TX_RINGS	64	/* Max. # of Tx rings per device */
824c352362SJakub Kicinski #define NFP_NET_MAX_RX_RINGS	64	/* Max. # of Rx rings per device */
8323a4e389SJakub Kicinski #define NFP_NET_MAX_R_VECS	(NFP_NET_MAX_TX_RINGS > NFP_NET_MAX_RX_RINGS ? \
8423a4e389SJakub Kicinski 				 NFP_NET_MAX_TX_RINGS : NFP_NET_MAX_RX_RINGS)
8523a4e389SJakub Kicinski #define NFP_NET_MAX_IRQS	(NFP_NET_NON_Q_VECTORS + NFP_NET_MAX_R_VECS)
864c352362SJakub Kicinski 
874c352362SJakub Kicinski #define NFP_NET_MIN_TX_DESCS	256	/* Min. # of Tx descs per ring */
884c352362SJakub Kicinski #define NFP_NET_MIN_RX_DESCS	256	/* Min. # of Rx descs per ring */
894c352362SJakub Kicinski #define NFP_NET_MAX_TX_DESCS	(256 * 1024) /* Max. # of Tx descs per ring */
904c352362SJakub Kicinski #define NFP_NET_MAX_RX_DESCS	(256 * 1024) /* Max. # of Rx descs per ring */
914c352362SJakub Kicinski 
924c352362SJakub Kicinski #define NFP_NET_TX_DESCS_DEFAULT 4096	/* Default # of Tx descs per ring */
934c352362SJakub Kicinski #define NFP_NET_RX_DESCS_DEFAULT 4096	/* Default # of Rx descs per ring */
944c352362SJakub Kicinski 
954c352362SJakub Kicinski #define NFP_NET_FL_BATCH	16	/* Add freelist in this Batch size */
96abeeec4aSJakub Kicinski #define NFP_NET_XDP_MAX_COMPLETE 2048	/* XDP bufs to reclaim in NAPI poll */
974c352362SJakub Kicinski 
984c352362SJakub Kicinski /* Offload definitions */
994c352362SJakub Kicinski #define NFP_NET_N_VXLAN_PORTS	(NFP_NET_CFG_VXLAN_SZ / sizeof(__be16))
1004c352362SJakub Kicinski 
101c0f031bcSJakub Kicinski #define NFP_NET_RX_BUF_HEADROOM	(NET_SKB_PAD + NET_IP_ALIGN)
102c0f031bcSJakub Kicinski #define NFP_NET_RX_BUF_NON_DATA	(NFP_NET_RX_BUF_HEADROOM +		\
103c0f031bcSJakub Kicinski 				 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
104c0f031bcSJakub Kicinski 
1054c352362SJakub Kicinski /* Forward declarations */
106bd5ca062SJakub Kicinski struct nfp_cpp;
10747465aedSJakub Kicinski struct nfp_eth_table_port;
1084c352362SJakub Kicinski struct nfp_net;
1094c352362SJakub Kicinski struct nfp_net_r_vector;
110eb488c26SJakub Kicinski struct nfp_port;
1114c352362SJakub Kicinski 
1124aa3b766SJakub Kicinski /* Convenience macro for wrapping descriptor index on ring size */
1134aa3b766SJakub Kicinski #define D_IDX(ring, idx)	((idx) & ((ring)->cnt - 1))
1144aa3b766SJakub Kicinski 
1154c352362SJakub Kicinski /* Convenience macro for writing dma address into RX/TX descriptors */
1164c352362SJakub Kicinski #define nfp_desc_set_dma_addr(desc, dma_addr)				\
1174c352362SJakub Kicinski 	do {								\
1184c352362SJakub Kicinski 		__typeof(desc) __d = (desc);				\
1194c352362SJakub Kicinski 		dma_addr_t __addr = (dma_addr);				\
1204c352362SJakub Kicinski 									\
1214c352362SJakub Kicinski 		__d->dma_addr_lo = cpu_to_le32(lower_32_bits(__addr));	\
1224c352362SJakub Kicinski 		__d->dma_addr_hi = upper_32_bits(__addr) & 0xff;	\
1234c352362SJakub Kicinski 	} while (0)
1244c352362SJakub Kicinski 
1254c352362SJakub Kicinski /* TX descriptor format */
1264c352362SJakub Kicinski 
1274c352362SJakub Kicinski #define PCIE_DESC_TX_EOP		BIT(7)
1284c352362SJakub Kicinski #define PCIE_DESC_TX_OFFSET_MASK	GENMASK(6, 0)
1294c352362SJakub Kicinski #define PCIE_DESC_TX_MSS_MASK		GENMASK(13, 0)
1304c352362SJakub Kicinski 
1314c352362SJakub Kicinski /* Flags in the host TX descriptor */
1324c352362SJakub Kicinski #define PCIE_DESC_TX_CSUM		BIT(7)
1334c352362SJakub Kicinski #define PCIE_DESC_TX_IP4_CSUM		BIT(6)
1344c352362SJakub Kicinski #define PCIE_DESC_TX_TCP_CSUM		BIT(5)
1354c352362SJakub Kicinski #define PCIE_DESC_TX_UDP_CSUM		BIT(4)
1364c352362SJakub Kicinski #define PCIE_DESC_TX_VLAN		BIT(3)
1374c352362SJakub Kicinski #define PCIE_DESC_TX_LSO		BIT(2)
1384c352362SJakub Kicinski #define PCIE_DESC_TX_ENCAP		BIT(1)
1394c352362SJakub Kicinski #define PCIE_DESC_TX_O_IP4_CSUM	BIT(0)
1404c352362SJakub Kicinski 
1414c352362SJakub Kicinski struct nfp_net_tx_desc {
1424c352362SJakub Kicinski 	union {
1434c352362SJakub Kicinski 		struct {
1444c352362SJakub Kicinski 			u8 dma_addr_hi; /* High bits of host buf address */
1454c352362SJakub Kicinski 			__le16 dma_len;	/* Length to DMA for this desc */
1464c352362SJakub Kicinski 			u8 offset_eop;	/* Offset in buf where pkt starts +
1474c352362SJakub Kicinski 					 * highest bit is eop flag.
1484c352362SJakub Kicinski 					 */
1494c352362SJakub Kicinski 			__le32 dma_addr_lo; /* Low 32bit of host buf addr */
1504c352362SJakub Kicinski 
1514c352362SJakub Kicinski 			__le16 mss;	/* MSS to be used for LSO */
152e53fc9faSEdwin Peer 			u8 lso_hdrlen;	/* LSO, TCP payload offset */
1534c352362SJakub Kicinski 			u8 flags;	/* TX Flags, see @PCIE_DESC_TX_* */
15428063be6SEdwin Peer 			union {
15528063be6SEdwin Peer 				struct {
15628063be6SEdwin Peer 					u8 l3_offset; /* L3 header offset */
15728063be6SEdwin Peer 					u8 l4_offset; /* L4 header offset */
15828063be6SEdwin Peer 				};
1594c352362SJakub Kicinski 				__le16 vlan; /* VLAN tag to add if indicated */
16028063be6SEdwin Peer 			};
1614c352362SJakub Kicinski 			__le16 data_len; /* Length of frame + meta data */
1624c352362SJakub Kicinski 		} __packed;
1634c352362SJakub Kicinski 		__le32 vals[4];
16495862749SJakub Kicinski 		__le64 vals8[2];
1654c352362SJakub Kicinski 	};
1664c352362SJakub Kicinski };
1674c352362SJakub Kicinski 
1684c352362SJakub Kicinski /**
1694c352362SJakub Kicinski  * struct nfp_net_tx_buf - software TX buffer descriptor
170703f578aSJakub Kicinski  * @skb:	normal ring, sk_buff associated with this buffer
171703f578aSJakub Kicinski  * @frag:	XDP ring, page frag associated with this buffer
1724c352362SJakub Kicinski  * @dma_addr:	DMA mapping address of the buffer
1734c352362SJakub Kicinski  * @fidx:	Fragment index (-1 for the head and [0..nr_frags-1] for frags)
1744c352362SJakub Kicinski  * @pkt_cnt:	Number of packets to be produced out of the skb associated
1754c352362SJakub Kicinski  *		with this buffer (valid only on the head's buffer).
1764c352362SJakub Kicinski  *		Will be 1 for all non-TSO packets.
1774c352362SJakub Kicinski  * @real_len:	Number of bytes which to be produced out of the skb (valid only
1784c352362SJakub Kicinski  *		on the head's buffer). Equal to skb->len for non-TSO packets.
1794c352362SJakub Kicinski  */
1804c352362SJakub Kicinski struct nfp_net_tx_buf {
181ecd63a02SJakub Kicinski 	union {
1824c352362SJakub Kicinski 		struct sk_buff *skb;
183ecd63a02SJakub Kicinski 		void *frag;
184ecd63a02SJakub Kicinski 	};
1854c352362SJakub Kicinski 	dma_addr_t dma_addr;
1864c352362SJakub Kicinski 	short int fidx;
1874c352362SJakub Kicinski 	u16 pkt_cnt;
1884c352362SJakub Kicinski 	u32 real_len;
1894c352362SJakub Kicinski };
1904c352362SJakub Kicinski 
1914c352362SJakub Kicinski /**
1924c352362SJakub Kicinski  * struct nfp_net_tx_ring - TX ring structure
1934c352362SJakub Kicinski  * @r_vec:      Back pointer to ring vector structure
1944c352362SJakub Kicinski  * @idx:        Ring index from Linux's perspective
1954c352362SJakub Kicinski  * @qcidx:      Queue Controller Peripheral (QCP) queue index for the TX queue
1964c352362SJakub Kicinski  * @qcp_q:      Pointer to base of the QCP TX queue
1974c352362SJakub Kicinski  * @cnt:        Size of the queue in number of descriptors
1984c352362SJakub Kicinski  * @wr_p:       TX ring write pointer (free running)
1994c352362SJakub Kicinski  * @rd_p:       TX ring read pointer (free running)
2004c352362SJakub Kicinski  * @qcp_rd_p:   Local copy of QCP TX queue read pointer
2014c352362SJakub Kicinski  * @wr_ptr_add:	Accumulated number of buffers to add to QCP write pointer
2024c352362SJakub Kicinski  *		(used for .xmit_more delayed kick)
2034c352362SJakub Kicinski  * @txbufs:     Array of transmitted TX buffers, to free on transmit
2044c352362SJakub Kicinski  * @txds:       Virtual address of TX ring in host memory
2054c352362SJakub Kicinski  * @dma:        DMA address of the TX ring
2064c352362SJakub Kicinski  * @size:       Size, in bytes, of the TX ring (needed to free)
20792e68195SJakub Kicinski  * @is_xdp:	Is this a XDP TX ring?
2084c352362SJakub Kicinski  */
2094c352362SJakub Kicinski struct nfp_net_tx_ring {
2104c352362SJakub Kicinski 	struct nfp_net_r_vector *r_vec;
2114c352362SJakub Kicinski 
2124c352362SJakub Kicinski 	u32 idx;
2134c352362SJakub Kicinski 	int qcidx;
2144c352362SJakub Kicinski 	u8 __iomem *qcp_q;
2154c352362SJakub Kicinski 
2164c352362SJakub Kicinski 	u32 cnt;
2174c352362SJakub Kicinski 	u32 wr_p;
2184c352362SJakub Kicinski 	u32 rd_p;
2194c352362SJakub Kicinski 	u32 qcp_rd_p;
2204c352362SJakub Kicinski 
2214c352362SJakub Kicinski 	u32 wr_ptr_add;
2224c352362SJakub Kicinski 
2234c352362SJakub Kicinski 	struct nfp_net_tx_buf *txbufs;
2244c352362SJakub Kicinski 	struct nfp_net_tx_desc *txds;
2254c352362SJakub Kicinski 
2264c352362SJakub Kicinski 	dma_addr_t dma;
2275ea14712SJakub Kicinski 	size_t size;
22892e68195SJakub Kicinski 	bool is_xdp;
2294c352362SJakub Kicinski } ____cacheline_aligned;
2304c352362SJakub Kicinski 
2314c352362SJakub Kicinski /* RX and freelist descriptor format */
2324c352362SJakub Kicinski 
2334c352362SJakub Kicinski #define PCIE_DESC_RX_DD			BIT(7)
2344c352362SJakub Kicinski #define PCIE_DESC_RX_META_LEN_MASK	GENMASK(6, 0)
2354c352362SJakub Kicinski 
2364c352362SJakub Kicinski /* Flags in the RX descriptor */
2374c352362SJakub Kicinski #define PCIE_DESC_RX_RSS		cpu_to_le16(BIT(15))
2384c352362SJakub Kicinski #define PCIE_DESC_RX_I_IP4_CSUM		cpu_to_le16(BIT(14))
2394c352362SJakub Kicinski #define PCIE_DESC_RX_I_IP4_CSUM_OK	cpu_to_le16(BIT(13))
2404c352362SJakub Kicinski #define PCIE_DESC_RX_I_TCP_CSUM		cpu_to_le16(BIT(12))
2414c352362SJakub Kicinski #define PCIE_DESC_RX_I_TCP_CSUM_OK	cpu_to_le16(BIT(11))
2424c352362SJakub Kicinski #define PCIE_DESC_RX_I_UDP_CSUM		cpu_to_le16(BIT(10))
2434c352362SJakub Kicinski #define PCIE_DESC_RX_I_UDP_CSUM_OK	cpu_to_le16(BIT(9))
2445bcb5c7eSDirk van der Merwe #define PCIE_DESC_RX_DECRYPTED		cpu_to_le16(BIT(8))
2454c352362SJakub Kicinski #define PCIE_DESC_RX_EOP		cpu_to_le16(BIT(7))
2464c352362SJakub Kicinski #define PCIE_DESC_RX_IP4_CSUM		cpu_to_le16(BIT(6))
2474c352362SJakub Kicinski #define PCIE_DESC_RX_IP4_CSUM_OK	cpu_to_le16(BIT(5))
2484c352362SJakub Kicinski #define PCIE_DESC_RX_TCP_CSUM		cpu_to_le16(BIT(4))
2494c352362SJakub Kicinski #define PCIE_DESC_RX_TCP_CSUM_OK	cpu_to_le16(BIT(3))
2504c352362SJakub Kicinski #define PCIE_DESC_RX_UDP_CSUM		cpu_to_le16(BIT(2))
2514c352362SJakub Kicinski #define PCIE_DESC_RX_UDP_CSUM_OK	cpu_to_le16(BIT(1))
2524c352362SJakub Kicinski #define PCIE_DESC_RX_VLAN		cpu_to_le16(BIT(0))
2534c352362SJakub Kicinski 
2544c352362SJakub Kicinski #define PCIE_DESC_RX_CSUM_ALL		(PCIE_DESC_RX_IP4_CSUM |	\
2554c352362SJakub Kicinski 					 PCIE_DESC_RX_TCP_CSUM |	\
2564c352362SJakub Kicinski 					 PCIE_DESC_RX_UDP_CSUM |	\
2574c352362SJakub Kicinski 					 PCIE_DESC_RX_I_IP4_CSUM |	\
2584c352362SJakub Kicinski 					 PCIE_DESC_RX_I_TCP_CSUM |	\
2594c352362SJakub Kicinski 					 PCIE_DESC_RX_I_UDP_CSUM)
2604c352362SJakub Kicinski #define PCIE_DESC_RX_CSUM_OK_SHIFT	1
2614c352362SJakub Kicinski #define __PCIE_DESC_RX_CSUM_ALL		le16_to_cpu(PCIE_DESC_RX_CSUM_ALL)
2624c352362SJakub Kicinski #define __PCIE_DESC_RX_CSUM_ALL_OK	(__PCIE_DESC_RX_CSUM_ALL >>	\
2634c352362SJakub Kicinski 					 PCIE_DESC_RX_CSUM_OK_SHIFT)
2644c352362SJakub Kicinski 
2654c352362SJakub Kicinski struct nfp_net_rx_desc {
2664c352362SJakub Kicinski 	union {
2674c352362SJakub Kicinski 		struct {
2684c352362SJakub Kicinski 			u8 dma_addr_hi;	/* High bits of the buf address */
2694c352362SJakub Kicinski 			__le16 reserved; /* Must be zero */
2704c352362SJakub Kicinski 			u8 meta_len_dd; /* Must be zero */
2714c352362SJakub Kicinski 
2724c352362SJakub Kicinski 			__le32 dma_addr_lo; /* Low bits of the buffer address */
2734c352362SJakub Kicinski 		} __packed fld;
2744c352362SJakub Kicinski 
2754c352362SJakub Kicinski 		struct {
2764c352362SJakub Kicinski 			__le16 data_len; /* Length of the frame + meta data */
2774c352362SJakub Kicinski 			u8 reserved;
2784c352362SJakub Kicinski 			u8 meta_len_dd;	/* Length of meta data prepended +
2794c352362SJakub Kicinski 					 * descriptor done flag.
2804c352362SJakub Kicinski 					 */
2814c352362SJakub Kicinski 
2824c352362SJakub Kicinski 			__le16 flags;	/* RX flags. See @PCIE_DESC_RX_* */
2834c352362SJakub Kicinski 			__le16 vlan;	/* VLAN if stripped */
2844c352362SJakub Kicinski 		} __packed rxd;
2854c352362SJakub Kicinski 
2864c352362SJakub Kicinski 		__le32 vals[2];
2874c352362SJakub Kicinski 	};
2884c352362SJakub Kicinski };
2894c352362SJakub Kicinski 
29019d0f54eSJakub Kicinski #define NFP_NET_META_FIELD_MASK GENMASK(NFP_NET_META_FIELD_SIZE - 1, 0)
29119d0f54eSJakub Kicinski 
292e524a6a9SJakub Kicinski struct nfp_meta_parsed {
293ddb98d94SJakub Kicinski 	u8 hash_type;
294ddb98d94SJakub Kicinski 	u8 csum_type;
295e524a6a9SJakub Kicinski 	u32 hash;
296e524a6a9SJakub Kicinski 	u32 mark;
29791bf82caSSimon Horman 	u32 portid;
298ddb98d94SJakub Kicinski 	__wsum csum;
299e524a6a9SJakub Kicinski };
300e524a6a9SJakub Kicinski 
3014c352362SJakub Kicinski struct nfp_net_rx_hash {
3024c352362SJakub Kicinski 	__be32 hash_type;
3034c352362SJakub Kicinski 	__be32 hash;
3044c352362SJakub Kicinski };
3054c352362SJakub Kicinski 
3064c352362SJakub Kicinski /**
3074c352362SJakub Kicinski  * struct nfp_net_rx_buf - software RX buffer descriptor
308c0f031bcSJakub Kicinski  * @frag:	page fragment buffer
3094c352362SJakub Kicinski  * @dma_addr:	DMA mapping address of the buffer
3104c352362SJakub Kicinski  */
3114c352362SJakub Kicinski struct nfp_net_rx_buf {
312c0f031bcSJakub Kicinski 	void *frag;
3134c352362SJakub Kicinski 	dma_addr_t dma_addr;
3144c352362SJakub Kicinski };
3154c352362SJakub Kicinski 
3164c352362SJakub Kicinski /**
3174c352362SJakub Kicinski  * struct nfp_net_rx_ring - RX ring structure
3184c352362SJakub Kicinski  * @r_vec:      Back pointer to ring vector structure
3194c352362SJakub Kicinski  * @cnt:        Size of the queue in number of descriptors
3204c352362SJakub Kicinski  * @wr_p:       FL/RX ring write pointer (free running)
3214c352362SJakub Kicinski  * @rd_p:       FL/RX ring read pointer (free running)
3224c352362SJakub Kicinski  * @idx:        Ring index from Linux's perspective
3234c352362SJakub Kicinski  * @fl_qcidx:   Queue Controller Peripheral (QCP) queue index for the freelist
3244c352362SJakub Kicinski  * @qcp_fl:     Pointer to base of the QCP freelist queue
3254c352362SJakub Kicinski  * @rxbufs:     Array of transmitted FL/RX buffers
3264c352362SJakub Kicinski  * @rxds:       Virtual address of FL/RX ring in host memory
327e76c1d3dSJakub Kicinski  * @xdp_rxq:    RX-ring info avail for XDP
3284c352362SJakub Kicinski  * @dma:        DMA address of the FL/RX ring
3294c352362SJakub Kicinski  * @size:       Size, in bytes, of the FL/RX ring (needed to free)
3304c352362SJakub Kicinski  */
3314c352362SJakub Kicinski struct nfp_net_rx_ring {
3324c352362SJakub Kicinski 	struct nfp_net_r_vector *r_vec;
3334c352362SJakub Kicinski 
3344c352362SJakub Kicinski 	u32 cnt;
3354c352362SJakub Kicinski 	u32 wr_p;
3364c352362SJakub Kicinski 	u32 rd_p;
3374c352362SJakub Kicinski 
33883d08a1dSJakub Kicinski 	u32 idx;
3394c352362SJakub Kicinski 
3404c352362SJakub Kicinski 	int fl_qcidx;
3414c352362SJakub Kicinski 	u8 __iomem *qcp_fl;
3424c352362SJakub Kicinski 
3434c352362SJakub Kicinski 	struct nfp_net_rx_buf *rxbufs;
3444c352362SJakub Kicinski 	struct nfp_net_rx_desc *rxds;
3454c352362SJakub Kicinski 
3467f1c684aSJesper Dangaard Brouer 	struct xdp_rxq_info xdp_rxq;
347e76c1d3dSJakub Kicinski 
348e76c1d3dSJakub Kicinski 	dma_addr_t dma;
3495ea14712SJakub Kicinski 	size_t size;
3504c352362SJakub Kicinski } ____cacheline_aligned;
3514c352362SJakub Kicinski 
3524c352362SJakub Kicinski /**
3534c352362SJakub Kicinski  * struct nfp_net_r_vector - Per ring interrupt vector configuration
3544c352362SJakub Kicinski  * @nfp_net:        Backpointer to nfp_net structure
3554c352362SJakub Kicinski  * @napi:           NAPI structure for this ring vec
356703f578aSJakub Kicinski  * @tasklet:        ctrl vNIC, tasklet for servicing the r_vec
357703f578aSJakub Kicinski  * @queue:          ctrl vNIC, send queue
358703f578aSJakub Kicinski  * @lock:           ctrl vNIC, r_vec lock protects @queue
3594c352362SJakub Kicinski  * @tx_ring:        Pointer to TX ring
3604c352362SJakub Kicinski  * @rx_ring:        Pointer to RX ring
361ecd63a02SJakub Kicinski  * @xdp_ring:	    Pointer to an extra TX ring for XDP
362fdace6c2SJakub Kicinski  * @irq_entry:      MSI-X table entry (use for talking to the device)
3634c352362SJakub Kicinski  * @rx_sync:	    Seqlock for atomic updates of RX stats
3644c352362SJakub Kicinski  * @rx_pkts:        Number of received packets
3654c352362SJakub Kicinski  * @rx_bytes:	    Number of received bytes
3664c352362SJakub Kicinski  * @rx_drops:	    Number of packets dropped on RX due to lack of resources
3674c352362SJakub Kicinski  * @hw_csum_rx_ok:  Counter of packets where the HW checksum was OK
3684c352362SJakub Kicinski  * @hw_csum_rx_inner_ok: Counter of packets where the inner HW checksum was OK
3690df57e60SJakub Kicinski  * @hw_csum_rx_complete: Counter of packets with CHECKSUM_COMPLETE reported
3704c352362SJakub Kicinski  * @hw_csum_rx_error:	 Counter of packets with bad checksums
3715bcb5c7eSDirk van der Merwe  * @hw_tls_rx:	    Number of packets with TLS decrypted by hardware
3724c352362SJakub Kicinski  * @tx_sync:	    Seqlock for atomic updates of TX stats
3734c352362SJakub Kicinski  * @tx_pkts:	    Number of Transmitted packets
3744c352362SJakub Kicinski  * @tx_bytes:	    Number of Transmitted bytes
3754c352362SJakub Kicinski  * @hw_csum_tx:	    Counter of packets with TX checksum offload requested
3764c352362SJakub Kicinski  * @hw_csum_tx_inner:	 Counter of inner TX checksum offload requests
3774c352362SJakub Kicinski  * @tx_gather:	    Counter of packets with Gather DMA
3784c352362SJakub Kicinski  * @tx_lso:	    Counter of LSO packets sent
37951a5e563SJakub Kicinski  * @hw_tls_tx:	    Counter of TLS packets sent with crypto offloaded to HW
38051a5e563SJakub Kicinski  * @tls_tx_fallback:	Counter of TLS packets sent which had to be encrypted
38151a5e563SJakub Kicinski  *			by the fallback path because packets came out of order
38251a5e563SJakub Kicinski  * @tls_tx_no_fallback:	Counter of TLS packets not sent because the fallback
38351a5e563SJakub Kicinski  *			path could not encrypt them
3844c352362SJakub Kicinski  * @tx_errors:	    How many TX errors were encountered
3854c352362SJakub Kicinski  * @tx_busy:        How often was TX busy (no space)?
38616f50cdaSJakub Kicinski  * @rx_replace_buf_alloc_fail:	Counter of RX buffer allocation failures
387fdace6c2SJakub Kicinski  * @irq_vector:     Interrupt vector number (use for talking to the OS)
3884c352362SJakub Kicinski  * @handler:        Interrupt handler for this ring vector
3894c352362SJakub Kicinski  * @name:           Name of the interrupt vector
3904c352362SJakub Kicinski  * @affinity_mask:  SMP affinity mask for this vector
3914c352362SJakub Kicinski  *
3924c352362SJakub Kicinski  * This structure ties RX and TX rings to interrupt vectors and a NAPI
3934c352362SJakub Kicinski  * context. This currently only supports one RX and TX ring per
3944c352362SJakub Kicinski  * interrupt vector but might be extended in the future to allow
3954c352362SJakub Kicinski  * association of multiple rings per vector.
3964c352362SJakub Kicinski  */
3974c352362SJakub Kicinski struct nfp_net_r_vector {
3984c352362SJakub Kicinski 	struct nfp_net *nfp_net;
39977ece8d5SJakub Kicinski 	union {
4004c352362SJakub Kicinski 		struct napi_struct napi;
40177ece8d5SJakub Kicinski 		struct {
40277ece8d5SJakub Kicinski 			struct tasklet_struct tasklet;
40377ece8d5SJakub Kicinski 			struct sk_buff_head queue;
40477ece8d5SJakub Kicinski 			struct spinlock lock;
40577ece8d5SJakub Kicinski 		};
40677ece8d5SJakub Kicinski 	};
4074c352362SJakub Kicinski 
4084c352362SJakub Kicinski 	struct nfp_net_tx_ring *tx_ring;
4094c352362SJakub Kicinski 	struct nfp_net_rx_ring *rx_ring;
4104c352362SJakub Kicinski 
411fdace6c2SJakub Kicinski 	u16 irq_entry;
4124c352362SJakub Kicinski 
4134c352362SJakub Kicinski 	struct u64_stats_sync rx_sync;
4144c352362SJakub Kicinski 	u64 rx_pkts;
4154c352362SJakub Kicinski 	u64 rx_bytes;
4164c352362SJakub Kicinski 	u64 rx_drops;
4174c352362SJakub Kicinski 	u64 hw_csum_rx_ok;
4184c352362SJakub Kicinski 	u64 hw_csum_rx_inner_ok;
4190df57e60SJakub Kicinski 	u64 hw_csum_rx_complete;
4205bcb5c7eSDirk van der Merwe 	u64 hw_tls_rx;
4214c352362SJakub Kicinski 
42251a5e563SJakub Kicinski 	u64 hw_csum_rx_error;
42351a5e563SJakub Kicinski 	u64 rx_replace_buf_alloc_fail;
42451a5e563SJakub Kicinski 
425ecd63a02SJakub Kicinski 	struct nfp_net_tx_ring *xdp_ring;
426ecd63a02SJakub Kicinski 
4274c352362SJakub Kicinski 	struct u64_stats_sync tx_sync;
4284c352362SJakub Kicinski 	u64 tx_pkts;
4294c352362SJakub Kicinski 	u64 tx_bytes;
43051a5e563SJakub Kicinski 
43151a5e563SJakub Kicinski 	u64 ____cacheline_aligned_in_smp hw_csum_tx;
4324c352362SJakub Kicinski 	u64 hw_csum_tx_inner;
4334c352362SJakub Kicinski 	u64 tx_gather;
4344c352362SJakub Kicinski 	u64 tx_lso;
43551a5e563SJakub Kicinski 	u64 hw_tls_tx;
43616f50cdaSJakub Kicinski 
43751a5e563SJakub Kicinski 	u64 tls_tx_fallback;
43851a5e563SJakub Kicinski 	u64 tls_tx_no_fallback;
4394c352362SJakub Kicinski 	u64 tx_errors;
4404c352362SJakub Kicinski 	u64 tx_busy;
4414c352362SJakub Kicinski 
44251a5e563SJakub Kicinski 	/* Cold data follows */
44351a5e563SJakub Kicinski 
444fdace6c2SJakub Kicinski 	u32 irq_vector;
4454c352362SJakub Kicinski 	irq_handler_t handler;
4464c352362SJakub Kicinski 	char name[IFNAMSIZ + 8];
4474c352362SJakub Kicinski 	cpumask_t affinity_mask;
4484c352362SJakub Kicinski } ____cacheline_aligned;
4494c352362SJakub Kicinski 
4504c352362SJakub Kicinski /* Firmware version as it is written in the 32bit value in the BAR */
4514c352362SJakub Kicinski struct nfp_net_fw_version {
4524c352362SJakub Kicinski 	u8 minor;
4534c352362SJakub Kicinski 	u8 major;
4544c352362SJakub Kicinski 	u8 class;
4554c352362SJakub Kicinski 	u8 resv;
4564c352362SJakub Kicinski } __packed;
4574c352362SJakub Kicinski 
4584c352362SJakub Kicinski static inline bool nfp_net_fw_ver_eq(struct nfp_net_fw_version *fw_ver,
4594c352362SJakub Kicinski 				     u8 resv, u8 class, u8 major, u8 minor)
4604c352362SJakub Kicinski {
4614c352362SJakub Kicinski 	return fw_ver->resv == resv &&
4624c352362SJakub Kicinski 	       fw_ver->class == class &&
4634c352362SJakub Kicinski 	       fw_ver->major == major &&
4644c352362SJakub Kicinski 	       fw_ver->minor == minor;
4654c352362SJakub Kicinski }
4664c352362SJakub Kicinski 
46766860bebSJakub Kicinski struct nfp_stat_pair {
46866860bebSJakub Kicinski 	u64 pkts;
46966860bebSJakub Kicinski 	u64 bytes;
47066860bebSJakub Kicinski };
47166860bebSJakub Kicinski 
4724c352362SJakub Kicinski /**
47379c12a75SJakub Kicinski  * struct nfp_net_dp - NFP network device datapath data structure
474fa43d2a8SJakub Kicinski  * @dev:		Backpointer to struct device
4754c352362SJakub Kicinski  * @netdev:		Backpointer to net_device structure
4764c352362SJakub Kicinski  * @is_vf:		Is the driver attached to a VF?
477b9dcf88aSJakub Kicinski  * @chained_metadata_format:  Firemware will use new metadata format
478c3991d39SDirk van der Merwe  * @ktls_tx:		Is kTLS TX enabled?
479c487e6b1SJakub Kicinski  * @rx_dma_dir:		Mapping direction for RX buffers
4806fe0c3b4SJakub Kicinski  * @rx_dma_off:		Offset at which DMA packets (for XDP headroom)
48197717acaSJakub Kicinski  * @rx_offset:		Offset in the RX buffers where packet data starts
4824c352362SJakub Kicinski  * @ctrl:		Local copy of the control register/word.
4834c352362SJakub Kicinski  * @fl_bufsz:		Currently configured size of the freelist buffers
484ecd63a02SJakub Kicinski  * @xdp_prog:		Installed XDP program
48579c12a75SJakub Kicinski  * @tx_rings:		Array of pre-allocated TX ring structures
48679c12a75SJakub Kicinski  * @rx_rings:		Array of pre-allocated RX ring structures
487d2b84397SJakub Kicinski  * @ctrl_bar:		Pointer to mapped control BAR
48879c12a75SJakub Kicinski  *
48979c12a75SJakub Kicinski  * @txd_cnt:		Size of the TX ring in number of descriptors
49079c12a75SJakub Kicinski  * @rxd_cnt:		Size of the RX ring in number of descriptors
49179c12a75SJakub Kicinski  * @num_r_vecs:		Number of used ring vectors
49279c12a75SJakub Kicinski  * @num_tx_rings:	Currently configured number of TX rings
49379c12a75SJakub Kicinski  * @num_stack_tx_rings:	Number of TX rings used by the stack (not XDP)
49479c12a75SJakub Kicinski  * @num_rx_rings:	Currently configured number of RX rings
49576e1e1a8SJakub Kicinski  * @mtu:		Device MTU
49679c12a75SJakub Kicinski  */
49779c12a75SJakub Kicinski struct nfp_net_dp {
49879c12a75SJakub Kicinski 	struct device *dev;
49979c12a75SJakub Kicinski 	struct net_device *netdev;
50079c12a75SJakub Kicinski 
501c487e6b1SJakub Kicinski 	u8 is_vf:1;
502c487e6b1SJakub Kicinski 	u8 chained_metadata_format:1;
503c3991d39SDirk van der Merwe 	u8 ktls_tx:1;
504c487e6b1SJakub Kicinski 
505c487e6b1SJakub Kicinski 	u8 rx_dma_dir;
50697717acaSJakub Kicinski 	u8 rx_offset;
50797717acaSJakub Kicinski 
508dbf637ffSJakub Kicinski 	u32 rx_dma_off;
509dbf637ffSJakub Kicinski 
51079c12a75SJakub Kicinski 	u32 ctrl;
51179c12a75SJakub Kicinski 	u32 fl_bufsz;
51279c12a75SJakub Kicinski 
51379c12a75SJakub Kicinski 	struct bpf_prog *xdp_prog;
51479c12a75SJakub Kicinski 
51579c12a75SJakub Kicinski 	struct nfp_net_tx_ring *tx_rings;
51679c12a75SJakub Kicinski 	struct nfp_net_rx_ring *rx_rings;
51779c12a75SJakub Kicinski 
518d2b84397SJakub Kicinski 	u8 __iomem *ctrl_bar;
519d2b84397SJakub Kicinski 
52079c12a75SJakub Kicinski 	/* Cold data follows */
52179c12a75SJakub Kicinski 
52279c12a75SJakub Kicinski 	unsigned int txd_cnt;
52379c12a75SJakub Kicinski 	unsigned int rxd_cnt;
52479c12a75SJakub Kicinski 
52579c12a75SJakub Kicinski 	unsigned int num_r_vecs;
52679c12a75SJakub Kicinski 
52779c12a75SJakub Kicinski 	unsigned int num_tx_rings;
52879c12a75SJakub Kicinski 	unsigned int num_stack_tx_rings;
52979c12a75SJakub Kicinski 	unsigned int num_rx_rings;
53076e1e1a8SJakub Kicinski 
53176e1e1a8SJakub Kicinski 	unsigned int mtu;
53279c12a75SJakub Kicinski };
53379c12a75SJakub Kicinski 
53479c12a75SJakub Kicinski /**
53579c12a75SJakub Kicinski  * struct nfp_net - NFP network device structure
53679c12a75SJakub Kicinski  * @dp:			Datapath structure
53751c1df83SJakub Kicinski  * @id:			vNIC id within the PF (0 for VFs)
5384c352362SJakub Kicinski  * @fw_ver:		Firmware version
5394c352362SJakub Kicinski  * @cap:                Capabilities advertised by the Firmware
5404c352362SJakub Kicinski  * @max_mtu:            Maximum support MTU advertised by the Firmware
5419ff304bfSJakub Kicinski  * @rss_hfunc:		RSS selected hash function
5424c352362SJakub Kicinski  * @rss_cfg:            RSS configuration
5434c352362SJakub Kicinski  * @rss_key:            RSS secret key
5444c352362SJakub Kicinski  * @rss_itbl:           RSS indirection table
5455f428401SJakub Kicinski  * @xdp:		Information about the driver XDP program
5465f428401SJakub Kicinski  * @xdp_hw:		Information about the HW XDP program
54779c12a75SJakub Kicinski  * @max_r_vecs:		Number of allocated interrupt vectors for RX/TX
5484c352362SJakub Kicinski  * @max_tx_rings:       Maximum number of TX rings supported by the Firmware
5494c352362SJakub Kicinski  * @max_rx_rings:       Maximum number of RX rings supported by the Firmware
550a646c9b2SJakub Kicinski  * @stride_rx:		Queue controller RX queue spacing
551a646c9b2SJakub Kicinski  * @stride_tx:		Queue controller TX queue spacing
5524c352362SJakub Kicinski  * @r_vecs:             Pre-allocated array of ring vectors
5534c352362SJakub Kicinski  * @irq_entries:        Pre-allocated array of MSI-X entries
5544c352362SJakub Kicinski  * @lsc_handler:        Handler for Link State Change interrupt
5554c352362SJakub Kicinski  * @lsc_name:           Name for Link State Change interrupt
5564c352362SJakub Kicinski  * @exn_handler:        Handler for Exception interrupt
5574c352362SJakub Kicinski  * @exn_name:           Name for Exception interrupt
5584c352362SJakub Kicinski  * @shared_handler:     Handler for shared interrupts
5594c352362SJakub Kicinski  * @shared_name:        Name for shared interrupt
5604c352362SJakub Kicinski  * @me_freq_mhz:        ME clock_freq (MHz)
561dd5b2498SJakub Kicinski  * @reconfig_lock:	Protects @reconfig_posted, @reconfig_timer_active,
562dd5b2498SJakub Kicinski  *			@reconfig_sync_present and HW reconfiguration request
563dd5b2498SJakub Kicinski  *			regs/machinery from async requests (sync must take
564dd5b2498SJakub Kicinski  *			@bar_lock)
5653d780b92SJakub Kicinski  * @reconfig_posted:	Pending reconfig bits coming from async sources
5663d780b92SJakub Kicinski  * @reconfig_timer_active:  Timer for reading reconfiguration results is pending
5673d780b92SJakub Kicinski  * @reconfig_sync_present:  Some thread is performing synchronous reconfig
5683d780b92SJakub Kicinski  * @reconfig_timer:	Timer for async reading of reconfig results
5696db3a9dcSJakub Kicinski  * @reconfig_in_progress_update:	Update FW is processing now (debug only)
570dd5b2498SJakub Kicinski  * @bar_lock:		vNIC config BAR access lock, protects: update,
5711f35a56cSDirk van der Merwe  *			mailbox area, crypto TLV
5724c352362SJakub Kicinski  * @link_up:            Is the link up?
573cee42951SJakub Kicinski  * @link_status_lock:	Protects @link_* and ensures atomicity with BAR reading
5744c352362SJakub Kicinski  * @rx_coalesce_usecs:      RX interrupt moderation usecs delay parameter
5754c352362SJakub Kicinski  * @rx_coalesce_max_frames: RX interrupt moderation frame count parameter
5764c352362SJakub Kicinski  * @tx_coalesce_usecs:      TX interrupt moderation usecs delay parameter
5774c352362SJakub Kicinski  * @tx_coalesce_max_frames: TX interrupt moderation frame count parameter
5784c352362SJakub Kicinski  * @vxlan_ports:	VXLAN ports for RX inner csum offload communicated to HW
5794c352362SJakub Kicinski  * @vxlan_usecnt:	IPv4/IPv6 VXLAN port use counts
5804c352362SJakub Kicinski  * @qcp_cfg:            Pointer to QCP queue used for configuration notification
5814c352362SJakub Kicinski  * @tx_bar:             Pointer to mapped TX queues
5824c352362SJakub Kicinski  * @rx_bar:             Pointer to mapped FL/RX queues
58373a0329bSJakub Kicinski  * @tlv_caps:		Parsed TLV capabilities
5841f35a56cSDirk van der Merwe  * @ktls_tx_conn_cnt:	Number of offloaded kTLS TX connections
585c0a4948eSJakub Kicinski  * @ktls_rx_conn_cnt:	Number of offloaded kTLS RX connections
58651a5e563SJakub Kicinski  * @ktls_no_space:	Counter of firmware rejecting kTLS connection due to
58751a5e563SJakub Kicinski  *			lack of space
588d3e4dfe0SJakub Kicinski  * @mbox_cmsg:		Common Control Message via vNIC mailbox state
589d3e4dfe0SJakub Kicinski  * @mbox_cmsg.queue:	CCM mbox queue of pending messages
590d3e4dfe0SJakub Kicinski  * @mbox_cmsg.wq:	CCM mbox wait queue of waiting processes
591e2c7114aSJakub Kicinski  * @mbox_cmsg.workq:	CCM mbox work queue for @wait_work and @runq_work
592e2c7114aSJakub Kicinski  * @mbox_cmsg.wait_work:    CCM mbox posted msg reconfig wait work
593e2c7114aSJakub Kicinski  * @mbox_cmsg.runq_work:    CCM mbox posted msg queue runner work
594d3e4dfe0SJakub Kicinski  * @mbox_cmsg.tag:	CCM mbox message tag allocator
5954c352362SJakub Kicinski  * @debugfs_dir:	Device directory in debugfs
596d4e7f092SJakub Kicinski  * @vnic_list:		Entry on device vNIC list
597fa43d2a8SJakub Kicinski  * @pdev:		Backpointer to PCI device
5987ac9ebd5SJakub Kicinski  * @app:		APP handle if available
599fe06a64eSJakub Kicinski  * @vnic_no_name:	For non-port PF vNIC make ndo_get_phys_port_name return
600fe06a64eSJakub Kicinski  *			-EOPNOTSUPP to keep backwards compatibility (set by app)
601eb488c26SJakub Kicinski  * @port:		Pointer to nfp_port structure if vNIC is a port
602c66a9cf4SJakub Kicinski  * @app_priv:		APP private data for this vNIC
6034c352362SJakub Kicinski  */
6044c352362SJakub Kicinski struct nfp_net {
60579c12a75SJakub Kicinski 	struct nfp_net_dp dp;
60673725d9dSJakub Kicinski 
6074c352362SJakub Kicinski 	struct nfp_net_fw_version fw_ver;
60879c12a75SJakub Kicinski 
60951c1df83SJakub Kicinski 	u32 id;
61051c1df83SJakub Kicinski 
6114c352362SJakub Kicinski 	u32 cap;
6124c352362SJakub Kicinski 	u32 max_mtu;
6134c352362SJakub Kicinski 
6149ff304bfSJakub Kicinski 	u8 rss_hfunc;
6154c352362SJakub Kicinski 	u32 rss_cfg;
6164c352362SJakub Kicinski 	u8 rss_key[NFP_NET_CFG_RSS_KEY_SZ];
6174c352362SJakub Kicinski 	u8 rss_itbl[NFP_NET_CFG_RSS_ITBL_SZ];
6184c352362SJakub Kicinski 
61905296620SJakub Kicinski 	struct xdp_attachment_info xdp;
6205f428401SJakub Kicinski 	struct xdp_attachment_info xdp_hw;
6219f82fca9SJakub Kicinski 
622a4b562bbSJakub Kicinski 	unsigned int max_tx_rings;
623a4b562bbSJakub Kicinski 	unsigned int max_rx_rings;
6244c352362SJakub Kicinski 
6254c352362SJakub Kicinski 	int stride_tx;
6264c352362SJakub Kicinski 	int stride_rx;
6274c352362SJakub Kicinski 
628b33ae997SJakub Kicinski 	unsigned int max_r_vecs;
62923a4e389SJakub Kicinski 	struct nfp_net_r_vector r_vecs[NFP_NET_MAX_R_VECS];
63023a4e389SJakub Kicinski 	struct msix_entry irq_entries[NFP_NET_MAX_IRQS];
6314c352362SJakub Kicinski 
6324c352362SJakub Kicinski 	irq_handler_t lsc_handler;
6334c352362SJakub Kicinski 	char lsc_name[IFNAMSIZ + 8];
6344c352362SJakub Kicinski 
6354c352362SJakub Kicinski 	irq_handler_t exn_handler;
6364c352362SJakub Kicinski 	char exn_name[IFNAMSIZ + 8];
6374c352362SJakub Kicinski 
6384c352362SJakub Kicinski 	irq_handler_t shared_handler;
6394c352362SJakub Kicinski 	char shared_name[IFNAMSIZ + 8];
6404c352362SJakub Kicinski 
6414c352362SJakub Kicinski 	u32 me_freq_mhz;
6424c352362SJakub Kicinski 
6434c352362SJakub Kicinski 	bool link_up;
6444c352362SJakub Kicinski 	spinlock_t link_status_lock;
6454c352362SJakub Kicinski 
6464c352362SJakub Kicinski 	spinlock_t reconfig_lock;
6473d780b92SJakub Kicinski 	u32 reconfig_posted;
6483d780b92SJakub Kicinski 	bool reconfig_timer_active;
6493d780b92SJakub Kicinski 	bool reconfig_sync_present;
6503d780b92SJakub Kicinski 	struct timer_list reconfig_timer;
6516db3a9dcSJakub Kicinski 	u32 reconfig_in_progress_update;
6524c352362SJakub Kicinski 
6533ed77bf7SJakub Kicinski 	struct semaphore bar_lock;
654dd5b2498SJakub Kicinski 
6554c352362SJakub Kicinski 	u32 rx_coalesce_usecs;
6564c352362SJakub Kicinski 	u32 rx_coalesce_max_frames;
6574c352362SJakub Kicinski 	u32 tx_coalesce_usecs;
6584c352362SJakub Kicinski 	u32 tx_coalesce_max_frames;
6594c352362SJakub Kicinski 
6604c352362SJakub Kicinski 	__be16 vxlan_ports[NFP_NET_N_VXLAN_PORTS];
6614c352362SJakub Kicinski 	u8 vxlan_usecnt[NFP_NET_N_VXLAN_PORTS];
6624c352362SJakub Kicinski 
6634c352362SJakub Kicinski 	u8 __iomem *qcp_cfg;
6644c352362SJakub Kicinski 
6654c352362SJakub Kicinski 	u8 __iomem *tx_bar;
6664c352362SJakub Kicinski 	u8 __iomem *rx_bar;
6674c352362SJakub Kicinski 
66873a0329bSJakub Kicinski 	struct nfp_net_tlv_caps tlv_caps;
66973a0329bSJakub Kicinski 
6701f35a56cSDirk van der Merwe 	unsigned int ktls_tx_conn_cnt;
671c0a4948eSJakub Kicinski 	unsigned int ktls_rx_conn_cnt;
6721f35a56cSDirk van der Merwe 
67351a5e563SJakub Kicinski 	atomic_t ktls_no_space;
67451a5e563SJakub Kicinski 
675d3e4dfe0SJakub Kicinski 	struct {
676d3e4dfe0SJakub Kicinski 		struct sk_buff_head queue;
677d3e4dfe0SJakub Kicinski 		wait_queue_head_t wq;
678e2c7114aSJakub Kicinski 		struct workqueue_struct *workq;
679e2c7114aSJakub Kicinski 		struct work_struct wait_work;
680e2c7114aSJakub Kicinski 		struct work_struct runq_work;
681d3e4dfe0SJakub Kicinski 		u16 tag;
682d3e4dfe0SJakub Kicinski 	} mbox_cmsg;
683d3e4dfe0SJakub Kicinski 
6844c352362SJakub Kicinski 	struct dentry *debugfs_dir;
68563461a02SJakub Kicinski 
686d4e7f092SJakub Kicinski 	struct list_head vnic_list;
687bd5ca062SJakub Kicinski 
688fa43d2a8SJakub Kicinski 	struct pci_dev *pdev;
6897ac9ebd5SJakub Kicinski 	struct nfp_app *app;
69047465aedSJakub Kicinski 
691fe06a64eSJakub Kicinski 	bool vnic_no_name;
692fe06a64eSJakub Kicinski 
693eb488c26SJakub Kicinski 	struct nfp_port *port;
694c66a9cf4SJakub Kicinski 
695c66a9cf4SJakub Kicinski 	void *app_priv;
6964c352362SJakub Kicinski };
6974c352362SJakub Kicinski 
6984c352362SJakub Kicinski /* Functions to read/write from/to a BAR
6994c352362SJakub Kicinski  * Performs any endian conversion necessary.
7004c352362SJakub Kicinski  */
7017533fdc0SJakub Kicinski static inline u16 nn_readb(struct nfp_net *nn, int off)
7027533fdc0SJakub Kicinski {
703d2b84397SJakub Kicinski 	return readb(nn->dp.ctrl_bar + off);
7047533fdc0SJakub Kicinski }
7057533fdc0SJakub Kicinski 
7064c352362SJakub Kicinski static inline void nn_writeb(struct nfp_net *nn, int off, u8 val)
7074c352362SJakub Kicinski {
708d2b84397SJakub Kicinski 	writeb(val, nn->dp.ctrl_bar + off);
7094c352362SJakub Kicinski }
7104c352362SJakub Kicinski 
7117533fdc0SJakub Kicinski static inline u16 nn_readw(struct nfp_net *nn, int off)
7127533fdc0SJakub Kicinski {
713d2b84397SJakub Kicinski 	return readw(nn->dp.ctrl_bar + off);
7147533fdc0SJakub Kicinski }
7157533fdc0SJakub Kicinski 
7167533fdc0SJakub Kicinski static inline void nn_writew(struct nfp_net *nn, int off, u16 val)
7177533fdc0SJakub Kicinski {
718d2b84397SJakub Kicinski 	writew(val, nn->dp.ctrl_bar + off);
7197533fdc0SJakub Kicinski }
7204c352362SJakub Kicinski 
7214c352362SJakub Kicinski static inline u32 nn_readl(struct nfp_net *nn, int off)
7224c352362SJakub Kicinski {
723d2b84397SJakub Kicinski 	return readl(nn->dp.ctrl_bar + off);
7244c352362SJakub Kicinski }
7254c352362SJakub Kicinski 
7264c352362SJakub Kicinski static inline void nn_writel(struct nfp_net *nn, int off, u32 val)
7274c352362SJakub Kicinski {
728d2b84397SJakub Kicinski 	writel(val, nn->dp.ctrl_bar + off);
7294c352362SJakub Kicinski }
7304c352362SJakub Kicinski 
7314c352362SJakub Kicinski static inline u64 nn_readq(struct nfp_net *nn, int off)
7324c352362SJakub Kicinski {
733d2b84397SJakub Kicinski 	return readq(nn->dp.ctrl_bar + off);
7344c352362SJakub Kicinski }
7354c352362SJakub Kicinski 
7364c352362SJakub Kicinski static inline void nn_writeq(struct nfp_net *nn, int off, u64 val)
7374c352362SJakub Kicinski {
738d2b84397SJakub Kicinski 	writeq(val, nn->dp.ctrl_bar + off);
7394c352362SJakub Kicinski }
7404c352362SJakub Kicinski 
7414c352362SJakub Kicinski /* Flush posted PCI writes by reading something without side effects */
7424c352362SJakub Kicinski static inline void nn_pci_flush(struct nfp_net *nn)
7434c352362SJakub Kicinski {
7444c352362SJakub Kicinski 	nn_readl(nn, NFP_NET_CFG_VERSION);
7454c352362SJakub Kicinski }
7464c352362SJakub Kicinski 
7474c352362SJakub Kicinski /* Queue Controller Peripheral access functions and definitions.
7484c352362SJakub Kicinski  *
7494c352362SJakub Kicinski  * Some of the BARs of the NFP are mapped to portions of the Queue
7504c352362SJakub Kicinski  * Controller Peripheral (QCP) address space on the NFP.  A QCP queue
7514c352362SJakub Kicinski  * has a read and a write pointer (as well as a size and flags,
7524c352362SJakub Kicinski  * indicating overflow etc).  The QCP offers a number of different
7534c352362SJakub Kicinski  * operation on queue pointers, but here we only offer function to
7544c352362SJakub Kicinski  * either add to a pointer or to read the pointer value.
7554c352362SJakub Kicinski  */
7564c352362SJakub Kicinski #define NFP_QCP_QUEUE_ADDR_SZ			0x800
75773e253f0SJakub Kicinski #define NFP_QCP_QUEUE_AREA_SZ			0x80000
7584c352362SJakub Kicinski #define NFP_QCP_QUEUE_OFF(_x)			((_x) * NFP_QCP_QUEUE_ADDR_SZ)
7594c352362SJakub Kicinski #define NFP_QCP_QUEUE_ADD_RPTR			0x0000
7604c352362SJakub Kicinski #define NFP_QCP_QUEUE_ADD_WPTR			0x0004
7614c352362SJakub Kicinski #define NFP_QCP_QUEUE_STS_LO			0x0008
7624c352362SJakub Kicinski #define NFP_QCP_QUEUE_STS_LO_READPTR_mask	0x3ffff
7634c352362SJakub Kicinski #define NFP_QCP_QUEUE_STS_HI			0x000c
7644c352362SJakub Kicinski #define NFP_QCP_QUEUE_STS_HI_WRITEPTR_mask	0x3ffff
7654c352362SJakub Kicinski 
766416db5c1SJakub Kicinski /* The offset of a QCP queues in the PCIe Target */
7674c352362SJakub Kicinski #define NFP_PCIE_QUEUE(_q) (0x80000 + (NFP_QCP_QUEUE_ADDR_SZ * ((_q) & 0xff)))
7684c352362SJakub Kicinski 
7694c352362SJakub Kicinski /* nfp_qcp_ptr - Read or Write Pointer of a queue */
7704c352362SJakub Kicinski enum nfp_qcp_ptr {
7714c352362SJakub Kicinski 	NFP_QCP_READ_PTR = 0,
7724c352362SJakub Kicinski 	NFP_QCP_WRITE_PTR
7734c352362SJakub Kicinski };
7744c352362SJakub Kicinski 
7754c352362SJakub Kicinski /* There appear to be an *undocumented* upper limit on the value which
7764c352362SJakub Kicinski  * one can add to a queue and that value is either 0x3f or 0x7f.  We
7774c352362SJakub Kicinski  * go with 0x3f as a conservative measure.
7784c352362SJakub Kicinski  */
7794c352362SJakub Kicinski #define NFP_QCP_MAX_ADD				0x3f
7804c352362SJakub Kicinski 
7814c352362SJakub Kicinski static inline void _nfp_qcp_ptr_add(u8 __iomem *q,
7824c352362SJakub Kicinski 				    enum nfp_qcp_ptr ptr, u32 val)
7834c352362SJakub Kicinski {
7844c352362SJakub Kicinski 	u32 off;
7854c352362SJakub Kicinski 
7864c352362SJakub Kicinski 	if (ptr == NFP_QCP_READ_PTR)
7874c352362SJakub Kicinski 		off = NFP_QCP_QUEUE_ADD_RPTR;
7884c352362SJakub Kicinski 	else
7894c352362SJakub Kicinski 		off = NFP_QCP_QUEUE_ADD_WPTR;
7904c352362SJakub Kicinski 
7914c352362SJakub Kicinski 	while (val > NFP_QCP_MAX_ADD) {
7924c352362SJakub Kicinski 		writel(NFP_QCP_MAX_ADD, q + off);
7934c352362SJakub Kicinski 		val -= NFP_QCP_MAX_ADD;
7944c352362SJakub Kicinski 	}
7954c352362SJakub Kicinski 
7964c352362SJakub Kicinski 	writel(val, q + off);
7974c352362SJakub Kicinski }
7984c352362SJakub Kicinski 
7994c352362SJakub Kicinski /**
8004c352362SJakub Kicinski  * nfp_qcp_rd_ptr_add() - Add the value to the read pointer of a queue
8014c352362SJakub Kicinski  *
8024c352362SJakub Kicinski  * @q:   Base address for queue structure
8034c352362SJakub Kicinski  * @val: Value to add to the queue pointer
8044c352362SJakub Kicinski  *
8054c352362SJakub Kicinski  * If @val is greater than @NFP_QCP_MAX_ADD multiple writes are performed.
8064c352362SJakub Kicinski  */
8074c352362SJakub Kicinski static inline void nfp_qcp_rd_ptr_add(u8 __iomem *q, u32 val)
8084c352362SJakub Kicinski {
8094c352362SJakub Kicinski 	_nfp_qcp_ptr_add(q, NFP_QCP_READ_PTR, val);
8104c352362SJakub Kicinski }
8114c352362SJakub Kicinski 
8124c352362SJakub Kicinski /**
8134c352362SJakub Kicinski  * nfp_qcp_wr_ptr_add() - Add the value to the write pointer of a queue
8144c352362SJakub Kicinski  *
8154c352362SJakub Kicinski  * @q:   Base address for queue structure
8164c352362SJakub Kicinski  * @val: Value to add to the queue pointer
8174c352362SJakub Kicinski  *
8184c352362SJakub Kicinski  * If @val is greater than @NFP_QCP_MAX_ADD multiple writes are performed.
8194c352362SJakub Kicinski  */
8204c352362SJakub Kicinski static inline void nfp_qcp_wr_ptr_add(u8 __iomem *q, u32 val)
8214c352362SJakub Kicinski {
8224c352362SJakub Kicinski 	_nfp_qcp_ptr_add(q, NFP_QCP_WRITE_PTR, val);
8234c352362SJakub Kicinski }
8244c352362SJakub Kicinski 
8254c352362SJakub Kicinski static inline u32 _nfp_qcp_read(u8 __iomem *q, enum nfp_qcp_ptr ptr)
8264c352362SJakub Kicinski {
8274c352362SJakub Kicinski 	u32 off;
8284c352362SJakub Kicinski 	u32 val;
8294c352362SJakub Kicinski 
8304c352362SJakub Kicinski 	if (ptr == NFP_QCP_READ_PTR)
8314c352362SJakub Kicinski 		off = NFP_QCP_QUEUE_STS_LO;
8324c352362SJakub Kicinski 	else
8334c352362SJakub Kicinski 		off = NFP_QCP_QUEUE_STS_HI;
8344c352362SJakub Kicinski 
8354c352362SJakub Kicinski 	val = readl(q + off);
8364c352362SJakub Kicinski 
8374c352362SJakub Kicinski 	if (ptr == NFP_QCP_READ_PTR)
8384c352362SJakub Kicinski 		return val & NFP_QCP_QUEUE_STS_LO_READPTR_mask;
8394c352362SJakub Kicinski 	else
8404c352362SJakub Kicinski 		return val & NFP_QCP_QUEUE_STS_HI_WRITEPTR_mask;
8414c352362SJakub Kicinski }
8424c352362SJakub Kicinski 
8434c352362SJakub Kicinski /**
8444c352362SJakub Kicinski  * nfp_qcp_rd_ptr_read() - Read the current read pointer value for a queue
8454c352362SJakub Kicinski  * @q:  Base address for queue structure
8464c352362SJakub Kicinski  *
8474c352362SJakub Kicinski  * Return: Value read.
8484c352362SJakub Kicinski  */
8494c352362SJakub Kicinski static inline u32 nfp_qcp_rd_ptr_read(u8 __iomem *q)
8504c352362SJakub Kicinski {
8514c352362SJakub Kicinski 	return _nfp_qcp_read(q, NFP_QCP_READ_PTR);
8524c352362SJakub Kicinski }
8534c352362SJakub Kicinski 
8544c352362SJakub Kicinski /**
8554c352362SJakub Kicinski  * nfp_qcp_wr_ptr_read() - Read the current write pointer value for a queue
8564c352362SJakub Kicinski  * @q:  Base address for queue structure
8574c352362SJakub Kicinski  *
8584c352362SJakub Kicinski  * Return: Value read.
8594c352362SJakub Kicinski  */
8604c352362SJakub Kicinski static inline u32 nfp_qcp_wr_ptr_read(u8 __iomem *q)
8614c352362SJakub Kicinski {
8624c352362SJakub Kicinski 	return _nfp_qcp_read(q, NFP_QCP_WRITE_PTR);
8634c352362SJakub Kicinski }
8644c352362SJakub Kicinski 
865042f4ba6SJakub Kicinski static inline bool nfp_net_is_data_vnic(struct nfp_net *nn)
866042f4ba6SJakub Kicinski {
867042f4ba6SJakub Kicinski 	WARN_ON_ONCE(!nn->dp.netdev && nn->port);
868042f4ba6SJakub Kicinski 	return !!nn->dp.netdev;
869042f4ba6SJakub Kicinski }
870042f4ba6SJakub Kicinski 
871042f4ba6SJakub Kicinski static inline bool nfp_net_running(struct nfp_net *nn)
872042f4ba6SJakub Kicinski {
873042f4ba6SJakub Kicinski 	return nn->dp.ctrl & NFP_NET_CFG_CTRL_ENABLE;
874042f4ba6SJakub Kicinski }
875042f4ba6SJakub Kicinski 
87677ece8d5SJakub Kicinski static inline const char *nfp_net_name(struct nfp_net *nn)
87777ece8d5SJakub Kicinski {
87877ece8d5SJakub Kicinski 	return nn->dp.netdev ? nn->dp.netdev->name : "ctrl";
87977ece8d5SJakub Kicinski }
88077ece8d5SJakub Kicinski 
881d48ae231SJakub Kicinski static inline void nfp_ctrl_lock(struct nfp_net *nn)
882d48ae231SJakub Kicinski 	__acquires(&nn->r_vecs[0].lock)
883d48ae231SJakub Kicinski {
884d48ae231SJakub Kicinski 	spin_lock_bh(&nn->r_vecs[0].lock);
885d48ae231SJakub Kicinski }
886d48ae231SJakub Kicinski 
887d48ae231SJakub Kicinski static inline void nfp_ctrl_unlock(struct nfp_net *nn)
888d48ae231SJakub Kicinski 	__releases(&nn->r_vecs[0].lock)
889d48ae231SJakub Kicinski {
890d48ae231SJakub Kicinski 	spin_unlock_bh(&nn->r_vecs[0].lock);
891d48ae231SJakub Kicinski }
892d48ae231SJakub Kicinski 
893dd5b2498SJakub Kicinski static inline void nn_ctrl_bar_lock(struct nfp_net *nn)
894dd5b2498SJakub Kicinski {
8953ed77bf7SJakub Kicinski 	down(&nn->bar_lock);
896dd5b2498SJakub Kicinski }
897dd5b2498SJakub Kicinski 
898e2c7114aSJakub Kicinski static inline bool nn_ctrl_bar_trylock(struct nfp_net *nn)
899e2c7114aSJakub Kicinski {
900e2c7114aSJakub Kicinski 	return !down_trylock(&nn->bar_lock);
901e2c7114aSJakub Kicinski }
902e2c7114aSJakub Kicinski 
903dd5b2498SJakub Kicinski static inline void nn_ctrl_bar_unlock(struct nfp_net *nn)
904dd5b2498SJakub Kicinski {
9053ed77bf7SJakub Kicinski 	up(&nn->bar_lock);
906dd5b2498SJakub Kicinski }
907dd5b2498SJakub Kicinski 
9084c352362SJakub Kicinski /* Globals */
9092633beb9SJakub Kicinski extern const char nfp_driver_version[];
9104c352362SJakub Kicinski 
911eb488c26SJakub Kicinski extern const struct net_device_ops nfp_net_netdev_ops;
912eb488c26SJakub Kicinski 
913eb488c26SJakub Kicinski static inline bool nfp_netdev_is_nfp_net(struct net_device *netdev)
914eb488c26SJakub Kicinski {
915eb488c26SJakub Kicinski 	return netdev->netdev_ops == &nfp_net_netdev_ops;
916eb488c26SJakub Kicinski }
917eb488c26SJakub Kicinski 
9184c352362SJakub Kicinski /* Prototypes */
9194c352362SJakub Kicinski void nfp_net_get_fw_version(struct nfp_net_fw_version *fw_ver,
9204c352362SJakub Kicinski 			    void __iomem *ctrl_bar);
9214c352362SJakub Kicinski 
922a4b562bbSJakub Kicinski struct nfp_net *
923e38f5d11SJakub Kicinski nfp_net_alloc(struct pci_dev *pdev, void __iomem *ctrl_bar, bool needs_netdev,
924a4b562bbSJakub Kicinski 	      unsigned int max_tx_rings, unsigned int max_rx_rings);
925beba69caSJakub Kicinski void nfp_net_free(struct nfp_net *nn);
926beba69caSJakub Kicinski 
927beba69caSJakub Kicinski int nfp_net_init(struct nfp_net *nn);
928beba69caSJakub Kicinski void nfp_net_clean(struct nfp_net *nn);
929beba69caSJakub Kicinski 
93077ece8d5SJakub Kicinski int nfp_ctrl_open(struct nfp_net *nn);
93177ece8d5SJakub Kicinski void nfp_ctrl_close(struct nfp_net *nn);
93277ece8d5SJakub Kicinski 
9334c352362SJakub Kicinski void nfp_net_set_ethtool_ops(struct net_device *netdev);
9344c352362SJakub Kicinski void nfp_net_info(struct nfp_net *nn);
935232eeb1fSJakub Kicinski int __nfp_net_reconfig(struct nfp_net *nn, u32 update);
9364c352362SJakub Kicinski int nfp_net_reconfig(struct nfp_net *nn, u32 update);
9379ff304bfSJakub Kicinski unsigned int nfp_net_rss_key_sz(struct nfp_net *nn);
9384c352362SJakub Kicinski void nfp_net_rss_write_itbl(struct nfp_net *nn);
9394c352362SJakub Kicinski void nfp_net_rss_write_key(struct nfp_net *nn);
9404c352362SJakub Kicinski void nfp_net_coalesce_write_cfg(struct nfp_net *nn);
941dd5b2498SJakub Kicinski int nfp_net_mbox_lock(struct nfp_net *nn, unsigned int data_size);
942dd5b2498SJakub Kicinski int nfp_net_mbox_reconfig(struct nfp_net *nn, u32 mbox_cmd);
943dd5b2498SJakub Kicinski int nfp_net_mbox_reconfig_and_unlock(struct nfp_net *nn, u32 mbox_cmd);
944e2c7114aSJakub Kicinski void nfp_net_mbox_reconfig_post(struct nfp_net *nn, u32 update);
945e2c7114aSJakub Kicinski int nfp_net_mbox_reconfig_wait_posted(struct nfp_net *nn);
946fdace6c2SJakub Kicinski 
947fdace6c2SJakub Kicinski unsigned int
948fdace6c2SJakub Kicinski nfp_net_irqs_alloc(struct pci_dev *pdev, struct msix_entry *irq_entries,
949fdace6c2SJakub Kicinski 		   unsigned int min_irqs, unsigned int want_irqs);
950fdace6c2SJakub Kicinski void nfp_net_irqs_disable(struct pci_dev *pdev);
951fdace6c2SJakub Kicinski void
952fdace6c2SJakub Kicinski nfp_net_irqs_assign(struct nfp_net *nn, struct msix_entry *irq_entries,
953fdace6c2SJakub Kicinski 		    unsigned int n);
954783496b0SJakub Kicinski 
955783496b0SJakub Kicinski struct nfp_net_dp *nfp_net_clone_dp(struct nfp_net *nn);
956d957c0f7SJakub Kicinski int nfp_net_ring_reconfig(struct nfp_net *nn, struct nfp_net_dp *new,
957d957c0f7SJakub Kicinski 			  struct netlink_ext_ack *extack);
9584c352362SJakub Kicinski 
9592633beb9SJakub Kicinski #ifdef CONFIG_NFP_DEBUG
9604c352362SJakub Kicinski void nfp_net_debugfs_create(void);
9614c352362SJakub Kicinski void nfp_net_debugfs_destroy(void);
9626f1cd5caSJakub Kicinski struct dentry *nfp_net_debugfs_device_add(struct pci_dev *pdev);
96351c1df83SJakub Kicinski void nfp_net_debugfs_vnic_add(struct nfp_net *nn, struct dentry *ddir);
9646f1cd5caSJakub Kicinski void nfp_net_debugfs_dir_clean(struct dentry **dir);
9654c352362SJakub Kicinski #else
9664c352362SJakub Kicinski static inline void nfp_net_debugfs_create(void)
9674c352362SJakub Kicinski {
9684c352362SJakub Kicinski }
9694c352362SJakub Kicinski 
9704c352362SJakub Kicinski static inline void nfp_net_debugfs_destroy(void)
9714c352362SJakub Kicinski {
9724c352362SJakub Kicinski }
9734c352362SJakub Kicinski 
9746f1cd5caSJakub Kicinski static inline struct dentry *nfp_net_debugfs_device_add(struct pci_dev *pdev)
9756f1cd5caSJakub Kicinski {
9766f1cd5caSJakub Kicinski 	return NULL;
9776f1cd5caSJakub Kicinski }
9786f1cd5caSJakub Kicinski 
9796f1cd5caSJakub Kicinski static inline void
98051c1df83SJakub Kicinski nfp_net_debugfs_vnic_add(struct nfp_net *nn, struct dentry *ddir)
9814c352362SJakub Kicinski {
9824c352362SJakub Kicinski }
9834c352362SJakub Kicinski 
9846f1cd5caSJakub Kicinski static inline void nfp_net_debugfs_dir_clean(struct dentry **dir)
9854c352362SJakub Kicinski {
9864c352362SJakub Kicinski }
9872633beb9SJakub Kicinski #endif /* CONFIG_NFP_DEBUG */
9884c352362SJakub Kicinski 
9894c352362SJakub Kicinski #endif /* _NFP_NET_H_ */
990