1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /* Copyright (c) 2018, Intel Corporation. */
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun #ifndef _ICE_TXRX_H_
5*4882a593Smuzhiyun #define _ICE_TXRX_H_
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun #include "ice_type.h"
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun #define ICE_DFLT_IRQ_WORK 256
10*4882a593Smuzhiyun #define ICE_RXBUF_3072 3072
11*4882a593Smuzhiyun #define ICE_RXBUF_2048 2048
12*4882a593Smuzhiyun #define ICE_RXBUF_1536 1536
13*4882a593Smuzhiyun #define ICE_MAX_CHAINED_RX_BUFS 5
14*4882a593Smuzhiyun #define ICE_MAX_BUF_TXD 8
15*4882a593Smuzhiyun #define ICE_MIN_TX_LEN 17
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun /* The size limit for a transmit buffer in a descriptor is (16K - 1).
18*4882a593Smuzhiyun * In order to align with the read requests we will align the value to
19*4882a593Smuzhiyun * the nearest 4K which represents our maximum read request size.
20*4882a593Smuzhiyun */
21*4882a593Smuzhiyun #define ICE_MAX_READ_REQ_SIZE 4096
22*4882a593Smuzhiyun #define ICE_MAX_DATA_PER_TXD (16 * 1024 - 1)
23*4882a593Smuzhiyun #define ICE_MAX_DATA_PER_TXD_ALIGNED \
24*4882a593Smuzhiyun (~(ICE_MAX_READ_REQ_SIZE - 1) & ICE_MAX_DATA_PER_TXD)
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun #define ICE_RX_BUF_WRITE 16 /* Must be power of 2 */
27*4882a593Smuzhiyun #define ICE_MAX_TXQ_PER_TXQG 128
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun /* Attempt to maximize the headroom available for incoming frames. We use a 2K
30*4882a593Smuzhiyun * buffer for MTUs <= 1500 and need 1536/1534 to store the data for the frame.
31*4882a593Smuzhiyun * This leaves us with 512 bytes of room. From that we need to deduct the
32*4882a593Smuzhiyun * space needed for the shared info and the padding needed to IP align the
33*4882a593Smuzhiyun * frame.
34*4882a593Smuzhiyun *
35*4882a593Smuzhiyun * Note: For cache line sizes 256 or larger this value is going to end
36*4882a593Smuzhiyun * up negative. In these cases we should fall back to the legacy
37*4882a593Smuzhiyun * receive path.
38*4882a593Smuzhiyun */
39*4882a593Smuzhiyun #if (PAGE_SIZE < 8192)
40*4882a593Smuzhiyun #define ICE_2K_TOO_SMALL_WITH_PADDING \
41*4882a593Smuzhiyun ((unsigned int)(NET_SKB_PAD + ICE_RXBUF_1536) > \
42*4882a593Smuzhiyun SKB_WITH_OVERHEAD(ICE_RXBUF_2048))
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun /**
45*4882a593Smuzhiyun * ice_compute_pad - compute the padding
46*4882a593Smuzhiyun * @rx_buf_len: buffer length
47*4882a593Smuzhiyun *
48*4882a593Smuzhiyun * Figure out the size of half page based on given buffer length and
49*4882a593Smuzhiyun * then subtract the skb_shared_info followed by subtraction of the
50*4882a593Smuzhiyun * actual buffer length; this in turn results in the actual space that
51*4882a593Smuzhiyun * is left for padding usage
52*4882a593Smuzhiyun */
ice_compute_pad(int rx_buf_len)53*4882a593Smuzhiyun static inline int ice_compute_pad(int rx_buf_len)
54*4882a593Smuzhiyun {
55*4882a593Smuzhiyun int half_page_size;
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun half_page_size = ALIGN(rx_buf_len, PAGE_SIZE / 2);
58*4882a593Smuzhiyun return SKB_WITH_OVERHEAD(half_page_size) - rx_buf_len;
59*4882a593Smuzhiyun }
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun /**
62*4882a593Smuzhiyun * ice_skb_pad - determine the padding that we can supply
63*4882a593Smuzhiyun *
64*4882a593Smuzhiyun * Figure out the right Rx buffer size and based on that calculate the
65*4882a593Smuzhiyun * padding
66*4882a593Smuzhiyun */
ice_skb_pad(void)67*4882a593Smuzhiyun static inline int ice_skb_pad(void)
68*4882a593Smuzhiyun {
69*4882a593Smuzhiyun int rx_buf_len;
70*4882a593Smuzhiyun
71*4882a593Smuzhiyun /* If a 2K buffer cannot handle a standard Ethernet frame then
72*4882a593Smuzhiyun * optimize padding for a 3K buffer instead of a 1.5K buffer.
73*4882a593Smuzhiyun *
74*4882a593Smuzhiyun * For a 3K buffer we need to add enough padding to allow for
75*4882a593Smuzhiyun * tailroom due to NET_IP_ALIGN possibly shifting us out of
76*4882a593Smuzhiyun * cache-line alignment.
77*4882a593Smuzhiyun */
78*4882a593Smuzhiyun if (ICE_2K_TOO_SMALL_WITH_PADDING)
79*4882a593Smuzhiyun rx_buf_len = ICE_RXBUF_3072 + SKB_DATA_ALIGN(NET_IP_ALIGN);
80*4882a593Smuzhiyun else
81*4882a593Smuzhiyun rx_buf_len = ICE_RXBUF_1536;
82*4882a593Smuzhiyun
83*4882a593Smuzhiyun /* if needed make room for NET_IP_ALIGN */
84*4882a593Smuzhiyun rx_buf_len -= NET_IP_ALIGN;
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun return ice_compute_pad(rx_buf_len);
87*4882a593Smuzhiyun }
88*4882a593Smuzhiyun
89*4882a593Smuzhiyun #define ICE_SKB_PAD ice_skb_pad()
90*4882a593Smuzhiyun #else
91*4882a593Smuzhiyun #define ICE_2K_TOO_SMALL_WITH_PADDING false
92*4882a593Smuzhiyun #define ICE_SKB_PAD (NET_SKB_PAD + NET_IP_ALIGN)
93*4882a593Smuzhiyun #endif
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun /* We are assuming that the cache line is always 64 Bytes here for ice.
96*4882a593Smuzhiyun * In order to make sure that is a correct assumption there is a check in probe
97*4882a593Smuzhiyun * to print a warning if the read from GLPCI_CNF2 tells us that the cache line
98*4882a593Smuzhiyun * size is 128 bytes. We do it this way because we do not want to read the
99*4882a593Smuzhiyun * GLPCI_CNF2 register or a variable containing the value on every pass through
100*4882a593Smuzhiyun * the Tx path.
101*4882a593Smuzhiyun */
102*4882a593Smuzhiyun #define ICE_CACHE_LINE_BYTES 64
103*4882a593Smuzhiyun #define ICE_DESCS_PER_CACHE_LINE (ICE_CACHE_LINE_BYTES / \
104*4882a593Smuzhiyun sizeof(struct ice_tx_desc))
105*4882a593Smuzhiyun #define ICE_DESCS_FOR_CTX_DESC 1
106*4882a593Smuzhiyun #define ICE_DESCS_FOR_SKB_DATA_PTR 1
107*4882a593Smuzhiyun /* Tx descriptors needed, worst case */
108*4882a593Smuzhiyun #define DESC_NEEDED (MAX_SKB_FRAGS + ICE_DESCS_FOR_CTX_DESC + \
109*4882a593Smuzhiyun ICE_DESCS_PER_CACHE_LINE + ICE_DESCS_FOR_SKB_DATA_PTR)
110*4882a593Smuzhiyun #define ICE_DESC_UNUSED(R) \
111*4882a593Smuzhiyun (u16)((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
112*4882a593Smuzhiyun (R)->next_to_clean - (R)->next_to_use - 1)
113*4882a593Smuzhiyun
114*4882a593Smuzhiyun #define ICE_TX_FLAGS_TSO BIT(0)
115*4882a593Smuzhiyun #define ICE_TX_FLAGS_HW_VLAN BIT(1)
116*4882a593Smuzhiyun #define ICE_TX_FLAGS_SW_VLAN BIT(2)
117*4882a593Smuzhiyun /* ICE_TX_FLAGS_DUMMY_PKT is used to mark dummy packets that should be
118*4882a593Smuzhiyun * freed instead of returned like skb packets.
119*4882a593Smuzhiyun */
120*4882a593Smuzhiyun #define ICE_TX_FLAGS_DUMMY_PKT BIT(3)
121*4882a593Smuzhiyun #define ICE_TX_FLAGS_IPV4 BIT(5)
122*4882a593Smuzhiyun #define ICE_TX_FLAGS_IPV6 BIT(6)
123*4882a593Smuzhiyun #define ICE_TX_FLAGS_TUNNEL BIT(7)
124*4882a593Smuzhiyun #define ICE_TX_FLAGS_VLAN_M 0xffff0000
125*4882a593Smuzhiyun #define ICE_TX_FLAGS_VLAN_PR_M 0xe0000000
126*4882a593Smuzhiyun #define ICE_TX_FLAGS_VLAN_PR_S 29
127*4882a593Smuzhiyun #define ICE_TX_FLAGS_VLAN_S 16
128*4882a593Smuzhiyun
129*4882a593Smuzhiyun #define ICE_XDP_PASS 0
130*4882a593Smuzhiyun #define ICE_XDP_CONSUMED BIT(0)
131*4882a593Smuzhiyun #define ICE_XDP_TX BIT(1)
132*4882a593Smuzhiyun #define ICE_XDP_REDIR BIT(2)
133*4882a593Smuzhiyun
134*4882a593Smuzhiyun #define ICE_RX_DMA_ATTR \
135*4882a593Smuzhiyun (DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING)
136*4882a593Smuzhiyun
137*4882a593Smuzhiyun #define ICE_ETH_PKT_HDR_PAD (ETH_HLEN + ETH_FCS_LEN + (VLAN_HLEN * 2))
138*4882a593Smuzhiyun
139*4882a593Smuzhiyun #define ICE_TXD_LAST_DESC_CMD (ICE_TX_DESC_CMD_EOP | ICE_TX_DESC_CMD_RS)
140*4882a593Smuzhiyun
141*4882a593Smuzhiyun struct ice_tx_buf {
142*4882a593Smuzhiyun struct ice_tx_desc *next_to_watch;
143*4882a593Smuzhiyun union {
144*4882a593Smuzhiyun struct sk_buff *skb;
145*4882a593Smuzhiyun void *raw_buf; /* used for XDP */
146*4882a593Smuzhiyun };
147*4882a593Smuzhiyun unsigned int bytecount;
148*4882a593Smuzhiyun unsigned short gso_segs;
149*4882a593Smuzhiyun u32 tx_flags;
150*4882a593Smuzhiyun DEFINE_DMA_UNMAP_LEN(len);
151*4882a593Smuzhiyun DEFINE_DMA_UNMAP_ADDR(dma);
152*4882a593Smuzhiyun };
153*4882a593Smuzhiyun
154*4882a593Smuzhiyun struct ice_tx_offload_params {
155*4882a593Smuzhiyun u64 cd_qw1;
156*4882a593Smuzhiyun struct ice_ring *tx_ring;
157*4882a593Smuzhiyun u32 td_cmd;
158*4882a593Smuzhiyun u32 td_offset;
159*4882a593Smuzhiyun u32 td_l2tag1;
160*4882a593Smuzhiyun u32 cd_tunnel_params;
161*4882a593Smuzhiyun u16 cd_l2tag2;
162*4882a593Smuzhiyun u8 header_len;
163*4882a593Smuzhiyun };
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun struct ice_rx_buf {
166*4882a593Smuzhiyun union {
167*4882a593Smuzhiyun struct {
168*4882a593Smuzhiyun struct sk_buff *skb;
169*4882a593Smuzhiyun dma_addr_t dma;
170*4882a593Smuzhiyun struct page *page;
171*4882a593Smuzhiyun unsigned int page_offset;
172*4882a593Smuzhiyun u16 pagecnt_bias;
173*4882a593Smuzhiyun };
174*4882a593Smuzhiyun struct {
175*4882a593Smuzhiyun struct xdp_buff *xdp;
176*4882a593Smuzhiyun };
177*4882a593Smuzhiyun };
178*4882a593Smuzhiyun };
179*4882a593Smuzhiyun
180*4882a593Smuzhiyun struct ice_q_stats {
181*4882a593Smuzhiyun u64 pkts;
182*4882a593Smuzhiyun u64 bytes;
183*4882a593Smuzhiyun };
184*4882a593Smuzhiyun
185*4882a593Smuzhiyun struct ice_txq_stats {
186*4882a593Smuzhiyun u64 restart_q;
187*4882a593Smuzhiyun u64 tx_busy;
188*4882a593Smuzhiyun u64 tx_linearize;
189*4882a593Smuzhiyun int prev_pkt; /* negative if no pending Tx descriptors */
190*4882a593Smuzhiyun };
191*4882a593Smuzhiyun
192*4882a593Smuzhiyun struct ice_rxq_stats {
193*4882a593Smuzhiyun u64 non_eop_descs;
194*4882a593Smuzhiyun u64 alloc_page_failed;
195*4882a593Smuzhiyun u64 alloc_buf_failed;
196*4882a593Smuzhiyun u64 gro_dropped; /* GRO returned dropped */
197*4882a593Smuzhiyun };
198*4882a593Smuzhiyun
199*4882a593Smuzhiyun /* this enum matches hardware bits and is meant to be used by DYN_CTLN
200*4882a593Smuzhiyun * registers and QINT registers or more generally anywhere in the manual
201*4882a593Smuzhiyun * mentioning ITR_INDX, ITR_NONE cannot be used as an index 'n' into any
202*4882a593Smuzhiyun * register but instead is a special value meaning "don't update" ITR0/1/2.
203*4882a593Smuzhiyun */
204*4882a593Smuzhiyun enum ice_dyn_idx_t {
205*4882a593Smuzhiyun ICE_IDX_ITR0 = 0,
206*4882a593Smuzhiyun ICE_IDX_ITR1 = 1,
207*4882a593Smuzhiyun ICE_IDX_ITR2 = 2,
208*4882a593Smuzhiyun ICE_ITR_NONE = 3 /* ITR_NONE must not be used as an index */
209*4882a593Smuzhiyun };
210*4882a593Smuzhiyun
211*4882a593Smuzhiyun /* Header split modes defined by DTYPE field of Rx RLAN context */
212*4882a593Smuzhiyun enum ice_rx_dtype {
213*4882a593Smuzhiyun ICE_RX_DTYPE_NO_SPLIT = 0,
214*4882a593Smuzhiyun ICE_RX_DTYPE_HEADER_SPLIT = 1,
215*4882a593Smuzhiyun ICE_RX_DTYPE_SPLIT_ALWAYS = 2,
216*4882a593Smuzhiyun };
217*4882a593Smuzhiyun
218*4882a593Smuzhiyun /* indices into GLINT_ITR registers */
219*4882a593Smuzhiyun #define ICE_RX_ITR ICE_IDX_ITR0
220*4882a593Smuzhiyun #define ICE_TX_ITR ICE_IDX_ITR1
221*4882a593Smuzhiyun #define ICE_ITR_8K 124
222*4882a593Smuzhiyun #define ICE_ITR_20K 50
223*4882a593Smuzhiyun #define ICE_ITR_MAX 8160
224*4882a593Smuzhiyun #define ICE_DFLT_TX_ITR (ICE_ITR_20K | ICE_ITR_DYNAMIC)
225*4882a593Smuzhiyun #define ICE_DFLT_RX_ITR (ICE_ITR_20K | ICE_ITR_DYNAMIC)
226*4882a593Smuzhiyun #define ICE_ITR_DYNAMIC 0x8000 /* used as flag for itr_setting */
227*4882a593Smuzhiyun #define ITR_IS_DYNAMIC(setting) (!!((setting) & ICE_ITR_DYNAMIC))
228*4882a593Smuzhiyun #define ITR_TO_REG(setting) ((setting) & ~ICE_ITR_DYNAMIC)
229*4882a593Smuzhiyun #define ICE_ITR_GRAN_S 1 /* ITR granularity is always 2us */
230*4882a593Smuzhiyun #define ICE_ITR_GRAN_US BIT(ICE_ITR_GRAN_S)
231*4882a593Smuzhiyun #define ICE_ITR_MASK 0x1FFE /* ITR register value alignment mask */
232*4882a593Smuzhiyun #define ITR_REG_ALIGN(setting) ((setting) & ICE_ITR_MASK)
233*4882a593Smuzhiyun
234*4882a593Smuzhiyun #define ICE_ITR_ADAPTIVE_MIN_INC 0x0002
235*4882a593Smuzhiyun #define ICE_ITR_ADAPTIVE_MIN_USECS 0x0002
236*4882a593Smuzhiyun #define ICE_ITR_ADAPTIVE_MAX_USECS 0x00FA
237*4882a593Smuzhiyun #define ICE_ITR_ADAPTIVE_LATENCY 0x8000
238*4882a593Smuzhiyun #define ICE_ITR_ADAPTIVE_BULK 0x0000
239*4882a593Smuzhiyun
240*4882a593Smuzhiyun #define ICE_DFLT_INTRL 0
241*4882a593Smuzhiyun #define ICE_MAX_INTRL 236
242*4882a593Smuzhiyun
243*4882a593Smuzhiyun #define ICE_WB_ON_ITR_USECS 2
244*4882a593Smuzhiyun #define ICE_IN_WB_ON_ITR_MODE 255
245*4882a593Smuzhiyun /* Sets WB_ON_ITR and assumes INTENA bit is already cleared, which allows
246*4882a593Smuzhiyun * setting the MSK_M bit to tell hardware to ignore the INTENA_M bit. Also,
247*4882a593Smuzhiyun * set the write-back latency to the usecs passed in.
248*4882a593Smuzhiyun */
249*4882a593Smuzhiyun #define ICE_GLINT_DYN_CTL_WB_ON_ITR(usecs, itr_idx) \
250*4882a593Smuzhiyun ((((usecs) << (GLINT_DYN_CTL_INTERVAL_S - ICE_ITR_GRAN_S)) & \
251*4882a593Smuzhiyun GLINT_DYN_CTL_INTERVAL_M) | \
252*4882a593Smuzhiyun (((itr_idx) << GLINT_DYN_CTL_ITR_INDX_S) & \
253*4882a593Smuzhiyun GLINT_DYN_CTL_ITR_INDX_M) | GLINT_DYN_CTL_INTENA_MSK_M | \
254*4882a593Smuzhiyun GLINT_DYN_CTL_WB_ON_ITR_M)
255*4882a593Smuzhiyun
256*4882a593Smuzhiyun /* Legacy or Advanced Mode Queue */
257*4882a593Smuzhiyun #define ICE_TX_ADVANCED 0
258*4882a593Smuzhiyun #define ICE_TX_LEGACY 1
259*4882a593Smuzhiyun
260*4882a593Smuzhiyun /* descriptor ring, associated with a VSI */
261*4882a593Smuzhiyun struct ice_ring {
262*4882a593Smuzhiyun /* CL1 - 1st cacheline starts here */
263*4882a593Smuzhiyun struct ice_ring *next; /* pointer to next ring in q_vector */
264*4882a593Smuzhiyun void *desc; /* Descriptor ring memory */
265*4882a593Smuzhiyun struct device *dev; /* Used for DMA mapping */
266*4882a593Smuzhiyun struct net_device *netdev; /* netdev ring maps to */
267*4882a593Smuzhiyun struct ice_vsi *vsi; /* Backreference to associated VSI */
268*4882a593Smuzhiyun struct ice_q_vector *q_vector; /* Backreference to associated vector */
269*4882a593Smuzhiyun u8 __iomem *tail;
270*4882a593Smuzhiyun union {
271*4882a593Smuzhiyun struct ice_tx_buf *tx_buf;
272*4882a593Smuzhiyun struct ice_rx_buf *rx_buf;
273*4882a593Smuzhiyun };
274*4882a593Smuzhiyun /* CL2 - 2nd cacheline starts here */
275*4882a593Smuzhiyun u16 q_index; /* Queue number of ring */
276*4882a593Smuzhiyun u16 q_handle; /* Queue handle per TC */
277*4882a593Smuzhiyun
278*4882a593Smuzhiyun u8 ring_active:1; /* is ring online or not */
279*4882a593Smuzhiyun
280*4882a593Smuzhiyun u16 count; /* Number of descriptors */
281*4882a593Smuzhiyun u16 reg_idx; /* HW register index of the ring */
282*4882a593Smuzhiyun
283*4882a593Smuzhiyun /* used in interrupt processing */
284*4882a593Smuzhiyun u16 next_to_use;
285*4882a593Smuzhiyun u16 next_to_clean;
286*4882a593Smuzhiyun u16 next_to_alloc;
287*4882a593Smuzhiyun
288*4882a593Smuzhiyun /* stats structs */
289*4882a593Smuzhiyun struct ice_q_stats stats;
290*4882a593Smuzhiyun struct u64_stats_sync syncp;
291*4882a593Smuzhiyun union {
292*4882a593Smuzhiyun struct ice_txq_stats tx_stats;
293*4882a593Smuzhiyun struct ice_rxq_stats rx_stats;
294*4882a593Smuzhiyun };
295*4882a593Smuzhiyun
296*4882a593Smuzhiyun struct rcu_head rcu; /* to avoid race on free */
297*4882a593Smuzhiyun struct bpf_prog *xdp_prog;
298*4882a593Smuzhiyun struct xsk_buff_pool *xsk_pool;
299*4882a593Smuzhiyun /* CL3 - 3rd cacheline starts here */
300*4882a593Smuzhiyun struct xdp_rxq_info xdp_rxq;
301*4882a593Smuzhiyun /* CLX - the below items are only accessed infrequently and should be
302*4882a593Smuzhiyun * in their own cache line if possible
303*4882a593Smuzhiyun */
304*4882a593Smuzhiyun #define ICE_TX_FLAGS_RING_XDP BIT(0)
305*4882a593Smuzhiyun #define ICE_RX_FLAGS_RING_BUILD_SKB BIT(1)
306*4882a593Smuzhiyun u8 flags;
307*4882a593Smuzhiyun dma_addr_t dma; /* physical address of ring */
308*4882a593Smuzhiyun unsigned int size; /* length of descriptor ring in bytes */
309*4882a593Smuzhiyun u32 txq_teid; /* Added Tx queue TEID */
310*4882a593Smuzhiyun u16 rx_buf_len;
311*4882a593Smuzhiyun u8 dcb_tc; /* Traffic class of ring */
312*4882a593Smuzhiyun } ____cacheline_internodealigned_in_smp;
313*4882a593Smuzhiyun
ice_ring_uses_build_skb(struct ice_ring * ring)314*4882a593Smuzhiyun static inline bool ice_ring_uses_build_skb(struct ice_ring *ring)
315*4882a593Smuzhiyun {
316*4882a593Smuzhiyun return !!(ring->flags & ICE_RX_FLAGS_RING_BUILD_SKB);
317*4882a593Smuzhiyun }
318*4882a593Smuzhiyun
ice_set_ring_build_skb_ena(struct ice_ring * ring)319*4882a593Smuzhiyun static inline void ice_set_ring_build_skb_ena(struct ice_ring *ring)
320*4882a593Smuzhiyun {
321*4882a593Smuzhiyun ring->flags |= ICE_RX_FLAGS_RING_BUILD_SKB;
322*4882a593Smuzhiyun }
323*4882a593Smuzhiyun
ice_clear_ring_build_skb_ena(struct ice_ring * ring)324*4882a593Smuzhiyun static inline void ice_clear_ring_build_skb_ena(struct ice_ring *ring)
325*4882a593Smuzhiyun {
326*4882a593Smuzhiyun ring->flags &= ~ICE_RX_FLAGS_RING_BUILD_SKB;
327*4882a593Smuzhiyun }
328*4882a593Smuzhiyun
ice_ring_is_xdp(struct ice_ring * ring)329*4882a593Smuzhiyun static inline bool ice_ring_is_xdp(struct ice_ring *ring)
330*4882a593Smuzhiyun {
331*4882a593Smuzhiyun return !!(ring->flags & ICE_TX_FLAGS_RING_XDP);
332*4882a593Smuzhiyun }
333*4882a593Smuzhiyun
334*4882a593Smuzhiyun struct ice_ring_container {
335*4882a593Smuzhiyun /* head of linked-list of rings */
336*4882a593Smuzhiyun struct ice_ring *ring;
337*4882a593Smuzhiyun unsigned long next_update; /* jiffies value of next queue update */
338*4882a593Smuzhiyun unsigned int total_bytes; /* total bytes processed this int */
339*4882a593Smuzhiyun unsigned int total_pkts; /* total packets processed this int */
340*4882a593Smuzhiyun u16 itr_idx; /* index in the interrupt vector */
341*4882a593Smuzhiyun u16 target_itr; /* value in usecs divided by the hw->itr_gran */
342*4882a593Smuzhiyun u16 current_itr; /* value in usecs divided by the hw->itr_gran */
343*4882a593Smuzhiyun /* high bit set means dynamic ITR, rest is used to store user
344*4882a593Smuzhiyun * readable ITR value in usecs and must be converted before programming
345*4882a593Smuzhiyun * to a register.
346*4882a593Smuzhiyun */
347*4882a593Smuzhiyun u16 itr_setting;
348*4882a593Smuzhiyun };
349*4882a593Smuzhiyun
350*4882a593Smuzhiyun struct ice_coalesce_stored {
351*4882a593Smuzhiyun u16 itr_tx;
352*4882a593Smuzhiyun u16 itr_rx;
353*4882a593Smuzhiyun u8 intrl;
354*4882a593Smuzhiyun u8 tx_valid;
355*4882a593Smuzhiyun u8 rx_valid;
356*4882a593Smuzhiyun };
357*4882a593Smuzhiyun
358*4882a593Smuzhiyun /* iterator for handling rings in ring container */
359*4882a593Smuzhiyun #define ice_for_each_ring(pos, head) \
360*4882a593Smuzhiyun for (pos = (head).ring; pos; pos = pos->next)
361*4882a593Smuzhiyun
ice_rx_pg_order(struct ice_ring * ring)362*4882a593Smuzhiyun static inline unsigned int ice_rx_pg_order(struct ice_ring *ring)
363*4882a593Smuzhiyun {
364*4882a593Smuzhiyun #if (PAGE_SIZE < 8192)
365*4882a593Smuzhiyun if (ring->rx_buf_len > (PAGE_SIZE / 2))
366*4882a593Smuzhiyun return 1;
367*4882a593Smuzhiyun #endif
368*4882a593Smuzhiyun return 0;
369*4882a593Smuzhiyun }
370*4882a593Smuzhiyun
371*4882a593Smuzhiyun #define ice_rx_pg_size(_ring) (PAGE_SIZE << ice_rx_pg_order(_ring))
372*4882a593Smuzhiyun
373*4882a593Smuzhiyun union ice_32b_rx_flex_desc;
374*4882a593Smuzhiyun
375*4882a593Smuzhiyun bool ice_alloc_rx_bufs(struct ice_ring *rxr, u16 cleaned_count);
376*4882a593Smuzhiyun netdev_tx_t ice_start_xmit(struct sk_buff *skb, struct net_device *netdev);
377*4882a593Smuzhiyun void ice_clean_tx_ring(struct ice_ring *tx_ring);
378*4882a593Smuzhiyun void ice_clean_rx_ring(struct ice_ring *rx_ring);
379*4882a593Smuzhiyun int ice_setup_tx_ring(struct ice_ring *tx_ring);
380*4882a593Smuzhiyun int ice_setup_rx_ring(struct ice_ring *rx_ring);
381*4882a593Smuzhiyun void ice_free_tx_ring(struct ice_ring *tx_ring);
382*4882a593Smuzhiyun void ice_free_rx_ring(struct ice_ring *rx_ring);
383*4882a593Smuzhiyun int ice_napi_poll(struct napi_struct *napi, int budget);
384*4882a593Smuzhiyun int
385*4882a593Smuzhiyun ice_prgm_fdir_fltr(struct ice_vsi *vsi, struct ice_fltr_desc *fdir_desc,
386*4882a593Smuzhiyun u8 *raw_packet);
387*4882a593Smuzhiyun int ice_clean_rx_irq(struct ice_ring *rx_ring, int budget);
388*4882a593Smuzhiyun void ice_clean_ctrl_tx_irq(struct ice_ring *tx_ring);
389*4882a593Smuzhiyun #endif /* _ICE_TXRX_H_ */
390